Skip to content

[graphics] implement raylib-based canvas [draft] - #23043

Draft
linev wants to merge 5 commits into
root-project:masterfrom
linev:raylib_canvas
Draft

[graphics] implement raylib-based canvas [draft]#23043
linev wants to merge 5 commits into
root-project:masterfrom
linev:raylib_canvas

Conversation

@linev

@linev linev commented Aug 6, 2026

Copy link
Copy Markdown
Member

raylib is very compact graphics library.
Just use it as basic demo how canvas can be implemented with it.

With some help of AI working code was generated within one day.
One can consider it just as demonstrator.
Still missing:

  • menus, can add via raygui
  • mouse event handling, straightforward

@linev
linev requested a review from jblomer August 6, 2026 15:55
@linev linev self-assigned this Aug 6, 2026
@linev
linev requested review from bellenot and dpiparo as code owners August 6, 2026 15:55
@linev
linev marked this pull request as draft August 6, 2026 15:55
@linev
linev requested a review from silverweed August 6, 2026 15:55
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

Test Results

    2 files      2 suites   2h 15m 12s ⏱️
2 602 tests 2 602 ✅ 0 💤 0 ❌
4 890 runs  4 890 ✅ 0 💤 0 ❌

Results for commit 4001e08.

♻️ This comment has been updated with latest results.

linev added 2 commits August 10, 2026 11:15
Provide three main classes:

   - TRaylibCanvas - canvas implementation for raylib
   - TRaylibPadPainter - actual painting of the root graphics with raylib
   - TRaylibGuiFactory - entry point, creates canvas implementation

raylib event loop runs with timer and processed every 10 ms
Actual painting performed in the TCanvas::Update() method

Fonts loading not works.

Basic primitives are implemented
When window resized - resize canvas
When window closed - confirm and stop painting
When canvas->Show() - show hidden window again

Trigger in EventsTimer canvas update
linev added 2 commits August 10, 2026 13:47
While raylib does not have own method to correctly fill generic polygon, add earcut.hpp from

https://github.com/mapbox/earcut.hpp
Use texture for graphics rendering.
It updated when canvas is modified and then just painted on the window - when necessary.

Decouple ROOT graphics and raylib paint loop.
Provide File menu prototype
@@ -0,0 +1,6460 @@
/*******************************************************************************************
*
* raygui v5.0 - A simple and easy-to-use immediate-mode gui library

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

This file could go into builtins/raygui/
and then from CMakeLists just target_include_directories(ROOTRaylibCanvas PRVIATE ../../builtins/raygui)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we actually want to merge this, it's (as far as I understand) a proof of concept meant to guide the evolution of the interface for TCanvas/PadPainter/etc

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is demo that API works with absolutely different gui/graphics framework.
raylib is not very popular in HEP community.
I want to make it to the point that it can be compiled and used with regular ROOT installation.

handle raylib drawing inside TRaylibCanvas class
Use internal class members instead of global/static variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants