OpenGL glGetTexImage2d option?

reading the docs I can see that the glGetTexImage2d () function has a type parameter. The docs say a parameter of type "sets the data type of the pixel" and gives some examples of types like GL_INT, GL_BYTE, etc.

but what does it mean when the image format is GL_RGBA and GL_INT? is it an int for each channel? or int for the whole color? and if it's an int for the whole color, then isn't it like GL_BYTE? since there are 4 bytes in int which makes each channel a byte each

+2


source to share


2 answers


It's an int per channel. RGBA means that each pixel has R, G, B and A int (if you set it to int) in the data array you give it. RBGA (if it exists, but not sure about it) also means four ints, but is ordered differently. RGB will only mean three (no alpha channel).



+4


source


The type parameter specifies the effective data type within the buffer you are sending to OpenGL.

The goal is that OpenGL is going to walk in your buffer and wants to know how many elements are present ( width * height * internalformat

) and their size and interpretation ( type

).



For example, if you want to provide an array of unsigned ints containing red / green / blue / alpha channels (in that order), you need to specify:

  • target

    : GL_TEXTURE_2D

  • level

    : 0 (except when you are using mipmaps)
  • internalformat

    : 4 because you have red, green, blue and alpha
  • width

    : 640
  • height

    : 480
  • border

    : 0
  • internal format

    : GL_RGBA to tell the order of our channels and what they mean
  • type

    : GL_UNSIGNED_INT

    will let opengl know the type of elements inside our array
  • pixels

    : a pointer to your array
+4


source







All Articles