🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Multiple OpenGL Windows

Started by
7 comments, last by DuhMe 24 years, 1 month ago
How can I create multiple OpenGL windows where I can render different things or maybe even a different view of the scene? Most modelers have a multiple window setup and I was wondering how they do it. This might be useful for my texturing utility I want to create. I''m in the windows environment and expect to write a non-MFC application. Any help would be appreciated. Thanks DuhMe I''m an idiot so you don''t have to be.
DuhMeI''m an idiot so you don''t have to be.
Advertisement
You could simply create two (or more) windows with two different wgl rendering contexts. Activate the context you want to draw to with wglMakeCurrent().

Visit our homepage: www.rarebyte.de.st

GA
Visit our homepage: www.rarebyte.de.stGA
Hi DuhMe,

You could also just split up a single window into different drawing areas by altering the viewport. Perhaps a simple example may help... here''s roughly what I''m getting at:

void MainDraw(){glClear(...)  //clear whatever buffers for new frameglViewPort(0, 0, windowWidth/2, windowHeight/2)DrawView1()glViewPort(windowWidth/2, 0, windowWidth/2, windowHeight/2)DrawView2()glViewPort(windowWidth/2, windowHeight/2, windowWidth/2, windowHeight/2)DrawView3()glViewPort(0, windowHeight/2, windowWidth/2, windowHeight/2)DrawView4()SwapBuffers()} 


This would give you four equal sized sub-windows in which you can render what ever you want (they needn''t have the same scene at all). If its a modelling style look you''re after, just set an orthographic projection for rendering three of them (using a different viewing rotation for each window before drawing), and set a perspective (if you like) projection for the solid-render sub-window which can have whatever viewing transform you like.

Hope I made sense just then

-------------
squirrels are a remarkable source of protein...
So here''s a question, but first a statement. I just got back from E3 where one of the cooler things I saw was (as much as I hate to admit it) Microsoft''s Mechwarrior. There is a cool ''zoom'' feature that creates a ''subwindow'' with a zoomed in view in it, in the center of the screen. I have implimented something similar in my terrain program using glViewport() - but (and maybe this is my video card, a voodoo3 that generally has terrible GL conformity) sometimes (randomly) fragments from my main (0,0,height,width) window overwrites my (50,50,100,100) window - any ideas why this is?
Maybe windows are repainting the section that are your (50,50,100,100) window. The way to fix this problem is create new window like ga said.
(At least I hope so.)
Oh, I''ve just figured it out.
Did you forget to call glClear(...); before write to new viewport?
Theres something on this here:
http://www.nk-exa.co.jp/~matumot/index-e.shtml
For you ''Anonymous poster''...
You set up a new viewport over the main one, just feeling everything inside will just overide the previous contents of the framebuffer... wrong!
Don''t you forget to call glClear( GL_DEPTH_BUFFER_BIT ) to clear the Z buffer?? I think just calling that extra clear will do in your case, but I also think you cannot explicitly tell OpenGL to clear the viewport''s contents only. Therefore clearing the Z buffer twice per frame will cost you much.
Try finding cheaper ways (disable the Z test, offset the Z values closer to your near plane, Z sort yourself, ...).
Read up on glScissor. That''ll do nicely. On the more modern cards you could look into using the stencil buffer (afterall, thats what it was originally designed for).

Paul Groves.
http://home.clara.net/paulyg/ogl.htm
OpenGL for Beginners
Paul Grovespauls opengl page

This topic is closed to new replies.

Advertisement