Texture Mapping

I completed to load a .tga file in cpp&opengl. The fallowing code is successful.


And I tried same .tga file to do texture mapping on the following codes,(I used same loader code) it didn’t run :
I try to solve problem.
1-) Pixel number is more than the object size. Is it a problem?
2-) There isn’t a load error on program, but object is not covered with .tga. What can be the problem?

glTexCoord2f(2.0, 0.0); glVertex3f(2.0, -2.0, -2.0);
glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -2.0, -2.0);
glTexCoord2f(2.0, 2.0); glVertex3f(2.0, -2.0, 2.0);
glTexCoord2f(0.0, 2.0); glVertex3f(-2.0, -2.0, 2.0);

Have you bound your texture with glBindTexture? Did you also enable the texture with glEnable(GL_TEXTURE_2D)? You also need to set the minification and the magnification filters for the texture. Do you get any gl errors? You could check that for instance with GLIntercept.

[ www.trenki.net | vector_math (3d math library) | software renderer ]

I will check glBindTexture.
Actually, second code runs with different .tga file which has same dimensions with object.
I used glEnable(GL_TEXTURE_2D) already.
There is not any error. But object surface is blank.

Is the image a power of 2 in its dimensions?

.tga file is larger than object dimensions. I don’t know how is larger. But it may be larger as twice as object dimensions or more.

Can you post the whole code? I think that you are loading your texture in a wrong way… Also, on older cards texture size has to be a power-of-two, like 256x256 or 512x512 etc… The texture-to-object size ratio plays no role here

It is not power-of-two.
It is 1280960. I think that’s the problem.
Because other .tga file has 256

It is solved.
I changed the .tga dimensions. It run.