Full support for dynamic reinitialization of video, with menu support.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1502 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -22,9 +22,9 @@
|
|||||||
#include "bbox.h"
|
#include "bbox.h"
|
||||||
#include "2xscalers.h"
|
#include "2xscalers.h"
|
||||||
|
|
||||||
static SDL_Surface *format_conv_surf;
|
static SDL_Surface *format_conv_surf = NULL;
|
||||||
static SDL_Surface *scaled_display;
|
static SDL_Surface *scaled_display = NULL;
|
||||||
static SDL_Surface *scaled_transition;
|
static SDL_Surface *scaled_transition = NULL;
|
||||||
|
|
||||||
static int ScreenFilterMode;
|
static int ScreenFilterMode;
|
||||||
static GLuint DisplayTexture;
|
static GLuint DisplayTexture;
|
||||||
@@ -59,23 +59,11 @@ Create_Screen (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
TFB_GL_ConfigureVideo (int driver, int flags, int width, int height, int bpp)
|
||||||
{
|
{
|
||||||
char VideoName[256];
|
|
||||||
int i, videomode_flags, texture_width, texture_height;
|
int i, videomode_flags, texture_width, texture_height;
|
||||||
|
|
||||||
GraphicsDriver = driver;
|
GraphicsDriver = driver;
|
||||||
ScreenColorDepth = bpp;
|
ScreenColorDepth = bpp;
|
||||||
|
|
||||||
fprintf (stderr, "Initializing SDL with OpenGL support.\n");
|
|
||||||
|
|
||||||
SDL_VideoDriverName (VideoName, sizeof (VideoName));
|
|
||||||
fprintf (stderr, "SDL driver used: %s\n", VideoName);
|
|
||||||
fprintf (stderr, "SDL initialized.\n");
|
|
||||||
fprintf (stderr, "Initializing Screen.\n");
|
|
||||||
|
|
||||||
ScreenWidth = 320;
|
|
||||||
ScreenHeight = 240;
|
|
||||||
ScreenWidthActual = width;
|
ScreenWidthActual = width;
|
||||||
ScreenHeightActual = height;
|
ScreenHeightActual = height;
|
||||||
|
|
||||||
@@ -133,26 +121,15 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
|||||||
glGetString (GL_RENDERER), glGetString (GL_VERSION));
|
glGetString (GL_RENDERER), glGetString (GL_VERSION));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < TFB_GFX_NUMSCREENS; i++)
|
|
||||||
{
|
|
||||||
SDL_Screens[i] = Create_Screen ();
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_Screen = SDL_Screens[0];
|
|
||||||
TransitionScreen = SDL_Screens[2];
|
|
||||||
|
|
||||||
format_conv_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, 32,
|
|
||||||
R_MASK, G_MASK, B_MASK, A_MASK);
|
|
||||||
if (format_conv_surf == NULL)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Couldn't create format_conv_surf: %s\n", SDL_GetError());
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPT ||
|
if (GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPT ||
|
||||||
GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPTADV ||
|
GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPTADV ||
|
||||||
GfxFlags & TFB_GFXFLAGS_SCALE_TRISCAN)
|
GfxFlags & TFB_GFXFLAGS_SCALE_TRISCAN)
|
||||||
{
|
{
|
||||||
|
if (scaled_display)
|
||||||
|
{
|
||||||
|
SDL_FreeSurface (scaled_display);
|
||||||
|
scaled_display = NULL;
|
||||||
|
}
|
||||||
scaled_display = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth * 2,
|
scaled_display = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth * 2,
|
||||||
ScreenHeight * 2, 32, R_MASK, G_MASK, B_MASK, 0x00000000);
|
ScreenHeight * 2, 32, R_MASK, G_MASK, B_MASK, 0x00000000);
|
||||||
if (scaled_display == NULL)
|
if (scaled_display == NULL)
|
||||||
@@ -160,6 +137,11 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
|||||||
fprintf (stderr, "Couldn't create scaled_display: %s\n", SDL_GetError());
|
fprintf (stderr, "Couldn't create scaled_display: %s\n", SDL_GetError());
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
if (scaled_transition)
|
||||||
|
{
|
||||||
|
SDL_FreeSurface (scaled_transition);
|
||||||
|
scaled_transition = NULL;
|
||||||
|
}
|
||||||
scaled_transition = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth * 2,
|
scaled_transition = SDL_CreateRGBSurface(SDL_SWSURFACE, ScreenWidth * 2,
|
||||||
ScreenHeight * 2, 32, R_MASK, G_MASK, B_MASK, 0x00000000);
|
ScreenHeight * 2, 32, R_MASK, G_MASK, B_MASK, 0x00000000);
|
||||||
if (scaled_transition == NULL)
|
if (scaled_transition == NULL)
|
||||||
@@ -177,8 +159,18 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
|||||||
texture_height = 256;
|
texture_height = 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pre-compute the RGB->YUV transformations
|
if (format_conv_surf)
|
||||||
Scale_PrepYUV();
|
{
|
||||||
|
SDL_FreeSurface (format_conv_surf);
|
||||||
|
format_conv_surf = NULL;
|
||||||
|
}
|
||||||
|
format_conv_surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, 32,
|
||||||
|
R_MASK, G_MASK, B_MASK, A_MASK);
|
||||||
|
if (format_conv_surf == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "Couldn't create format_conv_surf: %s\n", SDL_GetError());
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
if (GfxFlags & TFB_GFXFLAGS_SCALE_BILINEAR ||
|
if (GfxFlags & TFB_GFXFLAGS_SCALE_BILINEAR ||
|
||||||
GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPT ||
|
GfxFlags & TFB_GFXFLAGS_SCALE_BIADAPT ||
|
||||||
@@ -193,6 +185,15 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
|||||||
else
|
else
|
||||||
scanlines = FALSE;
|
scanlines = FALSE;
|
||||||
|
|
||||||
|
/* TODO: This leaks */
|
||||||
|
for (i = 0; i < TFB_GFX_NUMSCREENS; i++)
|
||||||
|
{
|
||||||
|
SDL_Screens[i] = Create_Screen ();
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Screen = SDL_Screens[0];
|
||||||
|
TransitionScreen = SDL_Screens[2];
|
||||||
|
|
||||||
glViewport (0, 0, ScreenWidthActual, ScreenHeightActual);
|
glViewport (0, 0, ScreenWidthActual, ScreenHeightActual);
|
||||||
glClearColor (0,0,0,0);
|
glClearColor (0,0,0,0);
|
||||||
glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
||||||
@@ -218,6 +219,29 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
||||||
|
{
|
||||||
|
char VideoName[256];
|
||||||
|
|
||||||
|
fprintf (stderr, "Initializing SDL with OpenGL support.\n");
|
||||||
|
|
||||||
|
SDL_VideoDriverName (VideoName, sizeof (VideoName));
|
||||||
|
fprintf (stderr, "SDL driver used: %s\n", VideoName);
|
||||||
|
fprintf (stderr, "SDL initialized.\n");
|
||||||
|
fprintf (stderr, "Initializing Screen.\n");
|
||||||
|
|
||||||
|
ScreenWidth = 320;
|
||||||
|
ScreenHeight = 240;
|
||||||
|
|
||||||
|
TFB_GL_ConfigureVideo (driver, flags, width, height, bpp);
|
||||||
|
|
||||||
|
// pre-compute the RGB->YUV transformations
|
||||||
|
Scale_PrepYUV();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void TFB_GL_UploadTransitionScreen (void)
|
void TFB_GL_UploadTransitionScreen (void)
|
||||||
{
|
{
|
||||||
upload_transitiontexture = TRUE;
|
upload_transitiontexture = TRUE;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "libs/graphics/sdl/sdl_common.h"
|
#include "libs/graphics/sdl/sdl_common.h"
|
||||||
|
|
||||||
int TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp);
|
int TFB_GL_InitGraphics (int driver, int flags, int width, int height, int bpp);
|
||||||
|
int TFB_GL_ConfigureVideo (int driver, int flags, int width, int height, int bpp);
|
||||||
void TFB_GL_UploadTransitionScreen (void);
|
void TFB_GL_UploadTransitionScreen (void);
|
||||||
void TFB_GL_SwapBuffers (int force_full_redraw);
|
void TFB_GL_SwapBuffers (int force_full_redraw);
|
||||||
SDL_Surface* TFB_GL_DisplayFormatAlpha (SDL_Surface *surface);
|
SDL_Surface* TFB_GL_DisplayFormatAlpha (SDL_Surface *surface);
|
||||||
|
|||||||
@@ -21,9 +21,9 @@
|
|||||||
#include "bbox.h"
|
#include "bbox.h"
|
||||||
#include "2xscalers.h"
|
#include "2xscalers.h"
|
||||||
|
|
||||||
static SDL_Surface *fade_black;
|
static SDL_Surface *fade_black = NULL;
|
||||||
static SDL_Surface *fade_white;
|
static SDL_Surface *fade_white = NULL;
|
||||||
static SDL_Surface *fade_temp;
|
static SDL_Surface *fade_temp = NULL;
|
||||||
|
|
||||||
static SDL_Surface *
|
static SDL_Surface *
|
||||||
Create_Screen (SDL_Surface *template)
|
Create_Screen (SDL_Surface *template)
|
||||||
@@ -37,32 +37,14 @@ Create_Screen (SDL_Surface *template)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height, int bpp)
|
||||||
{
|
{
|
||||||
char VideoName[256];
|
int i, videomode_flags;
|
||||||
int videomode_flags;
|
|
||||||
SDL_Surface *test_extra;
|
SDL_Surface *test_extra;
|
||||||
int i;
|
|
||||||
|
|
||||||
GraphicsDriver = driver;
|
GraphicsDriver = driver;
|
||||||
ScreenColorDepth = bpp;
|
ScreenColorDepth = bpp;
|
||||||
|
|
||||||
fprintf (stderr, "Initializing Pure-SDL graphics.\n");
|
|
||||||
|
|
||||||
SDL_VideoDriverName (VideoName, sizeof (VideoName));
|
|
||||||
fprintf (stderr, "SDL driver used: %s\n", VideoName);
|
|
||||||
// Set the environment variable SDL_VIDEODRIVER to override
|
|
||||||
// For Linux: x11 (default), dga, fbcon, directfb, svgalib,
|
|
||||||
// ggi, aalib
|
|
||||||
// For Windows: directx (default), windib
|
|
||||||
|
|
||||||
fprintf (stderr, "SDL initialized.\n");
|
|
||||||
|
|
||||||
fprintf (stderr, "Initializing Screen.\n");
|
|
||||||
|
|
||||||
ScreenWidth = 320;
|
|
||||||
ScreenHeight = 240;
|
|
||||||
|
|
||||||
// must use SDL_SWSURFACE, HWSURFACE doesn't work properly with fades/scaling
|
// must use SDL_SWSURFACE, HWSURFACE doesn't work properly with fades/scaling
|
||||||
if (width == 320 && height == 240)
|
if (width == 320 && height == 240)
|
||||||
{
|
{
|
||||||
@@ -118,10 +100,25 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
|||||||
SDL_Screen = SDL_Screens[0];
|
SDL_Screen = SDL_Screens[0];
|
||||||
TransitionScreen = SDL_Screens[2];
|
TransitionScreen = SDL_Screens[2];
|
||||||
|
|
||||||
|
if (fade_white)
|
||||||
|
{
|
||||||
|
SDL_FreeSurface (fade_white);
|
||||||
|
fade_white = NULL;
|
||||||
|
}
|
||||||
fade_white = Create_Screen(test_extra);
|
fade_white = Create_Screen(test_extra);
|
||||||
SDL_FillRect (fade_white, NULL, SDL_MapRGB (fade_white->format, 255, 255, 255));
|
SDL_FillRect (fade_white, NULL, SDL_MapRGB (fade_white->format, 255, 255, 255));
|
||||||
|
if (fade_black)
|
||||||
|
{
|
||||||
|
SDL_FreeSurface (fade_black);
|
||||||
|
fade_black = NULL;
|
||||||
|
}
|
||||||
fade_black = Create_Screen(test_extra);
|
fade_black = Create_Screen(test_extra);
|
||||||
SDL_FillRect (fade_black, NULL, SDL_MapRGB (fade_black->format, 0, 0, 0));
|
SDL_FillRect (fade_black, NULL, SDL_MapRGB (fade_black->format, 0, 0, 0));
|
||||||
|
if (fade_temp)
|
||||||
|
{
|
||||||
|
SDL_FreeSurface (fade_temp);
|
||||||
|
fade_temp = NULL;
|
||||||
|
}
|
||||||
fade_temp = Create_Screen(test_extra);
|
fade_temp = Create_Screen(test_extra);
|
||||||
|
|
||||||
SDL_FreeSurface (test_extra);
|
SDL_FreeSurface (test_extra);
|
||||||
@@ -133,6 +130,32 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
||||||
|
{
|
||||||
|
char VideoName[256];
|
||||||
|
|
||||||
|
fprintf (stderr, "Initializing Pure-SDL graphics.\n");
|
||||||
|
|
||||||
|
SDL_VideoDriverName (VideoName, sizeof (VideoName));
|
||||||
|
fprintf (stderr, "SDL driver used: %s\n", VideoName);
|
||||||
|
// Set the environment variable SDL_VIDEODRIVER to override
|
||||||
|
// For Linux: x11 (default), dga, fbcon, directfb, svgalib,
|
||||||
|
// ggi, aalib
|
||||||
|
// For Windows: directx (default), windib
|
||||||
|
|
||||||
|
fprintf (stderr, "SDL initialized.\n");
|
||||||
|
|
||||||
|
fprintf (stderr, "Initializing Screen.\n");
|
||||||
|
|
||||||
|
ScreenWidth = 320;
|
||||||
|
ScreenHeight = 240;
|
||||||
|
|
||||||
|
TFB_Pure_ConfigureVideo (driver, flags, width, height, bpp);
|
||||||
|
|
||||||
// pre-compute the RGB->YUV transformations
|
// pre-compute the RGB->YUV transformations
|
||||||
Scale_PrepYUV();
|
Scale_PrepYUV();
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "libs/graphics/sdl/sdl_common.h"
|
#include "libs/graphics/sdl/sdl_common.h"
|
||||||
|
|
||||||
int TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp);
|
int TFB_Pure_InitGraphics (int driver, int flags, int width, int height, int bpp);
|
||||||
|
int TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height, int bpp);
|
||||||
void TFB_Pure_SwapBuffers (int force_full_redraw);
|
void TFB_Pure_SwapBuffers (int force_full_redraw);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -73,6 +73,42 @@ TFB_PreInit (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
TFB_ReInitGraphics (int driver, int flags, int width, int height, int bpp)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
char caption[200];
|
||||||
|
|
||||||
|
GfxFlags = flags;
|
||||||
|
|
||||||
|
if (driver == TFB_GFXDRIVER_SDL_OPENGL)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_OPENGL
|
||||||
|
result = TFB_GL_ConfigureVideo (driver, flags, width, height, bpp);
|
||||||
|
#else
|
||||||
|
driver = TFB_GFXDRIVER_SDL_PURE;
|
||||||
|
fprintf (stderr, "OpenGL support not compiled in, so using pure "
|
||||||
|
"sdl driver\n");
|
||||||
|
result = TFB_Pure_ConfigureVideo (driver, flags, width, height, bpp);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = TFB_Pure_ConfigureVideo (driver, flags, width, height, bpp);
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf (caption, "The Ur-Quan Masters v%d.%d%s",
|
||||||
|
UQM_MAJOR_VERSION, UQM_MINOR_VERSION, UQM_EXTRA_VERSION);
|
||||||
|
SDL_WM_SetCaption (caption, NULL);
|
||||||
|
|
||||||
|
if (flags & TFB_GFXFLAGS_FULLSCREEN)
|
||||||
|
SDL_ShowCursor (SDL_DISABLE);
|
||||||
|
else
|
||||||
|
SDL_ShowCursor (SDL_ENABLE);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
TFB_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
TFB_InitGraphics (int driver, int flags, int width, int height, int bpp)
|
||||||
{
|
{
|
||||||
@@ -696,9 +732,9 @@ TFB_FlushGraphics () // Only call from main thread!!
|
|||||||
ClearSemaphore (DC.data.sendsignal.sem);
|
ClearSemaphore (DC.data.sendsignal.sem);
|
||||||
break;
|
break;
|
||||||
case TFB_DRAWCOMMANDTYPE_REINITVIDEO:
|
case TFB_DRAWCOMMANDTYPE_REINITVIDEO:
|
||||||
fprintf (stderr, "TODO: REINITVIDEO command sent. Not yet implemented. Pester McMartin.\n");
|
TFB_ReInitGraphics (DC.data.reinitvideo.driver, DC.data.reinitvideo.flags,
|
||||||
fprintf (stderr, " Request: %dx%d %dbpp %s Flags: %08x\n", DC.data.reinitvideo.width, DC.data.reinitvideo.height, DC.data.reinitvideo.bpp, DC.data.reinitvideo.driver ? "Pure-SDL" : "OpenGL", DC.data.reinitvideo.flags);
|
DC.data.reinitvideo.width, DC.data.reinitvideo.height,
|
||||||
|
DC.data.reinitvideo.bpp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -706,7 +706,9 @@ SetGlobalOptions (GLOBALOPTS *opts)
|
|||||||
(NewDriver != GraphicsDriver) ||
|
(NewDriver != GraphicsDriver) ||
|
||||||
(NewGfxFlags != GfxFlags))
|
(NewGfxFlags != GfxFlags))
|
||||||
{
|
{
|
||||||
|
FlushGraphics ();
|
||||||
TFB_DrawScreen_ReinitVideo (NewDriver, NewGfxFlags, NewWidth, NewHeight, NewDepth);
|
TFB_DrawScreen_ReinitVideo (NewDriver, NewGfxFlags, NewWidth, NewHeight, NewDepth);
|
||||||
|
FlushGraphics ();
|
||||||
}
|
}
|
||||||
optSubtitles = (opts->subtitles == OPTVAL_ENABLED) ? TRUE : FALSE;
|
optSubtitles = (opts->subtitles == OPTVAL_ENABLED) ? TRUE : FALSE;
|
||||||
// optWhichMusic = (opts->music == OPTVAL_3DO) ? OPT_3DO : OPT_PC;
|
// optWhichMusic = (opts->music == OPTVAL_3DO) ? OPT_3DO : OPT_PC;
|
||||||
@@ -714,4 +716,5 @@ SetGlobalOptions (GLOBALOPTS *opts)
|
|||||||
optWhichFonts = (opts->text == OPTVAL_3DO) ? OPT_3DO : OPT_PC;
|
optWhichFonts = (opts->text == OPTVAL_3DO) ? OPT_3DO : OPT_PC;
|
||||||
optWhichCoarseScan = (opts->cscan == OPTVAL_3DO) ? OPT_3DO : OPT_PC;
|
optWhichCoarseScan = (opts->cscan == OPTVAL_3DO) ? OPT_3DO : OPT_PC;
|
||||||
optSmoothScroll = (opts->scroll == OPTVAL_3DO) ? OPT_3DO : OPT_PC;
|
optSmoothScroll = (opts->scroll == OPTVAL_3DO) ? OPT_3DO : OPT_PC;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user