Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

3D-Terrain-Programming

A serie of examples increasing the complexity example-by-example. (WIP)

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

3D Terrain Programming

A serie of examples increasing the complexity example-by-example.

Based on Focus on 3D Terrain Rendering by Trent Polack.

1-Basic brute force

In: Delphi(GLScene)

Load a bitmap and render a very plain 3D Terrain without any optimization.

pascal
var
  z, x: integer;
  h: byte;
  y: single;
//***
for z := 0 to FHeightField.DimensionLength - 2 do
begin
  glBegin(GL_TRIANGLE_STRIP);
  for x := 0 to FHeightField.DimensionLength - 1 do
  begin
    h := FHeightField.GetValue(x, z);
    y := h * SCALE;
    glColor3ub(h, h, h);
    glVertex3f(x, y, z);

    h := FHeightField.GetValue(x, z + 1);
    y := h * SCALE;
    glColor3ub(h, h, h);
    glVertex3f(x, y, z + 1);
  end;
  glEnd;
end;