View Full Version : selective redraw in opengl
hi , how do i go about rendering only a portion of my view? for example, i have a background that is supposed to stay the same way thoughout, and in front should be an object that is moving, how do i only redraw the object every frame and not the background to cut down the processing? pls tell me some directions or fucntions to use as i know noting about opengl and only need to edit some codes...
i have one problem though...my image is not depth buffered meaning that the obj in the foreground maybe behind the background, but i only want the obj to appear in the front(therefore i did not do to depth test)...how do i do it?
You can't. You'll need to draw each frame totally.
For your second question, if I understood it correctly, just draw the background first, then your object, without enabling depth test.
02-20-2006, 01:07 AM
You could prerender the background and store the picture in a texture using the glCopyTexSubImage2D, so you only draw a full-screen quad as a backgrpund each time. Hovewer, it will only work if your view does not move.
thanks! can i use GlReadPixels and GlDrawPixels? i dont really know what they can do..
02-20-2006, 02:09 AM
ReadPixels and WritePixels are slow.
You should create a big enough texture first, then render the background(without swaping the buffers!) and use the glCopyTexImage2D function. It will copy the imag efrom the framebuffer to the texture. Now you have a texure of your background.
To draw it, just render a rectangle that has exacly screen size with this texture on it.
02-20-2006, 12:10 PM
you might want to look into WGL_ARB_buffer_region, if you are coding for windows. http://oss.sgi.com/projects/ogl-sample/registry/ARB/wgl_buffer_region.txt
it is based on the widely supported extension GL_KTX_buffer_region, whose spec is somewhat hard to find... but it was made for 3dsmax.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.