I am looking to create an application in Visual C++ .Net where I launch multiple dialogs through the same executable. I have seen several examples where people demonstrate how to use OpenGL with an MFC dialog. All of these examples have worked great. Now, however, I am trying to launch multiple dialogs and draw to each of them separately. Is this possible? I have been all over google and other search engines looking for help but have yet to find any. Any help would be greatly appreciated!!!
you need to make separate rendering context for each window and swap them (wglmakeactive) to the window you want to draw in
consider a hrc to opengl as you would an hdc to windows gdi
Is it possible to draw to both of them at the “same” time?
Also, did you mean wglMakeCurrent instead of wglMakeActive?
Thanks for the help. I appreciate it!
you can draw to 2 or more context, if you have a separate thread per each context, or you can just use 1 thread that swaps to the appropiate context in a manner where it appears to draw both at the same time
each thread has to have its own context to make opengl calls, even if it has no window.
each thread can have multiple context and use wglmakecurrent to choose each one.
then you call wglsharelists after you create the context and before you make it current
where the first argument is the father context and the second is that threads context
then after you share them , it behaves as one big context, drawing from any of the shared partners is drawn on all of them so all windows using a context that is shared with all of the other contexts has the same output
note if you share to a context, it is inherited to all the other context that are shared with the context you just shared with, so only make 1 call per thread and make 1 context for the sole purpose of being a shared context hub
the hub concept makes it easier to visualize imo
so useing a massive shared context blob…drawing a triangle in 1 thread’s context draws it in all of the other thread’s context that have made calls to wglsharelists with its context or a context shared to it
Thanks alot! I was able to get it working using your input. I appreciate it!
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.