Skip to main content
GameDev.net gamedev.net
🔒 Locked

Texture matrix

Started by BloodLust666 Feb 1, 2008 at 1:10 AM 1 replies 600+ views
Original Post
BloodLust666
BloodLust666
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...
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Vilem Otte
Vilem Otte
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 = zeroglActiveTexture(GL_TEXTURE0);// Enable texturingglEnable(GL_TEXTURE_2D);// Bind texture mapglBindTexture(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 matrixglMatrixMode(GL_TEXTURE);// Load identity matrixglLoadIdentity();// Rotate your texture matrixglRotatef(-W_toDegrees(m_fOrientation),0.0f,0.0f,1.0f);// Scale your texture matrixglScalef(m_v2UVtile.X, m_v2UVtile.Y, 1.0f);// Switch back to modelview matrixglMatrixMode(GL_MODELVIEW);// ... render VBO


This should work, well i presume u haven't some issues in rest of the code.
BloodLust666
BloodLust666
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.
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.