#GLFW with KMS/DRM support.

69 messages · Page 1 of 1 (latest)

silver orbit
#

Right now, a game that build with GLFW is not supported. Because GLFW require window manager (X11, Wayland, etc.). Most handheld only support KMS/DRM (with OpenGL ES).
There are 2 solutions:

  1. If the game is open source and use GLFW then replace GLFW with SDL.
  2. Overhaul GLFW library so that can support KMS DRM.

Each solution has plus and minus.

Solution No 1:

  • It's theoretically doable.
  • If the game is updated then the port may need to be updated too.

Solution No 2:

  • (until now) the GLFW developer is not interested in this option and none haven't done yet.
  • The port will be easier to keep up with the source of the game development. Just recompile / rebuild it.

So here is the good news...
I've learned about KMS/DRM how it works.
I've learned about the structure of GLFW library.
And here is the result:

a GLFW library with KMS/DRM support

The library is based in GLFW version 3.5.
The library i made is far from perfect. But it can do basic support for handheld (include gamepad support)

Build it in Linux aarch64.
How to build GLFW that support KMS/DRM:

git clone https://github.com/leonkasovan/glfw-plus.git
cmake -B build -D GLFW_BUILD_X11=0 -D GLFW_BUILD_WAYLAND=0 -D GLFW_BUILD_KMSDRM=1 .
make -j8 -C build

it will generate static and dynamic library.
It also build examples that use GLFW.

To test it, run this example in handheld:
./build/examples/triangle-opengles

silver orbit
#

A game (Famicom Fighter using Ikemen Go engine) that build with GLFW.

silver orbit
#

Basic usage of GLFW

int main(void) {
    if (!glfwInit())
        exit(EXIT_FAILURE);

    glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
    glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
    GLFWwindow* window = glfwCreateWindow(0, 0, "OpenGL ES 2.0 Triangle (EGL)", NULL, NULL);
    if (!window) {
        return GLFW_FALSE;
    }
    glfwSetKeyCallback(window, key_callback);
    glfwMakeContextCurrent(window);
    int version = gladLoadGLES2(glfwGetProcAddress);
    glfwSwapInterval(1);

    GLuint vertex_buffer;
    glGenBuffers(1, &vertex_buffer);
    glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

    const GLuint vertex_shader = compileShader(GL_VERTEX_SHADER, vertex_shader_text);
    const GLuint fragment_shader = compileShader(GL_FRAGMENT_SHADER, fragment_shader_text);
    const GLuint program = glCreateProgram();
    glAttachShader(program, vertex_shader);
    glAttachShader(program, fragment_shader);
    glLinkProgram(program);

    // do GL init
    glfwGetFramebufferSize(window, &width, &height);
    const float ratio = width / (float) height;
    glViewport(0, 0, width, height);
    while (!glfwWindowShouldClose(window)) {
        glClear(GL_COLOR_BUFFER_BIT);
        // do GL render
        glfwSwapBuffers(window);
        glfwPollEvents();
    }

    glfwDestroyWindow(window);
    glfwTerminate();
}
astral ridge
#

<@&1127639327049011350> <@&1123158742175846432> <@&1204708329226768394>

west nova
#

Wow Ikemen is working! Is it possible to play Hyper DBZ?

mild sandal
#

Y'all need anything in particular from me and my RGB30 and/or RGB10 MAX 3, both running Rocknix?

silver orbit
silver orbit
#

How many FPS it get?

mild sandal
#

So, I build the library ON each device first?

#

If so, how?

silver orbit
silver orbit
mild sandal
silver orbit
mild sandal
#

I've tried to build it and this happend:

-sh: git: command not found -sh: cmake: command not found make: Entering directory '/storage' make: *** build: No such file or directory. Stop. make: Leaving directory '/storage'

I assume that logging into root with Putty and pasting the above jazz that's supposed to build "GLFW that supports KMS/DRM" is me doing something wrong.

#

Should I be using the terminal in WinSCP?

astral ridge
#

You build that stuff in a aarch64 environment

mild sandal
astral ridge
#

You can't build on your device unless you have arkos

#

That's normal compiling we do for anything not Gmloader 😛

mild sandal
astral ridge
#

And I did not know that you don't know that it's not possible

#

Because of your role lol

#

But now you know 🙂

mild sandal
#

All this should have been mentioned in the original post for those of us who didn't know that only ArkOS users are needed.

astral ridge
#

Fyi like that this is possible to implement in code now

mild sandal
#

So, I'm not supposed to be a Port Cadet?

astral ridge
#

Hence the name Cadet and if one contributes more eventually he can become a port engineer

astral ridge
mild sandal
#

So, I just copy it onto my device and run it?

astral ridge
#

via ssh yes

#

ssh in

#

cd into the folder you copied it into

#

and do

#

./triangle-opengles

mild sandal
#

Where exactly do I copy it to?

astral ridge
mild sandal
#

I tried copying it to the roms folder via WinSCP and tried running it in the terminal and nothing happened.

astral ridge
#

you have to navigate to that folder via ssh anyway

#

it should show a triangle on screen

mild sandal
#

I can't. I tried it via the terminal but it can't find anything.

#

I even tried dir and it says ``-sh: line 20: dir: command not found`.

astral ridge
#

linxu is ls

#

for list directory

#

dir works too if its installed

#

but rocknix for example only has minimal packaged installed

#

so ls -l for example to list directory

mild sandal
#

Aside from ./triangle-opengles, what else do I have to type in?

astral ridge
#

that's it

#

thats how you run a binary in linux

mild sandal
astral ridge
mild sandal
#

RGB10 Max 3 running Rocknix.

astral ridge
#

i see

#

rocknix probably doesn't need it

#

they already have a display server

#

so glfww works anyway

mild sandal
#

So, I don't need to do anything on my end?