You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
880 B
38 lines
880 B
#include "miniwin/ddraw.h" |
|
|
|
namespace dvl { |
|
|
|
extern SDL_Surface *renderer_texture_surface; // defined in dx.cpp |
|
|
|
SDL_Surface *GetOutputSurface() |
|
{ |
|
#ifdef USE_SDL1 |
|
return SDL_GetVideoSurface(); |
|
#else |
|
if (renderer) |
|
return renderer_texture_surface; |
|
return SDL_GetWindowSurface(window); |
|
#endif |
|
} |
|
|
|
bool OutputRequiresScaling() |
|
{ |
|
#ifdef USE_SDL1 |
|
return SCREEN_WIDTH != GetOutputSurface()->w || SCREEN_HEIGHT != GetOutputSurface()->h; |
|
#else // SDL2, scaling handled by renderer. |
|
return false; |
|
#endif |
|
} |
|
|
|
void ScaleOutputRect(SDL_Rect *rect) |
|
{ |
|
if (!OutputRequiresScaling()) |
|
return; |
|
const auto *surface = GetOutputSurface(); |
|
rect->x = rect->x * surface->w / SCREEN_WIDTH; |
|
rect->y = rect->y * surface->h / SCREEN_HEIGHT; |
|
rect->w = rect->w * surface->w / SCREEN_WIDTH; |
|
rect->h = rect->h * surface->h / SCREEN_HEIGHT; |
|
} |
|
|
|
} // namespace dvl
|
|
|