Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any glPolygonMode alternative on iPhone (OpenGL ES)?

I'm new to OpenGL, and I found out that OpenGL ES doesn't support APIs such as glPolygonMode( GL_BACK, GL_FILL);

Any ideas how to implement it?

like image 219
Kordan Ou Avatar asked Jan 07 '11 16:01

Kordan Ou


1 Answers

In OpenGL ES, GL_FILL is the only available polygon mode. If you want to draw points or lines on edges then you need to upload your geometry directly for GL_POINTS, GL_LINES, GL_LINE_LOOP or whatever else is convenient. Of course, that means unpacking the more implicit triangle description modes, line strips and fans, in software for yourself, but the relevant code flows directly from the man pages.

There's no direct way to dictate whether line or point drawing will occur based on a triangle front/back facing test elsewhere. If you're in ES 2.x then you can get close to simulating the same thing by doing the triangle test you want in your geometry shader and setting a suitable flag for your fragment shader, but you'll end up duplicating the hardware test.

like image 82
Tommy Avatar answered Oct 02 '22 17:10

Tommy