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]);
glVertex3fv(vertex[i]);
}
glEnd ();
Which I’ve replaced with:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, GetVertex(0));
glTexCoordPointer(2, GL_FLOAT, 0, GetTexture(0));
glDrawArrays(GL_TRIANGLE_FAN, 0, numVertex);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
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?
cheers, Pete