View Full Version : Read/Draw Pixels Alternative
11-15-2000, 02:40 PM
My problem in brief: I am writing a program to visualize moving ground & aircraft units over a static terrain. The cost of rendering the terrain is mammoth compared to the cost of rendering the units over the terrain. Consequently I'm looking for a way to render the terrain once, save the color/depth buffers, and simply write the saved terrain to the buffers on every refresh before the units are drawn. I have tried to use glReadPixels and glDrawPixels for this purpose but the automatic transformations that the GL applies to each pixel during these routines actually take more time than re-rendering the entire terrain. So I ask 1) is there a way to disable these transformations or 2) is there another way to approach this problem which has eluded me. It seems to me as though there must be an elegant solution. Suggestions?
11-16-2000, 12:20 AM
Transformation is not the bottleneck when using pixel operations, only the current rasterpos is transformed, the rest is a simple onscreen rectangle.
Transfering and converting the data is the bottleneck.
To improve pixel operation performance, make sure you have everything disabled which could affect a simple copy operation.
(depth buffering, texturing, blending, zoom, bias, pixel mapping, etc.)
If I understand you correctly you have a 3D terrain, so you also have to save the depth buffer for proper rendering of moving objects.
Have a look at the GL_KTX_buffer_region or (newer) WGL_ARB_buffer_region. They can save and restore rectangular regions of color and depth buffers. Much faster than read and draw pixels, because the data in it cannot be accessed by the user.
11-17-2000, 11:26 AM
Thanks.. Disabling Blending and Depth Testing before DrawPixels improved performance ten fold. I appreciate your help.
[This message has been edited by DaveTheBrv (edited 11-17-2000).]
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.