return surface;
}
+Bitmap *SDLGetBitmapFromSurface(SDL_Surface *surface)
+{
+ int width = surface->w;
+ int height = surface->h;
+ int depth = video.default_depth;
+ Bitmap *bitmap = CreateBitmap(width, height, depth);
+
+ // free default surface (not needed anymore)
+ SDL_FreeSurface(bitmap->surface);
+
+ // get native, non-transparent surface from original surface
+ bitmap->surface = SDLGetOpaqueSurface(surface);
+
+ // get native, potentially transparent surface from original surface
+ bitmap->surface_masked = SDLGetNativeSurface(surface);
+
+ // set black pixel to transparent if no alpha channel / transparent color
+ if (!SDLHasAlpha(bitmap->surface_masked) &&
+ !SDLHasColorKey(bitmap->surface_masked))
+ SDL_SetColorKey(bitmap->surface_masked, SET_TRANSPARENT_PIXEL,
+ SDL_MapRGB(bitmap->surface_masked->format, 0x00, 0x00, 0x00));
+
+ return bitmap;
+}
+
static SDL_Texture *SDLCreateTextureFromSurface(SDL_Surface *surface)
{
if (program.headless)
return;
}
- if (Mix_OpenAudio(DEFAULT_AUDIO_SAMPLE_RATE, MIX_DEFAULT_FORMAT,
- AUDIO_NUM_CHANNELS_STEREO,
+ // set audio sample rate for mixer
+ audio.sample_rate = (setup.audio_sample_rate_44100 ? 44100 : 22050);
+
+ if (Mix_OpenAudio(audio.sample_rate, MIX_DEFAULT_FORMAT, AUDIO_NUM_CHANNELS_STEREO,
setup.system.audio_fragment_size) < 0)
{
Warn("Mix_OpenAudio() failed: %s", SDL_GetError());
SDL_QuitSubSystem(SDL_INIT_AUDIO);
}
+void SDLReopenAudio(void)
+{
+ SDLCloseAudio();
+ SDLOpenAudio();
+}
+
// ============================================================================
// event functions