View Full Version : [OGL-ES] How to draw polygon using triangles
11-04-2004, 11:35 AM
Also posted in the khronos forum (http://khronos.org/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=4&t=000129), but I didn't get an answer there.
Question is essentially how to replace OGL polygon drawing with OGL-ES triangles. I thought I could replace it with triangle fans but that didn't work fully.
11-04-2004, 12:15 PM
Well, triangle fans should be enought, as GL polygons must be convex.
Can you be more precise than "did not work fully" :p ?
11-04-2004, 01:37 PM
Ok, here are the relevant bits from my posting on the khronos site...
The game's original code does something like this texture most of its model:
for (i=0 ; i<numVertex ; i++)
glEnd ();Which I've replaced with:
glVertexPointer(3, GL_FLOAT, 0, GetVertex(0));
glTexCoordPointer(2, GL_FLOAT, 0, GetTexture(0));
glDrawArrays(GL_TRIANGLE_FAN, 0, numVertex);
glDisableClientState(GL_VERTEX_ARRAY);I store the original tex and vertex vector info in some global float arrays accessible via GetVertex () and GetTexture().
The model gets drawn ok, but small triangles and rectangulars are not correctly textured. They appear solid grey. As I move around in the game, the areas that are not correctly textured change all the time, resulting in a very flickery look and feel.
I've also tried to rewrite the polygon code by drawing n-2 triangles (GL_TRIANGLES) for an n polygon. The (not too surprising) result is exactly the same as for GL_TRIANGLE_FAN.
Am I making an obvious mistake?
11-07-2004, 12:50 AM
Found the problem!
For the record...
The game draws (1) the 3D model using polygons and then (2) applies lightning also using polygons. Things get messed up if I only change GL_POLYGON to GL_TRIANGLE_FAN in (1), if I change this in (2) as well then all works just fine.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.