Skip to content

Commit a464827

Browse files
run-time detection of render driver
1 parent b76b29b commit a464827

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

rott/modexlib.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ void SetShowCursor(int show)
9494
SDL_GetRelativeMouseState(NULL, NULL);
9595
}
9696

97+
static int (*StretchFunc)(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) = SDL_BlitScaled;
98+
static inline int SDL_SoftStretchWrapper(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect)
99+
{
100+
return SDL_SoftStretch(src, srcrect, dst, dstrect);
101+
}
102+
97103
void GraphicsMode ( void )
98104
{
99105
uint32_t flags = SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI;
@@ -140,6 +146,18 @@ void GraphicsMode ( void )
140146
iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT);
141147

142148
SetShowCursor(!sdl_fullscreen);
149+
150+
const char *driver = SDL_GetCurrentVideoDriver();
151+
#ifndef _WIN32
152+
if (driver && strcmp(driver, "x11") == 0)
153+
{
154+
StretchFunc = SDL_SoftStretchWrapper;
155+
}
156+
else
157+
#endif
158+
{
159+
StretchFunc = SDL_BlitScaled;
160+
}
143161
}
144162

145163
void ToggleFullScreen (void)
@@ -421,7 +439,7 @@ static void StretchMemPicture ()
421439
dest.y = 0;
422440
dest.w = iGLOBAL_SCREENWIDTH;
423441
dest.h = iGLOBAL_SCREENHEIGHT;
424-
SDL_SoftStretch(unstretch_sdl_surface, &src, sdl_surface, &dest);
442+
StretchFunc(unstretch_sdl_surface, &src, sdl_surface, &dest);
425443
}
426444

427445
// bna function added start

0 commit comments

Comments
 (0)