Jump to content
  • Advertisement
Sign in to follow this  
BloodLust666

Texture matrix

This topic is 3885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
cool thanks, i'll try that out; but what about if I am using shaders? I'm actually in the process of refactoring how my rendering works so I can incorporate shaders.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!