View Full Version : Rendering in a part of window
01-09-2003, 11:29 PM
The information in my window is logically splitted into two parts. The upper half of window is drawn by GDI, the lower - by OpenGL. I restrict OpenGL output by glScissor and glViewport - fine. But nevertheless OpenGL clears entire window. So if I make OpenGL drawing after GDI, OpenGL paints erases GDI part of window. I tried to make GDI drawing after OpenGL, it works but produces flickering of GDI part.
My question is: does it possible to fully restrict OpenGL by given rectangular area of window?
Create a sub-window in your window for OpenGL.
01-10-2003, 01:33 AM
- OpenGL clears are restricted by glScissor, you must be doing something wrong when the glClear erases the whole window.
- Defualt window handling for WM_ERASEBKGND is to clear the whole window. Add a WM_ERASEBKGND message handler which only returns non-zero.
- Restrict GDI drawing to the window area you want to render to with a clipping region.
- GDI does only know single buffering. If you render double buffered, the SwapBuffers call swaps the whole window area.
Conclusion: Use a different sub-window for OpenGL like evil suggested.
A common mistake is to set the scissor box but not enable the scissor test.
01-10-2003, 05:16 AM
If I use glViewport without glScissor entire window is filled with clear color. If I use glScissor only the area specified in glScissor is cleared with clear color but other area (GDI) is filled with gray color even if double buffering is turned off. So I suppose that this effect is Win32 or my OpenGL implementation feature (or a bug).
01-10-2003, 07:22 AM
The grey GDI area is probably the erase background handling I mentioned above. Implement the handler as
case WM_ERASEBKGND: return 1;
and that should stop.
Though it's a lost case, better use a separate or child window for OpenGL if the renderings don't overlap anyway. Clipping is handled by the windows subsystem then and you don't need tricks with scissor and viewports.
01-11-2003, 03:35 AM
Originally posted by airatsa:
If I use glScissor only the area specified in glScissor is cleared with clear color but other area (GDI) is filled with gray color even if double buffering is turned off.
Sorry, I was mistaken. GDI area is filled with gray color if double buffering is turned on. If double buffer is turned off all works fine (with flickering of course).
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.