why fails glTexImage2D sometimes?

Started by
5 comments, last by V-man 17 years, 11 months ago
this is also one of those things which i can't get my head around. at some times the glTexImage2D simply does not copy any pixels from my memory to a texture leaving things all black. there is no error code returned but still all is black. it happens only at some places and others it's working without a problem. how comes glTexImage2D copies no pixels but still returns success?

Life's like a Hydra... cut off one problem just to have two more popping out.
Leader and Coder: Project Epsylon | Drag[en]gine Game Engine

Advertisement
How exactly do you know no pixels are copied? Perfectly possible that pixels ARE copied, but the texture combiners are set such that the result is black. Have you made sure that the texture object is complete by changing the default minification filter or uploaded all required mipmap levels?
i tested by attaching the textured to a GLSL shader simply outputing it and black came out. using another texture i prefab during init-time it showed. what exactly you mean with 'not complete'? most probably something like this is missing but without any error message i have no clue why this could be. furthermore i used a similar code to what i use to load my other textures and there it works.

Life's like a Hydra... cut off one problem just to have two more popping out.
Leader and Coder: Project Epsylon | Drag[en]gine Game Engine

RPTD,

are all your textures power-of-2 sized ?
Alex BakerComputer science is dealing with computers as much as astronomy is dealing with telescopes.
Quote:Original post by RPTD
what exactly you mean with 'not complete'? most probably something like this is missing but without any error message i have no clue why this could be. furthermore i used a similar code to what i use to load my other textures and there it works.


you should call functions like
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);


after calling glBindTexture, and before glTexImage2D

Additionally if you are using mipmaps you must load all mipmap levels . From the man page:

Quote:
Suppose that a program has enabled texturing (by calling
glEnable with argument GL_TEXTURE_1D, GL_TEXTURE_2D or
GL_TEXTURE_3D) and has set GL_TEXTURE_MIN_FILTER to one of
the functions that requires a mipmap. If either the dimen-
sions of the texture images currently defined (with previous
calls to glTexImage1D, glTexImage2D, glTexImage3D,
glCopyTexImage1D, or glCopyTexImage2D) do not follow the
proper sequence for mipmaps (described above), or there are
fewer texture images defined than are needed, or the set of
texture images have differing numbers of texture components,
then it is as if texture mapping were disabled.

i have set the filtering before teximage2d so this should not be the problem. furthermore this particular image shall not use mipmaping ( as i want to use it later on to capture the depth buffer using DEPTH_COMPONENT ). i also use the linear filter, which should disable mipmapping. correct me if i got that wrong.

Life's like a Hydra... cut off one problem just to have two more popping out.
Leader and Coder: Project Epsylon | Drag[en]gine Game Engine

What does your call to glTexImage2D look like?
And just in case, what your hw+driver?
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement