I have asked this question on the beginner’s thread but not much luck so far. Maybe someone here could help me further.
I’m working on a simple application (let’s call that app. A) that will be launched from within a host application (let’s call that app. H). Both applications have an own OpenGL control to render some technical stuff on it.
When I launch A from outside of H, everything displays well on A’s canvas. However, when I launch it from within H, its OpenGL becomes black and nothing can be drawn on it.
A thread can have one current rendering context. A process can have multiple rendering contexts by means of multithreading. A thread must set a current rendering context before calling any OpenGL functions. Otherwise, all OpenGL calls are ignored.
I’m able to grab the host’s rendering context with wglGetCurrentContext() then when I try to set the current context with wglMakeCurrent() this function returns an error 0007D0.
My goal is to have in A an opengl window independent of the one being depicted in H. I do not want to share anything between them.
Change your code to call wglMakeCurrent(rc) before refresh and wglMakeCurrent(NULL) after SwapBuffers. This will ensure that there is no overlapped RC’s in same thread. So…
H: event OnPaint
wglMakeCurrent(H_rc);
DrawH();
SwapBuffers()
wglMakeCurrent(NULL);