Reputation: 33
I can't render my scene under a child window which is in my main window. I got two Registered windows:
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);
(the childwindow is later shown)
My loop looks like:
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;
}
When childwindow
is set as a hwnd in StartOpenGL();
there is no reaction I can only see a window with a white bg defined in window class (hbrBackground). When hwnd is set to mainwindow
scene renders in it at range of SW_MAXIMIZE
.
My StartOpenGL & StopOpenGL functions are from: Link
Upvotes: 0
Views: 1148
Reputation: 162194
Please stop using that Start/Stop OpenGL functions. StartOpenGL sets the windows PIXELFORMATDESCRIPTOR (PFD) which can be done only one time. You do that at best right after creating the window. If your two windows share a compatible PFD (which is the case if you create the child window after the PFDs of the parent has been set; you still need to set the very same PFD for the child then), you can simply use wglMakeCurrent
to switch a single OpenGL context between both windows, identified by their HDC.
Upvotes: 1