SDL2 error on RISC-V

hi,
I’m porting an app to StarFive VisionFive2 RISC-V @64bit Linux.
Compile work well, but once run, the app quit without creating any window.

Current init is as so:
SDL_Init(SDL_INIT_VIDEO);
and the error shown is:
SDL_Init Error: wayland not available
WL: ERROR initializing graphic system. Program aborted.

I tryed to change the init to:
SDL_Init(0);
and the error shown is:
SDL_CreateWindow Error: wayland not available
WL: ERROR initializing graphic system. Program aborted.

In the second case the error happen on
winPtr = SDL_CreateWindow(“Wilderland - A Hobbit Environment”, 40, 24, MAINWINWIDTH, MAINWINHEIGHT, WinMode | SDL_WINDOW_HIDDEN|SDL_WINDOW_ALLOW_HIGHDPI);

WinMode can be either 0, SDL_WINDOW_FULLSCREEN or SDL_WINDOW_FULLSCREEN_DESKTOP

Compile time SDL v.2.26.1
Link time SDL v.2.26.1

Someone can send me any hints, please?

Maybe you is just trying without a X11 window or wayland?
Here in my Xubuntu I use SDL2 just with X11.
Before SDL2 the SDL1.2 runs onframebuffer, but it appears was abandoned the support to framebuffer (which able any sdl1.2 app can run without wayland or x11).

as Windows Manager I use LightDM, while as Desktop Manager I use GNOME. Then I open a Terminal and launch the app.
Other Apps like Xeyes work, so DISPLAY is defined and X is available, I do not know if Wayland is already implemented on RISC-V.
Do you know how to choose between X11 and Framebuffer as backend for SDL2 (I prefer to have both, but at least one can be a good start)?

Games which would like to prefer wayland when available can use the following code before SDL_Init():
	SDL_SetHint(SDL_HINT_VIDEODRIVER, "wayland,x11");

So in your case you would use something like

SDL_SetHint(SDL_HINT_VIDEODRIVER, "x11,directfb");

or

SDL_SetHint(SDL_HINT_VIDEODRIVER, "x11");

Before you go compiling though, you could just try twiddling with the environment variable SDL_VIDEODRIVER instead. Then you could for instance call your application like so:

SDL_VIDEODRIVER=x11 ./whateverthisgamebinaryiscalled
1 Like

WOW, will try. Thank you

1 Like

I found the documentation in the wiki of possible video driver for env var SDL_VIDEODRIVER

But I cannot find documentation of “names” for SDL_SetHint() listing SDL_HINT_VIDEODRIVER and its possible values:

Names seems to be only those:

Where do you get “SDL_HINT_VIDEODRIVER” and its values:
“wayland,x11” or “x11,directfb” or “x11”

thank you

setting the env var to x11 works, here the valid values:

So I tested the SDL_SetHint() but is always ignored.
Using SDL_SetHintWithPriority(SDL_HINT_VIDEODRIVER, “x11”, SDL_HINT_NORMAL)
still wont work.
While using:
SDL_SetHintWithPriority(SDL_HINT_VIDEODRIVER, “x11”, SDL_HINT_OVERRIDE);
or
SDL_SetHintWithPriority(SDL_HINT_VIDEODRIVER, “x11,wayland,directfb”, SDL_HINT_OVERRIDE);
work.

Looking at the code in:
/usr/include/SDL2/SDL_hints.h
from 2.0.22, SDL_HINT_VIDEODRIVER is listed, so wiki/documentation isn’t updated (it is difficult so)

I still miss the list of valid values for this useful name

OK, performances are very poor on RISC-V as now seems there are no support for GPU, so graphics is really really slow via x11.
As wayland seems do not work, now I will try using directfb

with “directfb”, “wayland” or “kmsdrm” fail to start with error message:
SDL_Init Error: wayland not available
or directfb or kmsdrm
Performance using x11 with both a real desktop (so DISPLAY=:0) or via ssh/Xtunnel is poor but work, so I created a RISC-V package, available at:
https://github.com/efa/Wilderland/releases/tag/v2.10b

Running in a desktop (Mate) I got this error about a missing shared object:

$ WL
Wilderland - A Hobbit Environment v2.10b 64bit
(c) 2012-2019 by CH, Copyright 2019-2023 Valerio Messina
WL: Compile time SDL v.2.26.1, link time SDL v.2.26.1
libGL error: MESA-LOADER: failed to open starfive: /usr/lib/dri/starfive_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/riscv64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: starfive
libGL error: MESA-LOADER: failed to open starfive: /usr/lib/dri/starfive_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/riscv64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
libGL error: failed to load driver: starfive
WL: Using CPU emulator: 'z80emu' by Lin Ke-Fong
WL: Selected 'The Hobbit' binary version 1.2
WL: WARN 'InitGame': Can't open game file 'HOB_V12.bin'
WL: Tape file:'HOBBIT12.TAP' read successfully
WL: init done, starting ...

while running via SSH there are no errors at all.

Any hints to avoid the errors?