Search code examples
opengltextures

OpenGL texture format GL_R11F_G11F_B10F - choosing data type


I would like to use a texture with internal format GL_R11F_G11F_B10F as a framebuffer attachment (postprocessing effects, HDR rendering). I'm not sure which data type I should chosse - glTexImage2D 8th parameter. Here are the possible options:

  • GL_HALF_FLOAT
  • GL_FLOAT
  • GL_UNSIGNED_INT_10F_11F_11F_REV

Could you please explain based on which criteria should I choose that type ?


Solution

  • The format and type of glTexImage2D instruct OpenGL how to interpret the image that you pass to that function through the data argument. Since you're merely allocating your texture without specifying any image (i.e. set data = NULL) the exact values of format and type do not matter. The only requirement for them is to be compatible with the internalformat, or else glTexImage2D will generate GL_INVALID_OPERATION when validating the arguments.

    However, since you're not specifying an image, it's best to use glTexStorage2D here. This function has simpler semantics and you don't need to specify format, type and data at all.