Sign in to follow this  
Dragon_Strike

help with multitexturing

Recommended Posts

im trying to use multitexturing with 2 textures.. GL_TEXTURE0 is always rendered just fine... but for some reason GL_TEXTURE1 is never rendered... even if i skip binding GL_TEXTURE0.. what am i doing wrong? im using the glee library and header for extensions...

// INIT FUNCTION

glActiveTexture(GL_TEXTURE0);
Light.LoadRaw("Lightmap.RAW");
Light.CreateTexture(GL_LINEAR,GL_LINEAR,4.0f );
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
	
glActiveTexture(GL_TEXTURE1);
Grass.LoadData("mid2.tga");
Grass.CreateTexture(GL_LINEAR,GL_LINEAR,8.0f );
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

		void CreateTexture(unsigned int mag, unsigned int min, float samples)
		{

			unsigned int iTempID;
			glGenTextures(1, &iTempID);
			glBindTexture(GL_TEXTURE_2D, iTempID);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min);
			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, samples);
			gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, m_uiWidth, m_uiHeight, GL_RGB, GL_UNSIGNED_BYTE, GetData( ) );
			SetID( iTempID );
		}

// RENDER FUNCTION

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, Light.GetID());
						
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, Grass.GetID());

Render mesh with calls to RenderVertex()

		inline RenderVertex(CVECTOR& Vertex)
		{			
			glMultiTexCoord2f(GL_TEXTURE0, (float)Vertex.x/(float)m_iSize, (float)Vertex.z/(float)m_iSize);
			glMultiTexCoord2f(GL_TEXTURE1, (float)Vertex.x/(float)m_iSize*10, (float)Vertex.z/(float)m_iSize*10);
			glVertex3f( Vertex.x, Vertex.y, Vertex.z);
			
		}



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