r/pascal Jan 21 '23

mod volunteers?

12 Upvotes

Anyone would like to be added as a mod here? Bonus points for maintainers of projects such as Freepascal, Lazarus or any Pascal project.


r/pascal 4h ago

Porting a JavaScript game to Pascal

Enable HLS to view with audio, or disable this notification

10 Upvotes

Quite some time ago, I tried out a small JavaScript engine made by a friend and wrote a little game in it called Floaty Car. And yes, I'm absolutely FANTASTIC at naming stuff.

Now that I can run Pascal easily on the web, I wondered whether I've put enough work into my compiler to remake the car game and, well, yeah, I did! So I updated my blog to contain a quick tutorial about porting Floaty Car to Pascal. The full Pascal code is listed in the article, you can just copy & paste it into WasmPascal and it should run.

Not gonna lie... It's fun to be doing Pascal again. I need to find my high school projects, some of them are printed out somewhere in a box, that's how we rolled back then 😆

Anyway, back to writing Python APIs to earn money for dogfood.


r/pascal 13h ago

VertexArt - Bomberman 3D Demo ( ply versio )

Enable HLS to view with audio, or disable this notification

21 Upvotes

Pure Free Pascal 3.2.2 / GLFW3 / OpenGL 3.3 / DOD


r/pascal 7h ago

Is it possible to deserialized a saved file of an old pascal system?

5 Upvotes

I'm working on making a latest system from an old pascal system (created in year 2008). And am trying to retrieve all of the data from that old system.

It's has been said that the data was encrypted by the creator of the old system. But when i looked into the contents of the saved file using notepad, there are still readable text which are the raw data of the system. That made me think - it might not be encrypted. it might be serialized, instead. Like a saved file of c# unity game.

The old system is still alive but the source code of it is no more. And the creator already passed away. So, i can't sif

The internet or AI suggests that i use R language or python but it doesn't seem to work.

So now, I'm trying to recreate the data's blueprint/record using pascal but there's a lot of variables and the arrangement of those variables must be correct as the original bluprint..

Can you give me other ideas to reverse-engineer the file?


r/pascal 21h ago

VertexArt - Tetris ( cube.ply 3D ) - sense of space improved

Enable HLS to view with audio, or disable this notification

12 Upvotes

Vizuális megjelenítés

1. PLY alapú kockák

A generált kockák helyett cube.ply fájlt használ:

pascal

procedure LoadBaseCubeMesh;
begin
  PlyMesh := LoadPLY('cube.ply');
  BaseCubeMesh.VertexCount := Length(PlyMesh.Vertices);
  SetLength(BaseCubeMesh.Vertices, BaseCubeMesh.VertexCount);
  Move(PlyMesh.Vertices[0], BaseCubeMesh.Vertices[0], ...);
  NormalizeMeshCustom(BaseCubeMesh);  // Egységnyire méretez
end;

Normalizáló eljárás:

  • Megkeresi a mesh határait (MinXMaxX, stb.)
  • Kiszámolja a középpontot
  • Áthelyezi az origóba
  • Egységnyire méretezi (a legnagyobb méret = 1)

2. Színek

Minden darabtípus egyedi színt kap:

Darab Szín RGB
I Cián (0, 255, 255)
O Sárga (255, 255, 0)
T Lila (128, 0, 128)
S Zöld (0, 255, 0)
Z Piros (255, 0, 0)
J Kék (0, 0, 255)
L Narancs (255, 165, 0)

r/pascal 1d ago

Does anybody know about Domain Pascal (From the long dead Apollo Computers)?

10 Upvotes

The title of this post should have my question in it, but i had to ask this after finding myself knee-deep in a impromptu software archeology project that involves a very major piece of software for the Apollo/Domain computers.

If nobody can find and compare domain pascal with the current ones, i have some manuals found on bitsavers that do document this variant of pascal:

https://bitsavers.org/pdf/apollo/000792-A01_Domain_Pascal_Language_Reference_Dec90.pdf

