我无法在我的主窗口中的子窗口下渲染我的场景。我有两个注册窗口:
mainwindow = CreateWindow(bgwinNAME,
TEXT("Benchmark"),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(mhwnd, SW_MAXIMIZE);
UpdateWindow(mainwindow);
childwindow = CreateWindow(benchwinNAME,
NULL,
WS_CHILD,
(GetSystemMetrics(SM_CXSCREEN)-width)/2,
(GetSystemMetrics(SM_CYSCREEN)-hight)/2,
width,
hight,
mainwindow,
NULL,
hInstance,
NULL);
UpdateWindow(childwindow);
(子窗口稍后显示)
我的循环看起来像:
while(TRUE)
{
while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if(msg.message == WM_QUIT)
break;
StartOpenGL(childwindow, &hdc, &hrc );
// .... my GL functions
SwapBuffers(hdc);
}
StopOpenGL(childwindow, hdc, hrc );
return msg.wParam;
}
当childwindow
设置为 hwnd 时StartOpenGL();
没有反应,我只能看到一个在窗口类 (hbrBackground) 中定义的带有白色背景的窗口。当 hwnd 设置为mainwindow
场景渲染时,范围为SW_MAXIMIZE
.
我的 StartOpenGL 和 StopOpenGL 函数来自: 链接