Мне нужно сделать такие преобразования:
1) Вращать вокруг центра фигуры
2) Вращать вокруг верхнего левого угла
3) Зеркально отобразить фигуру
4) Масштабирование
program GL2D;
uses
Windows,
Messages,
OpenGL,
MiniEngine in 'MiniEngine.pas';
const
NAME = 'GL2D';
WIDTH = 800;
HEIGHT = 600;
var
scene : integer;
angle : single;
procedure Init;
begin
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
scene := 1;
end;
procedure Figure;
begin
glBegin(GL_LINE_STRIP);
glvertex2f(-0.8,-0.4);
glvertex2f(-0.3,-0.2);
glvertex2f(0,-0.4);
glvertex2f(0.3,-0.2);
glvertex2f(0.8,-0.4);
glvertex2f(0.8,0.4);
glvertex2f(0.3,0.2);
glvertex2f(0,0.4);
glvertex2f(-0.3,0.2);
glvertex2f(-0.8,0.4);
glvertex2f(-0.8,-0.4);
glEnd;
end;
procedure Net;
begin
glColor3ub(255,255,255);
glBegin(GL_LINES);
glVertex2f(0,1.3);
glVertex2f(0,-1.3);
glVertex2f(-1.3,0);
glVertex2f(1.3,0);
glEnd;
end;
procedure Scene1;
begin
net;
glRotatef(angle,0,0,1);
glColor3ub(250,25,150);
Figure;
end;
procedure Scene2;
begin
net;
glColor3ub(250,205,10);
Figure;
end;
procedure Render;
begin
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT);
glTranslatef(0.0,0.0,-3.0);
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
case scene of
1 : scene1;
2 : scene2;
end;
glFlush;
end;
procedure Update;
begin
if engine.Keys[27] then engine.Quit;
if engine.Keys[49] then scene := 1;
if engine.Keys[50] then scene := 2;
angle := angle + 0.1;
end;
begin
InitEngine;
engine.SetProc(PROC_INIT, @INIT);
engine.CreateAPP(NAME,WIDTH,HEIGHT,32);
engine.SetProc(PROC_RENDER, @RENDER);
engine.SetProc(PROC_UPDATE, @UPDATE);
engine.Loop(1000);
end.