https://bitsavers.org/pdf/apollo/000792-04_DOMAIN_Pascal_Language_Reference_Jan87.pdf


r/pascal 1d ago

VertexArt - Tetris

Enable HLS to view with audio, or disable this notification

12 Upvotes

1. Nincs dinamikus memória, nincsenek osztályok

A legtöbb Tetris implementáció objektumorientált, és dinamikusan allokálja a darabokat, a táblát vagy a részecskéket. Ez a verzió fix méretű tömböket használ mindenre, és procedurális felépítésű.

pascal

// A teljes játékállapot fix tömbben:
Board: array[0..COLS-1, 0..ROWS-1] of Byte;
Tetrominoes: array[0..6, 0..3, 0..3, 0..3] of Byte;

Előny: Kiszámítható memóriahasználat, nincs fragmentáció, gyors és biztonságos.

2. Interpolált mozgás a darabok között

A legtöbb Tetrisben a darabok ugrálnak celláról cellára. Itt a Lerp (lineáris interpoláció) simává teszi a mozgást.

pascal

function GetInterpolatedX: Single;
begin
if ActivePiece.IsMoving then
Result := ActivePiece.PrevX + (ActivePiece.X - ActivePiece.PrevX) * ActivePiece.Lerp
else
Result := ActivePiece.X;
end;

3. Előre definiált maszkok – nincs futásidőbeli forgatás

A legtöbb Tetrisben a darabokat matematikailag forgatják (mátrix transzformáció). Itt mind a 4 forgás előre definiálva van mind a 7 darabhoz.

pascal

// Példa: L alakzat összes forgása előre megadva
Tetrominoes[TYPE_L, 0, 1, 2] := 1; // 0. forgás
Tetrominoes[TYPE_L, 1, 1, 1] := 1; // 1. forgás
// stb.

Előny: Gyorsabb, egyszerűbb, és garantáltan pontos az ütközésvizsgálat.


r/pascal 1d ago

MoonCompiler 1.0.0 — a Delphi 12.2-compatible Win64/Linux toolchain built on FPC/Unleashed

9 Upvotes

We’ve released MoonCompiler 1.0.0, an open-source Object Pascal toolchain for Win64 and Linux x86-64.

It started from a practical requirement: keep one Delphi 12.2 source base for a high-load trading application while moving its server core to Linux. Unleashed supplied modern Delphi syntax; we then worked through compiler, RTL and runtime gaps against the full application.

The supported profile includes:

  • Delphi 12.2-compatible non-visual/server language surface;
  • Unicode RTL, threading, RTTI, exceptions and a bundled mORMot-based memory manager;
  • compiler work including LICM, address GVN, EH-aware register allocation and code alignment;
  • reproducible Win64/Linux toolchains and qualification suites;
  • more than 120 documented correctness and performance repairs.

On 243 cases shared with the original Moon/Unleashed baseline, the current compiler/RTL/MM stack is 1.31× faster. In the final 744-case comparison it is 1.20× faster than Delphi 12.2; across 20 server/trading hot paths it is 1.22× faster. The bundled MM is 1.65× faster than the standard FPC MM on allocator workloads with the same compiler and source.

This is intentionally not a universal FPC replacement: the supported targets are Win64 and Linux x86-64, and the focus is Delphi-compatible server and application-core code rather than VCL/FMX.

Repo, releases and full evidence: https://github.com/Moonbot-Tech/MoonCompiler

Technical feedback and real-world compatibility reports are very welcome.


r/pascal 2d ago

VertexArt - Bomberman mini Demo

Enable HLS to view with audio, or disable this notification

8 Upvotes

r/pascal 3d ago

VertexArt - Platformer framework test (3 demos)

Enable HLS to view with audio, or disable this notification

3 Upvotes

platformer demo, Doodle Jump, Plinko


r/pascal 3d ago

DEFRAG_M (Amaze Clone)

Enable HLS to view with audio, or disable this notification

20 Upvotes

I had some free time so i coded an AMAZE game clone.

Mechanic is simple, paint all the maze.

