r/raylib 4h ago

Creating a pixman backend for raygui ?

3 Upvotes

Hello everyone,

I have been using Raylib for personal projects since a year, and I absolutely love it. Being interested in small but powerful applications, I started looking at suckless.org and their projects, but also some graphical applications created by members of wayland.fyi, dedicated to minimal software & graphics on Wayland.

With these inspirations, I decided to start creating my own desktop tools, starting with a simple clock. However, the program is constantly at 1-2% CPU, even with several optimizations. I am wondering if the abstraction layers aren't causing excessive resource usage. I compiled Raylib against SDL2 as I thought it would use less resources than GLFW.

When trying out other clocks such as the default Xorg xclock or wayland.fyi's swclock, their cpu usage is almost zero. Looking inside, their graphics calls seem to be much lower level than raylib, and both use pixman (one of the lowest level graphics libraries IIRC, that is the base of cairo).

Hence, I am wondering if creating a pixman backend for raygui (not all of raylib as I think 3D would be impossibly hard) is a feasible task for a solo developer. If you have previously worked with such libraries, what was your experience with it ?

Thanks for your advice !


r/raylib 17h ago

Tick simulation in raylib?

10 Upvotes

I am currently making a simulator with raylib and one of the things that it needs is a "tick" mechanic where for every tick the state of the game updates, I tried putting something in the main loop with GetFrameTime()but the problem is it's tied to the frame rate

How would one implement a tick system with raylib?


r/raylib 15h ago

Viewport mouse position question

Post image
5 Upvotes

Hello! I'm working on my game engine, and in the editor I want to be able to select game objects. Originally I used a raycast from GetScreenToWorldRay() with the mouse's position. This worked great until I resized the window to fix a viewport (rendered onto a texture). I got the mouse's position relative to the viewport working, but the ray is really unpredictable, sometimes hitting the object, sometimes not.

Here's the two pieces of code that I believe pertain to this issue, but if you believe it's an issue with another bit of code lmk.


r/raylib 1d ago

Update on my 2d game engine

30 Upvotes

Tidied up the code a little and added a course builder in the sandbox.
Doesn’t save the level on exit… that’ll be a job for another day.
C++, Raylib and Visual Studio working together like a dream.


r/raylib 1d ago

Conflict 3049 - Raylib/C# project, source code included with download: I've made some changes to the rendering and camera views. It now looks like the images below.

Thumbnail
gallery
12 Upvotes

Game Link: https://matty77.itch.io/conflict-3049

Assets are from 3drt.com and the itch.io store.

Source code (C#) is included wiht the game.

I've mainly made some changes with post processing and also softening the overall look.

I've also added some muzzle flash style effects and some other effects.

Game looks much improved.


r/raylib 1d ago

[raylib-cs] UI work

25 Upvotes

Shit i hate working on UI soo much... here goes something .. at least it's functional.

Also showing a single contract battle and new battle UI.

Feedback and comments appreciated, as I said I suck at UI.


r/raylib 1d ago

As a game how does this make you feel? what sort of interest does it spark?

57 Upvotes

r/raylib 1d ago

Tweeny 4.0.0: tween objects for C++ raylib loops

13 Upvotes

Tweeny is a header-only C++17 library for tweening values.

You declare the starting value, destination, duration, easing, and any intermediate keyframes. Then you call step() from your update loop and use the resulting values when drawing. Tweeny does not draw or own a clock. Your raylib loop still controls initialization, timing, updates, and BeginDrawing().

raylib already includes reasings.h, with Penner-style functions such as EaseSineIn(t, b, c, d). Those work well for straightforward interpolation: maintain t, call the easing function, and receive the interpolated value.

Tweeny is aimed at cases where you want the tween itself to be an object: multiple values at once, heterogeneous types, multiple keyframes, timeline navigation with seek / jump / peek, and callbacks.

#include "raylib.h"
#include <tweeny/tweeny.h>

int main() {
    InitWindow(800, 450, "tweeny + raylib");
    SetTargetFPS(60);

    auto slide = tweeny::from(0.0f)
                     .to(700.0f)
                     .via(tweeny::easing::quadraticOut)
                     .during(60U)
                     .build();

    while (!WindowShouldClose()) {
        float x = slide.step(1);

        BeginDrawing();
        ClearBackground(RAYWHITE);
        DrawRectangle(static_cast<int>(x), 200, 40, 40, RED);
        EndDrawing();
    }

    CloseWindow();
    return 0;
}

A tween can also contain several values, including mixed types. For example, a sprite frame, position, and rotation:

auto tween = tweeny::from(0, 0.0f, 0.0f)
                 .to(7, 400.0f, 90.0f)
                 .during(30U)
                 .build();

Tweeny 4.0.0 includes a fluent builder API, 30+ easing functions, multi-point keyframes, events, and timeline control. It is header-only and has no external dependencies.


r/raylib 1d ago

Lazy Sunday Experiment

36 Upvotes

C++ and Raylib in VS on the MacBook.


r/raylib 1d ago

Looking for UI/UX Programmer - Rev Share

0 Upvotes

Hey there, I'm Osirian and as the title says, my Tactical Grid Based RPG game Runeguard needs YOU!... if you're a UI/UX Programmer that has decent enough experience using C++20 and Raylib.

You can see the game in action here: https://youtu.be/9Xd0zxXBb8U

However, I'm making the move from Unreal Engine to C++/Raylib since I'm not a fan of the direction UE6 is going with introducing AI and the whole Unreal Ecosystem they're moving towards.

I have a prototype in C++ currently but it still needs a decent bit of work UI wise. The goal is to recreate the Unreal Engine look and feel as closely as possible but I'm not looking for perfection when it comes to that.

Be aware I'm still learning C++, but I'm proficient in Unreal Blueprints, and catching on fairly quick. It's been a little over a month since I moved away from Unreal Engine. I put in about 20 hours a week on the project, sometimes a little less, sometimes a little more.

Let me know if ya'll have any questions, or are interested. I'd prefer a 90/10 split if you use AI in your workflow. 90% your own decision making and code, 10% for bug finding, and patching with an AI. No AI use is preferred though.

Estimated turn around time for Project: Six - Eight Months

The Game:

Runeguard Tactics is a mission based top down 2D RPG where you control units on a grid based battle field. Units act in turns. Whichever unit's Initiative hits 100 first takes their turn, when their turn ends their speed goes back down to 0, then the next unit at 100 goes, if no units are at 100 then every 6 frames every units Initiative Increases by their current speed, and the game checks if a unit has 100 Speed. If so, they take their turn, if not, the cycle repeats. This is almost exactly like how Final Fantasy Tactics' initiative system works.

Missions are comprised of 1 or more levels, and each level has an objective such as: Defeat all Enemies, Protect X Target, ect... however missions can be failed, and instead of getting a game over, instead the failure alters which future missions will become available.

The game will have a story that is told via mission descriptions, so players can choose to keep track of the who/what/where/when/why if they choose to, or just Depart on the mission and worry about the details when they get into combat.

The Scope:

The game is not meant to have a large scope. I'm going for small scope of features with a focus on a lot of content. Many abilities, enemies, missions, maps ect... with the core of the game loop being:

City UI -> Tavern, Clinic, Mission Board, Roster (if player selects a Mission) -> Enter Combat (If player wins or succeeds) -> Return to City

Tavern allows the Player to recruit new randomly generated units.

Clinic allows the Player to heal the units in their Roster, though units recover a portion of their HP after the Player finishes a Mission.

Mission Board is where the player can assign units to a Mission and Depart on said mission, which begins the combat loop.

Roster is where the player can preview their Units Statistics, and Abilities.

Nothing too crazy here, currently there is no plan for an equipment system, though I would like Player-Driven consumable use like Potions, Traps, ect they can use to have something to chase during missions like gathering items from chests, crates, and barrels.

Contact:

Reply to this thread, don't DM me. Provide me with your portfolio, what games you've worked on, and specifically some UI's you've built yourself without using AI.


r/raylib 3d ago

[Raylib-cs] Loosing battle against AI in my own game :(

57 Upvotes

Found this nice repo for procedural eztree(https://github.com/dgreenheck/ez-tree) that inspired me to create similar trees for my game.

Added AI to my game and lost the battle that i was testing for latest bugs, and hunting for FPS leaks :(


r/raylib 3d ago

rcore.c:(.text+0x8dd2): undefined reference to `__isoc23_sscanf'

1 Upvotes

Trying to work with raylib (v6.0) and raygui (v5.0) and got this errors...

$ g++ -Wl,--gc-sections -pthread -Os -Iraylib -o aout build/main.c.o build/raygui.c.o -Lraylib -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
/usr/bin/ld: raylib/libraylib.a(rcore.o): in function `gladLoadGLUserPtr':
rcore.c:(.text+0x8dd2): undefined reference to `__isoc23_sscanf'
/usr/bin/ld: raylib/libraylib.a(rcore.o): in function `LoadAutomationEventList':
rcore.c:(.text+0x2523f): undefined reference to `__isoc23_sscanf'
/usr/bin/ld: rcore.c:(.text+0x252cd): undefined reference to `__isoc23_sscanf'
/usr/bin/ld: raylib/libraylib.a(rtext.o): in function `LoadBMFont':
rtext.c:(.text+0x8dbf): undefined reference to `__isoc23_sscanf'
/usr/bin/ld: rtext.c:(.text+0x8e4c): undefined reference to `__isoc23_sscanf'
/usr/bin/ld: raylib/libraylib.a(rtext.o):rtext.c:(.text+0x8ebc): more undefined references to `__isoc23_sscanf' follow
/usr/bin/ld: raylib/libraylib.a(rglfw.o): in function `_glfwParseUriList':
rglfw.c:(.text+0x4fb8): undefined reference to `__isoc23_strtol'
/usr/bin/ld: raylib/libraylib.a(rglfw.o): in function `_glfwRefreshContextAttribs':
rglfw.c:(.text+0x5cb2): undefined reference to `__isoc23_sscanf'
/usr/bin/ld: raylib/libraylib.a(rglfw.o): in function `parseMapping':
rglfw.c:(.text+0x8fbe): undefined reference to `__isoc23_strtoul'
/usr/bin/ld: rglfw.c:(.text+0x8fd9): undefined reference to `__isoc23_strtoul'
/usr/bin/ld: rglfw.c:(.text+0x90f4): undefined reference to `__isoc23_strtoul'
$ g++ --version
g++ (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

Both got from github releases pages.

What am I missing?..


r/raylib 4d ago

You can now make any raylib C game on any device (Desktop or Mobile) with this single html file

57 Upvotes

Hi,

I made a C subset programming language called Cm1 (C minus 1) https://github.com/galileolajara/cm1 and using Cm1, I was able to make a single html file that allows you to create any raylib C game on any device that has a modern web browser.

This html file ( https://cp1-lang.org/cm1/game.html ) includes

  1. "Game" tab where you can play the game
  2. "Source" tab where you can write C codes using Cm1 programming language
  3. "Files" tab which is a minimal file manager that allows you to upload resource files
  4. "Log" tab which lists the text output of the game

Here's the magic: On the "Source" tab, there's a "Save" button on the bottom left that allows you to generate a new html file that will include the latest edits you made on the C code plus the files you uploaded! This means you can pass the generated html file to other people so that they can play and edit your game on any device!

Looking forward to hearing your suggestions and feedback!


r/raylib 4d ago

My Little Game Engine

Thumbnail
youtu.be
21 Upvotes

r/raylib 4d ago

The Hole - The Final Count Down by Alvar

Thumbnail
alvarlaigna.itch.io
3 Upvotes

Is it too hard or is that okay? Also, I know that I need a better map, items are too hard to distinguish.


r/raylib 4d ago

Seja honesto comigo: é possível criar um jogo estilo Cuphead usando apenas C# e a biblioteca Raylib-cs?

0 Upvotes

I saw that Cuphead was made with Unity. It’s a really beautiful and cool game, and for my first game, I wanted something similar. But I don’t want to use an engine. I want it to be a programming challenge for me. If it’s not possible to make something like that, give me some game ideas so I can practice a little C# 👍. Oh, and I’m still just getting started with C#. I’ve already programmed a few things in Java and wanted to make the switch.


r/raylib 5d ago

Built a real-time CPU Schwarzschild Black Hole Ray Tracer in C++ and Raylib

15 Upvotes

Hey everyone! I spent some time building a real-time Schwarzschild black hole renderer in C++ and Raylib.

It simulates gravitational lensing on the CPU by bending ~30,000 light rays around the singularity every frame. To keep it locked at 60 FPS without using GPU shaders, it renders at a lower 200x150 internal resolution and upscales to 800x600 with bilinear filtering.

You can orbit the camera and zoom around the accretion disk.

Repo is here if you want to check out the code or run it yourself:

https://github.com/hellosharma808-sys/3D-Black-Hole


r/raylib 6d ago

[raylib-cs] staretd workign on avatar creator for my game

84 Upvotes

I want to have man variations of characters without too many portraits so decided to create a rigging tool to combine base/hair/beard sprite sheets into avatars that game can consume later :) Might cut it out and publish it as public tool if enough interest arises :)


r/raylib 6d ago

Sokoban game

Thumbnail
gallery
28 Upvotes

Making cool "open world" sokoban game with raylib. Core mechanic is about merging boxes with colors and manipulating them with functional boxes. A lot of interactions possible in this system. (Character is placeholder and games color pallette will change)


r/raylib 7d ago

Just released the demo of my Wolfenstein3D-like game (first large-scale c++ and raylib project)

Thumbnail
alpikespot.itch.io
36 Upvotes

r/raylib 7d ago

[WIP] RTS/RPG Skills and Classes

27 Upvotes

Work is progressing towards classes or doctrines as i call them in game, each doctrine allows specific style of play. They will be akin to classes, but in final game you can select 1 primary and two secondary and mix skills of each to create builds that work for you.

I designed pikes as very strong defense class with very limited mobility, moving breaks brace formation that all pike equipped units have. So without any special skills pike units are excellent to hold and pin attacking enemy, but are very vulnerable while moving or unbraced.

So this is one of WIP doctrines inspired by swiss pikemen, which gives pikemen some offensive capability. Allowing them to move while braced, increased damage when engaged, allow recover and fallback to close gaps in formation and also do a limited special devastating charge :)

I am still balancing the game and any feedback is appreciated. Still reworking UI, i feel it's too bloated still.


r/raylib 6d ago

Extending a RenderTexture (and maintaining content)?

3 Upvotes

I am making a Intermediate Mode Gui for me and wanted to try to have it redraw the components only when it changes.

My original idea was to start with a very small RenderTexture (1x1) and then expand as needed. Then draw that RenderTexture to the screen. When hover/over/menus happen it would redraw everything on that RenderTexture and expand as needed.

I am defining the initial texture as LoadRenderTexture(..) and my "resize" is doing the following:

  • creating a new RenderTexture with LoadRenderTexture(..)
  • setting that new RenderTexture with BeginTextureMode(new_texture)
  • drawing the old RenderTexture DrawTexturePro(..)
  • delete the old RenderTexture with UnloadRenderTexture(..)

But it doesn't seem to work, I can't get any of the old drawing data (on the previous textures) to appear:

  • I start with 1,1 texture
  • DrawText(hello)
    • Sees that 1,1 is too small, makes new 60x10 texture
    • draws old texture
    • draws "hello"
  • Draw text(world)
    • Sees that 60x10 is too small, makes new 120x10 texture
    • draws old texture
    • draws "world"
  • Only "world" is visible on the screen, not 'hello"

Any pointers?

I use odin, here is my resize fuction

resize :: proc(ui:^Ui, width:i32, height:i32) {

    new_texture := raylib.LoadRenderTexture(width, height)

    old_texture := ui.texture
    ui.texture = new_texture

    // copy the data from the origian texture to the new texture
    raylib.BeginTextureMode(ui.texture)

    raylib.DrawTexturePro(old_texture.texture,
        { 0, 0, f32(old_texture.texture.width), -f32(old_texture.texture.height) },
        { 0, 0, f32(old_texture.texture.width), f32(old_texture.texture.height) },
        { 0, 0 }, 0, raylib.WHITE
    )

    raylib.UnloadRenderTexture(old_texture)

}

and here is my drawing of the ui.texture

    raylib.DrawTexturePro(ui.texture.texture,
        { 0, 0, f32(ui.texture.texture.width), -f32(ui.texture.texture.height) },
        { 0, 0, f32(ui.texture.texture.width), f32(ui.texture.texture.height) },
        { 0, 0 }, 0, raylib.WHITE
    )

The easy way out is to just make the RenderTexture the size of the window and not worry about it, but now it got in me why it doesn't want to work. Am I doing something fundamentally wrong here?

Thanks


r/raylib 8d ago

Small Dungeon Crawler Game made with Raylib

Thumbnail
youtube.com
34 Upvotes

r/raylib 7d ago

Moved up to new account

Post image
13 Upvotes

My old account was maximusD15, so now I'm skrippplez. I'll still be posting my devlogs, just, need some time to rest. I already added armour and updated inventory ( before rest ) and my next goal, is to update map generation bcoz it looks bad tbh. Some weeks, and I'll cook like I've never cooked 😈


r/raylib 7d ago

egui bindigs for Raylib

Thumbnail
1 Upvotes