Jump to content
  • Advertisement
Sign in to follow this  
ruzhenchao

OpenGL Depth Component

This topic is 3502 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!