It's written entirely in Turbo Pascal 7.

Movement: Cursor Keys
Restart Current Level: R
Terminate Game: ESC Key

You can play it via your web browser here: https://archive.org/details/amaze_pas

If you play it tell me what you think.


r/pascal 6d ago

VertexArt - Space Invaders - Tech Demo

Enable HLS to view with audio, or disable this notification

20 Upvotes

Játék állapotai:

  1. Menü - Főmenü, ahol indíthatod vagy kiléphetsz a játékból
  2. Játék - Aktív játékmenet
  3. Game Over - Játék vége állapot (vereség vagy győzelem)

⌨️ Irányítás

Menüben:

  • ← / → - Menüpontok közötti váltás
  • ENTER - Kiválasztás

Játékban:

Billentyű |Funkció
Egér |Hajó mozgatása
SZÓKÖZ |Rakéta kilövése
R |Játék újraindítása
P |Szünet / Folytatás
ESC |Vissza a menübe ⚙️** Játékmechanik**ák

1. 🚀 Lövedékrendszer

  • A játékos 3 csövű ágyúval rendelkezik
  • Lövedékek sebessége: 12.0 egység/másodperc
  • Lövési sebesség: 0.1 másodperc
  • A lövedékek 

cián

  • színűek és 0.08 egység méretűek

2. 💥 Rakétarendszer

  • Aktiválás: SZÓKÖZ billentyű
  • Sebesség: 5.0 egység/másodperc
  • Robbanási sugár: 4.0 egység
  • Sebzés: 3 életpont
  • Lökőerő: 5.0 egység
  • Gyújtóidő: 0.5 másodperc (érintéskor)
  • A rakéta automatikusan felrobban, ha ellenséget érzékel

3. 🎆 Részecskerendszer

  • Max részecskék: 2000
  • Gravitáció: -9.8 m/s²
  • Típusok:
    • Robbanás részecskék: Sárga színűek
    • Nyomvonal részecskék: Sárga színűek
    • Tűzijáték részecskék: Sárga színűek

4. 🎇 Tűzijáték rendszer

  • Max tűzijátékok: 5
  • Részecskék/tűzijáték: 100
  • Élettartam: 2.5 másodperc
  • Időköz: 0.3-1.5 másodperc
  • Csak győzelem esetén aktiválódik

👾 Ellenségek viselkedése

Alap tulajdonságok:

  • Életerő: 9 HP (boostolt állapotban 18)
  • Méret: 0.9 x 0.5 x 0.9 egység
  • Lövési időköz: 2.5-4.5 másodperc
  • Lövedék sebessége: 4.0 egység/másodperc

Viselkedési minták:

1. 🏃 Dodge (Kitérés)

  • Reagál a játékos lövedékeire
  • Érzékelési sugár: 2.5 egység
  • Kitérési sebesség: 4.0
  • Fal elkerülés: Automatikus visszafordulás a falaktól

2. 📉 Menekülési mód (Boost)

  • Aktiválódás: Amikor 10 vagy kevesebb ellenség marad
  • Tulajdonságok:
    • Életerő megduplázódik (18 HP)
    • Gyorsabb lövés (1.0-1.3 másodperc)

3. 💨 Visszatérés a rácsba

  • Rakéta robbanás után aktiválódik
  • Sebesség: 0.5-1.3 (véletlenszerű)
  • Közben dőlés a mozgás irányába

4. ☠️ Halál animáció

  • Zuhanás sebessége: 2.5 egység/másodperc
  • Forgás: Véletlenszerű (20-60 fok/másodperc)
  • Nyomvonal: Sárga részecskék
  • Eltűnés: -20.0 egységnél

Ellenségek szétválasztása

  • Erő: 2.5
  • Távolság: 1.2 egység
  • Megakadályozza az ellenségek egymásba olvadását

r/pascal 8d ago

VertexArt - Space Invaders Demo - almost finished Tech Demo

Enable HLS to view with audio, or disable this notification

27 Upvotes

