go-sdl2 icon indicating copy to clipboard operation
go-sdl2 copied to clipboard

Window Doesn't Show

Open clseibold opened this issue 10 months ago • 10 comments

Go version: 1.22 Go-SDL2 version: v0.5.0-alpha.5 SDL2 version: 2.28.5 OS: Linux Fedora 39 (Kernel 6.8.4) w/ Wayland Architecture: x86_64

After updating to the lastest alpha, the window doesn't show, but I can tell that the main loop is still running because it prints stuff in the terminal.

clseibold avatar Apr 23 '24 22:04 clseibold

Hi @clseibold, I was able to reproduce it on my Fedora machine. It seems like drawing on the window would make it show up. Could you try that to see if that works for you?

For example, adding the following after the CreateWindow function:

surface, _ := window.GetSurface()
surface.FillRect(nil, 0)
window.UpdateSurface()

veeableful avatar Apr 24 '24 08:04 veeableful

Sorry for the late response.

That code doesn't work for me. The window is still hidden.

clseibold avatar Apr 30 '24 10:04 clseibold

I moved some stuff around and got the window to show for a split second, but SDL forbids you from getting a Window surface when you plan to create and use a Renderer.

There seems to be some change that happened between 0.4.38 and 0.5.0-alpha.5 that broke things, because 0.4.38 works perfectly fine.

clseibold avatar Apr 30 '24 11:04 clseibold

Hi @clseibold, would you be able to provide the complete but minimal source code that produces the issue? I will try on my Fedora 40 laptop.

veeableful avatar May 02 '24 09:05 veeableful

I'm using v0.4.38 Fedora 34 (I know it's old) kernel 5.17.12-100.fc34.x86_64 on X.org GPU Nvidia RTX 2060 Mobile go version go1.22.1 linux/amd64

Using the nouveau.fc34 driver the code works, but when updated just the video driver to nvidia 560.28.03 then window is created, but nothing is drawed inside (it drags the background). This is the effect when I move a little bit the window cyclock

I can upload the program, (I can get a reduced version of the code, if you prefer) cyclock_v2.tar.gz

It connects to the SDL events, just the drawing is stopped. By pressing the NumEnter (KP_ENTER) key, half-hour is added to the clock and time is shown on title bar.

With nouveau driver, same pc, same kernel, same X.org, same go compiler, it works. Rebooting for using the nvidia driver (tried also before recompiling the program), it stops working.

I tried also to delete the go.sum file and to recreate it in order to update all the dependencies.

Tell me if there is some more debugging informations (or how to put it as verbose).

The Fillrect + UpdateSurface was and is already made every frame I draw.

pasckosky avatar Jul 30 '24 15:07 pasckosky

Hi @pasckosky, could you try putting drawing calls in the main thread? At the very least, putting window.UpdateSurface() in the main loop seems to have fixed it for me.

veeableful avatar Aug 03 '24 05:08 veeableful

Hi @pasckosky, could you try putting drawing calls in the main thread? At the very least, putting window.UpdateSurface() in the main loop seems to have fixed it for me.

It worked. Many thanks

pasckosky avatar Aug 03 '24 09:08 pasckosky

UpdateSurface doesn't work when you are using the Renderer. You cannot use a Window Surface and the Renderer at the same time. SDL forbids this. It will panic your program. So this solution of using UpdateSurface is not a solution for everyone, and is completely unrelated to this issue.

clseibold avatar Aug 03 '24 13:08 clseibold

Hi @clseibold, since you are here I wonder if you have had time to provide the minimal example that reproduces the issue?

Hi @clseibold, would you be able to provide the complete but minimal source code that produces the issue? I will try on my Fedora 40 laptop.

veeableful avatar Aug 03 '24 14:08 veeableful

@veeableful I will write up a minimum example. It will use a Renderer because many programs require Hardware Rendering, not Software Rendering. I will upload it as soon as I can.

Btw, you were able to reproduce the bug according to what you said in your first comment. The workaround you provided for it relies on software rendered programs. It does not work for those that need to use hardware rendering with a Renderer.

clseibold avatar Sep 29 '24 03:09 clseibold