diff --git a/GL/draw.c b/GL/draw.c index 8811480..753ee11 100644 --- a/GL/draw.c +++ b/GL/draw.c @@ -528,30 +528,18 @@ static void genTriangleStrip(Vertex* output, GLuint count) { output[count - 1].flags = PVR_CMD_VERTEX_EOL; } -#define MAX_POLYGON_SIZE 32 - static void genTriangleFan(Vertex* output, GLuint count) { - assert(count < MAX_POLYGON_SIZE); - static Vertex buffer[MAX_POLYGON_SIZE]; + assert(count <= 255); - if(count <= 3){ - output[2].flags = PVR_CMD_VERTEX_EOL; - return; - } + Vertex* dst = output + (((count - 2) * 3) - 1); + Vertex* src = output + (count - 1); - memcpy(buffer, output, sizeof(Vertex) * count); - - // First 3 vertices are in the right place, just end early - output[2].flags = PVR_CMD_VERTEX_EOL; - - GLsizei i = 3, target = 3; - Vertex* first = &output[0]; - - for(; i < count; ++i) { - output[target++] = *first; - output[target++] = buffer[i - 1]; - output[target] = buffer[i]; - output[target++].flags = PVR_CMD_VERTEX_EOL; + GLubyte i = count - 2; + while(i--) { + *dst = *src--; + (*dst--).flags = PVR_CMD_VERTEX_EOL; + *dst-- = *src; + *dst-- = *output; } } diff --git a/samples/polymark/main.c b/samples/polymark/main.c index 2cad762..092fb9b 100644 --- a/samples/polymark/main.c +++ b/samples/polymark/main.c @@ -72,8 +72,6 @@ void do_frame() { int i; float col; - - for(i = 0; i < polycnt; i++) { glBegin(GL_POLYGON); x = rand() % 640; @@ -91,8 +89,6 @@ void do_frame() { glEnd(); } - - glKosSwapBuffers(); }