Skip to content

Instantly share code, notes, and snippets.

@DavidLudwig
Created September 18, 2016 15:16
Show Gist options
  • Save DavidLudwig/7a354c283cf9f886e1f15d26b0ad9b3a to your computer and use it in GitHub Desktop.
Save DavidLudwig/7a354c283cf9f886e1f15d26b0ad9b3a to your computer and use it in GitHub Desktop.
void DrawTestPattern_OpenGL1(float w, float h)
{
glCullFace(GL_FRONT_AND_BACK);
glBegin(GL_TRIANGLES);
glColor3f(1, 0, 0); // top-left
glVertex2f(-w, h); // triangle 1
glVertex2f(-w, 0);
glVertex2f( 0, 0);
glVertex2f( 0, 0); // triangle 2
glVertex2f( 0, h);
glVertex2f(-w, h);
glColor3f(1, 1, 0); // bottom-left
glVertex2f(-w, 0); // triangle 1
glVertex2f(-w, -h);
glVertex2f( 0, -h);
glVertex2f( 0, -h); // triangle 2
glVertex2f( 0, 0);
glVertex2f(-w, 0);
glColor3f(1, .5, 0); // bottom-right
glVertex2f( 0, 0); // triangle 1
glVertex2f( 0, -h);
glVertex2f( w, -h);
glVertex2f( w, -h); // triangle 2
glVertex2f( w, 0);
glVertex2f( 0, 0);
glColor3f(0, 1, 0); // top-left
glVertex2f( 0, 0); // triangle 1
glVertex2f( 0, h);
glVertex2f( w, h);
glVertex2f( w, h); // triangle 2
glVertex2f( w, 0);
glVertex2f( 0, 0);
glEnd();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment