Advertisement

Multitexturing problems...

Started by March 12, 2003 02:53 PM
0 comments, last by James Trotter 21 years, 11 months ago
I''m using multitexturing and vertex arrays together, but it doesn''t work. I''m trying to create a detail texture over my terrain, but it only displays the detail texture, and not the combined texture, like it should! I''ve read the tutorials on Gametutorials.com, and done exactly like they did, except that I''m using vertex arrays, and glClientActiveTexture(). Can someone plz help?
  				glClientActiveTextureARB(GL_TEXTURE0_ARB);
				glEnable(GL_TEXTURE_2D);
				glBindTexture(GL_TEXTURE_2D, map[patch[i]->mapID]->TerrainTex.texID);
				glEnableClientState(GL_TEXTURE_COORD_ARRAY);
				glTexCoordPointer(2, GL_FLOAT, 0, patch[i]->texcoord);

				glClientActiveTextureARB(GL_TEXTURE1_ARB);
				glEnable(GL_TEXTURE_2D);
				glBindTexture(GL_TEXTURE_2D, texture[patch[i]->detailtex].texID);

				glEnableClientState(GL_TEXTURE_COORD_ARRAY);
				glTexCoordPointer(2, GL_FLOAT, 0, patch[i]->texcoord);

				glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);			// Here we turn on the COMBINE properties and increase our RGB

				glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);							// gamma for the detail texture.  2 seems to work just right.


				glMatrixMode(GL_TEXTURE);												// Switch to the texture matrix

				glLoadIdentity();														// Reset the texture matrix

				glScalef(16, 16, 1);													// Scale it by detailscale

				glMatrixMode(GL_MODELVIEW);												// Switch back to the modelview matrix


				glVertexPointer(3, GL_FLOAT, 0, patch[i]->vertex);
				glColorPointer(3, GL_FLOAT, 0, map[patch[i]->mapID]->LightMapData);
				glNormalPointer(GL_FLOAT, 0, map[patch[i]->mapID]->normalMap);
				if (glLockArraysEXT)
					glLockArraysEXT(0, patch[i]->numvertex);

				glDrawElements(GL_TRIANGLE_STRIP,
				(((patch[i]->size + detail) / detail) * (patch[i]->size) / detail) * 2, GL_UNSIGNED_INT,
				&patch[i]->vertindex[0]);
			}
			glPopMatrix();
		}

		glDisable(GL_BLEND);
		glDisableClientState(GL_VERTEX_ARRAY);
		glDisableClientState(GL_COLOR_ARRAY);
		glDisableClientState(GL_NORMAL_ARRAY);

		glClientActiveTextureARB(GL_TEXTURE1_ARB);
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		glDisable(GL_TEXTURE_2D);

		glClientActiveTextureARB(GL_TEXTURE0_ARB);
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);

		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
		glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 0);

		glMatrixMode(GL_TEXTURE);												// Switch to the texture matrix

		glLoadIdentity();														// Reset the texture matrix

		glMatrixMode(GL_MODELVIEW);												// Switch back to the modelview matrix


		glActiveTextureARB(GL_TEXTURE0_ARB);
		glEnable(GL_TEXTURE_2D);
  
Nevermind, I''m so stupid, I found out right now, two seconds after posting this =). Sorry for anyone eager to answer my stupid post... hehe.

This topic is closed to new replies.

Advertisement