Skip to main content
gamedev.net
🔒 Locked

Depth Component

Started by ruzhenchao 1 reply 750+ views
Original Post
ruzhenchao
ruzhenchao
Recently, I was writing code about texture using OpenGL API. there are two parameters that doubt me in the function glTexImage* they are format(image format) and type(image type) if the format is GL_RGB and the type is GL_UNSIGNED_BYTE then a pixel has red,green,blue component and each component is 8 bits, if the type is GL_UNSIGNED_SHORT then each component is 16 bits. Yes It's obvious! The question is how many bits in a pixel if the format is GL_DEPTH_COMPONENT and the type is GL_UNSIGNED_BYTE and what about GL_UNSIGNED_SHORT?
dpadam450
dpadam450
When you create your depth buffer, how many bits did you request? I think depth component will just match that.
NBA2K, Madden, Maneater, Killing Floor, Sims 
Promit
Promit
Quote:
Original post by ruzhenchao
The question is how many bits in a pixel if the format is GL_DEPTH_COMPONENT and the type is GL_UNSIGNED_BYTE and what about GL_UNSIGNED_SHORT?
According to the docs:
Quote:
GL_DEPTH_COMPONENT
Each element is a single depth component. It is converted to floating-point, then multiplied by the signed scale factor GL_DEPTH_SCALE, added to the signed bias GL_DEPTH_BIAS, and clamped to the range [0, 1] (see glPixelTransfer).

So if you use GL_UNSIGNED_BYTE, each pixel is 8 bits. 16 if SHORT, 32 if INT.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

Topic Locked

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

Sign in to reply to this topic.