SlideShare a Scribd company logo
1 of 60
Download to read offline
Developing games
and graphic visualizations
in Pascal
Michalis Kamburelis
Me me me
● Castle Game Engine - https://castle-engine.io/
● PasDoc - https://pasdoc.github.io/
● Modern Object Pascal Introduction - https://castle-engine.io/modern_pascal
● Web3d member, Khronos<->Web3d liaison (3D standards - glTF, X3D)
● Co-owner of Cat-astrophe Games - https://cat-astrophe-games.com/
Why this talk?
Long time ago
(Graph unit):
Source: https://www.deviantart.com/sledge3/art/Pac-Man-in-Turbo-Pascal-310027352
Now we got this
Source: Castle Game Engine fps_game demo
1. Modern graphic APIs
Modern graphic APIs
● 3D (higher poly each day)
● textures to provide details (of various params)
● shaders (for both mundane stuff and cool vfx)
● hardware-accelerated (utilize GPU hardware)
● Examples:
○ OpenGL(ES), WebGL
○ Vulkan, WebGPU
○ Metal
○ Direct3D
0. Input: 3D vertexes that form triangles (e.g. box is 8 vertexes, connected into 12 triangles)
1. Process each vertex to map it to screen (3D -> 2D) with extra info (vertex shaders)
2. Rasterization (having 3x 2D screen coordinates, determine pixels to draw)
(Img source: https://joshbeam.com/articles/triangle_rasterization/ )
3. Process each fragment (pixel) using per vertex data (typical place to apply texture) (fragment shaders)
(determine pixel color)
How does rendering on GPUs work
Parallelism
Source:
https://www.researchgate.net/publication/221209860_GPU-Accelerated_KLT_Tracking_with_Monte-Carlo-Based_Feature_Reselection/figures?lo=1
Parallelism
This is simplified view,
to get the point across. In
reality:
- OpenGL guarantees
rendering order in
primitive.
- OTOH there are
additional tricks like early
Z-test.
Shaders (1)
● Specialized language, compiled, and then executed on GPU
● Examples:
○ GLSL (OpenGL Shading Language)
○ HLSL (Direct3D)
● Has operations to work with vectors, matrices
● Doesn't have I/O, strings, any recursion allowed (so you can inline
everything!)
Shaders (2)
● Has uniforms: parameters defined for entire draw call
● Has inputs and outputs
● Vertex shader input:
○ position of each vertex in 3D (actually 4D, but nevermind)
○ any additional per-vertex data (like tex coords, per-vertex colors)
● Vertex shader output:
○ where the vertex is on screen
○ any additional data for fragment shader (like texture coords)
Shaders (3)
● Fragment shader input:
○ additional data from vertex shader (like texture coords)
● Fragment shader output:
○ color of the pixel
○ it can also "discard" pixel (e.g. to not draw pixels with alpha < 0.5)
Demo (1)
https://github.com/castle-engine/demo-models/blob/master/shaders/shaders_inlined.x3dv
Rendered using view3dscene (Castle Game Engine tool)
https://castle-engine.io/view3dscene.php
Experiment yourself!
Demo (2)
Demo (3)
More shaders
● Geometry shaders
○ between vertex and fragment, can generate primitives
○ e.g. vertexes could define NURBS control points, geometry shader
does actual triangles
● Compute shaders
○ perform arbitrary calculations on GPU
OpenGL, essentially
● Load VBO data (per-vertex data, like positions, normals, colors, texture coordinates)
● Load textures
● Compile and link shaders
● Each frame: Render each VBO using "draw call" (glDrawArrays)
Beyond OpenGL (1)
● OpenGLES - very like OpenGL, common on mobile
● WebGL - very like OpenGLES, in modern browsers from JS
Beyond OpenGL (2)
● Vulkan - new API from Khronos (authors of OpenGL and other standards),
○ low level
○ needs much more work to render anything
○ even more work to do it with reasonable performance
○ but if you want to go extra mile, you can get amazing performance
■ because low level, organize data closer to what you need
■ because low level, closer to how modern GPUs work
■ can split CPU work in threads, so utilize cores better for rendering
● WebGPU: like Vulkan, but in browser. A bit of WebGL counterpart.
2. Pascal access: low-level
Lazarus (LCL) TOpenGLControl
Easiest direct OpenGL
In a browser?
pas2js (Pascal to JS transpiler) with WebGL - https://github.com/genericptr/Pas2JS-WebGL
More
● https://github.com/neslib/DelphiLearnOpenGL
● https://github.com/neurolabusc/OpenGLCoreTutorials
Many OpenGL bindings
● FPC and Delphi: dglOpenGL
https://github.com/SaschaWillems/dglOpenGL
● FPC: built-in FPC GL, GLExt
● Delphi: built-in OpenGL / OpenGLExt (only for Windows)
● FPC and Delphi (excited about this)
○ GLAD
○ https://glad.dav1d.de/ - supports Pascal
○ generates the loading code with entry points you need
○ it is always up-to-date as it reads Khronos specs
○ Let's add Pascal to GLAD2 https://gen.glad.sh/ , and get also Vulkan!
3. Pascal high-level drawing
libraries
Skia4Delphi (1)
● https://github.com/skia4delphi/skia4delphi
● 2D effects library, based on Google Skia https://skia.org/
● Pretty UI with fancy effects - got it easily
● Can be your rendering workhorse for rendering something more complex,
like a game
Skia4Delphi (2)
FireMonkey 3D
● Built-in Delphi
● 3D shapes, camera, materials
● Internet has lots of examples how to extend it -- e.g. to read some popular
3D file formats
● https://github.com/VincentGsell/FMeX (by Vincent Gsell)
FireMonkey 3D + FMeX
GLScene
● https://glscene.sourceforge.net/wikka/
● https://wiki.freepascal.org/GLScene
● https://sourceforge.net/p/glscene/code/HEAD/tree/branches/GLSceneLCL/
3.5. Pascal game engines
Castle Game Engine (1)
● https://castle-engine.io/
● Open-source (OK to use it for proprietary apps too)
● 3D and 2D
● Editor to design 3D, 2D games, UI
● Powerful OOP API, using type-safe and fast code.
○ Following Delphi and Lazarus visual designing concept: everything you see
in editor is a class/property in Pascal. But applied to games.
Castle Game Engine - Hello World
uses SysUtils,
CastleWindow, CastleSceneCore, CastleScene, CastleViewport, CastleCameras, CastleVectors;
var
Window: TCastleWindow;
Viewport: TCastleViewport;
Scene: TCastleScene;
begin
Window := TCastleWindow.Create(Application);
Window.Open;
Viewport := TCastleViewport.Create(Application);
Viewport.FullSize := true;
Viewport.Camera.SetView(
Vector3(0, 0, 10), // position
Vector3(0, 0, -1), // direction
Vector3(0, 1, 0) // up
);
Viewport.InsertBack(TCastleExamineNavigation.Create(Application));
Viewport.Camera.Add(TCastleDirectionalLight.Create(Application));
Window.Controls.InsertFront(Viewport);
Scene := TCastleScene.Create(Application);
Scene.Load('castle-data:/jetpack-cat/scene.gltf');
Scene.RenderOptions.Blending := false;
Viewport.Items.Add(Scene);
Application.Run;
end.
Castle Game Engine (2) - Features
● For Pascal (FPC and Delphi both fully supported), engine and games are both written
in Pascal.
● Assets
○ We like standards. glTF rocks, X3D rocks.
○ Great integration with e.g. Blender through glTF
○ Sketchfab importer through glTF
○ Sprite sheets, Spine, many other assets supported too
● Gfx effects - shaders, mirrors, shadows, PBR, bump mapping...
● Friendly to CI: command-line build tool, GitHub Actions, GitLab CI, Jenkins, Docker
image.
Castle Game Engine (3):
Cross-platform - many source platforms, and
even more target platforms
● Desktops (target+source) - Windows, Linux, macOS, FreeBSD, Raspberry
Pi
● Mobile (target) - Android, iOS
● Consoles (target) - Nintendo Switch
● Planned next - WebAssembly (target+source) and Oculus Quest (OpenXR;
target)
● Games released on Steam, Nintendo Switch, Android, iOS…
https://unholy-society.com/
Castle Game Engine (4)
● No longer a solo project, so happy about it!
● We are looking for
○ community support https://www.patreon.com/castleengine
○ and cooperation with companies (consulting, dedicated features,
platforms…) - talk to me :)
BeRo (1) - Kraft (physics engine)
What is "physics engine"?
● you define a world of objects ("rigid bodies"),
● each with certain shape (simple shapes are supported and can be dynamic, complex
shapes like meshes are supported too albeit static)
● certain mass,
● you define some forces (e.g. to push some object)
● you let physics engine to calculate what happens - how objects move/rotate, when
collisions between objects occur.
BeRo (2) - Kraft (physics engine)
● Kraft is a physics engine implemented in Pascal.
● Open-source - https://github.com/BeRo1985/kraft/
● By Benjamin Rosseaux - https://www.patreon.com/bero/
● Used by Castle Game Engine as our default physics engine now.
○ It rocks.
BeRo (3) - RNL (Realtime Network Library) using
reliable UDP
● Networking library to real-time games
● Made for multi-player games, using UDP but made to be reliable
● Quite easy API to use.
○ You can extend both client and server using Pascal code, and easily share
code between client/server, which is a big plus.
● Open-source https://github.com/BeRo1985/rnl/
● By Benjamin Rosseaux - https://www.patreon.com/bero/
BeRo (4) - RNL (Realtime Network Library)
with Castle Game Engine
● I did use it, with success!
○ https://github.com/castle-engine/not-quake , Online multi-player
first-person shooter using Castle Game Engine and RNL.
● Runs on actual server (michalis.xyz)
● Download from https://cat-astrophe-games.itch.io/not-quake and shoot me (and
send chat) within this talk, if you want:) You can get the client from (Windows
and Linux are stable, macOS is not for now) and shoot me now :)
BeRo (5) - PasVulkan
● Framework using Vulkan, in Pascal.
● Prospective game engine.
● Open-source https://github.com/BeRo1985/pasvulkan/
● By Benjamin Rosseaux - https://www.patreon.com/bero/
BeRo (6) - PasVulkan
● Cross-platform, everywhere where Vulkan is
○ (or compat layer like MoltenVK on macOS)
● Sprites
● UI
● Integrated with other BeRo projects, in particular PasGLTF to read and render glTF,
here in Vulkan
● Custom project manager
● https://github.com/Cooler2/ApusGameEngine
● Open-source game engine, 3D and 2D, Delphi and FPC
● By Ivan Polyacov - https://www.patreon.com/ApusGameEngine/
● Unique features
○ Powerful 2D - effects (GPU particles), GUI system
○ Scripting
○ Can be used as a framework - utilities for various things, like 3D and 2D geometry
Apus Game Engine (1)
Apus Game Engine (2)
It is actually used to make production games
● Spectromancer - http://spectromancer.com/
● Astral Heroes - http://astralheroes.com/
Apus Game Engine (3): Features in
development now
● GUI styling in CSS manner
○ "color=FFF; borderColor=444; borderWidth=1"
● 3D Import of more formats
○ Using the ASSIMP library.
● Cross-platform TCP server
○ For Windows and Linux
4. Important features of 3D
visualization engines
3D model formats
Standards matter.
● Look what others support and what is designed in a way that welcomes more ecosystem.
○ If something doesn't pass 1 of these 2 tests, it will not exist in long-term.
○ And software adapts better to changes than a bunch of data files, by design.
○ So think what will happen with your data in long-term.
● Use glTF.
○ Observe what X3D and USD are doing too.
● Ecosystem of applications around you.
○ like exporter from Blender
○ like Sketchfab integration
This is the benefit of interoperability: ~3 days of
work and we're the first engine on Sketchfab :)
https://sketchfab.com/importers#game-engine
Graphic effects to improve realism
● Physically-Based Rendering is now standard, across tools and renderers
● Shadows, mirrors - look for techniques that make your world realistic automatically
● Look at shaders support - ability to write custom shaders opens new world of possibilities
○ CGE has composable shader effects
Physics Engine
Physics is always fun.
● Unexpected things happen naturally.
● Integrate with existing physics engines (Pascal or non-Pascal: Kraft, Bullet, PhysX…)
Platforms
Selling games today is hard - lots of competition.
Cross-platform game engines allow to counter this by releasing on N markets instead of 1.
Without having Nx cost of development.
● desktop
● mobile
● consoles
● web
● vr ar
Integrations, like Steam and Google Play, come here into play too.
You are doing this for long-term
● Active community and developers are the value of a project
● Documentation
● Continuous Integration and Delivery!
○ Your QA will love you for this.
○ Games need QA desperately, good games are naturally "generators of
unexpected experiences". And we know what "something unexpected may
happen" usually means for software.
Graphic tools
Native to the engine, and/or external but well integrated.
● CGE editor
● Blender
● Tiled
● Spine
● Ask your artists, not only devs.
● Again, love standards.
Thank you!
https:/
/castle-engine.io
michalis@castle-engine.io

