You are not logged in.

#1 2022-09-27 21:37:36

SalmonSeasoning
Member
Registered: 2020-03-30
Posts: 11

SDL buggy on Wayland?

Hello all,

My OpenGL set up with SDL on Gnome+Wayland environment is super laggy with the window moving.

It's not a complex set up at all, essentially just:

while (should_run)
    {
        while (SDL_PollEvent(&window.getWindowData()->event))
            if (window.getWindowData()->event.type == SDL_QUIT)
                should_run = false;

        // ensure that SDL2 updated the keyboard state
        SDL_PumpEvents();

        // // automatically update window size
        // UpdateWindowSize(&window);

        // SDL2 should automatically clear this memory after each loop
        keys = SDL_GetKeyboardState(0);

        // black background color
        glClearColor(0.00f, 0.00f, 0.00f, 1.00f);

        // red background color if pressing W
        if(keys[SDL_SCANCODE_W])
            glClearColor(1.00f, 0.00f, 0.00f, 1.00f);
        
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        SDL_GL_SwapWindow(window.getWindowData()->window);
    }

There's nothing inherently slow with this code, it's pretty standard. Not seeing any performance loss when window is stagnant, only when moving.

Just asking because I didn't experience this issue on Mint, and I'm just curious if it's because SDL2 works better on Xorg or is it Gnome to blame?

Offline

#2 2022-09-27 21:39:20

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: SDL buggy on Wayland?

There is an issue with window resizes not properly registering in SDL under wayland, though that doesn't sound like what you're describing (it doesn't affect window movement).  If you provide complete code I'd be happy to test whether I could replicate your issue.

Last edited by Trilby (2022-09-27 21:40:04)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2022-10-02 19:29:22

SalmonSeasoning
Member
Registered: 2020-03-30
Posts: 11

Re: SDL buggy on Wayland?

Sorry for the late reply, I kinda forgot I posted this. Anyway, yeah, so I went through my entire project here https://youtu.be/XCMcJ27nUpA and my recording crashed near the end it was lagging so bad while moving.

Essentially my project has a C implementation and a C++ wrapper connected together for ease of use. I have tried both, but only showed the C++ wrapped version in the video. There is no window resizing, but clearly showing a lot of lag (I mean, it crashed my recording lol) when moving the window. Stagnant, it's fine.

Offline

#4 2022-10-10 05:10:06

SalmonSeasoning
Member
Registered: 2020-03-30
Posts: 11

Re: SDL buggy on Wayland?

Update: I've given up on OpenGL because of its vagueness, I find it rather tough to learn even if it is all around simpler.

However, with relevance to this thread, I've tried Vulkan. Haven't gone into rendering much yet, however I am not having the same issues with the window lagging.

Possibly has to do with SDL_GLContext?

I don't know. Guess I'll update if I give up on Vulkan too lol.

Offline

#5 2022-10-10 13:32:40

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: SDL buggy on Wayland?

As you're trying out different toolkits, are you looking for something specifically cross platform and / or display-server agnostic?  As a shameless plug, I've made a wayland client library that will handle the heavy lifting for creating an egl context and allows the user to just do the gl drawing.  However, it is just for linux / wayland.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2022-10-10 23:33:17

SalmonSeasoning
Member
Registered: 2020-03-30
Posts: 11

Re: SDL buggy on Wayland?

Trilby wrote:

As you're trying out different toolkits, are you looking for something specifically cross platform and / or display-server agnostic?

No, quite frankly, SDL does everything I need it to, and in a way I am very much happy with. Needs cross-platform compatibility, sound, input, window management, and support for OpenGL or Vulkan. I'm slowly but surely building an ecosystem for me to start my game development journey. Right now, I'm working on the build manager (CarePackage) and game engine (not available). I'm still in the process of learning 3D graphics. Wish I had more time and will to dedicate to it.

Offline

Board footer

Powered by FluxBB