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

help with multitexturing

Started by Dragon_Strike Sep 9, 2006 at 6:15 PM 2 replies 450+ views
Original Post
Dragon_Strike
Dragon_Strike
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);
			
		}



bakery2k1
bakery2k1
Don't forget to enable texturing [glEnable(GL_TEXTURE_2D)] on both texture units.
Dragon_Strike
Dragon_Strike
ur a genious! thx... i thought the enable function was global

EDIT:

since im alrdy on the topic... when i move the camera my textures get noisy/flimmery... what migth be causing this?
MARS_999
MARS_999
You are using the incorrect filtering for mipmapping. Its not GL_LINEAR it's

GL_LINEAR_MIPMAP_LINEAR for the min filter and GL_LINEAR for the max filter... HTH

Topic Locked

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

Sign in to reply to this topic.