CreateDevice失败,窗口句柄传递正常,Direct3DCreate9返回正常!

zhiweiyouzhishenghuo 2012-07-27 02:48:30
RT,求解答。。。。。。
...全文
205 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jackfrank078 2012-07-28
  • 打赏
  • 举报
回复
楼主,麻烦把你的解决方案公布,方便小弟学习
傻X 2012-07-28
  • 打赏
  • 举报
回复
最好公布下原因,恭喜楼主了
  • 打赏
  • 举报
回复
问题解决了,来个人接分?
  • 打赏
  • 举报
回复
奇怪,我用this->GetSafeWnd()传进去没问题。
但是m_hWndRender的确是生成正确了的。。。
  • 打赏
  • 举报
回复
CreateVideoWindow();
------------------
WNDCLASSEX wcex;
HBRUSH hBrush = CreateSolidBrush(BACKGROUNDCOLOR);

//preview
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_OWNDC | CS_DBLCLKS ;
wcex.lpfnWndProc = (WNDPROC)VideoWndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = _G_.g_hInst;
wcex.hIcon = NULL;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = CreateSolidBrush( BACKGROUNDCOLOR ); //CreateSolidBrush( BACKGROUNDCOLOR );
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "VIEW";
wcex.hIconSm = NULL;

RegisterClassEx(&wcex);

// 创建窗口
m_hWndRender = ::CreateWindowEx(
WS_EX_TOPMOST|WS_EX_OVERLAPPEDWINDOW, //WS_EX_LAYERED,//WS_EX_TOPMOST,//WS_EX_OVERLAPPEDWINDOW, // extended window style
"VIEW", // registered class name
"", // window name
WS_CHILD,//WS_BORDER | //SS_CENTER| SS_BLACKRECT|WS_BORDER| // window style
g_bk_position.left, // horizontal position of window
g_bk_position.top, // vertical position of window
g_bk_position.right - g_bk_position.left, // window width
g_bk_position.bottom- g_bk_position.top, // window height
this->GetSafeHwnd(), // handle to parent or owner window
NULL, // menu handle or child identifier
_G_.g_hInst, // handle to application instance
NULL ); // window-creation data

::ShowWindow(m_hWndRender, SW_SHOW );

------------------------------
if (!InitVideoRender())
{
AfxMessageBox("InitVideoRender falied!");
exit(-1);

return ;
}
------------------------------
bool CMainDlg::InitVideoRender()
{
//
m_pRender = new CVideoRender(m_hWndRender, BACKGROUNDCOLOR);

//
if (NULL == m_pRender)
{
return false;
}

return true;
}
---------------------
CVideoRender::CVideoRender( HWND hWnd, COLORREF color)
{……
InitD3D();
}
------------
HRESULT CVideoRender::InitD3D()
{
//Create the D3D object.
m_pD3D = Direct3DCreate9( D3D_SDK_VERSION );

// Set up the structure used to create the D3DDevice
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.BackBufferCount = 0;
d3dpp.Flags = D3DPRESENTFLAG_VIDEO;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;

// Create the D3DDevice
if( FAILED( m_pD3D->CreateDevice( D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
m_hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED,//D3DCREATE_MIXED_VERTEXPROCESSING,
&d3dpp,
&m_pD3DDevice ) ) )
{
int ret=GetLastError();
return E_FAIL;
}

// Turn off culling
//m_pD3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );

// Turn on the zbuffer
//m_pD3DDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
HFONT hFont = (HFONT)GetStockObject( SYSTEM_FONT );
D3DXCreateFont( m_pD3DDevice, hFont, &m_pD3DFont );

D3DXCreateLine( m_pD3DDevice, &m_pD3DLine );


………………………………………………

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