hdtv101
Posts: 67
Joined: Sun May 01, 2016 9:26 pm

Raylib on RPI4

Sun Apr 04, 2021 7:43 pm

I am trying to get Raylib to work on a fresh RPi4. I need Boreland BGI type graphics and Raylib seems to fit the bill. The end solution is to design industrial controller touch screens, which I have done for years using Boreland C BGI.

I downloaded the Raylib GIT version for the RPi4 then extracted it into a new raylib-rpi4 directory under /home/pi.

I also installed libdrm-dev and libgbm-dev. Don't know why, just following instructions.

Using Code Blocks to build the color demo. I had to change the path to raylib.h in the C source but it gives many errors due to missing Raylib function calls. Note I have not linked yet, just complied. Shouldn't raylib.h contain prototypes? (it does)

Then once that is fixed, how do I get the GCC linker to see the Raylib library?

Note if I am barking up the wrong tree here using Raylib, I am open to other GUI suggestions.

User avatar
topguy
Posts: 7045
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Raylib on RPI4

Tue Apr 06, 2021 9:31 am

Did you follow these instructions ?

https://github.com/raysan5/raylib/wiki/ ... spberry-Pi

Are you familiar with Cmake and development on Linux in general ?

hdtv101
Posts: 67
Joined: Sun May 01, 2016 9:26 pm

Re: Raylib on RPI4

Wed Apr 07, 2021 12:32 am

Well I installed cmake and see the cmake files in the raylib package.

So how do you use them?

The raylib page has some simple instructions but I can get the examples to link. Missing a lot of libraries. This is not simple!

I have deep C expereince in DOS, Windows, and embedded processors. But not much in Linux.

User avatar
Gavinmc42
Posts: 5261
Joined: Wed Aug 28, 2013 3:31 am

Re: Raylib on RPI4

Wed Apr 07, 2021 1:36 am

NOTE: Raspberry Pi 4 native mode compilation requires PLATFORM_DRM compilation flag instead of PLATFORM_RPI!

Supported OpenGL backends
OpenGL ES 2.0 in native mode (no X11 required)
Interesting, I might have a play with that.
GUI's without X11 are of interest to me.

The instructions seem simple enough. "easy" ;)
Just have to install those dependencies first.

But it sounds like you might just have PATH issues if it cannot find the libs?

In Linux it can be as simples as
1) git clone xxxx
2) cd xxxx
3) cmake .
4) make -j3
5) sudo make install

That last step is more for updating apps, drivers and libraries etc.
It can also update the PATH environment.

For something like Raylib which looks pretty active use the git clone option, not downloading the zip.
Later you can "cd raylib" and do a "git pull" to get the latest code.
"git clone" does extra stuff than getting just the zip.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

hdtv101
Posts: 67
Joined: Sun May 01, 2016 9:26 pm

Re: Raylib on RPI4

Wed Apr 07, 2021 2:44 am

GUI's without X11 are of interest to me.
Yes I have been using the Boreland C 3.1 (1992) BGI with the Ryle Designs SVGA library up to now. Yes under DOS for industrial control systems.

I love to tell people "That is a dedicated computer to serve a critical dedicated function. No, you can check your EMAILS on it or download Itunes!"

But DOS is becoming a problem as the newer networking chip sets don't support packet drivers anymore. VGA and RS232 are also an issue and now my touchscreen vendor has dropped RS232 models. So it's about time to move to the RPi4 and Linux.

But this Raylib installation has been a challenge - still not working. I just need to compile, link, and run shapes_colors_palette.c. Once I have that working, I can take off with the library and use many of my Boreland C functions with minimal modification - none in many cases.

Note the Git Clone seems to be only available for X86 PC use.

User avatar
Gavinmc42
Posts: 5261
Joined: Wed Aug 28, 2013 3:31 am

Re: Raylib on RPI4

Wed Apr 07, 2021 2:57 am

You are old school :D
I preferred MS QuickC.

These days I baremetal with Ultibo.
Brings back vague memories of the Turbo Pascal days.

Cannot use a Pi4 yet so PiCore Linux is my fall back.
GUI is the issue.

I found the Python based Guizero just worked on Raspbian
https://lawsie.github.io/guizero/#raspberry-pi

I usually make single purpose embedded gadgets, I don't need an OS most of the time.
24/7 stuff and corrupted uSDs have been an issue with Raspbian before for me.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Heater
Posts: 17830
Joined: Tue Jul 17, 2012 3:02 pm

Re: Raylib on RPI4

Wed Apr 07, 2021 5:14 am

hdtv101 wrote:
Wed Apr 07, 2021 2:44 am
Note the Git Clone seems to be only available for X86 PC use.
No. git clone fetches all the source code. Which can be compiled for all the supported platforms.

Why not just follow the directions on the ray lib installation page?

Like so for the Pi 4 with no X11:

Code: Select all

$ git clone https://github.com/raysan5/raylib.git
$ cd raylib/src
$ make PLATFORM=PLATFORM_DRM
When that is done the last line of the output on the terminal tells you where the library is:

Code: Select all

ar rcs ../src/libraylib.a core.o shapes.o textures.o text.o utils.o models.o raudio.o
raylib static library generated (libraylib.a) in ../src!
Sure enough there it is:

Code: Select all

$ ls /home/pi/raylib/src/*.a
/home/pi/raylib/src/libraylib.a
Now you can copy that to wherever you want it to be. Or just point your IDE at it.

I notice the usual:

Code: Select all

$ sudo make install
Does not work so don't do that.
Memory in C++ is a leaky abstraction .

Heater
Posts: 17830
Joined: Tue Jul 17, 2012 3:02 pm

Re: Raylib on RPI4

Wed Apr 07, 2021 5:27 am

Hmm.... there is something very weird going on with the raylib build instructions as I used above.

Turns out that just doing a "make PLATFORM=PLATFORM_DRM" fails with an error about a missing egl.h file.

I found that what you have to do is just a simple "make" first. Then the "make PLATFORM=PLATFORM_DRM". Like so:

Code: Select all

$ make
$ make PLATFORM=PLATFORM_DRM
That first "make" will build a load of stuff and then fail with an error about a missing Xlib.h file.

Never mind, proceed to the next make command and it will build correctly.

This is all very strange but it does result in a libraylib.a file. I have no idea if it actually works mind, none of my Pi have a screen attached.

All my instructions here on a Pi 4 with Pi OS.
Memory in C++ is a leaky abstraction .

hdtv101
Posts: 67
Joined: Sun May 01, 2016 9:26 pm

Re: Raylib on RPI4

Wed Apr 07, 2021 5:31 pm

I finally got the example program to link using CodeBlocks.

But when built as a Console application I get this in a terminal widow:

INFO: Initializing raylib 3.5
INFO DISPLAY No graphic card set, trying card1
WARNING: DISPLAY: Failed to get DRM resources
INFO: TIMER: Target time per frame: 16.667 milliseconds
INFO: TEXTURE: [ID 0] Unloaded default texture data from VRAM (GPU)
INFO: Window closed sucessfully

Process returned 0 (0x0) execution time : 0.018 s
Press ENTER to continue.

When built as a GUI application no errors but nothing happens it runs in the CodeBlocks debug window area then quits.

Heater
Posts: 17830
Joined: Tue Jul 17, 2012 3:02 pm

Re: Raylib on RPI4

Wed Apr 07, 2021 7:07 pm

If it were me I would first try and run the examples in the raylib repository. They should have been built when you built raylib.

I would run them without X Windows running.

If they do not run, it's time to raise an issue with the ray lib developer(s) on GitHub. See "issues" on the repository page.
Memory in C++ is a leaky abstraction .

hdtv101
Posts: 67
Joined: Sun May 01, 2016 9:26 pm

Re: Raylib on RPI4

Wed Apr 07, 2021 9:01 pm

Well after a lot of help from Mr. Raylib on GitHub, I got it sorted out.

The NATIVE mode must be run from a command line only config. Once the desktop is launched, the Pi is not capable of running a native graphics app. So you can see how development is not practical in this configuration. So I re-installed Raylib for DESKTOP mode and that works great.

If I do deploy this prototype I may go back to NATIVE mode for distribution but then that means two systems, develop on the desktop and then I have to copy the source to a different RPi4 set up for NATIVE mode. Unless there is a way to re-complie the RELEASE to NATIVE mode? So we degug in DESKTOP mode and the debugged app runs on other RPi4's in NATIVE mode.

I guess there is no reason I can't run full screen in desktop as a touchscreen kiosk. Just use a keyboard command to kill the app and then don't provide a keyboard.

User avatar
Gavinmc42
Posts: 5261
Joined: Wed Aug 28, 2013 3:31 am

Re: Raylib on RPI4

Thu Apr 08, 2021 2:21 am

Use another headless Pi on a network?
That's how I use most of mine, Midnight Commander works for remote editing/file manager.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Heater
Posts: 17830
Joined: Tue Jul 17, 2012 3:02 pm

Re: Raylib on RPI4

Thu Apr 08, 2021 2:50 am

Great. I works.

Mr Ray Lib seems to be a very helpful chap.
Memory in C++ is a leaky abstraction .

Return to “Graphics programming”