RayLib 5.0 lazarus / 74-Games ---------------------------------------------------------------------- Guva · 2023-11-18 14:30 Hello everyone The new ray4Laz release is available on github at https://github.com/GuvaCode/Ray4Laz  New version is also available in the network package manager. there are a lot of changes in this release !!! here are some of them : NEW Platform backend supported: SDL: Thanks to the new rcore platform- split, the addition of new platforms/backends to raylib has been greatly simplified. As a proof of concept, SDL2 platform backend has been added to raylib as an aternative for GLFW library for desktop builds: platforms/rcore_desktop_sdl. Lot of work has been put to provide exactly the same features as the other platforms and carefully test the new implementation. Now SDL2 fans can use this new backend, just providing the required include libraries on compilation and linkage (not included in raylib, like GLFW). SDL backend support also eases the process of supporting a wider range of platforms that already support SDL.NEW Platform backend supported: Nintendo Switch (closed source): The addition of the SDL backend was quite a challenge but to really verify the robustness and ease of the new platform plugin system, adding support for a console was a more demanding adventure. Surprisingly, only two days of work were required to add support for Nintendo Switch to raylib! Implementation result showed an outstanding level of simplicity, with a self-contained module (rcore_swith.cpp) supporting graphics and inputs. Unfortunately this module can not be open-sourced due to licensing restrictions.NEW Splines drawing and evaluation API: A complete set of functions has been added to draw and evaluate different types of splines: Linear, Basis, Catmull-Rom, Quadratic Bezier and Cubic Bezier. Splines are extremely useful for game development (describe paths, control NPC movement...) but they can also be very useful on tools development (node-conections, elements-movement, 3d modelling, animations...). This was the missing feature on the raylib rshapes module to make it complete! Note that rshapes module can also be used independently of raylib just providing the only 6 functions required for vertex definition and drawing.NEW Pseudo-random numbers generator: rprand: After several years of users asking for this missing piece, a brand new pseudo-random generator module has been added to raylib. rprand implements the Xoshiro128** algorithm combined with SplitMix64, specially suited for fast software pseudo-random numbers generation. The module also implies some useful functions to generate non- repetitive random numbers sequences, functionality exposed by raylib. usage of this module can be controlled by a compilation flag, in case the default libc rand() function was preferred.NEW Automation Events System API: This new system was first added in raylib 4.0 as an experimental feature but it was a bit clumsy and there was no API exposed to users. For the new raylib 5.0 the system has been redesigned and proper API added for the users. With this new events automation system, users can record input events for later replay, very useful feature for testing automation, tutorials generation, assisted game playing, in-game cinematics, speedruns saving or even AI assited game playing!NEW raygui 4.0: The official raylib immediate- mode gui library designed for tools development has been updated to a new version, aligned with raylib 5.0. This new version is a complete redesign of raygui to unify all controls structure and usage, now all controls have the same function signature!. raygui has been battle- tested with the development of +12 published tools in the last few years. The tools can be seen and used for free in the raylib technologies tools page. Worth mentioning that several of those tools have been open sourced for anyone to use, compile, contribute or learn how the code works. ps: added compiled raylib (with physics and gui enabled) for Linux x32 and x64, Windows x32 and x64 platforms. ---------------------------------------------------------------------- DrakkTheSeafarer · 2023-11-19 21:48 great work! ---------------------------------------------------------------------- YiannisKam · 2023-12-09 11:44 In raymath.pas, line 132 the function Vector2Equals(p, q: TVector2): TVector2; ... should return an integer not a TVector2. ---------------------------------------------------------------------- Guva · 2023-12-10 07:42 Quote from: YiannisKam on December 09, 2023, 12:44:59 pmIn raymath.pas, line 132 the function Vector2Equals(p, q: TVector2): TVector2; ... should return an integer not a TVector2. thanks I fixed it ---------------------------------------------------------------------- YiannisKam · 2023-12-10 12:02 You're welcome, thank you too. ---------------------------------------------------------------------- Mongkey · 2023-12-18 01:42 Hello @guva, is there a container for raylib in a form? i would use raylib 5.0 for data visualization, this one is much cheap cpu usage game engine. I couldn't run gui example, it always crash. Thank you. ---------------------------------------------------------------------- Mongkey · 2023-12-19 13:59 I found a sample https://gist.github.com/ChrisDill/c2ca6a0ccf592c073a8d2aaeaa4adb7f https://gist.github.com/flibitijibibo/cf282bfccc1eaeb47550 Thank you ---------------------------------------------------------------------- Guva · 2023-12-22 03:26 Quote from: Mongkey on December 19, 2023, 02:59:55 pmI found a sample https://gist.github.com/ChrisDill/c2ca6a0ccf592c073a8d2aaeaa4adb7f https://gist.github.com/flibitijibibo/cf282bfccc1eaeb47550 Thank you you can see how the renderer for lcl is implemented in zengl https://github.com/Seenkao/New- ZenGL/tree/ZenGL_4_2/Zengl_SRC/demos/Lazarus/18%20-%20LCLZenGL next weekend I'll try to realize ---------------------------------------------------------------------- Seenkao · 2023-12-22 16:16 Quote from: Guva on December 22, 2023, 04:26:44 amyou can see how the renderer for lcl is implemented in zengl Это не совсем правильная реализация. Но работать будет. ZenGL считается однопотоковым приложением и данные не защищены от многопотока. Лучше всего реализовать в таких случаях защиту данных в многопоточных приложениях. В дальнейшем я буду думать над правкой ZenGL для многопоточных приложений. И, вернее всего, потом не нужны будут данные ограничения для таймера в каждой вызываемой процедуре/функции. Google translate: This is not a completely correct implementation. But it will work. ZenGL is considered a single threaded application and the data is not thread safe. In such cases, it is best to implement data protection in multi-threaded applications. In the future I will think about editing ZenGL for multi-threaded applications. And, most likely, then these restrictions for the timer in each called procedure/function will not be needed. ---------------------------------------------------------------------- Guva · 2023-12-23 12:23 Quote from: Seenkao on December 22, 2023, 05:16:08 pmQuote from: Guva on December 22, 2023, 04:26:44 amyou can see how the renderer for lcl is implemented in zengl Это не совсем правильная реализация. Но работать будет. ZenGL считается однопотоковым приложением и данные не защищены от многопотока. Лучше всего реализовать в таких случаях защиту данных в многопоточных приложениях. В дальнейшем я буду думать над правкой ZenGL для многопоточных приложений. И, вернее всего, потом не нужны будут данные ограничения для таймера в каждой вызываемой процедуре/функции. Google translate: This is not a completely correct implementation. But it will work. ZenGL is considered a single threaded application and the data is not thread safe. In such cases, it is best to implement data protection in multi-threaded applications. In the future I will think about editing ZenGL for multi-threaded applications. And, most likely, then these restrictions for the timer in each called procedure/function will not be needed. Серж, ну я не говорил что нужно использовать именно код из ZenGl. Я имел ввиду что можно посмотреть как реализовано. С наступающим новым годом Yandex translate: Serge, well, I did not say that it is necessary to use the code from ZenGl. I meant that you can see how it is implemented. Happy New Year ---------------------------------------------------------------------- Mongkey · 2024-02-23 08:06 Still waiting for sample in regular lazarus form ---------------------------------------------------------------------- Guva · 2024-02-23 08:43 Quote from: Mongkey on February 23, 2024, 09:06:24 amStill waiting for sample in regular lazarus form  here is an example for c#. it should not be hard to implement it for pascal under vindows https://gist.github.com/ChrisDill/c2ca6a0ccf592c073a8d2aaeaa4adb7f ---------------------------------------------------------------------- mosquito · 2024-04-15 16:35 Hello, thank you very much for the Ray4Laz. It seems that the compiled binaries are not dependent on any dynamic libraries, but you provide a .dll or .so in your package. So, what is the desired behavior when compiling: totally static or dynamic? ---------------------------------------------------------------------- Guva · 2024-04-17 09:25 Quote from: mosquito on April 15, 2024, 06:35:40 pm So, what is the desired behavior when compiling: totally static or dynamic? Well, it's as convenient for you. But for Windows, it is better to compile the library yourself, since cross-compilation from linux does not catch raygui. ---------------------------------------------------------------------- fireboxsoft · 2024-12-26 10:00 DrawText('FONT SIZE字体: 30.0', GetScreenWidth() - 240, 20, 20, DARKGRAY);    How can this engine support displaying Chinese and unicode when drawing text? ---------------------------------------------------------------------- Guva · 2024-12-26 13:54 Quote from: fireboxsoft on December 26, 2024, 11:00:02 amDrawText('FONT SIZE字体: 30.0', GetScreenWidth() - 240, 20, 20, DARKGRAY);    How can this engine support displaying Chinese and unicode when drawing text? https://github.com/raysan5/raylib/blob/master/examples/text/text_unico de.c ---------------------------------------------------------------------- fireboxsoft · 2024-12-27 00:17 Thank you for your reply and guidance. I don't know C language, only pascal, but I would like to try using lazarus+Raylib to develop games. I will try to see if I can successfully support unicode. But we still hope that the author of the engine will officially release a demo and example, so that we will avoid detours. Looking forward to it, thank you! ---------------------------------------------------------------------- Seenkao · 2024-12-27 06:55 fireboxsoft, {$codepage utf-8} ??? ---------------------------------------------------------------------- Guva · 2024-12-27 14:38 Quote from: Seenkao on December 27, 2024, 07:55:16 amfireboxsoft, {$codepage utf-8} ??? ru: Серж к сожалению в raylib так не работает для отображения юникода есть свои функции и процедуры. en: Serge unfortunately raylib does not work like that for displaying Unicode has its own functions and procedures. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {Draw one character (codepoint)}procedure DrawTextCodepoint(font: TFont; codepoint: Integer; position: TVector2; fontSize: Single; tint: TColorB); {Draw multiple character (codepoint)}procedure DrawTextCodepoints(font: TFont; const codepoints: PInteger; codepointCount: Integer; position: TVector2; fontSize, spacing: Single; tint: TColorB);  {Load UTF-8 text encoded from codepoints array}function LoadUTF8(const codepoints: PInteger; length: Integer): PChar;{Unload UTF-8 text encoded from codepoints array}procedure UnloadUTF8(text: PChar);{Load all codepoints from a UTF-8 text string, codepoints count returned by parameter}function LoadCodepoints(const text: PChar; count: PInteger): PInteger; {Unload codepoints data from memory}procedure UnloadCodepoints(codepoints: PInteger); {Get total number of codepoints in a UTF-8 encoded string}function GetCodepointCount(const text: PChar): Integer; {Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure}function GetCodepoint(const text: PChar; codepointSize: PInteger): Integer; {Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure}function GetCodepointNext(const text: PChar; codepointSize: PInteger): Integer; {Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure}function GetCodepointPrevious(const text: PChar; codepointSize: PInteger): Integer; {Encode one codepoint into UTF-8 byte array (array length returned as parameter)}function CodepointToUTF8(codepoint: Integer; utf8Size: PInteger): PChar; ---------------------------------------------------------------------- fireboxsoft · 2024-12-28 01:24 thank you very much! ---------------------------------------------------------------------- Guva · 2025-04-10 02:27 Quote from: fireboxsoft on December 26, 2024, 11:00:02 amDrawText('FONT SIZE字体: 30.0', GetScreenWidth() - 240, 20, 20, DARKGRAY);    How can this engine support displaying Chinese and unicode when drawing text? I needed to display other languages. Note: Your font must support the language you want. To use in raygi, you need to download the font Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i MyFont := LoadUnicodeFont(16,'Cornerita_Regular.ttf');GuiSetFont(MyFont); To use in your code, use the DrawTextEx or Draw Text Pro procedures . Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program TestFont; {$mode objfpc}{$H+} usescmem, {$IFDEF LINUX} cthreads,{$ENDIF}raylib, fontUtil; const  screenWidth = 800;  screenHeight = 450; var  MyFont: TFont; begin  // Initialization  InitWindow(screenWidth, screenHeight, 'raylib - simple project');  SetTargetFPS(60);// Set our game to run at 60 frames-per-second   MyFont := LoadUnicodeFont('NotoSansTC-Regular.ttf', 48);   // Main game loop  while not WindowShouldClose() do    begin      // Update    // TODO: Update your variables here       // Draw      BeginDrawing();        ClearBackground(RAYWHITE);        DrawTextEx(MyFont, '恭喜! 你创建了你的第一个窗口!', Vector2Create(140,200), 48, 1, LIGHTGRAY);      EndDrawing();    end;   // De-Initialization  UnloadFont(MyFont);  CloseWindow();        // Close window and OpenGL contextend.  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit fontUtil; {$mode ObjFPC}{$H+} interface uses  raylib, SysUtils; function LoadUnicodeFont(FileName: String; FontSize: Integer;  TextureFilter: TTextureFilter = TEXTURE_FILTER_POINT): TFont; implementation function LoadUnicodeFont(FileName: String; FontSize: Integer;  TextureFilter: TTextureFilter): TFont;var  cp: array of Integer;  // Array to store Unicode codepoints  count: Integer;        // Counter for codepoints   // Helper procedure to add a range of Unicode codepoints  procedure AddRange(start, stop: Integer);  begin    while start <= stop do    begin      // Dynamically expand array if needed      if count >= Length(cp) then      SetLength(cp, Length(cp) + 1024);      // Add current codepoint and increment      cp[count] := start;      Inc(count);      Inc(start);    end;  end; begin  // Initialize codepoint array with initial capacity  SetLength(cp, 65536);  count := 0;   // --------------------------------------------------  // 1. BASIC ASCII CHARACTERS  // --------------------------------------------------  AddRange(32, 126);  // Basic Latin (letters, digits, punctuation)   // --------------------------------------------------  // 2. EUROPEAN LANGUAGES (LATIN SCRIPT)  // --------------------------------------------------  AddRange($C0, $17F);  // Latin-1 Supplement + Latin Extended-A  AddRange($180, $24F); // Latin Extended-B  AddRange($1E00, $1EFF); // Latin Extended Additional  AddRange($2C60, $2C7F); // Latin Extended-C   // --------------------------------------------------  // 3. GREEK AND COPTIC  // --------------------------------------------------  AddRange($370, $3FF); // Greek and Coptic  AddRange($1F00, $1FFF); // Greek Extended   // --------------------------------------------------  // 4. CYRILLIC SCRIPTS  // --------------------------------------------------  AddRange($400, $4FF); // Basic Cyrillic  AddRange($500, $52F); // Cyrillic Supplement  AddRange($2DE0, $2DFF); // Cyrillic Extended-A  AddRange($A640, $A69F); // Cyrillic Extended-B   // --------------------------------------------------  // 5. CJK LANGUAGES (CHINESE, JAPANESE, KOREAN)  // --------------------------------------------------  AddRange($4E00, $9FFF); // CJK Unified Ideographs  AddRange($3400, $4DBF); // CJK Extension A  AddRange($3000, $303F); // CJK Symbols and Punctuation  AddRange($3040, $309F); // Hiragana (Japanese)  AddRange($30A0, $30FF); // Katakana (Japanese)  AddRange($31F0, $31FF); // Katakana Phonetic Extensions  AddRange($FF00, $FFEF); // Halfwidth and Fullwidth Forms  AddRange($AC00, $D7AF); // Hangul Syllables (Korean)  AddRange($1100, $11FF); // Hangul Jamo   // --------------------------------------------------  // 6. SOUTHEAST ASIAN LANGUAGES  // --------------------------------------------------  AddRange($0E00, $0E7F); // Thai  AddRange($0E80, $0EFF); // Lao  AddRange($1780, $17FF); // Khmer  AddRange($1000, $109F); // Myanmar  AddRange($1980, $19DF); // New Tai Lue   // --------------------------------------------------  // 7. INDIAN SUBCONTINENT LANGUAGES  // --------------------------------------------------  AddRange($900, $97F);  // Devanagari (Hindi, Sanskrit)  AddRange($980, $9FF);  // Bengali  AddRange($A00, $A7F);  // Gurmukhi (Punjabi)  AddRange($A80, $AFF);  // Gujarati  AddRange($B00, $B7F);  // Oriya  AddRange($B80, $BFF);  // Tamil  AddRange($C00, $C7F);  // Telugu  AddRange($C80, $CFF);  // Kannada  AddRange($D00, $D7F);  // Malayalam  AddRange($D80, $DFF);  // Sinhala   // --------------------------------------------------  // 8. MIDDLE EASTERN LANGUAGES  // --------------------------------------------------  AddRange($600, $6FF);  // Arabic  AddRange($750, $77F);  // Arabic Supplement  AddRange($8A0, $8FF);  // Arabic Extended-A  AddRange($FB50, $FDFF); // Arabic Presentation Forms-A  AddRange($5D0, $5EA);  // Hebrew  AddRange($591, $5C7);  // Hebrew Extended  AddRange($7C0, $7FF);  // N'Ko  AddRange($640, $6FF);  // Syriac   // --------------------------------------------------  // 9. AFRICAN LANGUAGES  // --------------------------------------------------  AddRange($2C80, $2CFF); // Coptic  AddRange($2D30, $2D7F); // Tifinagh  AddRange($A6A0, $A6FF); // Bamum  AddRange($AB00, $AB2F); // Ethiopic Extended   // --------------------------------------------------  // 10. SPECIAL CHARACTERS AND SYMBOLS  // --------------------------------------------------  AddRange($300, $36F);  // Combining Diacritical Marks  AddRange($1DC0, $1DFF); // Combining Diacritical Marks Supplement  AddRange($2000, $206F); // General Punctuation  AddRange($20A0, $20CF); // Currency Symbols  AddRange($2100, $214F); // Letterlike Symbols  AddRange($2190, $21FF); // Arrows  AddRange($2200, $22FF); // Mathematical Operators   // Trim the array to actual used size  SetLength(cp, count);   // Attempt to load the specified font file with all collected codepoints  if FileExists(FileName) then    Result := LoadFontEx(PChar(FileName), FontSize, @cp[0], Length(cp));   // Fallback to default font if loading fails  if Result.texture.id = 0 then    Result := GetFontDefault();   // Apply requested texture filter (defaults to point filtering)  SetTextureFilter(Result.texture, TextureFilter);end; end. ---------------------------------------------------------------------- threedslider · 2025-05-11 18:19 Awesome ! God job ! Keep it up please the good work !  I am new to Lazarus, I may ask you, this RayLib 5.0 supports to the latest with Lazarus 4.0, right ? Thank you. ---------------------------------------------------------------------- Guva · 2025-05-13 03:12 Quote from: threedslider on May 11, 2025, 08:19:39 pmI am new to Lazarus, I may ask you, this RayLib 5.0 supports to the latest with Lazarus 4.0, right ? Yes, it supports. Are you having any problems with the installation?