-
Texture Mapping
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();
-
Junior Member
Regular Contributor
Re: Texture Mapping
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 ]
-
Re: Texture Mapping
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.
???
-
Re: Texture Mapping
Is the image a power of 2 in its dimensions?
-
Re: Texture Mapping
.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.
-
Senior Member
OpenGL Pro
Re: Texture Mapping
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
-
Re: Texture Mapping
It is not power-of-two.
It is 1280*960. I think that's the problem.
Because other .tga file has 256*256.
-
Re: Texture Mapping
It is solved.
I changed the .tga dimensions. It run.
Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules