Discussion:
Use of GL_TEXTURE_2D_ARRAY
(too old to reply)
Cathy L.
2013-09-12 14:34:54 UTC
Permalink
Hello

I have several questions about the use of 2D texture arrays.

- before using glGenTextures/glBindTexture/glTexParameteri/glTexImage3D,
do I need to glEnable(GL_TEXTURE_3D) or glEnable(GL_TEXTURE_2D_ARRAY)?

- Is the way to compute the "depth" (the third) texture coordinate the
similar to the way for 3D texture in the shader?

Thanks
Cathy L.
Wolfgang Draxinger
2013-09-13 17:02:32 UTC
Permalink
Post by Cathy L.
Hello
I have several questions about the use of 2D texture arrays.
- before using glGenTextures/glBindTexture/glTexParameteri/glTexImage3D,
do I need to glEnable(GL_TEXTURE_3D) or glEnable(GL_TEXTURE_2D_ARRAY)?
No. glEnable(GL_TEXTURE_...) selects the specified texture target fixed
function pipeline sampling source for the active texturing unit. If
you're using shaders, you don't need glEnable(GL_TEXTURE_...) at all.
Post by Cathy L.
- Is the way to compute the "depth" (the third) texture coordinate the
similar to the way for 3D texture in the shader?
The third coordinate is the integer texture layer. If specified as a
floating point coordinate the integer part is used as if calculated by

actual_layer = max(0, min(d​ - 1, floor(layer​ + 0.5)) )

where d is the number of layers, and layer the accessed layer. I.e.
layer gets clamped into the range [0, d-1] and proper rounding is applied.


Wolfgang

Loading...