Sign in to follow this  
RPTD

why fails glTexImage2D sometimes?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
What does your call to glTexImage2D look like?
And just in case, what your hw+driver?

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