Skip to content

Instantly share code, notes, and snippets.

@blkrt
Created May 28, 2018 07:58
Show Gist options
  • Save blkrt/ee13bb07b946bc8050fd08bf96ccafde to your computer and use it in GitHub Desktop.
Save blkrt/ee13bb07b946bc8050fd08bf96ccafde to your computer and use it in GitHub Desktop.
Cube 2D
#include <Gl/glut.h>
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glRotatef(50,1,0,1);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glBegin(GL_QUADS);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.5, 0.0, 0.0);
glVertex3f(0.5, 0.5, 0.0);
glVertex3f(0.0,0.5, 0.0);
glVertex3f(0.0, 0.0, -0.5);
glVertex3f(0.5, 0.0, -0.5);
glVertex3f(0.5, 0.5, -0.5);
glVertex3f(0.0, 0.5, -0.5);
glEnd();
glBegin(GL_LINES);
glVertex3f(0.0, 0.5, 0.0);
glVertex3f(0.0, 0.5, -0.5);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(0.0, 0.0, -0.5);
glVertex3f(0.5, 0.0, 0.0);
glVertex3f(0.5, 0.0, -0.5);
glVertex3f(0.5,0.5, 0.0);
glVertex3f(0.5, 0.5, -0.5);
glEnd();
glutSwapBuffers();
}
int main(int argc,char ** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH);
glutInitWindowSize(500,500);
glutInitWindowPosition(0,0);
glutCreateWindow("Rotating Cube");
glutDisplayFunc(display);
glutMainLoop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment