Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

DuhMe

Multiple OpenGL Windows

This topic is 6904 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 frame


glViewPort(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...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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?

Share this post


Link to post
Share on other sites
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.)

Share this post


Link to post
Share on other sites
Oh, I''ve just figured it out.
Did you forget to call glClear(...); before write to new viewport?

Share this post


Link to post
Share on other sites
Theres something on this here:
http://www.nk-exa.co.jp/~matumot/index-e.shtml

Share this post


Link to post
Share on other sites
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, ...).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!