I've trying to load different textures to the GL_TEXTUREX variables and then assign them to different spheres. but so far I've having problems. I tried some of the suggestions in post like this and this but couldnt solve it.
This is part of my code:
GLuint textures[2];
void LoadTextures(std::string const& dirname)
{
glGenTextures(2, textures);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textures[0]);
Image_t sun = loadPNG(std::string(dirname + "/sun.png"));
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, &(sun.data[0]));
glBindTexture(GL_TEXTURE_2D, textures[0]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, textures[1]);
Image_t mercury = loadPNG(std::string(dirname + "/mercury.png"));
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1024, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, &(mercury.data[0]));
}
and
void draw(void)
{
glEnable (GL_TEXTURE_2D);
glBindTexture (GL_TEXTURE_2D, textures[0]);
glPushMatrix();
glTranslatef(0.4,0,0);
gluSphere(sun, 0.5, 36, 36); //I want this sphere to use the texture GL_TEXTURE0
glPopMatrix();
glDisable(GL_TEXTURE_2D);
}