Jump to content
  • Advertisement
Sign in to follow this  
Hand_Of_Destruction

Texture mapping - something doesn't work...

This topic is 4466 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

I don't know how to load texture from a .bmp file. It did worked one time, but now it doesn't. quad displays white... BMP loading lib is from ultimategameprogramming.com
texture.LoadBitmap("c:\\tex.bmp");
glGenTextures(1, &texture.ID);
glBindTexture(GL_TEXTURE_2D, texture.ID);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, texture.imageWidth,
	                  texture.imageHeight, GL_RGB, GL_UNSIGNED_BYTE,
	                  texture.image);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

and later
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture.ID);
    glBegin(GL_QUADS);
      glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.5f, -0.5f, 0.5f);
      glTexCoord2f(1.0f, 0.0f); glVertex3f(0.5f, -0.5f, 0.5f);
      glTexCoord2f(1.0f, 1.0f); glVertex3f(0.5f, 0.5f, 0.5f);
      glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.5f, 0.5f, 0.5f);
   glEnd();

Share this post


Link to post
Share on other sites
Advertisement
u need to set the clamping modes as well, check the chapter 'texture completeness' in the opegl spec

Share this post


Link to post
Share on other sites
I suggest trying OpenIL http://openil.sourceforge.net/. It supports many image formats and it has a native OpenGL texture loading mechanism, so you don't even have to call glGenTextures and gluBuild2DMipmaps.

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!