Skip to content

Instantly share code, notes, and snippets.

@jsheedy
Created March 28, 2017 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsheedy/7becd9180b851b0db67d76f236653eea to your computer and use it in GitHub Desktop.
Save jsheedy/7becd9180b851b0db67d76f236653eea to your computer and use it in GitHub Desktop.
boring old cube GL
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <OpenGL/gl.h>
#include <GLUT/glut.h>
int windowWidth;
float rot = 0.0f;
static void display( void )
{
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rot, 1, 1, 1);
glBegin(GL_POLYGON);
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);
glEnd();
glPopMatrix();
glutSwapBuffers();
printf("WAT %1.1f\n", rot);
}
static void idle(void) {
rot += 0.1;
display();
}
int main(int argc, char** argv)
{
glutInit (&argc,argv);
// glutInitDisplayMode (GLUT_SINGLE);
glutInitDisplayMode (GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
glutInitWindowSize (300,300);
glutInitWindowPosition (0,0);
glutCreateWindow ("BORING OLD CUBE");
glutDisplayFunc (display);
glutIdleFunc(idle);
glutMainLoop();
return 0;
}
cube:
gcc boring_old_cube.cpp -framework OpenGL -framework GLUT -o boring_old_cube -w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment