View Full Version : how to draw on the screen without cleaning others drawn object..?
tranckhanh
06-27-2001, 10:21 PM
Dear developers,
My drawing function CView::RenderScene is called on WM_PAINT event.
How can I draw something on the screen without clearing screen(put
OpenGL drawing code outside RenderScene function).
Howdy,
er. I don't know anything about the windows event model, but i'm guessin' its similar to X's event model (and how glut is like a duplo version of it=).
The short answer is:
you can stick gl commands anywhere in your program, and they WILL be rendered (providing you have a current opengl context, of course). you can draw stuff in the reshape callback, for example.
however: you may want to rethink how you're structurnig your program. do you really need to add drawing code elsewhere? consider this example:
bool clear=true;
void render(void)
{
if(clear)
glClear(GL_COLOUR_BUFFER_BIT);
drawSomeFunkyStuff();
}
void reshape(int w, int h)
{
clear=!clear;
}
this simple example will alternatively clear the screen every time the window is reshaped, but **the drawing code still remains in the render fucntion**. So, think abouyt your program flow before you get too carried away.
cheers,
John
i think what you will do, is only clear the depthbuffer(if you use one), so you can draw over the last frame without clearing it
Deiussum
06-28-2001, 05:34 AM
Also override the OnEraseBkgnd() function and have it simply return TRUE, or windows will try to clear the scene for you.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.