- Код: Выделить всё
- program project1;
 {mode objfpc}
 uses
 gl, glu, glut;
 begin
 glutInit(@argc,argv);
 glutCreateWindow('OpenGL: Cube 2');
 glutMainLoop;
 end.
Модератор: Модераторы
program project1;
{mode objfpc}
uses
  gl, glu, glut;
begin
  glutInit(@argc,argv);
  glutCreateWindow('OpenGL: Cube 2');
  glutMainLoop;
end.     program FirstGlutPrg;
uses gl, glut, glu;
const
   WIN_WIDTH = 640;
   WIN_HEIGHT = 480;
(* wrap the initialization of GLUT because it expects the commandline args in C style *)
procedure Initialize_GLUT(parse : boolean);
   var
      argv  : array of pchar;
      argc  : integer;
      index : integer;
   begin
      if parse then
         argc := ParamCount + 1
      else
         argc := 1;
      SetLength(argv, argc);
      for index := 0 to argc - 1 do
         argv[index] := pchar(ParamStr(index));
      glutInit(@argc, @argv);
   end;
procedure Initialize_GL;
   begin
      glClearColor(0.18, 0.20, 0.66, 0);
   end;
procedure GLHandler_DrawScene; cdecl;
   begin
      glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
      glutSwapBuffers;
   end;
procedure GLHandler_ResizeScene(width, height : longint); cdecl;
   begin
      if height = 0 then height := 1;
      glViewport(0, 0, width, height);
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity;
      gluPerspective(45, width / height, 0.1, 1000);
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity;
   end;
procedure GLHandler_Keyboard(key : byte; x, y : longint); cdecl;
   begin
      if key = 27 then halt(0);
   end;
(* variables *)
var
   screenWidth, screenHeight : integer;
(* main code *)
begin
   Initialize_GLUT(true);
   glutInitDisplayMode(GLUT_DOUBLE or GLUT_RGB or GLUT_DEPTH);
   glutInitWindowSize(WIN_WIDTH, WIN_HEIGHT);
   screenWidth  := GlutGet(GLUT_SCREEN_WIDTH);
   screenHeight := GlutGet(GLUT_SCREEN_HEIGHT);
   glutInitWindowPosition((screenWidth - WIN_WIDTH) div 2, (screenHeight - WIN_HEIGHT) div 2);
   glutCreateWindow('GLUT in Pascal #1');
   Initialize_GL;
   glutDisplayFunc(@GLHandler_DrawScene);
   glutReshapeFunc(@GLHandler_ResizeScene);
   glutKeyboardFunc(@GLHandler_Keyboard);
   glutMainLoop;
end.         
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1