简体   繁体   中英

Back face culling + GL_TRIANGLE_STRIP?

If I've got 4 vertices which I render in this order:

2-3
|\|
0-1

using GL_TRIANGLE_STRIP and then I enable back-face culling with the front face defined as CCW, then would the bottom-left triangle be facing me and the other one not? If so, what's the most efficient way of rendering a square so that both faces are visible? Do I have to use GL_TRIANGLES and pass down 6 vertices instead of 4?

All triangles in triangle strip maintain same direction/winding order. They don't flip one after another. So either both triangles will be towards you or away from you (assuming your primitive is flat square shape (that is convex and doesn't intersect itself) where all vertices belong to same plane).

PS You know, you COULD render trianglestrip primitive in OpenGL application with culling enabled and see for yourself.

The strip primitive does the right thing with respect to backface culling. You can think of the tris' winding order as being managed so that the order is consistent for each triangle in the strip - eg you can think of the GPU rendering (0,1,2), (2,1,3) ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM