Jump to content

  • Log In with Google      Sign In   
  • Create Account


Using glaux replacement code with multiple textures


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 V12Games   Members   -  Reputation: 100

Like
0Likes
Like

Posted 02 January 2011 - 01:02 PM

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[i]);

...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.

Sponsor:

#2 lc_overlord   Members   -  Reputation: 435

Like
0Likes
Like

Posted 02 January 2011 - 10:04 PM

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[i]);, if the texture goes white then at least that part works

2. add glBindTexture(GL_TEXTURE_2D, texture[i]); 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

#3 V12Games   Members   -  Reputation: 100

Like
0Likes
Like

Posted 03 January 2011 - 04:33 AM

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...




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS