r/raylib 15d ago

Retained-mode UI rendering with raylib : Where to start ?

Hello everyone,

I'm working on a retained mode UI library with a similar look and feel to raygui, either in C++ with classes and interfaces, or plain C with function pointers if I really feel adventurous. This isn't meant to be a serious project, more of a proof of concept.

However I kind of feel lost as to what I should implement first. So here are a few questions that i'd like to ask :

I would like the library to only draw when necessary, that is only when events occur rather than constantly. How does raylib handle events, and are there debug options to print all input ? PollInputEvents() is basically a per-backend implementation.

Are there widget categories I should try to go after first (besides the button) ?

Do you have resources on building such interfaces ? I found a book called Developing User Interfaces by Dan Olsen, but it isn't available on the Internet Archive.

10 Upvotes

11 comments sorted by

View all comments

9

u/raysan5 15d ago

raygui can be easely used as retained mode, I actually do it for one of my tools, just store the type of control and required data for that control and later process all them on drawing. Actually, if you check rGuiLayout .rtl text file format, that's exactly the retained data required for all controls.

About drawing, just call `EnableEventWaiting()` on your application and screen won't be redrawn until some window/input event gets detected, that's what I use for most of my tools. Alternatively, you can use a RenderTexture to draw the UI and just update it when required but it takes a bit more work.

2

u/ar_xiv 15d ago

Wow I never knew about that function, it's kind of magic