Free Pascal 3.2.2 / GLFW3 / OpenGL 3.3 / DOD / Intel N4100 ( runs on one CPU core )


r/pascal 8d ago

I built an AI coding assistant that looks like Turbo Pascal 7

16 Upvotes

I wanted to see what would happen if a modern AI coding agent had the UI of Turbo Pascal 7 / the old DOS IDEs.

So I made Turbo-AI — a retro-style TUI frontend for the Pi coding agent.

It currently supports things like AI chat, PLAN/BUILD modes, model switching, reasoning settings, project tree, Git diff and build/test actions.

It's still quite rough and definitely not production-ready. This is more of an experiment at the moment, and there are probably plenty of things that need to be fixed or redesigned.

I'm mainly interested in feedback from people who actually remember using Turbo Pascal / DOS IDEs: does the interface feel authentic, and what would you change?

GitHub: https://github.com/kvv256512-ux/turbo-ai


r/pascal 9d ago

A DOS-era game running in the browser

Post image
20 Upvotes

I finally managed to get my online compiler to output standalone packages. You can see the breakout clone example running on a static server at https://nofuss.co.za/games/breakout/ now. The wasmpascal compiler exports either a zip archive of all the required files, or, if you are lazy, a single html file with the wasm binary BASE64 endcoded inside it. For small things, that's fine, but it gets really chunky for larger projects.

I also made some improvements to the editor experience and the documentation for https://nofuss.co.za/wasmpascal/. Thank you for the feedback I got, I fixed as many of the bugs as I could. The plan is to spend the next few weekends improving Pascal language support and sorting out some kinks, especially in the export system to make it a bit leaner.


r/pascal 10d ago

VertexArt - Space Invaders / Memoria cubes - explosion effect

Enable HLS to view with audio, or disable this notification

15 Upvotes

r/pascal 11d ago

VertexArt - Space Invaders - opponents flee

Enable HLS to view with audio, or disable this notification

17 Upvotes

r/pascal 11d ago

VertexArt - MemoryBoxes 6x6

Enable HLS to view with audio, or disable this notification

4 Upvotes

never enough development...


r/pascal 12d ago

VertexArt - Wallbreaker - with fluorescent ball - some Tetris logic in the use of boxes

Enable HLS to view with audio, or disable this notification

12 Upvotes

Breakout 3D Dokumentáció

A program egy 3D-s Breakout játék, amelyet Free Pascal 3.2.2, GLFW3 és OpenGL
3.3 felhasználásával készítettem. A játék különlegessége, hogy a téglák emeletes
elrendezésben helyezkednek el, és Tetris-szerűen esnek lefelé,
ha az alattuk lévő téglák eltűnnek.

2. FELHASZNÁLT MODULOK

SysUtils, Math

· Alacsony szintű segédprogramok, matematikai függvények

glfw3

· Ablakkezelés, billentyűzet/egér kezelés

gl33

· OpenGL 3.3 függvények

SterilTypes, SterilMath

· Saját típusok (TVector3, TMat4) és mátrix műveletek

SterilWindow

· Ablak inicializálás

FrameLimiter

· FPS korlátozás és időzítés

RenderTypes, RenderQueue, RenderState

· Renderelő parancsok, sor, állapotok

ShaderCore

· Shader programok

SimpleRenderEngine

· Fő renderelő motor

MeshGenerators

· 3D primitívek generálása

3. ÁLLAPOTGÉP

A játéknak három állapota van:

gsMenu

· Főmenü – START és EXIT gombok

gsPlaying

· A játék fut

gsQuit

· Kilépés a programból

A főállapot-változó: GameState: TGameState

4. ADATSZERKEZETEK

4.1. TBrick – Tégla

TBrick = record
Pos: TVector3; // pozíció a térben
Size: TVector3; // méret
Color: TVector3; // szín (RGB 0..1)
Active: Boolean; // létezik-e még
VAO, VBO: GLuint; // GPU azonosítók
VertexCount: Integer; // csúcsok száma
Mesh: TGeneratedMesh; // generált háló
GridX, GridY, GridZ: Integer; // pozíció a 3D rácsban
Falling: Boolean; // esik-e éppen
FallProgress: Single; // 0..1 esés állapota
FallStartZ, FallTargetZ: Integer;
FallStartPosY, FallTargetPosY: Single;
end;

