I have a really bad problem, I am not an OpenGL expert but this problem doesn’t seems to be easy.
I use an OpenGL screen as a component of a Window, let call that window A.
Window A is contained itself in another Window B.
This container window can change to another window C.
When then parent (container) window of A change (from B to C or from C to B), I re-initialize the context (if I don’t do anything the OpenGL screen becomes white):
Actions executed after parent window changed:
// release current context
wglMakeCurrent(0,0);
wglDeleteContext(frc);
ReleaseDC(fwinhandle, fdc);
// init pixel format :flags = PFD_DRAW_TO_WINDOW,PFD_SUPPORT_OPENGL,PFD_DOUBLEBUFFER;
// iPixelType=PFD_TYPE_RGBA and cColorBits=32
SetPixelFormat(fdc, FPixFmt, @FPixFmtDesc)
// init DC
frc := wglCreateContext(fdc);
wglMakeCurrent(fdc,frc)
Sometime (it can be after 2 changes or never), this procedure hang on wglMakeCurrent
Is it the correct way to proceed ? If yes what can be the problem ?
I’ve tried to remove the SetPixelFormat instruction but in this case the OpenGL screen becomes white after parent window change and nothing can be draw on it any more.
Well, my application manage it’s own desktop (that is a window) so I can’t skip window parent changement. I’ve tested different Window styles like CS_OWNDC, CS_CLASSDC (as describe in http://msdn2.microsoft.com/en-us/library/ms537559(VS.85).aspx ) but the behaviour is still the same, without a call to SetPixelFormat, the Open GL screen becomes white when parent change, (that is not a good solution cause, as you said, it must be call only once per window - http://msdn2.microsoft.com/en-us/library/ms537559(VS.85).aspx)..)
Re-creating the window (as suggested) is a solution. But I’m still searching a solution without any initialization (or as few as possible).
I did a test with GLscene (my app is in D7): I’ve integrated a GLscene demo window in my app (without doing anything when window parent change) and … opengl screen is working fine. I need to analyze their opengl init process to see how they do that. Maybe an issue ?