PDA

View Full Version : Texture Mapping



senem
09-23-2007, 01:24 PM
I completed to load a .tga file in cpp&opengl. The fallowing code is successful.
...
glRasterPos2i(0,0);
glDrawPixels..
..

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?

glBegin(GL_TRIANGLE_STRIP);
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);
glEnd();

Trenki
09-23-2007, 01:57 PM
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 (http://www.trenki.net) | vector_math (3d math library) (http://www.trenki.net/content/view/16/36/) | software renderer (http://www.trenki.net/content/view/18/38/) ]

senem
09-24-2007, 02:35 AM
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.
???

Joseph Steel
09-24-2007, 06:33 AM
Is the image a power of 2 in its dimensions?

senem
09-24-2007, 08:12 AM
.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.

Zengar
09-24-2007, 08:25 AM
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

senem
09-24-2007, 11:09 AM
It is not power-of-two.
It is 1280*960. I think that's the problem.
Because other .tga file has 256*256.

senem
09-24-2007, 11:29 AM
It is solved.
I changed the .tga dimensions. It run.
Thanks.