4.2. TBall – Labda

TBall = record
Pos: TVector3;
Vel: TVector3;
Size: Single;
Color: TVector3;
Active: Boolean;
VAO, VBO: GLuint;
VertexCount: Integer;
Mesh: TGeneratedMesh;
end;

4.3. TPaddle – Ütő

TPaddle = record
Pos: TVector3;
Size: TVector3;
Color: TVector3;
VAO, VBO: GLuint;
VertexCount: Integer;
Mesh: TGeneratedMesh;
end;

5. JÁTÉKMECHANIKA

5.1. Téglák elrendezése (3D rács)

A téglák egy 3D rácsban helyezkednek el:

· GRID_SIZE_X = 10 – szélesség
· GRID_SIZE_Y = 10 – mélység
· GRID_SIZE_Z = 3 – magasság (szintek)

Egy tégla pozíciója a rácsban: (GridX, GridY, GridZ)

Térbeli pozíció számítás:
PosX := (GridX - (GRID_SIZE_X-1)/2) * BRICK_SPACING
PosY := GROUND_Y + 0.35 + GridZ * BRICK_SPACING
PosZ := 10.0 + (GridY - (GRID_SIZE_Y-1)/2) * BRICK_SPACING

5.2. Esés animáció (Tetris-stílus)

Ha egy téglát eltalál a labda, a felette lévő téglák (azonos GridX, GridY,
nagyobb GridZ) elindulnak lefelé. Az esés animált:
BRICK_FALL_SPEED = 2.0 szint/másodperc. A UpdateBrickFalls ciklus minden
frame-ben frissíti az eső téglák pozícióját.

5.3. Labda fizika

A labda vízszintes síkban (X-Z) mozog, Y pozíciója fix (GROUND_Y + Size).
Ütközés a falakkal, a paddle-el és a téglákkal. Pattanás: a téglákra a
legkisebb átfedés alapján pattan (X vagy Z irányban). Sebesség normalizálás:
a labda sebessége mindig BALL_SPEED.

5.4. Ütő (Paddle)

Mozgása: egér X irányú mozgása (vízszintes). A paddle csak X irányban
mozoghat (-5.0 és 5.0 között).

5.5. Kamera

A kamera az ütőt követi X irányban:
CamPos := Vec3(Paddle.Pos.X, 4.0, -4.0)
CamTarget := Vec3(Paddle.Pos.X, 0.5, 4.0)

6. BILLENTYŰKEZELÉS

ESC

· Játékból → menü, menüből → kilépés

← / →

· Menüben váltás a START és EXIT között

Enter

· Menüben választás

R

· Játék újraindítása

P

· Szünet / folytatás

Space

· Új játék Game Over után

7. RENDERELÉS

A renderelés a SimpleRenderEngine-en keresztül történik:

  1. Queue töltése: a téglák, labda és paddle TRenderCommand-jeit hozzáadjuk
  2. a SimpleRE.FRenderQueue-hoz.
  3. RenderFrame hívás: a motor végrehajtja a mélységpasszt, vonalpasszt

(ha van)

  1. és
  2. színpasszt.
  3. Pontfény: a labdára egy zöld pontfényt állítunk be (SetPointLight).

8. FŐSZERKEZET

Inicializálás:

· Ablak, OpenGL, SimpleRE
· Menü gombok létrehozása
· FrameLimiter indítása

Főciklus:
amíg az ablak nyitva:
DeltaTime számítása
case GameState of
gsMenu:
RenderMenu
gsPlaying:
UpdateBrickFalls
UpdatePaddle
UpdateBall
UpdateCamera
RenderGame
gsQuit:
kilépés
SwapBuffers
PollEvents
FPS kiírás

Leállítás:

· GPU erőforrások felszabadítása
· SimpleRE.Shutdown
· Ablak bezárása

9. KONSTANSOK ÉS HANGOLHATÓ PARAMÉTEREK

SCR_WIDTH = 1280

· Képernyő szélesség

SCR_HEIGHT = 720

· Képernyő magasság

GROUND_Y = -0.5

· Talaj szintje

BALL_SPEED = 6.0

· Labda sebessége

GRID_SIZE_X = 10

· Téglák száma X irányban

GRID_SIZE_Y = 10

· Téglák száma Y irányban

GRID_SIZE_Z = 3

· Téglák száma Z irányban (szintek)

BRICK_SPACING = 1.1

· Téglák közötti távolság

BRICK_FALL_SPEED = 2.0

· Esés sebessége (szint/másodperc)

PADDLE_WIDTH = 1.6

· Ütő szélessége

PADDLE_HEIGHT = 0.12

· Ütő magassága

PADDLE_DEPTH = 0.6

· Ütő mélysége

10. ÖSSZEGZÉS

A Breakout 3D - egy megbízható, jól strukturált 3D-s
játékmotor demo, amely bemutatja a VertexArt Arcade keretrendszer képességeit. A kód tiszta,
moduláris, és könnyen bővíthető új funkciókkal (pl. több pálya, nehezítés).

================================================================================

Fejlesztő: Kovács István


r/pascal 12d ago

Desktop app what is the dimension of the form to design to?

11 Upvotes

Currently struggling with the size of the form. I m developing on a 27" 4k screen with 175% scale factor and also a 24" 1920x1200 screen with 100% scale.

The app currently doesn't span full screen. It is meant to be a floating form. But while it works ok on my system I try this out on another laptop that is 1920x1080 15" screen, the app becomes bigger than the screen.

So I am thinking my original design form is of the wrong size. What should I design the form size to be?


r/pascal 12d ago

VertexArt - Space Invaders: Gameplay Logic Foundation

Enable HLS to view with audio, or disable this notification

9 Upvotes

r/pascal 13d ago

Nostalgic-driven development

Enable HLS to view with audio, or disable this notification

31 Upvotes

Back in 1992, I chanced upon someone using Turbo Pascal 5. I was hooked immediately, since I've been doing BASIC until then, to write my own little games and programs for my amusement. I got my own copy of Turbo Pascal 7 in 1994 and had years and years of fun with. Switched to Delphi, and loved it, until the .NET era.

Over the years, I've tinkered with FreePascal (so amazing!) and of course wrote many a small Pascal interpreter. Then, last year, I needed a project to work on so I could learn the Odin programming language for an upcoming project. I worked on a small Pascal interpreter and it was actually a lot of fun. The commercial Odin project never happened, but I had put a lot of time and energy into this Pascal interpreter.

Fast forward a few months, I'm working on a web assembly project using Odin and it dawns upon me I can use a lot of this knowledge to port my interpreter to the web. Oh boy, did that run away with me!

Now I have wasmpascal - which is a crappy editor that encapsulates the Pascal compiler, yes, COMPILER, I ended up writing so I can run Pascal code in Web Assembly in the browser. It's very early days, but I have managed to get some bits and pieces working.

My first order of business was some basic HTML5 Canvas support, with call-batching so that one gets alright frame rates. And there's some basic support for CRT-based applications, because back in the day, 'uses CRT' was a thing!

I've added some examples and documentation and will be working on this over weekends for many months in the future.

I thought I'd share it here - in-case there's another older-than-the-average person who wants a trip down memory lane, running Pascal like it's the 90's again!


r/pascal 13d ago

Seed7 - Memory Safety and Management • Thomas Mertes • 05/2026

Thumbnail
youtube.com
8 Upvotes

This talk is not about C++. It is about the Seed7 programming language. Seed7 is inspired by Pascal. The cpp usergroup vienna allowed me a talk about Seed7. Properties of Seed7 are:

