Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Binding Texture.... I don't get it

This topic is 5451 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 have successfully loaded a windows bitmap as a texture in my little demo and it looks great... however, the only reason I was able to do this is because I was only using one texture and not binding it... I was just loading it and using glTexImage2D. Now I''d like to bind it to a ''name'' so that I can actually delete it when I''m done or maybe have more than one texture... so I add these two lines from just about every tutorial on the subject:
glGenTextures(1, &texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[0]);
Now, when my object moves I get randomly moving black strips over the surface that is textured... when I comment out the glBindTexture, this problem goes away.. I don''t get it... how could attempting to bind the texture cause this problem? Here is my code for loading the texture:
void LoadTexture()
	TextureTest = (HBITMAP)LoadImage(0,
					0, 0,
	GLvoid * Pixels;
	BITMAP bmpTex;
	GetObject(TextureTest, sizeof(BITMAP), &bmpTex);
	Pixels = bmpTex.bmBits;

	glPixelStorei(GL_UNPACK_ALIGNMENT, 8);//needed for windows bitmaps


	//GLuint textures[1]; //moved to global

	glGenTextures(1, &texture[0]);
	glBindTexture(GL_TEXTURE_2D, texture[0]); //when I comment out this line it works just fine... however clearly not bound

	/*This is for debugging
	the message has been showing up so I know it is being
	generated, correct?*/
	if (glIsTexture(texture[0])==GL_TRUE)
		MessageBox(NULL, "texture was generated", "supposedly", MB_OK);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, bmpTex.bmWidth, bmpTex.bmHeight, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, Pixels);
	DeleteObject(TextureTest); //release from system ram

My texture is 64x64 and I''m using MingW... does anyone have any clue why this would happen?

Share this post

Link to post
Share on other sites
glTexParameter sets parameters specific to a texture, so you need to bind the texture name before you set the filter parameters.

Share this post

Link to post
Share on other sites

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