PDA

View Full Version : save me from glGenTextures-induced baldness!



Khrob
10-12-2000, 05:58 AM
Can people please tell my what kind of variable you're using to store what glGenTextures() gives you.

Currently I have

unsigned int textureID[MAX_TEXTURES];

and I call

glGenTextures(1, &textureID[0]);

and when I do an
fprintf(f, "%d", texture[0]);

I usually get a 0, or sometimes a negative number...

this is vexing me more than I can say, as I have identical code running in two projects, and one texturemaps, and the other doesnt...

Heeeeeelpp!!!

Inquisitor
10-12-2000, 07:04 AM
At least for the negative values there is a simple explanation:
Don't use %d but %u cause %d is for SIGNED ints only!
The type you're using is correct. Although you should use the OpenGL type GLuint instead.

mcraighead
10-12-2000, 07:05 AM
void glGenTextures(GLsizei n, GLuint *textures);

So GLuint is right, but unsigned int would also almost certainly work.

- Matt

LordKronos
10-12-2000, 08:22 AM
Are you sure you have set your rendering context and everything before you do your glGenTextures? Otherwise, I think it will give you zeros.

Khrob
10-12-2000, 04:05 PM
What a %d%umbass!

Thankyou for your help guys, it's working like a dream!

It was being called in my init code before the window was actually created...

Cheers!