Skip to content

Instantly share code, notes, and snippets.

@notpushkin
Created July 24, 2012 07:30
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 notpushkin/3168598 to your computer and use it in GitHub Desktop.
Save notpushkin/3168598 to your computer and use it in GitHub Desktop.
//{$apptype GUI}
uses Gl, Glu, Glut;
const width = 600;
height = 600;
var rotation: integer;
procedure display;
cdecl;
begin
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glRotatef(rotation, 0.0, 0.0, 1.0);
//top triangle
glBegin(GL_TRIANGLES);
glColor3f(1.0, 1.0, 0.0); // rgb
glVertex3f(-1.2, 2.4, 0.0);
glVertex3f(-1.8, 2.4, 0.0);
glColor3f(1.0, 1.0, 1.0); // rgb
glVertex3f(-1.5, 1.8, 0.0); //<--
glEnd();
//bottom triangle
glBegin(GL_TRIANGLES);
glColor3f(1.0, 1.0, 1.0); // rgb
glVertex3f(-1.5, 1.8, 0.0); //<--
glColor3f(0.0, 1.0, 1.0); // rgb
glVertex3f(-1.8, 1.2, 0.0);
glVertex3f(-1.2, 1.2, 0.0);
glEnd();
glFlush();
end;
procedure rotate;
begin
rotation := rotation + 1;
display();
end;
procedure keyboard(code: byte; x, y: longint);
cdecl;
begin
case code of
27: halt;
32: rotate();
end;
end;
procedure initGl;
begin
//glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-4, 4, -4*height/width, 4*height/width, -4, 4);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// Z!
glClearDepth(1.0);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
end;
procedure initGlut;
begin
glutInitDisplayMode(GLUT_SINGLE or GLUT_RGB);
glutInitWindowSize(width, height);
glutCreateWindow('HW');
glutDisplayFunc(@display);
glutKeyboardFunc(@keyboard);
end;
Begin
initGlut;
initGl;
glutMainLoop();
End.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment