floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
7.08k stars 498 forks source link

sokol_app: RaspberryPI support #195

Open septag opened 5 years ago

septag commented 5 years ago

I wanted to know if you are interested in RaspberryPI support for sokol_app with Direct FB access. In case you don't know, there is a mode in RaspberryPI which does not need X11 or any kind of graphical shell, you can setup GL surface directly from the command shell and bring up the graphics. which is the thing that I'm trying to add to sokol.

I'm new to the platform, but I've managed to run it with the bare-bone features, mouse and keyboard inputs can be read from /dev/input files and will be emulated to match the API behavior. Some other features like window events will not be supported obviously.

If you are interested, I can submit a pull request tomorrow.

floooh commented 5 years ago

Yep that's the plan. I have this working for Oryol, but didn't get around adding this to sokol_app.h.

This is the GL context setup for RaspberryPi (most of this is EGL and shared with the Android code path:

https://github.com/floooh/oryol/blob/master/code/Modules/Gfx/private/egl/eglDisplayMgr.cc

The RaspberryPi specific stuff is here:

https://github.com/floooh/oryol/blob/043683dcb3181beb64ae1c85ea76e4a4eb71c124/code/Modules/Gfx/private/egl/eglDisplayMgr.cc#L118-L151

The lowlevel mouse/keyboard input code is here (this read from /dev/input):

https://github.com/floooh/oryol/blob/master/code/Modules/Input/private/raspi/raspiInputMgr.cc

A PR would be nice :)

septag commented 5 years ago

Oh cool. Yes, as for EGL I already took most of it from the android code with very minor changes. Thanks for the code samples and resources, the actual documentation for rpi APIs are very much lacking.