Jump to content
  • Advertisement
Sign in to follow this  
C Fuller

OpenGL Can you prevent OpenGL taking over the entire window?

This topic is 5061 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

Hi, I'm making an engine which allows you to create windows applications, and one of the gadgets it allows you to create is a 3D OpenGL viewport. However, when I render the viewport (or to be more precise swap the buffers (SwapBuffers( hDC )) it fills the entire window with the OpenGL clear colour (glClearColor( )) instead of just the area defined by the width and height of the viewport I created. Obviously this doesn't look very good when there are other gadgets such as buttons / check boxes etc on the window. Regards, Chris

Share this post


Link to post
Share on other sites
Advertisement
Create a child window inside your window, without borders or anything and use that with OpenGL.. work's fine for me. I find it easier too, for example if I want to move the area OpenGL draws on within the parent window.

Share this post


Link to post
Share on other sites
Thanks Erik, that's certainly a viable option and one I never thought of :P I'll use it if I can't find a better way.

Any other suggestions for a cleaner fix?

Regards,
Chris

Share this post


Link to post
Share on other sites
Hi, instead of creating a new child window for all the other gadgets would making a new window (each with its own rendering context) for each Viewport gadget work at all?

I mean I can test if it actually works or not but would it be logical/practical to do it?

Regards,
Chris

Share this post


Link to post
Share on other sites
I know that in for example Delphi I can just get the DC of a panel (or any other control that has a handle for that matter) and setup opengl to display on it without problems.
You have to make sure you swapbuffer that DC and not the window DC tho ;)

Share this post


Link to post
Share on other sites
Hi,

Thanks for the replies all! I'm creating a window with a STATIC class for each viewport now and it works great!

Each viewport has it's own DC and RC, and I simply call wglMakeCurrent( pCamera->hDC, pCamera->hRC ); in the rendering loop.

The only problem now is the framerate has dropped noticably due to calling SwapBuffers( ) so many times. Basically I have 4 viewports, so I'm calling SwapBuffers( ) 4 times, but each viewport is a quarter of the size of the screen so I would have thought there should be no speed loss?

Is there any way to speed things up?

Regards,
Chris

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!