Fix issues with triangle fans / polygons
This commit is contained in:
parent
1807a0119c
commit
b00b65af54
11
GL/draw.c
11
GL/draw.c
|
@ -768,19 +768,24 @@ static void genArraysTriangleFan(
|
||||||
const GLubyte* nptr, GLuint nstride,
|
const GLubyte* nptr, GLuint nstride,
|
||||||
GLboolean doTexture, GLboolean doMultitexture, GLboolean doLighting) {
|
GLboolean doTexture, GLboolean doMultitexture, GLboolean doLighting) {
|
||||||
|
|
||||||
|
assert(count < MAX_POLYGON_SIZE);
|
||||||
|
static ClipVertex buffer[MAX_POLYGON_SIZE];
|
||||||
|
|
||||||
genArraysCommon(
|
genArraysCommon(
|
||||||
output, count,
|
output, count,
|
||||||
vptr, vstride, cptr, cstride, uvptr, uvstride, stptr, ststride, nptr, nstride,
|
vptr, vstride, cptr, cstride, uvptr, uvstride, stptr, ststride, nptr, nstride,
|
||||||
doTexture, doMultitexture, doLighting
|
doTexture, doMultitexture, doLighting
|
||||||
);
|
);
|
||||||
|
|
||||||
assert(count < MAX_POLYGON_SIZE);
|
if(count <= 3){
|
||||||
static ClipVertex buffer[MAX_POLYGON_SIZE];
|
swapVertex(&output[1], &output[2]);
|
||||||
|
output[2].flags = PVR_CMD_VERTEX_EOL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(buffer, output, sizeof(ClipVertex) * count);
|
memcpy(buffer, output, sizeof(ClipVertex) * count);
|
||||||
|
|
||||||
// First 3 vertices are in the right place, just end early
|
// First 3 vertices are in the right place, just end early
|
||||||
swapVertex(&output[1], &output[2]);
|
|
||||||
output[2].flags = PVR_CMD_VERTEX_EOL;
|
output[2].flags = PVR_CMD_VERTEX_EOL;
|
||||||
|
|
||||||
GLsizei i = 3, target = 3;
|
GLsizei i = 3, target = 3;
|
||||||
|
|
|
@ -41,7 +41,7 @@ void DrawGLScene()
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
|
||||||
glLoadIdentity(); // Reset The View
|
glLoadIdentity(); // Reset The View
|
||||||
|
|
||||||
glTranslatef(-3.0f, 0.0f, -10.0f); // Move Left 1.5 Units And Into The Screen 6.0
|
glTranslatef(-3.0f, 1.5f, -10.0f); // Move Left 1.5 Units And Into The Screen 6.0
|
||||||
|
|
||||||
// draw a triangle
|
// draw a triangle
|
||||||
glBegin(GL_TRIANGLES); // start drawing a polygon
|
glBegin(GL_TRIANGLES); // start drawing a polygon
|
||||||
|
@ -73,6 +73,37 @@ void DrawGLScene()
|
||||||
glVertex3f( 0.75f, 0.75f, 0.0f);
|
glVertex3f( 0.75f, 0.75f, 0.0f);
|
||||||
glEnd(); // done with the polygon
|
glEnd(); // done with the polygon
|
||||||
|
|
||||||
|
glTranslatef(-6.0f, -3.0f, 0.0f);
|
||||||
|
|
||||||
|
// draw a triangle
|
||||||
|
glBegin(GL_POLYGON); // start drawing a polygon
|
||||||
|
glVertex3f( 0.0f, 1.0f, 0.0f); // Top
|
||||||
|
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
|
||||||
|
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
|
||||||
|
glEnd(); // we're done with the polygon
|
||||||
|
|
||||||
|
glTranslatef(3.0f, 0.0f, 0.0f); // Move Right 3 Units
|
||||||
|
|
||||||
|
// draw a square (quadrilateral)
|
||||||
|
glBegin(GL_POLYGON); // start drawing a polygon (4 sided)
|
||||||
|
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
|
||||||
|
glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right
|
||||||
|
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
|
||||||
|
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
|
||||||
|
glEnd(); // done with the polygon
|
||||||
|
|
||||||
|
glTranslatef(3.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
glBegin(GL_POLYGON); // start drawing a polygon (4 sided)
|
||||||
|
glVertex3f(-0.0f, 1.0f, 0.0f); // Top Left
|
||||||
|
glVertex3f(-0.75f, 0.75f, 0.0f);
|
||||||
|
glVertex3f(-1.0f, 0.0f, 0.0f); // Top Right
|
||||||
|
glVertex3f(-0.75f,-0.75f, 0.0f); // Bottom Right
|
||||||
|
glVertex3f(-0.0f,-1.0f, 0.0f); // Bottom Left
|
||||||
|
glVertex3f( 0.75f,-0.75f, 0.0f); // Bottom Right
|
||||||
|
glVertex3f( 1.0f, 0.0f, 0.0f); // Top Right
|
||||||
|
glVertex3f( 0.75f, 0.75f, 0.0f);
|
||||||
|
glEnd(); // done with the polygon
|
||||||
// swap buffers to display, since we're double buffered.
|
// swap buffers to display, since we're double buffered.
|
||||||
glKosSwapBuffers();
|
glKosSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user