Sign in to follow this  
zeldatoothemax

OpenGL OpenGL (SFML) texture mapping problems

Recommended Posts

All im trying to do is map a simple texture onto a box, i have followed several tutorials, but i think i must be doing something wrong. the texture i want to use loads fine, here is the code for the front face of my cube, and its texture mapping: -------- glNormal3f( 0.0f, 0.0f, 50.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-50.0f, -50.0f, 50.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 50.0f, -50.0f, 50.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 50.0f, 50.0f, 50.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(-50.0f, 50.0f, 50.0f); --------------------------------------------- and here is the result: http://i210.photobucket.com/albums/bb217/zfan5/box.jpg there is no red in the texture file and the cube before the application of the texture is white. im not quite sure why it will only texture the bottom 1/3 of the cube.... any advice or suggestions would be greatly appreciated, thanks in advanced.

Share this post


Link to post
Share on other sites
There could be several problems, without more code it is hard to say. From what you have posted I would suggest
1. Your normal is wrong, it should be a normalized vector. Use glNormal3f(0.0f,0.0f,1.0f).
2. Your fourth texture coord is wrong, it should be glTexCoord2f(0.0f,1.0f).
3. Wrong colors could be a problem of the wrong texture/file format combination. The most common formats use either RGB or BGR, if you use the wrong format the red and the blue color channel are exchanged.
4. From the image you have posted I would guess that your texture load/upload is wrong.

--
Ashaman


Share this post


Link to post
Share on other sites
Quote:
Original post by zeldatoothemax
--------
glNormal3f( 0.0f, 0.0f, 50.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-50.0f, -50.0f, 50.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 50.0f, -50.0f, 50.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 50.0f, 50.0f, 50.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-50.0f, 50.0f, 50.0f);
---------------------------------------------


Well your texture mapping is incorrect. It should be:


glNormal3f( 0.0f, 0.0f, 50.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-50.0f, -50.0f, 50.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 50.0f, -50.0f, 50.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 50.0f, 50.0f, 50.0f);
glTexCoord2f([b]0.0f[/b], 1.0f); glVertex3f(-50.0f, 50.0f, 50.0f);



Share this post


Link to post
Share on other sites
Oh, sorry guys about the wrong texture cord, in the version im using its actually right, but i think it is probably the way im loading my image, thanks ill look into it ;)

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