Jump to content
  • Advertisement
Sign in to follow this  
Dragon_Strike

help with multitexturing

This topic is 4302 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

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
Advertisement
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?

Share this post


Link to post
Share on other sites
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

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!