- var ground:gluint;
- ...
- procedure mapInit(sourceHighs:string;sourcetex:Pansichar;r,g,b:Byte);
- var Bitmaps,Bitmaptex: TBitmap;
- INI:TStringlist;
- xf,yf: Integer;
- z1,z2,z3,z4:double;
- p: ^PixArray;
- begin
- glenable(gl_texture_2d); //Texturen aktivieren
- InitTextures(sourcetex,tex);
- Bitmaps:=TBitmap.Create;
- Bitmaps.LoadFromFile(sourcehighs);
- ground:=glgenlists(1);
- glnewlist(ground,gl_compile);
- for xf:=0 to Bitmaps.Width-2 do
- for Yf:=0 to Bitmaps.Height-2 do
- begin
- p:=Bitmaps.ScanLine[yf];
- inc(p,xf);
- z1:=(p^[3]/5);
- inc(p);
- z2:=(p^[3]/5);
- p:=Bitmaps.ScanLine[yf+1];
- inc(p,xf);
- z4:=(p^[3]/5);
- inc(p);
- z3:=(p^[3]/5);
- glcolor3f(r/255,g/255,b/255);
- glBindTexture(GL_TEXTURE_2D, tex);
- glBegin(gl_Quads);
- gltexcoord2f(0,0);
- glVertex3d(xf,z1,yf);
- gltexcoord2f(1,0);
- glVertex3d(xf+1,z2,yf);
- gltexcoord2f(1,1);
- glVertex3d(xf+1,z3,yf+1);
- gltexcoord2f(0,1);
- glVertex3d(xf,z4,yf+1);
- glend;
- end;
- glendlist;
- end;
- ...
- procedure TForm1.Render(X,Y,Z:glfloat;wH,wV:single);
- begin
- Kamera(x,y,z,wH,wV);
- glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
- glLoadIdentity;
- glEnable(GL_DEPTH_TEST); //Tiefenkontrolle
- glcalllist(ground);
- swapbuffers(dc);
- end;
- ...
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- mapinit('map.bmp','corni.bmp',255,255,255);
- if Edit1.Text<>'' then MapX:=StrtoFloat(Edit1.Text);
- if Edit2.Text<>'' then MapY:=StrtoFloat(Edit2.Text);
- if Edit3.Text<>'' then MapZ:=StrToFloat(Edit3.Text);
- if Edit4.Text<>'' then WinkelKH:=StrToFloat(Edit4.Text);
- if Edit5.text<>'' then WinkelKV:=StrtoFloat(Edit5.Text);
- end;