inline void SDLInitVideoDisplay(void)
{
+ putenv("SDL_VIDEO_CENTERED=1");
+
/* initialize SDL video */
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
Error(ERR_EXIT, "SDL_InitSubSystem() failed: %s", SDL_GetError());
/* http://www.ferzkopp.net/Software/SDL_gfx-2.0/index.html */
/* ========================================================================= */
-typedef struct
-{
- Uint8 r;
- Uint8 g;
- Uint8 b;
- Uint8 a;
-} tColorRGBA;
-
/*
-----------------------------------------------------------------------------
32 bit zoomer
-----------------------------------------------------------------------------
*/
+typedef struct
+{
+ Uint8 r;
+ Uint8 g;
+ Uint8 b;
+ Uint8 a;
+} tColorRGBA;
+
int zoomSurfaceRGBA(SDL_Surface *src, SDL_Surface *dst)
{
int x, y, sx, sy, *sax, *say, *csax, *csay, csx, csy;
-----------------------------------------------------------------------------
*/
-void zoomSurfaceSize(int width, int height, float zoom_x, float zoom_y,
- int *dst_width, int *dst_height)
-{
- const float value_limit = 0.001;
-
- /* sanity check zoom factors */
- if (zoom_x < value_limit)
- zoom_x = value_limit;
- if (zoom_y < value_limit)
- zoom_y = value_limit;
-
- /* calculate target size */
- *dst_width = (int) ((float) width * zoom_x);
- *dst_height = (int) ((float) height * zoom_y);
-
- if (*dst_width < 1)
- *dst_width = 1;
- if (*dst_height < 1)
- *dst_height = 1;
-}
-
-SDL_Surface *zoomSurface(SDL_Surface *src, float zoom_x, float zoom_y)
+SDL_Surface *zoomSurface(SDL_Surface *src, int dst_width, int dst_height)
{
SDL_Surface *zoom_src = NULL;
SDL_Surface *zoom_dst = NULL;
- int dst_width, dst_height;
boolean is_converted = FALSE;
boolean is_32bit;
int i;
is_converted = TRUE;
}
- /* get size of destination surface */
- zoomSurfaceSize(zoom_src->w, zoom_src->h, zoom_x, zoom_y,
- &dst_width, &dst_height);
-
/* allocate surface to completely contain the zoomed surface */
if (is_32bit)
{
return zoom_dst;
}
-SDL_Surface *SDLZoomSurface(SDL_Surface *src, float zoom_x, float zoom_y)
+void SDLZoomBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap)
{
- return zoomSurface(src, zoom_x, zoom_y);
+ SDL_Surface *sdl_surface_tmp;
+ int dst_width = dst_bitmap->width;
+ int dst_height = dst_bitmap->height;
+
+ /* throw away old destination surface */
+ SDL_FreeSurface(dst_bitmap->surface);
+
+ /* create zoomed temporary surface from source surface */
+ sdl_surface_tmp = zoomSurface(src_bitmap->surface, dst_width, dst_height);
+
+ /* create native format destination surface from zoomed temporary surface */
+ dst_bitmap->surface = SDL_DisplayFormat(sdl_surface_tmp);
+
+ /* free temporary surface */
+ SDL_FreeSurface(sdl_surface_tmp);
}
inline void SDLOpenAudio(void)
{
+ if (strcmp(setup.system.sdl_audiodriver, ARG_DEFAULT) != 0)
+ putenv(getStringCat2("SDL_AUDIODRIVER=", setup.system.sdl_audiodriver));
+
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
{
Error(ERR_WARN, "SDL_InitSubSystem() failed: %s", SDL_GetError());
if (Mix_OpenAudio(DEFAULT_AUDIO_SAMPLE_RATE, MIX_DEFAULT_FORMAT,
AUDIO_NUM_CHANNELS_STEREO,
- DEFAULT_AUDIO_FRAGMENT_SIZE) < 0)
+ setup.system.audio_fragment_size) < 0)
{
Error(ERR_WARN, "Mix_OpenAudio() failed: %s", SDL_GetError());
return;