Created
July 24, 2012 07:30
-
-
Save notpushkin/3168598 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//{$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