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

testoverlay.c doesn't work #193

Closed
icculus opened this issue Aug 26, 2022 · 3 comments
Closed

testoverlay.c doesn't work #193

icculus opened this issue Aug 26, 2022 · 3 comments
Assignees
Milestone

Comments

@icculus
Copy link
Collaborator

icculus commented Aug 26, 2022

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
Copy link
Collaborator Author

icculus commented Aug 26, 2022

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

if(!scale)
{
rect.w=overlay->w;
rect.h=overlay->h;
for(i=0; i<h-rect.h && i<w-rect.w; i++)
{
rect.x=i;
rect.y=i;
SDL_DisplayYUVOverlay(overlay,&rect);
}
}
else
{
rect.w=overlay->w/2;
rect.h=overlay->h/2;
rect.x=(w-rect.w)/2;
rect.y=(h-rect.h)/2;
disp=rect.y-1;
for(i=0; i<disp; i++)
{
rect.w+=2;
rect.h+=2;
rect.x--;
rect.y--;
SDL_DisplayYUVOverlay(overlay,&rect);
}

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
Copy link
Collaborator Author

icculus commented Aug 26, 2022

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
Copy link
Collaborator Author

icculus commented Aug 26, 2022

Okay, found a reasonable workaround.

@icculus icculus self-assigned this Aug 26, 2022
@icculus icculus added this to the 1.2.54 milestone Aug 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant