Sign in to follow this  
Hand_Of_Destruction

Texture mapping - something doesn't work...

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
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

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