- procedure Draw_Quad;
- begin
- glBegin(GL_QUADS); // DRAW
- glVertex2f(-60,-60);
- glVertex2f(60,-60);
- glVertex2f(60,60);
- glVertex2f(-60,60);
- glEnd();
- end;
- procedure TForm1.Render(Sender : TObject; var Done : Boolean);
- begin
- angle := angle - 5;
- glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
- glLoadIdentity(); // Reset View
- glOrtho(0,1024,0,768,-10,10);
- glMatrixMode(GL_MODELVIEW); // Return to the modelview matrix
- glLoadIdentity(); // Reset View
- glEnable(GL_ALPHA_TEST);
- glAlphaFunc(GL_GREATER, 0.1);
- glBindTexture(GL_TEXTURE_2D, MyTex);
- y := 500;
- x := 350;
- glTranslatef(X, Y ,0); // x,y = QUAD POSITION
- glRotatef(angle, 0, 0, 1); // ROTATE
- Draw_Quad;
- glpushmatrix;
- y := 400;
- x := 500;
- glMatrixMode(GL_MODELVIEW); // Return to the modelview matrix
- glLoadIdentity(); // Reset View
- glTranslatef(X, Y ,0); // x,y = QUAD POSITION
- glRotatef(angle, 0, 0, 1); // ROTATE
- Draw_Quad;
- glpopmatrix;
- glpushmatrix;
- y := 500;
- x := 650;
- glMatrixMode(GL_MODELVIEW); // Return to the modelview matrix
- glLoadIdentity(); // Reset View
- glTranslatef(X, Y ,0); // x,y = QUAD POSITION
- glRotatef(angle, 0, 0, 1); // ROTATE
- Draw_Quad;
- glpopmatrix;
- SwapBuffers(DC);
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- InitOpenGL;
- DC := GetDC(Handle);
- RC := CreateRenderingContext(DC, [opDoubleBuffered], 32, 24, 0, 0, 0, 0);
- ActivateRenderingContext(DC, RC);
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LESS);
- glEnable(GL_TEXTURE_2D);
- glViewport(0, 0, 1024,768); // Set the viewport for the OpenGL window
- glMatrixMode(GL_PROJECTION); // Change Matrix Mode to Projection
- glLoadIdentity(); // Reset View
- LoadTexture('c:\pic.tga', MyTex, False);
- end;