Seed7 is based on my PHD thesis and is the result of life-long work. The project consists of more than 500k lines of manually written code, several hundred pages of documentation, a test suite to check the functionality of interpreter and compiler and much more. I give it away for free with GPL/LGPL licensing. From time to time I do talks about my project. This is my latest talk.


r/pascal 14d ago

VertexArt - WorldEditor (Gen1) - Documentation (this version is built on simple functionality)

Enable HLS to view with audio, or disable this notification

13 Upvotes

VertexArt - WorldEditor - Documentation

Developer: Kovács István

  1. INTRODUCTION

Steril Editor is a desktop application designed for placing 3D models stored in

ASCII PLY format. The program allows loading, positioning, scaling, rotating,

and then baking models into a chunk-based world. The final result can be

exported as a PLY file.

  1. SYSTEM ARCHITECTURE

The program has a modular structure, consisting of the following main

components:

- SterilTypes – Fundamental data types (TVector3, TVertex, TMat4).

- SterilMath – Vector and matrix operations (addition, multiplication,

normalisation, transformations).

- UShaderCore – Shader compilation and program creation.

- Renderer / RenderQueue – Rendering pipeline.

- PLYLoader – Loading ASCII PLY files into triangle meshes.

- UChunkSystem – Chunk system: divides the world into 50x50 metre blocks,

manages active chunks (9x9), stores vertices.

- URenderCore – GPU management: VAO/VBO creation, chunk upload and update.

- UTilemap – Tilemap mode: snap-to-grid movement and baking of objects.

- UEngineCore – Core engine: camera, ghost (preview model), rendering loop.

- UPlyManager – Scans the program directory for PLY files, navigation between

them.

- UExport – PLY export with timestamp.

Data flow:

PLY file -> UPlyManager -> UEngineCore (Ghost loaded)

-> (editing) -> UTilemap / UEngineCore (Bake)

-> UChunkSystem (organised into chunks)

-> URenderCore (GPU upload)

-> Renderer (display)

-> UExport (PLY save)

  1. CHUNK SYSTEM

- The world is divided into 50x50 metre blocks (chunks).

- Only a 9x9 area (81 chunks) around the camera is active – these are rendered

and can receive baked objects.

- Each chunk stores its own vertex array and a Dirty flag indicating whether

its content has changed.

- During baking, the ghost's triangles are placed into the appropriate chunk

based on the triangle's centre point.

- Modified chunks are automatically uploaded to the GPU in the next frame

(UpdateAllDirtyChunks).

Chunk data structure:

TChunkNode = record

ChunkX, ChunkZ: Integer; // Chunk coordinates

Vertices: array of TVertex; // Vertex list

VertexCount: Integer;

Dirty: Boolean; // Pending update?

Active: Boolean; // Within view range?

end;

  1. RENDERING

Rendering is performed in two passes to avoid overdraw.

- Depth prepass: Only the depth buffer is filled; colour buffer writes are

disabled. This ensures that in the subsequent colour pass only visible

surfaces are shaded.

- Colour pass: Colour buffer writes are enabled, depth test is set to

GL_LEQUAL. The fragment shader includes lighting calculations.

Shader programs:

- DepthProg – vertex shader only, applies the model-view-projection matrix.

- ColorProg – vertex and fragment shader.

  1. FUNCTIONAL DESCRIPTION

5.1. Object (Ghost) Handling

The central element of editing is the ghost – a preview model that follows the

cursor position, indicating where the object would be placed.

- Loading: On startup, the program scans the directory for .ply files. If

found, the first one is loaded as the ghost; otherwise, a default coloured

cube is created.

- Navigation between PLY files: F2 (previous) and F3 (next) switch between

available models.

- Modifications:

- Position: In free mode, W,A,S,D move the ghost in the camera direction; in

Tilemap mode, movement is snapped to the bounding box size.

- Rotation: Q (left), E (right) rotate by 2-degree increments; R randomises

rotation.

- Scale: F4 cycles through preset scale values (0.25, 0.5, 1, 2, 4, 8, 16,

32, 64).

5.2. Baking

The ghost's current state (position, rotation, scale) is permanently placed

into the chunk system by pressing SPACE.

