program glutdemo; // Trivial framework for an OpenGL application that uses GLUT. // Copyright (c) 2001 Tempest Software, Inc. // Permission is granted to use this source code under the terms // of the common public license. // http://www.opensource.org/licenses/cpl.html // // To use this project, install the JEDI OpenGL code from the // Kylix companion CD, or download it from the JEDI web site: // ftp://delphi-jedi.org/api/Cross_Platform/OpenGL.tar.gz // // You need the Mesa OpenGL libraries, which is a free implementation // of the OpenGL specification. Most Linux distributions include Mesa. uses Libc, MesaGL in 'mesa/pas/MesaGL.pas', MesaGLU in 'mesa/pas/MesaGLU.pas', Glut in 'Glut/pas/Glut.pas'; var Width: Integer; Height: Integer; procedure InitTransform; begin glViewport(0, 0, Width, Height); glMatrixMode(GL_Projection); glLoadIdentity; gluOrtho2d(0, Width, 0, Height); glMatrixMode(GL_ModelView); glClearColor(1.0, 1.0, 1.0, 0.0); glClear(GL_Color_Buffer_Bit); end; // GLUT callback when the window changes size. procedure Reshape(W, H: Integer); cdecl; begin Width := W; Height := H; InitTransform; end; // GLUT callback to paint the window. procedure Display; cdecl; var X, Y: Integer; XSide, YSide: Integer; begin X := Width div 2; Y := Height div 2; XSide := X div 2; YSide := Y div 2; glColor3f(1.0, 0.0, 0.0); glBegin(GL_POLYGON); glVertex2f(X - XSide, Y - YSide); glVertex2f(X + XSide, Y - YSide); glVertex2f(X + XSide, Y + YSide); glVertex2f(X - XSide, Y + YSide); glEnd; glFlush; glutSwapBuffers; end; begin LoadGL; LoadGLU; LoadGlut; Width := 300; Height := 200; {$warn symbol_platform off} glutInit(@ArgCount, ArgValues); {$warn symbol_platform on} glutInitDisplayMode(GLUT_DOUBLE or GLUT_RGB); glutCreateWindow('test'); InitTransform; glutReshapeFunc(Reshape); glutDisplayFunc(Display); glutMainLoop; UnloadGlut; UnloadGLU; UnloadGL; end.