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

Two textures

Started by Maxwan May 29, 2003 at 10:02 AM 3 replies 650+ views
Original Post
Maxwan
Maxwan
I would like to use two textures one the same quad. So I wrote a easy code that solved my problem. Anyway, this code uses two quads at the same size, one with the first texture, and the second with the other texture, and the second texture has partly a alpha-channal. It looks nice and the way I want it, but, would''nt it go faster if I used two textures on the same quad, instead of making two quads? Here''s my code. Can someone make it better?
  
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_ALPHA_TEST);
	for (int a=0 ; a<2 ; a++)
	{
		glLoadIdentity();
		glTranslatef(0.0f, 0.0f, -10.0f);
		if (a==0) {
			glBindTexture(GL_TEXTURE_2D, textur[0]);
			glAlphaFunc(GL_ALWAYS, 0.0f);
		}
		if (a==1) {
			glBindTexture(GL_TEXTURE_2D, textur[1]);
			glAlphaFunc(GL_EQUAL, 1.0f);
		}
		glBegin(GL_QUADS);
			glTexCoord2f(0.0f, 0.0f);	glVertex3f(-1.0f, -1.0f, 0.0f);
			glTexCoord2f(1.0f, 0.0f);	glVertex3f( 1.0f, -1.0f, 0.0f);
			glTexCoord2f(1.0f, 1.0f);	glVertex3f( 1.0f,  1.0f, 0.0f);
			glTexCoord2f(0.0f, 1.0f);	glVertex3f(-1.0f,  1.0f, 0.0f);
		glEnd();
	}
  
vember
vember
True, it would be faster if you used multitexturing instead.

Have a look here: http://www.berkelium.com/OpenGL/GDC99/multitexture.html
Maxwan
Maxwan
Tack för hjälpen men..

''glActiveTextureARB'' : undeclared identifier
Missing a include-file? or am I just stupid..
vember
vember
inga problem.

You have to include these extensions as they''re not a part of the main gl.h file which unfortunately is a quite cumbersome procedure(at least I thought so). If you want to make life easy for yourself have a look at "extension loading library" at this site:

http://www.levp.de/3d/
supagu
supagu
im using a extension loading library.. ive tried glux and glee, and both have the same problem :-/
it has to be something else, i looked in the glee header and its defined in there but wtf!!! visual studio :| ?

Topic Locked

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

Sign in to reply to this topic.