Sign in to follow this  
BloodLust666

Texture matrix

Recommended Posts

I think there may be something wrong with the way i'm doing my texture matrix... The code below is how i'm doing things. By the way, i'm using VBO's, don't know if that matters or not.

glActiveTexture(GL_TEXTURE0);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

glMatrixMode(GL_TEXTURE);
glLoadIdentity();

glRotatef(-W_toDegrees(m_fOrientation),0.0f,0.0f,1.0f);
glScalef(m_v2UVtile.X, m_v2UVtile.Y, 1.0f);

glBindTexture(GL_TEXTURE_2D, m_pMap->_GetGLTextureID());

// ... render VBO


Even when I have texture that is to be rotating (inc the m_fOrientation), nothing moves, no spinning, no nothing...

Share this post


Link to post
Share on other sites
Well, as far as I know, you need to set matrix mode on modelview matrix after rotating and scaling texture coordinates. And if you are not using shaders, than you need to enable texture, so it'd look like:


// Active texel unit = zero
glActiveTexture(GL_TEXTURE0);
// Enable texturing
glEnable(GL_TEXTURE_2D);
// Bind texture map
glBindTexture(GL_TEXTURE_2D, m_pMap->_GetGLTextureID());
// Dunno why are u modulating texture, try replacing it:
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

// Texture matrix
glMatrixMode(GL_TEXTURE);
// Load identity matrix
glLoadIdentity();

// Rotate your texture matrix
glRotatef(-W_toDegrees(m_fOrientation),0.0f,0.0f,1.0f);
// Scale your texture matrix
glScalef(m_v2UVtile.X, m_v2UVtile.Y, 1.0f);

// Switch back to modelview matrix
glMatrixMode(GL_MODELVIEW);

// ... render VBO


This should work, well i presume u haven't some issues in rest of the code.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this