Consolidate duplicate screen init functions
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3770 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -69,30 +69,6 @@ static TFB_GRAPHICS_BACKEND opengl_unscaled_backend = {
|
|||||||
TFB_GL_ColorLayer };
|
TFB_GL_ColorLayer };
|
||||||
|
|
||||||
|
|
||||||
static SDL_Surface *
|
|
||||||
Create_Screen (SDL_Surface *templat, int w, int h)
|
|
||||||
{
|
|
||||||
SDL_Surface *newsurf = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h,
|
|
||||||
templat->format->BitsPerPixel,
|
|
||||||
templat->format->Rmask, templat->format->Gmask,
|
|
||||||
templat->format->Bmask, 0);
|
|
||||||
if (newsurf == 0) {
|
|
||||||
log_add (log_Error, "Couldn't create screen buffers: %s",
|
|
||||||
SDL_GetError());
|
|
||||||
}
|
|
||||||
return newsurf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ReInit_Screen (SDL_Surface **screen, SDL_Surface *templat, int w, int h)
|
|
||||||
{
|
|
||||||
if (*screen)
|
|
||||||
SDL_FreeSurface (*screen);
|
|
||||||
*screen = Create_Screen (templat, w, h);
|
|
||||||
|
|
||||||
return *screen == 0 ? -1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
AttemptColorDepth (int flags, int width, int height, int bpp)
|
AttemptColorDepth (int flags, int width, int height, int bpp)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,30 +47,6 @@ static TFB_GRAPHICS_BACKEND pure_unscaled_backend = {
|
|||||||
TFB_Pure_ScreenLayer,
|
TFB_Pure_ScreenLayer,
|
||||||
TFB_Pure_ColorLayer };
|
TFB_Pure_ColorLayer };
|
||||||
|
|
||||||
static SDL_Surface *
|
|
||||||
Create_Screen (SDL_Surface *templat, int w, int h)
|
|
||||||
{
|
|
||||||
SDL_Surface *newsurf = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h,
|
|
||||||
templat->format->BitsPerPixel,
|
|
||||||
templat->format->Rmask, templat->format->Gmask,
|
|
||||||
templat->format->Bmask, 0);
|
|
||||||
if (newsurf == 0) {
|
|
||||||
log_add (log_Error, "Couldn't create screen buffers: %s",
|
|
||||||
SDL_GetError());
|
|
||||||
}
|
|
||||||
return newsurf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ReInit_Screen (SDL_Surface **screen, SDL_Surface *templat, int w, int h)
|
|
||||||
{
|
|
||||||
if (*screen)
|
|
||||||
SDL_FreeSurface (*screen);
|
|
||||||
*screen = Create_Screen (templat, w, h);
|
|
||||||
|
|
||||||
return *screen == 0 ? -1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We cannot rely on SDL_DisplayFormatAlpha() anymore. It can return
|
// We cannot rely on SDL_DisplayFormatAlpha() anymore. It can return
|
||||||
// formats that we do not expect (SDL v1.2.14 on Mac OSX). Mac likes
|
// formats that we do not expect (SDL v1.2.14 on Mac OSX). Mac likes
|
||||||
// ARGB surfaces, but SDL_DisplayFormatAlpha thinks that only RGBA are fast.
|
// ARGB surfaces, but SDL_DisplayFormatAlpha thinks that only RGBA are fast.
|
||||||
|
|||||||
@@ -352,3 +352,27 @@ TFB_SetGamma (float gamma)
|
|||||||
{
|
{
|
||||||
return (SDL_SetGamma (gamma, gamma, gamma) == 0);
|
return (SDL_SetGamma (gamma, gamma, gamma) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_Surface *
|
||||||
|
Create_Screen (SDL_Surface *templat, int w, int h)
|
||||||
|
{
|
||||||
|
SDL_Surface *newsurf = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h,
|
||||||
|
templat->format->BitsPerPixel,
|
||||||
|
templat->format->Rmask, templat->format->Gmask,
|
||||||
|
templat->format->Bmask, 0);
|
||||||
|
if (newsurf == 0) {
|
||||||
|
log_add (log_Error, "Couldn't create screen buffers: %s",
|
||||||
|
SDL_GetError());
|
||||||
|
}
|
||||||
|
return newsurf;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ReInit_Screen (SDL_Surface **screen, SDL_Surface *templat, int w, int h)
|
||||||
|
{
|
||||||
|
if (*screen)
|
||||||
|
SDL_FreeSurface (*screen);
|
||||||
|
*screen = Create_Screen (templat, w, h);
|
||||||
|
|
||||||
|
return *screen == 0 ? -1 : 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -48,4 +48,7 @@ extern SDL_Surface *format_conv_surf;
|
|||||||
|
|
||||||
SDL_Surface* TFB_DisplayFormatAlpha (SDL_Surface *surface);
|
SDL_Surface* TFB_DisplayFormatAlpha (SDL_Surface *surface);
|
||||||
|
|
||||||
|
SDL_Surface* Create_Screen (SDL_Surface *templat, int w, int h);
|
||||||
|
int ReInit_Screen (SDL_Surface **screen, SDL_Surface *templat, int w, int h);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user