glBindTexture issues

I have a program that gives crashes with the “0xc0…05 Access Violation” whenever I make a call to glBindTexture at a certain point in the program. It is important to note that glBindTexture is called twice in the program, and the second call will work correctly if the first one is commented out. The only thing that I understand could be wrong is that the identifier is 0 or <0, but given that I use glGenTextures that shouldn’t be the case. I even reinstalled my .lib’s in case one or more had gotten corrupted, but that had no effect. So, has anyone else experienced something like this, or if not at least know the cause of what is happening? Any and all replies are welcome.

So when you call gentextures it returns negative values?

Have you tested this properly, ie checked the values directly after they are returned from gentextures?

You should be using unsigned ints for this, maybe that is the problem…

Just to check you are doing this:

unsigned int id1,id2;
glGenTextures(1, &id1);
glBindTexture(GL_TEXTURE_2D, id1);
// upload texture 1
glGenTextures(1, &id2);
glBindTexture(GL_TEXTURE_2D, id2);
// upload texture 2

glBindTexture(GL_TEXTURE_2D, id1);
// draw first stuff
glBindTexture(GL_TEXTURE_2D, id2);
// draw next stuff

Actually, for some reason, the program has begun to hang at the glBindTexture call rather than crash outright, but my guess is the culprit is still the same problem (whatever the hell it is). My need is overwhelmingly simple: I have one texture to define for clouds, and my code goes something like this:

GLuint texture;
glGenTextures(GL_TEXTURE_2D, &texture);
glBindTexture(GL_TEXTURE_2D, texture);

At that third line, the program hangs indefinitely, for no reason whatsoever. I have been using an unsigned int, and according to the debug mode, texture is always assigned a value of 1. So…what is going on here?

Look at your glGenTextures line. Look at the first parateter you pass. Thats WAY wrong. You should have a 1 in there like harryx has not GL_TEXTURE_2D!! Look at your opengl book/tutorials again where it talks about glGenTextures. GL_TEXTURE_2D has a value of 0x0DE1. Your telling opengl to generate that many textures and store the tex ids into your 2nd parameter in GenTextures, which for one is not an array, and two even if it was, that array would have to be pretty big. 3553 to be exact! Im quite sure this is your problem.

-SirKnight

[This message has been edited by SirKnight (edited 02-23-2002).]

hrm, quite.