I’m recreating the old game “Chuckie egg” for a university project, I’ve drawn the character fine using the below code, but I’m unsure of what type to use in glBegin(?) to colour the object in.
I’ve tried, GL_QUADS, GL_TRIANGLE_FAN, GL_TRIANGLE_STRIP and GL_QUAD_STRIP but the only one that works without displaying incorrectly is GL_LINE_LOOP, but this, of course, does not colour the whole shape in.
Does anyone know how to fix this?
void drawMan(void){
//main body outline
glBegin(GL_LINE_LOOP);
//set our colour
glColor3ub(255, 255, 0); // yellow
glVertex2f(-0.25f, 1.0f);
glVertex2f(0.25f, 1.0f);
glVertex2f(0.25f, 0.875f);
glVertex2f(0.5f, 0.875f);
glVertex2f(0.5f, 0.75f);
glVertex2f(1.0f, 0.75f);
glVertex2f(1.0f, 0.625f);
glVertex2f(0.5f, 0.625f);
glVertex2f(0.5f, 0.375f);
glVertex2f(0.0f, 0.375f);
glVertex2f(0.0f, 0.25f);
glVertex2f(0.25f, 0.25f);
glVertex2f(0.25f, 0.125f);
glVertex2f(0.5f, 0.125f);
glVertex2f(0.5f, 0.0f);
glVertex2f(0.75f, 0.0f);
glVertex2f(0.75f, -0.5f);
glVertex2f(0.5f, -0.5f);
glVertex2f(0.5f, -0.625f);
glVertex2f(0.25f, -0.625f);
glVertex2f(0.25f, -0.75f);
glVertex2f(0.0f, -0.75f);
glVertex2f(0.0f, -0.875f);
glVertex2f(0.25f, -0.875f);
glVertex2f(0.25f, -1.0f);
glVertex2f(-0.25f, -1.0f);
glVertex2f(-0.25f, -0.625f);
glVertex2f(-0.5f, -0.625f);
glVertex2f(-0.5f, -0.5f);
glVertex2f(-0.75f, -0.5f);
glVertex2f(-0.75f, 0.0f);
glVertex2f(-0.5f, 0.0f);
glVertex2f(-0.5f, 0.125f);
glVertex2f(-0.25f, 0.125f);
glVertex2f(-0.25f, 0.375f);
glVertex2f(-0.5f, 0.375f);
glVertex2f(-0.5f, 0.625f);
glVertex2f(-1.0f, 0.625f);
glVertex2f(-1.0f, 0.75f);
glVertex2f(-0.5f, 0.75f);
glVertex2f(-0.5f, 0.85f);
glVertex2f(-0.25f, 0.85f);
//glVertex2f(-0.25f, 1.0f);
glEnd();
//eyes
glBegin(GL_LINE_LOOP);
glColor3ub(0, 0, 0); // black
glVertex2f(0.0f, 0.625f);
glVertex2f(0.25f, 0.625f);
glVertex2f(0.25f, 0.5f);
glVertex2f(0.0f, 0.5f);
glEnd();
//arm
glBegin(GL_LINE_LOOP);
glColor3ub(0, 0, 0); // black
glVertex2f(-0.25f, 0.0f);
glVertex2f(0.0f, 0.0f);
glVertex2f(0.0f, -0.5f);
glVertex2f(-0.25f, -0.5f);
glEnd();}
You can’t just draw a random outline and colour it in. You would have to correctly triangulate your shape.
Really this is a job for either a drawing package which can output reasonable geometry, or using a texture instead.