More Related Content

Similar to Developing games and graphic visualizations in Pascal

Developing mobile games and applications using Castle Game Engine
Developing mobile games and applications using Castle Game EngineDeveloping mobile games and applications using Castle Game Engine
Developing mobile games and applications using Castle Game EngineMichalis Kamburelis
 
Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)Alexander Dolbilov
 
Html5 Game Development with Canvas
Html5 Game Development with CanvasHtml5 Game Development with Canvas
Html5 Game Development with CanvasPham Huy Tung
 
Minecraft in 500 lines of Python with Pyglet
Minecraft in 500 lines of Python with PygletMinecraft in 500 lines of Python with Pyglet
Minecraft in 500 lines of Python with PygletRichard Donkin
 
LMG Lightning Talks - SFO17-205
LMG Lightning Talks - SFO17-205LMG Lightning Talks - SFO17-205
LMG Lightning Talks - SFO17-205Linaro
 
OTOY Presentation - 2016 NVIDIA GPU Technology Conference - April 5 2016
OTOY Presentation - 2016 NVIDIA GPU Technology Conference - April 5 2016 OTOY Presentation - 2016 NVIDIA GPU Technology Conference - April 5 2016
OTOY Presentation - 2016 NVIDIA GPU Technology Conference - April 5 2016 otoyinc
 
Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Prabindh Sundareson
 
[KubeCon EU 2020] containerd Deep Dive
[KubeCon EU 2020] containerd Deep Dive[KubeCon EU 2020] containerd Deep Dive
[KubeCon EU 2020] containerd Deep DiveAkihiro Suda
 
Smedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicschangehee lee
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'acorehard_by
 
Power of WebGL (FSTO 2014)
Power of WebGL (FSTO 2014)Power of WebGL (FSTO 2014)
Power of WebGL (FSTO 2014)Verold
 
Are AAA 3D Games for the Web Possible?
Are AAA 3D Games for the Web Possible?Are AAA 3D Games for the Web Possible?
Are AAA 3D Games for the Web Possible?Renaun Erickson
 
Node in Real Time - The Beginning
Node in Real Time - The BeginningNode in Real Time - The Beginning
Node in Real Time - The BeginningAxilis
 
Minko - Targeting Flash/Stage3D with C++ and GLSL
Minko - Targeting Flash/Stage3D with C++ and GLSLMinko - Targeting Flash/Stage3D with C++ and GLSL
Minko - Targeting Flash/Stage3D with C++ and GLSLMinko3D
 
Vpu technology &gpgpu computing
Vpu technology &gpgpu computingVpu technology &gpgpu computing
Vpu technology &gpgpu computingArka Ghosh
 
Vpu technology &gpgpu computing
Vpu technology &gpgpu computingVpu technology &gpgpu computing
Vpu technology &gpgpu computingArka Ghosh
 
Vpu technology &gpgpu computing
Vpu technology &gpgpu computingVpu technology &gpgpu computing
Vpu technology &gpgpu computingArka Ghosh
 
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special EditionIntroduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special EditionJérôme Petazzoni
 
Using GPUs to handle Big Data with Java by Adam Roberts.
Using GPUs to handle Big Data with Java by Adam Roberts.Using GPUs to handle Big Data with Java by Adam Roberts.
Using GPUs to handle Big Data with Java by Adam Roberts.J On The Beach
 
Introduction to Computing on GPU
Introduction to Computing on GPUIntroduction to Computing on GPU
Introduction to Computing on GPUIlya Kuzovkin
 

Similar to Developing games and graphic visualizations in Pascal (20)

Developing mobile games and applications using Castle Game Engine
Developing mobile games and applications using Castle Game EngineDeveloping mobile games and applications using Castle Game Engine
Developing mobile games and applications using Castle Game Engine
 
Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)Optimizing unity games (Google IO 2014)
Optimizing unity games (Google IO 2014)
 
Html5 Game Development with Canvas
Html5 Game Development with CanvasHtml5 Game Development with Canvas
Html5 Game Development with Canvas
 
Minecraft in 500 lines of Python with Pyglet
Minecraft in 500 lines of Python with PygletMinecraft in 500 lines of Python with Pyglet
Minecraft in 500 lines of Python with Pyglet
 
LMG Lightning Talks - SFO17-205
LMG Lightning Talks - SFO17-205LMG Lightning Talks - SFO17-205
LMG Lightning Talks - SFO17-205
 
OTOY Presentation - 2016 NVIDIA GPU Technology Conference - April 5 2016
OTOY Presentation - 2016 NVIDIA GPU Technology Conference - April 5 2016 OTOY Presentation - 2016 NVIDIA GPU Technology Conference - April 5 2016
OTOY Presentation - 2016 NVIDIA GPU Technology Conference - April 5 2016
 
Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011Advanced Graphics Workshop - GFX2011
Advanced Graphics Workshop - GFX2011
 
[KubeCon EU 2020] containerd Deep Dive
[KubeCon EU 2020] containerd Deep Dive[KubeCon EU 2020] containerd Deep Dive
[KubeCon EU 2020] containerd Deep Dive
 
Smedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphicsSmedberg niklas bringing_aaa_graphics
Smedberg niklas bringing_aaa_graphics
 
Настройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'aНастройка окружения для кросскомпиляции проектов на основе docker'a
Настройка окружения для кросскомпиляции проектов на основе docker'a
 
Power of WebGL (FSTO 2014)
Power of WebGL (FSTO 2014)Power of WebGL (FSTO 2014)
Power of WebGL (FSTO 2014)
 
Are AAA 3D Games for the Web Possible?
Are AAA 3D Games for the Web Possible?Are AAA 3D Games for the Web Possible?
Are AAA 3D Games for the Web Possible?
 
Node in Real Time - The Beginning
Node in Real Time - The BeginningNode in Real Time - The Beginning
Node in Real Time - The Beginning
 
Minko - Targeting Flash/Stage3D with C++ and GLSL
Minko - Targeting Flash/Stage3D with C++ and GLSLMinko - Targeting Flash/Stage3D with C++ and GLSL
Minko - Targeting Flash/Stage3D with C++ and GLSL
 
Vpu technology &gpgpu computing
Vpu technology &gpgpu computingVpu technology &gpgpu computing
Vpu technology &gpgpu computing
 
Vpu technology &gpgpu computing
Vpu technology &gpgpu computingVpu technology &gpgpu computing
Vpu technology &gpgpu computing
 
Vpu technology &gpgpu computing
Vpu technology &gpgpu computingVpu technology &gpgpu computing
Vpu technology &gpgpu computing
 
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special EditionIntroduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
 
Using GPUs to handle Big Data with Java by Adam Roberts.
Using GPUs to handle Big Data with Java by Adam Roberts.Using GPUs to handle Big Data with Java by Adam Roberts.
Using GPUs to handle Big Data with Java by Adam Roberts.
 
Introduction to Computing on GPU
Introduction to Computing on GPUIntroduction to Computing on GPU
Introduction to Computing on GPU
 

Recently uploaded

Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 

Recently uploaded (20)

Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 

Developing games and graphic visualizations in Pascal

  • 1. Developing games and graphic visualizations in Pascal Michalis Kamburelis
  • 2. Me me me ● Castle Game Engine - https://castle-engine.io/ ● PasDoc - https://pasdoc.github.io/ ● Modern Object Pascal Introduction - https://castle-engine.io/modern_pascal ● Web3d member, Khronos<->Web3d liaison (3D standards - glTF, X3D) ● Co-owner of Cat-astrophe Games - https://cat-astrophe-games.com/
  • 3. Why this talk? Long time ago (Graph unit): Source: https://www.deviantart.com/sledge3/art/Pac-Man-in-Turbo-Pascal-310027352
  • 4. Now we got this Source: Castle Game Engine fps_game demo
  • 6. Modern graphic APIs ● 3D (higher poly each day) ● textures to provide details (of various params) ● shaders (for both mundane stuff and cool vfx) ● hardware-accelerated (utilize GPU hardware) ● Examples: ○ OpenGL(ES), WebGL ○ Vulkan, WebGPU ○ Metal ○ Direct3D
  • 7. 0. Input: 3D vertexes that form triangles (e.g. box is 8 vertexes, connected into 12 triangles) 1. Process each vertex to map it to screen (3D -> 2D) with extra info (vertex shaders) 2. Rasterization (having 3x 2D screen coordinates, determine pixels to draw) (Img source: https://joshbeam.com/articles/triangle_rasterization/ ) 3. Process each fragment (pixel) using per vertex data (typical place to apply texture) (fragment shaders) (determine pixel color) How does rendering on GPUs work
  • 9. Parallelism This is simplified view, to get the point across. In reality: - OpenGL guarantees rendering order in primitive. - OTOH there are additional tricks like early Z-test.
  • 10. Shaders (1) ● Specialized language, compiled, and then executed on GPU ● Examples: ○ GLSL (OpenGL Shading Language) ○ HLSL (Direct3D) ● Has operations to work with vectors, matrices ● Doesn't have I/O, strings, any recursion allowed (so you can inline everything!)
  • 11. Shaders (2) ● Has uniforms: parameters defined for entire draw call ● Has inputs and outputs ● Vertex shader input: ○ position of each vertex in 3D (actually 4D, but nevermind) ○ any additional per-vertex data (like tex coords, per-vertex colors) ● Vertex shader output: ○ where the vertex is on screen ○ any additional data for fragment shader (like texture coords)
  • 12. Shaders (3) ● Fragment shader input: ○ additional data from vertex shader (like texture coords) ● Fragment shader output: ○ color of the pixel ○ it can also "discard" pixel (e.g. to not draw pixels with alpha < 0.5)
  • 13. Demo (1) https://github.com/castle-engine/demo-models/blob/master/shaders/shaders_inlined.x3dv Rendered using view3dscene (Castle Game Engine tool) https://castle-engine.io/view3dscene.php Experiment yourself!
  • 16. More shaders ● Geometry shaders ○ between vertex and fragment, can generate primitives ○ e.g. vertexes could define NURBS control points, geometry shader does actual triangles ● Compute shaders ○ perform arbitrary calculations on GPU
  • 17. OpenGL, essentially ● Load VBO data (per-vertex data, like positions, normals, colors, texture coordinates) ● Load textures ● Compile and link shaders ● Each frame: Render each VBO using "draw call" (glDrawArrays)
  • 18. Beyond OpenGL (1) ● OpenGLES - very like OpenGL, common on mobile ● WebGL - very like OpenGLES, in modern browsers from JS
  • 19. Beyond OpenGL (2) ● Vulkan - new API from Khronos (authors of OpenGL and other standards), ○ low level ○ needs much more work to render anything ○ even more work to do it with reasonable performance ○ but if you want to go extra mile, you can get amazing performance ■ because low level, organize data closer to what you need ■ because low level, closer to how modern GPUs work ■ can split CPU work in threads, so utilize cores better for rendering ● WebGPU: like Vulkan, but in browser. A bit of WebGL counterpart.
  • 20. 2. Pascal access: low-level
  • 22. In a browser? pas2js (Pascal to JS transpiler) with WebGL - https://github.com/genericptr/Pas2JS-WebGL
  • 24. Many OpenGL bindings ● FPC and Delphi: dglOpenGL https://github.com/SaschaWillems/dglOpenGL ● FPC: built-in FPC GL, GLExt ● Delphi: built-in OpenGL / OpenGLExt (only for Windows) ● FPC and Delphi (excited about this) ○ GLAD ○ https://glad.dav1d.de/ - supports Pascal ○ generates the loading code with entry points you need ○ it is always up-to-date as it reads Khronos specs ○ Let's add Pascal to GLAD2 https://gen.glad.sh/ , and get also Vulkan!
  • 25. 3. Pascal high-level drawing libraries
  • 26. Skia4Delphi (1) ● https://github.com/skia4delphi/skia4delphi ● 2D effects library, based on Google Skia https://skia.org/ ● Pretty UI with fancy effects - got it easily ● Can be your rendering workhorse for rendering something more complex, like a game
  • 28. FireMonkey 3D ● Built-in Delphi ● 3D shapes, camera, materials ● Internet has lots of examples how to extend it -- e.g. to read some popular 3D file formats ● https://github.com/VincentGsell/FMeX (by Vincent Gsell)
  • 30. GLScene ● https://glscene.sourceforge.net/wikka/ ● https://wiki.freepascal.org/GLScene ● https://sourceforge.net/p/glscene/code/HEAD/tree/branches/GLSceneLCL/
  • 31. 3.5. Pascal game engines
  • 32. Castle Game Engine (1) ● https://castle-engine.io/ ● Open-source (OK to use it for proprietary apps too) ● 3D and 2D ● Editor to design 3D, 2D games, UI ● Powerful OOP API, using type-safe and fast code. ○ Following Delphi and Lazarus visual designing concept: everything you see in editor is a class/property in Pascal. But applied to games.
  • 33.
  • 34. Castle Game Engine - Hello World uses SysUtils, CastleWindow, CastleSceneCore, CastleScene, CastleViewport, CastleCameras, CastleVectors; var Window: TCastleWindow; Viewport: TCastleViewport; Scene: TCastleScene; begin Window := TCastleWindow.Create(Application); Window.Open; Viewport := TCastleViewport.Create(Application); Viewport.FullSize := true; Viewport.Camera.SetView( Vector3(0, 0, 10), // position Vector3(0, 0, -1), // direction Vector3(0, 1, 0) // up ); Viewport.InsertBack(TCastleExamineNavigation.Create(Application)); Viewport.Camera.Add(TCastleDirectionalLight.Create(Application)); Window.Controls.InsertFront(Viewport); Scene := TCastleScene.Create(Application); Scene.Load('castle-data:/jetpack-cat/scene.gltf'); Scene.RenderOptions.Blending := false; Viewport.Items.Add(Scene); Application.Run; end.
  • 35. Castle Game Engine (2) - Features ● For Pascal (FPC and Delphi both fully supported), engine and games are both written in Pascal. ● Assets ○ We like standards. glTF rocks, X3D rocks. ○ Great integration with e.g. Blender through glTF ○ Sketchfab importer through glTF ○ Sprite sheets, Spine, many other assets supported too ● Gfx effects - shaders, mirrors, shadows, PBR, bump mapping... ● Friendly to CI: command-line build tool, GitHub Actions, GitLab CI, Jenkins, Docker image.
  • 36. Castle Game Engine (3): Cross-platform - many source platforms, and even more target platforms ● Desktops (target+source) - Windows, Linux, macOS, FreeBSD, Raspberry Pi ● Mobile (target) - Android, iOS ● Consoles (target) - Nintendo Switch ● Planned next - WebAssembly (target+source) and Oculus Quest (OpenXR; target) ● Games released on Steam, Nintendo Switch, Android, iOS…
  • 38. Castle Game Engine (4) ● No longer a solo project, so happy about it! ● We are looking for ○ community support https://www.patreon.com/castleengine ○ and cooperation with companies (consulting, dedicated features, platforms…) - talk to me :)
  • 39. BeRo (1) - Kraft (physics engine) What is "physics engine"? ● you define a world of objects ("rigid bodies"), ● each with certain shape (simple shapes are supported and can be dynamic, complex shapes like meshes are supported too albeit static) ● certain mass, ● you define some forces (e.g. to push some object) ● you let physics engine to calculate what happens - how objects move/rotate, when collisions between objects occur.
  • 40. BeRo (2) - Kraft (physics engine) ● Kraft is a physics engine implemented in Pascal. ● Open-source - https://github.com/BeRo1985/kraft/ ● By Benjamin Rosseaux - https://www.patreon.com/bero/ ● Used by Castle Game Engine as our default physics engine now. ○ It rocks.
  • 41.
  • 42. BeRo (3) - RNL (Realtime Network Library) using reliable UDP ● Networking library to real-time games ● Made for multi-player games, using UDP but made to be reliable ● Quite easy API to use. ○ You can extend both client and server using Pascal code, and easily share code between client/server, which is a big plus. ● Open-source https://github.com/BeRo1985/rnl/ ● By Benjamin Rosseaux - https://www.patreon.com/bero/
  • 43. BeRo (4) - RNL (Realtime Network Library) with Castle Game Engine ● I did use it, with success! ○ https://github.com/castle-engine/not-quake , Online multi-player first-person shooter using Castle Game Engine and RNL. ● Runs on actual server (michalis.xyz) ● Download from https://cat-astrophe-games.itch.io/not-quake and shoot me (and send chat) within this talk, if you want:) You can get the client from (Windows and Linux are stable, macOS is not for now) and shoot me now :)
  • 44.
  • 45. BeRo (5) - PasVulkan ● Framework using Vulkan, in Pascal. ● Prospective game engine. ● Open-source https://github.com/BeRo1985/pasvulkan/ ● By Benjamin Rosseaux - https://www.patreon.com/bero/
  • 46. BeRo (6) - PasVulkan ● Cross-platform, everywhere where Vulkan is ○ (or compat layer like MoltenVK on macOS) ● Sprites ● UI ● Integrated with other BeRo projects, in particular PasGLTF to read and render glTF, here in Vulkan ● Custom project manager
  • 47.
  • 48. ● https://github.com/Cooler2/ApusGameEngine ● Open-source game engine, 3D and 2D, Delphi and FPC ● By Ivan Polyacov - https://www.patreon.com/ApusGameEngine/ ● Unique features ○ Powerful 2D - effects (GPU particles), GUI system ○ Scripting ○ Can be used as a framework - utilities for various things, like 3D and 2D geometry Apus Game Engine (1)
  • 49.
  • 50. Apus Game Engine (2) It is actually used to make production games ● Spectromancer - http://spectromancer.com/ ● Astral Heroes - http://astralheroes.com/
  • 51. Apus Game Engine (3): Features in development now ● GUI styling in CSS manner ○ "color=FFF; borderColor=444; borderWidth=1" ● 3D Import of more formats ○ Using the ASSIMP library. ● Cross-platform TCP server ○ For Windows and Linux
  • 52. 4. Important features of 3D visualization engines
  • 53. 3D model formats Standards matter. ● Look what others support and what is designed in a way that welcomes more ecosystem. ○ If something doesn't pass 1 of these 2 tests, it will not exist in long-term. ○ And software adapts better to changes than a bunch of data files, by design. ○ So think what will happen with your data in long-term. ● Use glTF. ○ Observe what X3D and USD are doing too. ● Ecosystem of applications around you. ○ like exporter from Blender ○ like Sketchfab integration
  • 54. This is the benefit of interoperability: ~3 days of work and we're the first engine on Sketchfab :) https://sketchfab.com/importers#game-engine
  • 55. Graphic effects to improve realism ● Physically-Based Rendering is now standard, across tools and renderers ● Shadows, mirrors - look for techniques that make your world realistic automatically ● Look at shaders support - ability to write custom shaders opens new world of possibilities ○ CGE has composable shader effects
  • 56. Physics Engine Physics is always fun. ● Unexpected things happen naturally. ● Integrate with existing physics engines (Pascal or non-Pascal: Kraft, Bullet, PhysX…)
  • 57. Platforms Selling games today is hard - lots of competition. Cross-platform game engines allow to counter this by releasing on N markets instead of 1. Without having Nx cost of development. ● desktop ● mobile ● consoles ● web ● vr ar Integrations, like Steam and Google Play, come here into play too.
  • 58. You are doing this for long-term ● Active community and developers are the value of a project ● Documentation ● Continuous Integration and Delivery! ○ Your QA will love you for this. ○ Games need QA desperately, good games are naturally "generators of unexpected experiences". And we know what "something unexpected may happen" usually means for software.
  • 59. Graphic tools Native to the engine, and/or external but well integrated. ● CGE editor ● Blender ● Tiled ● Spine ● Ask your artists, not only devs. ● Again, love standards.