multiple textures

hey guys im a bit new at the opengl stuff, what i wanted to know is how to do multiple textures in a level, im able to texture the floor of my game level but i want texture cubes as well but i dont know how to call multiple textures

struct Image
{
unsigned long size_x;
unsigned long size_y;
char *data;
};

typedef struct Image Image;

const int textureCount = 1;

Image myTextureData[textureCount];
GLuint theTexture[textureCount];

char* textureFilenames[textureCount] = {“road.bmp”};

and my texture loader code

void textureLoader()
{

glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

for(int k=0; k < textureCount; k++)
{
if(!imageLoader(textureFilenames[k], &myTextureData[k]))
exit(1);

  glGenTextures(1, &theTexture[k]);
  
  glBindTexture(GL_TEXTURE_2D, theTexture[k]);
  glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
  glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
  
 	gluBuild2DMipmaps(GL_TEXTURE_2D, 3, myTextureData[k].size_x, myTextureData[k].size_y, GL_RGB, GL_UNSIGNED_BYTE, myTextureData[k].data);

}

Hey Man

If you want to apply different Textures to different objects in a level or to different walls for example The easiest way to do it is to place glEnable(GL_TEXTURE_2D) at the top of each section of code to do with your wall/object, Then place your glBindTexture(GL_TEXTURE_2D, theTexture[k]); directly underneith this and then place glEnd() at the end of them, of course you should push and pop the matrix each time this is done.

This is the basics of the basics for textures so I dont know how much this will help but I hope it does.

Good luck mate.

Fatch1990 is right, You should use GL_TEXTURE_2D for each object unless you are using 3D textures. A good way to texture each object is to generate your textures using:

glGenTextures(GLsizei n, GLuint *textures);

This will give you some “handles” to the textures that then you use to bind the textures before the rending of each object:

glBindTexture(GL_TEXTURE_2D, texture[<index>]);
<Render Object>

That should work.
I hope that helps!

Check out this site, it has video tutorials on the subject, I believe it’s lesson 5. If your level is going to be large your going to want to pack all your textures into one big one, then read only part of the file at a time. You can only use one texture per render call (or so I was told a while back when I asked this same question), and your game is going to slow down after so many render calls. Sadly there isn’t a tutorial on that site for this…I guess the MD2 animation tutorial goes into it a little bit, but it barely goes into any depth on the subject.

Hope that helps some!
Goblin