Using glaux replacement code with multiple textures

Started by
1 comment, last by V12Games 13 years, 3 months ago
I am currently trying to incorporate the NeHe GLaux replacement code into a little game I'm working on, and I am wanting to load more than one texture.

I am currently using the following (I won't reproduce the "NeHeLoadBitmap" function) code:

In the opening declarations:

GLuint texture[2];


In the OpenGL init function:

if (!NeHeLoadBitmap("Data/img1.bmp", texture[0])){  return false;}if (!NeHeLoadBitmap("Data/img2.bmp", texture[1])){  return false;}


Then in the display code, I am calling...

glBindTexture(GL_TEXTURE_2D, texture);


...whenever I want a certain texture to be applied to the subsequent triangles I draw, Where "i" is the ID of the texture created.

However it is always the most recent texture to be loaded (via the NeHeLoadBitmap function) that is applied to every triangle I draw, regardless of what I do with the later glBindTexture calls. I am obviously missing something obvious and doing something wrong, I was wondering if anyone who has experience with the GLaux replacement code could point me in the right direction.

Any assistance will be much appreciated, thanks.
Advertisement
I can't see anything obvious, but here is a few things to try

1. try glBindTexture(GL_TEXTURE_2D, 0); instead of glBindTexture(GL_TEXTURE_2D, texture);, if the texture goes white then at least that part works

2. add glBindTexture(GL_TEXTURE_2D, texture); after the previous line and then test each texture you load, it lets you see if there is a problem with the textureID

3. use individual variables instead of an array, if there is still no change then the bug is in NeHeLoadBitmap

4. you could try rewriting it so that it returns the textureID like this texture[0]=NeHeLoadBitmap("Data/img1.bmp"); since pointers have a tendency to live their own life sometimes
Massive brain fade on my part...Was calling glBindTexture within glBegin/glEnd calls. Taking the calls outside fixed it. I'll post this for the benefit of any googlers/forum searchers who might find their way to this thread with similar problems...

This topic is closed to new replies.

Advertisement