Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL2 instead of Xlib, possible? #7

Open
vanfanel opened this issue Jun 13, 2020 · 10 comments
Open

SDL2 instead of Xlib, possible? #7

vanfanel opened this issue Jun 13, 2020 · 10 comments
Assignees
Labels
enhancement New feature or request

Comments

@vanfanel
Copy link

Hi there!

I am a big fan of open source games on GNU/Linux and I would like to build this Solomon's Key to Raspberry Pi without Xorg. Gaming without Xorg is possible by using the KMSDRM backend that SDL2 has.
So, do you have any plans for SDL2 instead of Xlib?

@mdodis
Copy link
Owner

mdodis commented Jun 14, 2020

It largely depends on how the KMSDRM backend is implemented in SDL2. I haven't looked into it too much, but in general if it's possible to create an OpenGL 3.3 context then it won't be too hard to do.
Otherwise, I'd need to do some refactoring to abstract the renderer, which would be a bit more work.

This is definitely going on my to-do list though!

@mdodis mdodis self-assigned this Jun 14, 2020
@mdodis mdodis added the enhancement New feature or request label Jun 14, 2020
@vanfanel
Copy link
Author

vanfanel commented Jun 14, 2020

@mdodis Thing is, I did part of the KMSDRM backen on SDL2!
You can create both OpenGL and OpenGL_ES2 contexts from it.
In fact, SDL2 does this for you, you simply have to as for an OPENGL window wnd it will be given to you at no cost! :)
No problem at all. But GLES is more compatible than OpenGL, and would allow the game to run without X, directly on KMSDRM without an X server running (that's how I play all my games on the Pi).
So if you can use GLES instead of old-style OpenGL (desktop only...) it would be better.
And let SDL2 do the scaling, please. Software scaling is SLOW in things like the Pi.

@mdodis
Copy link
Owner

mdodis commented Jun 14, 2020

That's amazing! I'll give it a try on the next session then! Thank you for the advice!
Okay so with a quick glance at GLES, I see that they have 2D texture arrays (which is what I use now for tilemaps) in version 3. So maybe it won't be too bad!

@vanfanel
Copy link
Author

vanfanel commented Jun 14, 2020

@mdodis This is the fn that lets you create a window in SDL2:

https://wiki.libsdl.org/SDL_CreateWindow

Just pass the SDL_WINDOW_OPENGL flag, and presto!

You can also set the context version (GLES; OpenGL version, etc..)

This will init a GLES2 context:


SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
    SDL_GL_SetSwapInterval(0);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);

@mdodis
Copy link
Owner

mdodis commented Jun 14, 2020

Okay, a8a3c15 seems to be working ok, in terms of GLES stuff. I'll test out the KMSDRM backend to see if everything's alright tomorrow and then I'll upload the new build.

Thank you so much for the help!

@vanfanel
Copy link
Author

@mdodis You seem to be using GLES3 there. Can you please use GLES2? That would allow Raspberry Pi 1-2-3 compatibility.

@vanfanel
Copy link
Author

vanfanel commented Jun 15, 2020

@mdodis Also remember that in order to test the KMSDRM backend, you have to build your own SDL2 passing --enable-video-kmsdrm to the configure script.

You can do so in the latest SDL2 version from mercurial, which you can download like this:

hg clone http://hg.libsdl.org/SDL

@mdodis
Copy link
Owner

mdodis commented Jun 15, 2020

@vanfanel Alright, I've tested it on the one machine I have and it seems to be working, (I also needed to build SDL with libudev). Audio should be working as well, though that's not a main priority.

Regarding the use of GLES3, that's going to take a bit more time because version 2 doesn't have the extension I use for tilemaps.

@mcpalmer1980
Copy link

I loved Solomon's Key on the NES and it inspired some of the mechanics in my pygame-based game Flyboy.

Did you ever get the game running on gles and without requiring x-lib? I would like to add it to the portmaster project for the Anbernic rg351 retro handheld. The firmware I run on it lacks x-windows but well supports sld2.

@mdodis
Copy link
Owner

mdodis commented Oct 24, 2021

I'm not 100% sure that it will work, but the latest version here does include an sdl_solomons_key executable that should support the KMS-DRM backend. I don't have anything to test it on right now but can you try running it with "-fullscreen"? It should work if your device supports GLES 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants