Generalize more common elements of graphics backends, isolate backend-specific parts
This commit is contained in:
@@ -52,6 +52,7 @@ static BOOLEAN first_init = TRUE;
|
|||||||
|
|
||||||
static void TFB_GL_Preprocess (int force_full_redraw, int transition_amount, int fade_amount);
|
static void TFB_GL_Preprocess (int force_full_redraw, int transition_amount, int fade_amount);
|
||||||
static void TFB_GL_Postprocess (void);
|
static void TFB_GL_Postprocess (void);
|
||||||
|
static void TFB_GL_UploadTransitionScreen (void);
|
||||||
static void TFB_GL_Scaled_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect);
|
static void TFB_GL_Scaled_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect);
|
||||||
static void TFB_GL_Unscaled_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect);
|
static void TFB_GL_Unscaled_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect);
|
||||||
static void TFB_GL_ColorLayer (Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_Rect *rect);
|
static void TFB_GL_ColorLayer (Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_Rect *rect);
|
||||||
@@ -59,12 +60,14 @@ static void TFB_GL_ColorLayer (Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_Rect *rec
|
|||||||
static TFB_GRAPHICS_BACKEND opengl_scaled_backend = {
|
static TFB_GRAPHICS_BACKEND opengl_scaled_backend = {
|
||||||
TFB_GL_Preprocess,
|
TFB_GL_Preprocess,
|
||||||
TFB_GL_Postprocess,
|
TFB_GL_Postprocess,
|
||||||
|
TFB_GL_UploadTransitionScreen,
|
||||||
TFB_GL_Scaled_ScreenLayer,
|
TFB_GL_Scaled_ScreenLayer,
|
||||||
TFB_GL_ColorLayer };
|
TFB_GL_ColorLayer };
|
||||||
|
|
||||||
static TFB_GRAPHICS_BACKEND opengl_unscaled_backend = {
|
static TFB_GRAPHICS_BACKEND opengl_unscaled_backend = {
|
||||||
TFB_GL_Preprocess,
|
TFB_GL_Preprocess,
|
||||||
TFB_GL_Postprocess,
|
TFB_GL_Postprocess,
|
||||||
|
TFB_GL_UploadTransitionScreen,
|
||||||
TFB_GL_Unscaled_ScreenLayer,
|
TFB_GL_Unscaled_ScreenLayer,
|
||||||
TFB_GL_ColorLayer };
|
TFB_GL_ColorLayer };
|
||||||
|
|
||||||
@@ -96,6 +99,7 @@ ReInit_Screen (SDL_Surface **screen, SDL_Surface *template, int w, int h)
|
|||||||
static int
|
static int
|
||||||
AttemptColorDepth (int flags, int width, int height, int bpp)
|
AttemptColorDepth (int flags, int width, int height, int bpp)
|
||||||
{
|
{
|
||||||
|
SDL_Surface *SDL_Video;
|
||||||
int videomode_flags;
|
int videomode_flags;
|
||||||
ScreenColorDepth = bpp;
|
ScreenColorDepth = bpp;
|
||||||
ScreenWidthActual = width;
|
ScreenWidthActual = width;
|
||||||
@@ -298,7 +302,8 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TFB_GL_UploadTransitionScreen (void)
|
static void
|
||||||
|
TFB_GL_UploadTransitionScreen (void)
|
||||||
{
|
{
|
||||||
GL_Screens[TFB_SCREEN_TRANSITION].updated.x = 0;
|
GL_Screens[TFB_SCREEN_TRANSITION].updated.x = 0;
|
||||||
GL_Screens[TFB_SCREEN_TRANSITION].updated.y = 0;
|
GL_Screens[TFB_SCREEN_TRANSITION].updated.y = 0;
|
||||||
@@ -307,7 +312,7 @@ void TFB_GL_UploadTransitionScreen (void)
|
|||||||
GL_Screens[TFB_SCREEN_TRANSITION].dirty = TRUE;
|
GL_Screens[TFB_SCREEN_TRANSITION].dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
TFB_GL_ScanLines (void)
|
TFB_GL_ScanLines (void)
|
||||||
{
|
{
|
||||||
int y;
|
int y;
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
int TFB_GL_InitGraphics (int driver, int flags, int width, int height);
|
int TFB_GL_InitGraphics (int driver, int flags, int width, int height);
|
||||||
int TFB_GL_ConfigureVideo (int driver, int flags, int width, int height, int togglefullscreen);
|
int TFB_GL_ConfigureVideo (int driver, int flags, int width, int height, int togglefullscreen);
|
||||||
void TFB_GL_UploadTransitionScreen (void);
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENGL
|
#ifdef HAVE_OPENGL
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "scalers.h"
|
#include "scalers.h"
|
||||||
#include "libs/log.h"
|
#include "libs/log.h"
|
||||||
|
|
||||||
|
static SDL_Surface *SDL_Video = NULL;
|
||||||
static SDL_Surface *fade_color_surface = NULL;
|
static SDL_Surface *fade_color_surface = NULL;
|
||||||
static SDL_Surface *fade_temp = NULL;
|
static SDL_Surface *fade_temp = NULL;
|
||||||
static SDL_Surface *scaled_display = NULL;
|
static SDL_Surface *scaled_display = NULL;
|
||||||
@@ -32,18 +33,21 @@ static void TFB_Pure_Scaled_Preprocess (int force_full_redraw, int transition_am
|
|||||||
static void TFB_Pure_Scaled_Postprocess (void);
|
static void TFB_Pure_Scaled_Postprocess (void);
|
||||||
static void TFB_Pure_Unscaled_Preprocess (int force_full_redraw, int transition_amount, int fade_amount);
|
static void TFB_Pure_Unscaled_Preprocess (int force_full_redraw, int transition_amount, int fade_amount);
|
||||||
static void TFB_Pure_Unscaled_Postprocess (void);
|
static void TFB_Pure_Unscaled_Postprocess (void);
|
||||||
|
static void TFB_Pure_UploadTransitionScreen (void);
|
||||||
static void TFB_Pure_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect);
|
static void TFB_Pure_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect);
|
||||||
static void TFB_Pure_ColorLayer (Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_Rect *rect);
|
static void TFB_Pure_ColorLayer (Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_Rect *rect);
|
||||||
|
|
||||||
static TFB_GRAPHICS_BACKEND pure_scaled_backend = {
|
static TFB_GRAPHICS_BACKEND pure_scaled_backend = {
|
||||||
TFB_Pure_Scaled_Preprocess,
|
TFB_Pure_Scaled_Preprocess,
|
||||||
TFB_Pure_Scaled_Postprocess,
|
TFB_Pure_Scaled_Postprocess,
|
||||||
|
TFB_Pure_UploadTransitionScreen,
|
||||||
TFB_Pure_ScreenLayer,
|
TFB_Pure_ScreenLayer,
|
||||||
TFB_Pure_ColorLayer };
|
TFB_Pure_ColorLayer };
|
||||||
|
|
||||||
static TFB_GRAPHICS_BACKEND pure_unscaled_backend = {
|
static TFB_GRAPHICS_BACKEND pure_unscaled_backend = {
|
||||||
TFB_Pure_Unscaled_Preprocess,
|
TFB_Pure_Unscaled_Preprocess,
|
||||||
TFB_Pure_Unscaled_Postprocess,
|
TFB_Pure_Unscaled_Postprocess,
|
||||||
|
TFB_Pure_UploadTransitionScreen,
|
||||||
TFB_Pure_ScreenLayer,
|
TFB_Pure_ScreenLayer,
|
||||||
TFB_Pure_ColorLayer };
|
TFB_Pure_ColorLayer };
|
||||||
|
|
||||||
@@ -402,6 +406,12 @@ TFB_Pure_Unscaled_Postprocess (void)
|
|||||||
updated.w, updated.h);
|
updated.w, updated.h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
TFB_Pure_UploadTransitionScreen (void)
|
||||||
|
{
|
||||||
|
/* This is a no-op in SDL1 Pure mode */
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
TFB_Pure_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect)
|
TFB_Pure_ScreenLayer (SCREEN screen, Uint8 a, SDL_Rect *rect)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,7 +35,6 @@
|
|||||||
#include "libs/vidlib.h"
|
#include "libs/vidlib.h"
|
||||||
#include SDL_INCLUDE(SDL_thread.h)
|
#include SDL_INCLUDE(SDL_thread.h)
|
||||||
|
|
||||||
SDL_Surface *SDL_Video;
|
|
||||||
SDL_Surface *SDL_Screen;
|
SDL_Surface *SDL_Screen;
|
||||||
SDL_Surface *TransitionScreen;
|
SDL_Surface *TransitionScreen;
|
||||||
|
|
||||||
@@ -584,12 +583,7 @@ TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst,
|
|||||||
void
|
void
|
||||||
TFB_UploadTransitionScreen (void)
|
TFB_UploadTransitionScreen (void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_OPENGL
|
graphics_backend->uploadTransitionScreen ();
|
||||||
if (GraphicsDriver == TFB_GFXDRIVER_SDL_OPENGL)
|
|
||||||
{
|
|
||||||
TFB_GL_UploadTransitionScreen ();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -30,13 +30,13 @@
|
|||||||
typedef struct _tfb_graphics_backend {
|
typedef struct _tfb_graphics_backend {
|
||||||
void (*preprocess) (int force_redraw, int transition_amount, int fade_amount);
|
void (*preprocess) (int force_redraw, int transition_amount, int fade_amount);
|
||||||
void (*postprocess) (void);
|
void (*postprocess) (void);
|
||||||
|
void (*uploadTransitionScreen) (void);
|
||||||
void (*screen) (SCREEN screen, Uint8 alpha, SDL_Rect *rect);
|
void (*screen) (SCREEN screen, Uint8 alpha, SDL_Rect *rect);
|
||||||
void (*color) (Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_Rect *rect);
|
void (*color) (Uint8 r, Uint8 g, Uint8 b, Uint8 a, SDL_Rect *rect);
|
||||||
} TFB_GRAPHICS_BACKEND;
|
} TFB_GRAPHICS_BACKEND;
|
||||||
|
|
||||||
extern TFB_GRAPHICS_BACKEND *graphics_backend;
|
extern TFB_GRAPHICS_BACKEND *graphics_backend;
|
||||||
|
|
||||||
extern SDL_Surface *SDL_Video;
|
|
||||||
extern SDL_Surface *SDL_Screen;
|
extern SDL_Surface *SDL_Screen;
|
||||||
extern SDL_Surface *TransitionScreen;
|
extern SDL_Surface *TransitionScreen;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user