Regarding Depth Buffer


im using glDrawPixels() to draw some pixel data that i read from a file. After that, im trying to draw other objects. But, im the objects are not visible when i enable depth buffering.

glDrawPixels(640, 480, GL_RGB, GL_UNSIGNED_BYTE, image_data);
glColor3f(1.0, 0.0, 0.0);

Here, the Cube appears when i disable depth buffer. But i cannot see the cube when depth buffering is enabled.

i even tried using Textures, but the cube does not appear.

Can anyone please tell me what the problem could be?

I think you should use glRasterPos to select the depth value before using glDrawPixels.

I don’t know what default values it is when you don’t specify glRasterPos before.

try a glClear(GL_DEPTH_BUFFER); after glDrawPixels.

Thanks arts, Zbuffer.

Both the methods worked. :slight_smile: