Skip to main content
gamedev.net
🔒 Locked

glGenTextures

Started by cwhite 4 replies 4.4k views
Original Post
cwhite
cwhite
What would cause glGenTextures to fail to return a valid texture identifier? For example, I have the following code in my project:
[source language=c++]
glGenTextures(1, &grassTex_);
if (!glIsTexture(grassTex_))
	cout << "OpenGL I curse at you" << endl;

The output of this snippet is "OpenGL I curse at you." I therefore, cannot use my grass texture. Any help would be greatly appreciated.
nts
nts
dont you actually need to fill the texture with some data first before you can use glIsTexture? AFAIK it can only fail if you pass in a negative number or call it between glBegin and end.

If the handle returned isn't 0 then you are fine, just place some data in the texture first using glTexImage2D or gluBuild2DMipMaps

HTH

Myopic Rhino
Myopic Rhino
A name isn't actually a texture object until you call glBindTexture() on it.
cwhite
cwhite
Thank you to both of you. I was using glIsTexture() to debug a program when the texture wasn't displaying. I thought I had found the reason, but now I see I have to keep looking. Moving the glBindTexture to before the glIsTexture() call made the glIsTexture() return true, but still didn't make my textures display
Myopic Rhino
Myopic Rhino
Most common reason I see for that: You're either not loading mipmap levels, or you're not changing the minification filter from its default value, which is one of the mipmap modes.
cwhite
cwhite
Thanks again. I now have my terrain textured, so it's time to get lighting working.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.