PDA

View Full Version : Multiple OpenGL rendering contexts



vgo
30-01-2007, 09:38 PM
Has anyone used multiple windows/rendering contexts?

I'm working on a map editor for my project and I wanted to add a preview window for the material editor, so that the textures/shaders can be seen in action right away.

However, I haven't figured out the way to deal with the contexts, should I have a thread running for each context and use that for drawing on that particular context? I tried using one thread for both contexts and I keep getting "invalid operation" OpenGL errors. When using application idle event everything works but a bit choppy, the animation etc. isn't smooth enough this way.

I'm doing this in Delphi/Windows, but a cross-platform friendly method would be nice to have.

JSoftware
30-01-2007, 10:56 PM
Don't you just use wglMakeCurrent to change contexts between each rendering and remember to share resources for all the contexts? I would do that and just render each context on each idle event

That's the only way I can think of pulling it. And I have no idea how you would manage contexts on another platform

NecroDOME
31-01-2007, 02:02 AM
Im using DirectX and make 4 directx instances (yes, I know I should use swap chaining...), 1 3D view, a top, left and front view. I suggest to look for some swap channing or something...
I think NeHe has some tutorials on it. http://nehe.gamedev.net/

vgo
01-02-2007, 10:12 AM
I modified the OpenGL window class that I used to share the textures and display lists.

For now I'll use the application idle event for rendering. Everything seems to work ok and I haven't got any OpenGL errors anymore.

Guess I'll have a look on this in Lazarus to see how it could be done in a cross-platform way.