Archived

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

Maxwan

Two textures

Recommended Posts

Maxwan    122
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();
	}
  

Share this post


Link to post
Share on other sites
vember    122
True, it would be faster if you used multitexturing instead.

Have a look here: http://www.berkelium.com/OpenGL/GDC99/multitexture.html

Share this post


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

Share this post


Link to post
Share on other sites
supagu    148
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 :| ?

Share this post


Link to post
Share on other sites