Sign in to follow this  

OpenGL texture2DArray

Recommended Posts


im having problem trying to implement my texture2d Array. here is the c++/opengl code where i put my texture value:

unsigned char* texture3DFit = new unsigned char[textureWidth*textureDepth*textureHeight*3];

for(int i = 0; i<textureWidth*textureDepth*textureHeight*3;i++) {
texture3DFit[i] = 50;

glBindTexture(GL_TEXTURE_2D_ARRAY, texName);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB8, textureWidth, textureHeight,
textureDepth, 0, GL_RGB, GL_UNSIGNED_BYTE, texture3DFit);

i put the default value 50 for a while to check its right or wrong.
here is the glsl code:

#version 130
#extension GL_EXT_gpu_shader4: enable

uniform sampler2DArray tex;

varying float sphIndexY;
varying float sphIndexZ;

void main() {

vec3 coord;
coord.x = gl_TexCoord[0].s;
coord.y = gl_TexCoord[0].t;
coord.z = 1;
vec4 color = texture2DArray(tex,;

gl_FragColor = color;

the color appear on the screen is just blank. there are no error appeared when compiling the glsl. any1 notice anything wrong in the code?

thanks in advance

EDIT: i used geforce 9600GT 512MB if thats important

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this