mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-03 08:28:29 +00:00
Added support for SDL_RENDERER_PRESENTVSYNC to the software renderer
This fixes https://github.com/libsdl-org/SDL/issues/4612
This commit is contained in:
@@ -833,7 +833,8 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (SDL_GetHint(SDL_HINT_RENDER_VSYNC)) {
|
||||
hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
|
||||
if (hint && *hint) {
|
||||
if (SDL_GetHintBoolean(SDL_HINT_RENDER_VSYNC, SDL_TRUE)) {
|
||||
flags |= SDL_RENDERER_PRESENTVSYNC;
|
||||
} else {
|
||||
|
@@ -859,9 +859,22 @@ SW_CreateRendererForSurface(SDL_Surface * surface)
|
||||
static SDL_Renderer *
|
||||
SW_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
{
|
||||
const char *hint;
|
||||
SDL_Surface *surface;
|
||||
|
||||
/* Set the vsync hint based on our flags, if it's not already set */
|
||||
hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
|
||||
if (!hint || !*hint) {
|
||||
SDL_SetHint(SDL_HINT_RENDER_VSYNC, (flags & SDL_RENDERER_PRESENTVSYNC) ? "1" : "0");
|
||||
}
|
||||
|
||||
surface = SDL_GetWindowSurface(window);
|
||||
|
||||
/* Reset the vsync hint if we set it above */
|
||||
if (!hint || !*hint) {
|
||||
SDL_SetHint(SDL_HINT_RENDER_VSYNC, "");
|
||||
}
|
||||
|
||||
if (!surface) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -872,7 +885,7 @@ SDL_RenderDriver SW_RenderDriver = {
|
||||
SW_CreateRenderer,
|
||||
{
|
||||
"software",
|
||||
SDL_RENDERER_SOFTWARE | SDL_RENDERER_TARGETTEXTURE,
|
||||
SDL_RENDERER_SOFTWARE | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE,
|
||||
8,
|
||||
{
|
||||
SDL_PIXELFORMAT_ARGB8888,
|
||||
|
Reference in New Issue
Block a user