Advertisement

Texture mapping just one side of a polygon?

Started by June 17, 2001 05:07 PM
4 comments, last by WoolyUK 23 years, 8 months ago
Lo again When I texture map a polygon, it applies the texture to both sides. Well at least it looks like it is - is OpenGl actually texture mapping to both sides or just which ever one is currenty visible please? If it''s doing both, surely this doubles the ammount of work it has to do? And is there any way to just apply it to one side please?? Thanks again! Adam
If you enable backface culling it will not draw the backside of the polygon.

glFrontFace( GL_CW );
glEnable( GL_CULL_FACE );

You have to assign your vertices in a particular order, either clockwise or counter-clockwise. If it is clockwise use glFrontFace( GL_CW ) if it is counter-clockwise use glFrontFace( GL_CCW )

I''m not sure exactly how OpenGL handles it but there was a noticable improvement on my system when I did that.

Seeya
Krippy
Advertisement
Enable back-face culling, and/or tell OGL to render backfaces as wireframe only. In your OGL init code, put the following:

	glPolygonMode(GL_FRONT,GL_FILL);	glPolygonMode(GL_BACK,GL_LINE);	glCullFace(GL_BACK);	glEnable(GL_CULL_FACE); 


Cheers.
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
if you want a poly textured different on each side, do the backface culling as they said, then do a glRotate(180,0,1,0) and draw the new poly with a new glBindTexture command.
www.EberKain.comThere it is, Television, Look Listen Kneel Pray.
I think the first two posts misunderstood your question. If not, then sorry Anyway, here's my attempt at explaining your question:

OpenGL doesn't have any notion of "sides". It draws polygons whether you think it's the "front" side or the "back" side. It draws each polygon only once.

The idea of backface culling just means that if the polygon transform such that the vertices go in a counter-clockwise direction on the screen, then the triangle is not drawn at all. If they go clockwise, then it is drawn. This is probably what you're looking for. BTW, this effect of clockwise vs counter-clockwise is called the "winding" of the vertices.

When backface culling is turned off though, opengl still only draws your triangle once, it just means that it draws it no matter what the winding is.


War Worlds - A 3D Real-Time Strategy game in development.

Edited by - Dean Harding on June 17, 2001 9:22:17 PM
Thanks again guys!

I was already using backface culling, but wasnt sure whether it was still drawing the backs of the visible polygons, but you''ve cleared this up for me now!

Thanks!
Adam

This topic is closed to new replies.

Advertisement