Jump to content
  • Advertisement
Sign in to follow this  
zeldatoothemax

OpenGL OpenGL (SFML) texture mapping problems

This topic is 3318 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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(0.0f, 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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!