Hi,
I am using the programming language C and the openGL-library freeglut under Windows 8.1.
I am trying to apply a 3D Texture to a 3D model which I draw by loading it from an obj-file. To do so I use the following code:
glEnable(GL_TEXTURE_3D);
unsigned int texname;
glGenTextures(1, &texname);
glBindTexture (GL_TEXTURE_3D, texname);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGB32F, WIDTH, HEIGHT, DEPTH, 0, GL_RGB, GL_FLOAT, solidTexture);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY_EXT);
glVertexPointer(3, GL_FLOAT, 0, faces);
glColorPointer(3, GL_FLOAT, 0, solidTexture);
glTexCoordPointer(3, GL_FLOAT, 0, solidTexture);
glDrawArrays(GL_QUADS, 0, TotalConnectedComponents);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY_EXT);
glDisable(GL_TEXTURE_3D);
Drawing the quad which I loaded from an obj-file works fine, but applying the 3D-texture creates these crazy stripes on the quad:
[ATTACH=CONFIG]959[/ATTACH]
The texture is actually some kind of white noise which I created by using the rand()-function to fill a 3-dimensional array including 3 values per colour (RGB):
GLfloat *solidTexture= (GLfloat*) malloc(sizeof(GLfloat) * WIDTH * HEIGHT * DEPTH * 3);
Can someone please help me getting rid of those stripes? I can also post my whole code if necessary.
Thank you!
Fatman_Stoned