Skip to main content
gamedev.net
🔒 Locked

Depthbuffering

Started by Luctus Jun 11, 2002 at 3:06 AM 0 replies 550+ views
Original Post
Luctus
Luctus
I''m just about to begin on the graphics part of my(our really) 3d in 2d engine and I have a question about depthtesting. My original idea was to first draw a mesh of the current scene, draw the pre-rendered background then draw the 3d-models on top of that and do the depth-testing against the scene mesh. That approach brings a problem though. If using very complex scenes (and I''m probably talking about VERY complex scenes), the background mesh will also get very complex and will take alot of time to draw every frame. Also, the clipping would not get "perfect" However, now I begun thinking about that instead of drawing a mesh for depth-testing, I could write directly to the depth buffer. However, the only way I found to do that is using the glDrawPixels function that should be REALLY slow. A solution to that would be to blit the pixels to the depth buffer, lock the depth bufffer, sort the 3d objects depth- wise and render them back-to-front (since I''ve locked the depth buffer because I only want to draw it once). So, my question is if there is any faster way than using glDrawPixels for writing in the depth buffer and whetever I should stick to the first approach or try the depth blitting? -Luctus -Luctus
-LuctusIn the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move - Douglas Adams
Xero-X2
Xero-X2
if you want to write directy to the depth buffer and nothing else then enable depthtesting and use

  
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
...
DRAW MESH USEING GEOMETRY
...
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);

that will stop writing to the color buffer.
"I seek knowledge and to help those who also seek it"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.