Porting OpenGL sw to OpenGL-ES, help needed - take 2

Follow up on http://khronos.org/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=4&t=000121

Got rid of most of the glBegin/glEnd stuff, only polygons needs rewriting. Thought this was relatively easy, but unfortunately it’s not.

The game’s original code does something like this texture most of its model:
glBegin (GL_POLYGON);
for (i=0 ; i<numVertex ; i++)
glTexCoord2f(tex[i][0], tex[i][1]);
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);

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?

cheers, Pete

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.


This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.