Archived

This topic is now archived and is closed to further replies.

TheAvenger

Problems with Multitexture

Recommended Posts

Hi I'm trying to learn OpenGL and I want to do multitexturing. The problem is, that when I enable multitexture the fps drops from about 280 to 10. I'm rendering quads from a displaylist, and I have calles to glMultiTexCoord2fARB inside it. It all workes well if I only include one texture. Lets say I comment out the texture coordinates for GL_TEXTURE1_ARB and let GL_TEXTURE0_ARB stand as it is. As soon as I enable one call to glMultiTexCoord2fARB with GL_TEXTURE1_ARB the fps drops. The textures are correctly rendered thou. I'm trying to texture a terrain. Here is the loading code I use for the display list (shortend): Here I loop through the data and draw a quad from 4 vertices:
			glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(x1/(float)m_dwMapSize),(-z1/(float)m_dwMapSize));
			glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(x1/(float)m_dwMapSize),(-z1/(float)m_dwMapSize));
			glVertex3f(x1,y1,z1);

			glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(x2/(float)m_dwMapSize),(-z2/(float)m_dwMapSize));
			glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(x2/(float)m_dwMapSize),(-z2/(float)m_dwMapSize));
			glVertex3f(x2,y2,z2);
			glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(x3/(float)m_dwMapSize),(-z3/(float)m_dwMapSize));
			glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(x3/(float)m_dwMapSize),(-z3/(float)m_dwMapSize));
			glVertex3f(x3,y3,z3);

			glMultiTexCoord2fARB(GL_TEXTURE0_ARB,(x4/(float)m_dwMapSize),(-z4/(float)m_dwMapSize));
			glMultiTexCoord2fARB(GL_TEXTURE1_ARB,(x4/(float)m_dwMapSize),(-z4/(float)m_dwMapSize));
			glVertex3f(x4,y4,z4);
Here is how I render this:
int CWorld::Draw()
{
	glActiveTextureARB(GL_TEXTURE0_ARB);
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, m_textures[0].texID);

	// Check if we have a detailed texture

	if(m_textures[1].texID != 0)
	{
		// Activate the second texture ID and bind the fog texture to it

		glActiveTextureARB(GL_TEXTURE1_ARB);
		glEnable(GL_TEXTURE_2D);
		
		// Bind the detail texture

		glBindTexture(GL_TEXTURE_2D, m_textures[1].texID);

		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
		glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);
	
		// Now we want to enter the texture matrix.  This will allow us

		// to change the tiling of the detail texture.

		glMatrixMode(GL_TEXTURE);

			// Reset the current matrix and apply scaling to the texture

			glLoadIdentity();
			glScalef(16.0f, 16.0f, 1);

		// Leave the texture matrix and set us back in the model view matrix

		glMatrixMode(GL_MODELVIEW);
	}

	glCallList(m_uWorldList);

	// Clean up multitexture

	glActiveTextureARB(GL_TEXTURE1_ARB);
	glDisable(GL_TEXTURE_2D);

	glActiveTextureARB(GL_TEXTURE0_ARB);
	glDisable(GL_TEXTURE_2D);

	// return success

	return 1;
}
Any help would be great, as I'm completely stuck! And I don't think it's a hardware problem, I'm on a AMD XP 1800+, ATI Radeon 9800 PRO. [edited by - TheAvenger on April 22, 2004 6:00:29 PM] [edited by - TheAvenger on April 22, 2004 6:01:16 PM] [edited by - TheAvenger on April 22, 2004 6:15:22 PM]

Share this post


Link to post
Share on other sites
I found out that rendering to smaller object, the framerate increased greatly.
The first object was a large terrain I drew with 66049 quads.

When redusing it to 10000 quads the framerate increased to 70-80.

With 10000 quads, the framerate went from 450-480 to 70-80.

Now I wondering, is Multitexture such a large performance drop?

Share this post


Link to post
Share on other sites