Using efficently multiple rendering contexts

I’m working on an application that looks like this:

In the central zone I’m gonna render the scene, while on the small panel on the right (under the “immagine” label) I want to show the texture associated to the selected object from the main scene.

Since the main rendering frame and the panel on the right have different window handles, I thought it would be cool to use two rendering contexts.

But why I need an OpenGL rendering context for showing just a texture? Well, that’s simple: the textures can also be created on the fly by a shader, so I won’t have a physical copy of it and simply fill a picture box with it.

The application is written in C# and uses an OpenGL rendering engine (also made by me) written in C++ as a DLL. So, I can easily create two instances of the rendering engine and use it in this way (simply put):


Engine1.grabContext(); //wglMakeCurrent(…);


but doing two wglMakeCurrent for each frame is fugly and also causes a HUGE drop on performance.

Can you suggest an alternative way? Someone told me to use glScissors but I can’t see how this helps me (I’m not rendering in the same frame!).


Make two threads that render to different windows. Also, do you really need to redraw the texture each frame?

No, I don’t need it. Infact, in my implementation I redraw the texture once in 100 frames… Currently my textures are static: even if are drawn by a shader, I shouldn’t expect animated textures by now. In future this could be the case, and that’s why I’m exploring this possibility…

As for the static texture case, I could easily render the texture just once and redraw it each time the main window is being maximized/minimized.

If you only need to update the texture once every X frames, then use a dirty bit to decide when you have to redraw the ‘texture’ context.

I don’t think that using two threads will bring you anything, after all, the driver/OS will make your two context’ current on one GPU at his choosing, which can only be worse than you doing optimized make current’s from one thread.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.