texture loading

Started by
3 comments, last by GameDev.net 18 years, 8 months ago
I feel like an idiot for asking this, but here goes. Why does this work?

                glGenTextures(1, &Texture);
		glBindTexture(GL_TEXTURE_2D, Texture);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, 256,256,GL_RGB,GL_UNSIGNED_BYTE, image);
		glBindTexture(GL_TEXTURE_2D, Texture);
But this doesn't?

                glGenTextures(1, &Texture);
		glBindTexture(GL_TEXTURE_2D, Texture);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 255, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
		glBindTexture(GL_TEXTURE_2D, Texture);
The first one displays the texture, the second one doesn't. Am I forgetting something?
"It's better to regret something you've done than to regret something you haven't done."
Advertisement
Probably because in the second example the image isn't power of 2 glTexImage2D won't work if the image isn't power of two. In the other example the size of the image shouldn't really matter because it'll resize it to be power of two I believe. I don't see why it wouldn't work aside from that though... Ah and don't forget to enable GL_TEXTURE_2D, stupid but it happens =)
Yeah, I can't help but wonder if it was just a simple typo?

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 255, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
gaaa, I can't believe I didn't see that :(

thanks guys
"It's better to regret something you've done than to regret something you haven't done."
dont think it will make a difference, but I found using RGB8 instead of RGB should be more compatible for some reason in the texturebuild options

This topic is closed to new replies.

Advertisement