- Free mode: The entire triangle mesh of the ghost is placed at the cursor

position, into the corresponding chunk.

- Tilemap mode: The ghost moves in steps equal to its bounding box size,

allowing precise alignment. Baking works identically.

- After each bake, the chunk's Dirty flag is set to True, and the GPU buffer

and chunk data are updated in the next frame.

Baking process:

  1. Copy the ghost's vertices.

  2. Apply scaling.

  3. Apply rotation (around the Y axis).

  4. Translate to the target position.

  5. Compute chunk coordinates: Floor(Position / ChunkSize).

  6. Add vertices to the chunk (AddVerticesToChunk).

  7. Set Dirty := True.

  8. UpdateAllDirtyChunks in the next frame.

5.3. Tilemap Mode

Toggled with the T key. In this mode:

- The ghost moves in steps equal to its bounding box size (W,A,S,D), not in

the camera direction.

- Baking (SPACE) works the same way, but placement is guaranteed to be

grid-aligned.

Tilemap movement:

procedure MoveGhostTilemap(Direction: Integer);

var

GhostMinX, GhostMaxX, GhostMinZ, GhostMaxZ: Single;

StepX, StepZ: Single;

begin

GetGhostBounds(GhostMinX, GhostMaxX, GhostMinZ, GhostMaxZ);

StepX := GhostMaxX - GhostMinX;

StepZ := GhostMaxZ - GhostMinZ;

// Step in the given direction

end;

5.4. Export

- Pressing F12 saves all vertices and triangles from every chunk into a single

PLY file.

- The filename automatically includes a timestamp:

export_YYYY-MM-DD_HH-MM-SS.ply.

- The export uses ASCII format.

Exported PLY format:

ply

format ascii 1.0

element vertex {N}

property float x

property float y

property float z

property uchar red

property uchar green

property uchar blue

property uchar alpha

element face {M}

property list uchar int vertex_indices

end_header

{x0} {y0} {z0} {r0} {g0} {b0} {a0}

...

3 {i0} {i1} {i2}

...

  1. KEYBOARD SHORTCUTS AND OPERATIONS

Key Function

-------------------------------------------------------------------------------

W, A, S, D Move ghost (free: camera direction; tilemap: grid-stepped)

Q Rotate ghost left (2 degrees)

E Rotate ghost right (2 degrees)

R Randomise ghost rotation

T Toggle Tilemap mode

F1 Toggle mouse capture (cursor lock)

F2 Load previous PLY file

F3 Load next PLY file

F4 Cycle scale presets

SPACE Bake ghost (place into chunks)

F12 Export entire scene to PLY file

ESC Exit

Scroll wheel Camera zoom

Mouse move Rotate camera (when mouse is captured)

UP / DOWN Change ghost height

  1. FILE STRUCTURE AND MODULES

File Description

-------------------------------------------------------------------------------

SterilEditor.pas Main program, GLFW window, event handling, main loop

UEngineCore.pas Core engine: camera, ghost handling, rendering, baking

UChunkSystem.pas Chunk system: storage, lookup, addition, export

URenderCore.pas GPU management: VAO/VBO, chunk upload, update

Renderer.pas Rendering pipeline (Depth+Colour pass)

RenderQueue.pas Render command storage

RenderState.pas OpenGL state management

RenderTypes.pas Rendering-related types

UShaderCore.pas Shader compilation and linking

UTilemap.pas Tilemap mode, ghost movement, baking

UPlyManager.pas PLY file scanning and navigation

UExport.pas Timestamped PLY export

SterilMath.pas Mathematical helper functions (vector, matrix)

SterilTypes.pas Basic data types

SterilMeshUtils.pas Mesh normalisation, bounding box calculation

UEditorData.pas Editor data (Ghost, etc.)


r/pascal 15d ago

Sharing VertexArt with you, maybe I can do it now:

Post image
4 Upvotes

on the video sharing site, if you search for the VertexArt Project playlist, you will find the link to my hosting in the VertexArt profile description, I hope you have found it.