GL Primitive Types

 

circle-primitivetype

void display( void )
{
glClear( GL_COLOR_BUFFER_BIT ); // clear the window

// circle
glBindVertexArray(vao);
if (g_colormode == 0)
glVertexAttrib3f((GLuint)1, 1, 0, 0); // set constant color attribute (red)
else if (g_colormode == 1)
glVertexAttrib3f((GLuint)1, 0, 1, 0); // set constant color attribute (green)
else if (g_colormode == 2)
glVertexAttrib3f((GLuint)1, 0, 0, 1); // set constant color attribute (blue)

// set drawmode
if (g_wiremode)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // draw wireframe
else
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); // draw filled

// primitive type
if (g_primitivemode == GL_POINTS) // 0
{
glPointSize(MOGL_THICKNESS);
glDrawArrays(GL_POINTS, 0, MOGL_STEP); // draw points
glPointSize(1);
}
else if (g_primitivemode == GL_LINES) // 1
{
glLineWidth(MOGL_THICKNESS);
glDrawArrays(GL_LINES, 0, MOGL_STEP); // draw lines
glLineWidth(1);
}
else if (g_primitivemode == GL_LINE_LOOP) // 2
{
glLineWidth(MOGL_THICKNESS);
glDrawArrays(GL_LINE_LOOP, 0, MOGL_STEP); // draw line loop
glLineWidth(1);
}
else if (g_primitivemode == GL_LINE_STRIP) // 3
{
glLineWidth(MOGL_THICKNESS);
glDrawArrays(GL_LINE_STRIP, 0, MOGL_STEP); // draw line strip
glLineWidth(1);
}
else if (g_primitivemode == GL_TRIANGLES) // 4
{
glDrawArrays(GL_TRIANGLES, 0, MOGL_STEP); // draw triangles
}
else if (g_primitivemode == GL_TRIANGLE_STRIP) // 5
{
glDrawArrays(GL_TRIANGLE_STRIP, 0, MOGL_STEP); // draw triangle strip
}
else if (g_primitivemode == GL_TRIANGLE_FAN) // 6
{
glDrawArrays(GL_TRIANGLE_FAN, 0, MOGL_STEP); // draw triangle fan
}
else if (g_primitivemode == GL_POLYGON) // 9
{
glDrawArrays(GL_POLYGON, 0, MOGL_STEP); // draw polygon
}

glBindVertexArray(0);
glDisableVertexAttribArray(0);

glFlush();
}