Have been trying to figure out how to put a different texture on each side of a cube using OpenGL and GLUT. I can get it to be a simple texture but multiple texture won't. I would put up my code but it is ugly and cluttered right now. If this is pretty easy to do please post some code for me to follow. Thanks!
A:
its NEHE openGL lesson #22 http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=22 , then if you want to have different texture for each face, you can modify the cube rendering part for each face by switching glClientActiveTextureARB(GL_TEXTURE0_ARB);
,or glClientActiveTextureARB(GL_TEXTURE1_ARB);
depend on the number of texture you have.
for example: `
// Back Face
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glNormal3f( 0.0f, 0.0f,-1.0f);
for (i=4; i<8; i++) {
glTexCoord2f(data[5*i],data[5*i+1]);
glVertex3f(data[5*i+2],data[5*i+3],data[5*i+4]);
}
// Top Face
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glNormal3f( 0.0f, 1.0f, 0.0f);
for (i=8; i<12; i++) {
glTexCoord2f(data[5*i],data[5*i+1]);
glVertex3f(data[5*i+2],data[5*i+3],data[5*i+4]);
}
`
disclaimer: i never test those codes, its based on my memory, you should check ii'am in doubt whether it was glClientActiveTexture() or glActiveTexture()
uray
2010-03-07 12:22:29