libsdl-org / sdl12-compat

An SDL-1.2 compatibility layer that uses SDL 2.0 behind the scenes.
Other
194 stars 40 forks source link

testoverlay.c doesn't work #193

Closed icculus closed 2 years ago

icculus commented 2 years ago

It just makes a black window, and then quits:

image

Does this in classic SDL 1.2, on x11:

image

Might just fail to present in the short time frame, or need a pumpevents, I don't know yet.

icculus commented 2 years ago

Yeah, it calls SDL_DisplayYUVOverlay() in a tight loop.

https://github.com/libsdl-org/sdl12-compat/blob/7df03158d31945d1491d4db51b85dd85f019c3e9/test/testoverlay.c#L272-L297

Sticking an SDL_PumpEvents() in the loop gets a single frame to draw but the image doesn't animate a slide across the window. Needs more research.

icculus commented 2 years ago

Sticking an SDL_PumpEvents() in the loop gets a single frame to draw but the image doesn't animate a slide across the window. Needs more research.

This is because sdl12-compat only draws the overlay at the display's refresh rate, and its version of SDL_DisplayYUVOverlay basically just queues up a draw and returns immediately, so the loop runs through super-fast and never gets a chance to do a second present. Adding an SDL_Delay and an SDL_PumpEvents fixes it.

testoverlay is sort of a pathological case, since nothing would ever really do this in real life (draw overlays as fast as possible without any event loop or animation timing), so we're probably okay to not fix this...but I'm going to try something real fast before I close this.

icculus commented 2 years ago

Okay, found a reasonable workaround.