Can you prevent OpenGL taking over the entire window?
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
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.
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
Any other suggestions for a cleaner fix?
Regards,
Chris
Check out information on doing an opengl renderer in a dialog box, or in MFC, they tell you how to do that.
~Main
~Main
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
I mean I can test if it actually works or not but would it be logical/practical to do it?
Regards,
Chris
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 ;)
You have to make sure you swapbuffer that DC and not the window DC tho ;)
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
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
I recently asked this same question - check it out.
Multiple Rendering Contexts and Performance
It involves using the WGL_EXT_swap_control extension.
Multiple Rendering Contexts and Performance
It involves using the WGL_EXT_swap_control extension.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement