Getting Started with PasSFML in Lazarus
- display of images;
- display of 2d shapes such as circles, rectangles and other polygons;
- display of text when supplied with font files such as arial.ttf;
- motion graphics;
- recording and output of audio;
- networking by TCP and UDP;
- use of shaders in advanced graphics;
- use of your existing OpenGL code for 3D graphics.
Christian Budde has developed a Pascal binding for the library available on GitHub and named it PasSFML. The C++ version is well documented with official tutorials and online API documentation. It also has samples which Christian has converted to PasSFML. Our tutorial C/C++ after Pascal should help you to understand the C++ tutorials and documentation. The tutorials are very readable and contain useful background information.
You should learn quickly how to write Pascal code based on the C++ documentation. For example, instead of circle.setOutlineThickness(10) you can change the value of the property with circle.OutlineThickness := 10 or directly access the library with SfmlCircleShapeSetOutlineThickness(circle.Handle, 10).
C++ offers a little sample console program to test the set-up. Here is a Pascal version. It uses only the SfmlSystem.pas unit and the corresponding library file (csfml-system-2.dll on Windows).
program Clock; uses SfmlSystem; var MyClock: TsfmlClock; begin MyClock := TsfmlClock.Create; while MyClock.ElapsedTime.AsSeconds < 5 do begin writeln(MyClock.ElapsedTime.AsSeconds : 5 : 3); sfmlSleep(sfmlMilliseconds(500)); end; readln; end.
0.000 0.501 1.002 1.503 2.003 2.504 3.005 3.506 4.007 4.508
Follow the links below for straightforward demonstrations. In some of them we make the code shorter by closing the program after a sleeping period instead of handling events to close the graphics window.