PDA

View Full Version : Resizing Textures - Multitexturing



wvufan87
11-19-2008, 09:15 AM
I'm having trouble resizing my textures when using multiple textures. I thought I could just manipulate the texture matrix but it only works for the first texture. The second is not affected at all. Here is my code:


glPushMatrix();
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glScalef(2.0f, 2.0f, 1.0f); //make the texture smaller
glMatrixMode(GL_MODELVIEW);

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[2]);

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[3]);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); //set the texture mode to combine the two
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2); //scale the color of this

//east wall
if((room[i].flags & ROOM_EAST_EXIT) != ROOM_EAST_EXIT)
{
glBegin(GL_QUADS);
glNormal3f(-1.0f, 0.0f, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f); glVertex3f(room[i].v4.x, room[i].v4.y, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 1.0f); glVertex3f(room[i].v4.x, room[i].v4.y, 3.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 1.0f); glVertex3f(room[i].v3.x, room[i].v3.y, 3.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 0.0f); glVertex3f(room[i].v3.x, room[i].v3.y, 0.0f);
glEnd();
}

//west
if((room[i].flags & ROOM_WEST_EXIT) != ROOM_WEST_EXIT)
{
glBegin(GL_QUADS);
glNormal3f(1.0f, 0.0f, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f); glVertex3f(room[i].v1.x, room[i].v1.y, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 1.0f); glVertex3f(room[i].v1.x, room[i].v1.y, 3.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 1.0f); glVertex3f(room[i].v2.x, room[i].v2.y, 3.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 0.0f); glVertex3f(room[i].v2.x, room[i].v2.y, 0.0f);
glEnd();
}

//north wall
if((room[i].flags & ROOM_NORTH_EXIT) != ROOM_NORTH_EXIT)
{
glBegin(GL_QUADS);
glNormal3f(0.0f, -1.0f, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f); glVertex3f(room[i].v2.x, room[i].v2.y, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 1.0f); glVertex3f(room[i].v2.x, room[i].v2.y, 3.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 1.0f); glVertex3f(room[i].v3.x, room[i].v3.y, 3.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 0.0f); glVertex3f(room[i].v3.x, room[i].v3.y, 0.0f);
glEnd();
}

//south wall
if((room[i].flags & ROOM_SOUTH_EXIT) != ROOM_SOUTH_EXIT)
{
glBegin(GL_QUADS);
glNormal3f(0.0f, 1.0f, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f); glVertex3f(room[i].v1.x, room[i].v1.y, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 1.0f); glVertex3f(room[i].v1.x, room[i].v1.y, 3.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 1.0f); glVertex3f(room[i].v4.x, room[i].v4.y, 3.0f);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 1.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 1.0f, 0.0f); glVertex3f(room[i].v4.x, room[i].v4.y, 0.0f);
glEnd();
}

glPopMatrix();
//reset texturing
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE0_ARB);

ZbuffeR
11-19-2008, 09:28 AM
Each active texture has its own set of texture parameters, env, and texture matrix.

_NK47
11-19-2008, 09:29 AM
i don't see any code manipulating the texture matrix AFTER glActiveTextureARB(GL_TEXTURE1_ARB). first select the active texture unit you want to change then do all operations on it.

a bit late :)