- procedure TGLForm.Render;
- var
- x, y: integer;
- begin
- glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
- glEnable(GL_TEXTURE_2D);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity;
- gluPerspective(45.0, ClientWidth/ClientHeight, NearClipping, FarClipping);
- //========================================================
- //xwinkel, ywinkel und entfernung sind globale variablen vom typ single
- if GetAsyncKeyState(VK_NUMPAD0)<>0 then
- xwinkel:= xwinkel - VarFrames(0.5);
- if GetAsyncKeyState(VK_NUMPAD1)<>0 then
- xwinkel:= xwinkel + VarFrames(0.5);
- if GetAsyncKeyState(VK_LEFT)<>0 then
- ywinkel:= ywinkel - VarFrames(1.5);
- if GetAsyncKeyState(VK_RIGHT)<>0 then
- ywinkel:= ywinkel + VarFrames(1.5);
- if GetAsyncKeyState(VK_UP)<>0 then
- entfernung:= entfernung + VarFrames(0.3);
- if GetAsyncKeyState(VK_DOWN)<>0 then
- entfernung:= entfernung - VarFrames(0.3);
- //========================================================
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity;
- glRotatef(xWinkel, 1, 0, 0);
- glRotatef(ywinkel, 0, 1, 0);
- glTranslatef(0, -3, entfernung);
- glTranslatef(XCount / -2, 0, 0);
- //========================================================
- //Dieser Code ist hauptsächlich aus den Wiki-Tutorials
- for y:=0 to YCount-1 do
- begin
- glPushMatrix;
- for x:=0 to XCount-1 do
- begin
- glBegin(GL_QUADS);
- glTexCoord2f(x / XCount, (y+1) / YCount);
- glVertex3f(0, Map[x,y+1], 0);
- glTexCoord2f(x / XCount,y / YCount);
- glVertex3f(0, Map[x,y], 1);
- glTexCoord2f((x+1) / XCount,y / YCount);
- glVertex3f(1, Map[x+1,y], 1);
- glTexCoord2f((x+1) / XCount,(y+1) / YCount);
- glVertex3f(1, Map[x+1,y+1], 0);
- glEnd;
- glTranslatef(1,0,0);
- end;
- glPopMatrix;
- glTranslatef(0,0,-1);
- end;
- //========================================================
- SwapBuffers(DC);
- end;