added fullscreen/windowed toggle key F11
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2821 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
Changes towards version 0.7:
|
Changes towards version 0.7:
|
||||||
|
- Added fullscreen/windowed toggle key F11 - Mika
|
||||||
- Allow building without ogg vorbis support (bug #852) - SvdB
|
- Allow building without ogg vorbis support (bug #852) - SvdB
|
||||||
- Reworked SuperMelee fleet loading (fixes bug #823) - SvdB
|
- Reworked SuperMelee fleet loading (fixes bug #823) - SvdB
|
||||||
- Fixed enemy ships getting recrewed between ecnounters in HyperSpace
|
- Fixed enemy ships getting recrewed between ecnounters in HyperSpace
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ menu.next.1 = key Tab
|
|||||||
menu.pause.1 = key Pause
|
menu.pause.1 = key Pause
|
||||||
menu.pause.2 = key F1
|
menu.pause.2 = key F1
|
||||||
menu.exit.1 = key F10
|
menu.exit.1 = key F10
|
||||||
|
menu.fullscreen.1 = key F11
|
||||||
menu.special.1 = key LeftAlt
|
menu.special.1 = key LeftAlt
|
||||||
menu.special.2 = key RightAlt
|
menu.special.2 = key RightAlt
|
||||||
|
|
||||||
|
|||||||
@@ -656,6 +656,7 @@ the QUIT button in the lower right.
|
|||||||
|
|
||||||
F1 or PAUSE Pause game
|
F1 or PAUSE Pause game
|
||||||
F10 Exit game
|
F10 Exit game
|
||||||
|
F11 Toggle between fullscreen and windowed mode
|
||||||
|
|
||||||
FULL GAME CONTROLS SUMMARY
|
FULL GAME CONTROLS SUMMARY
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ enum {
|
|||||||
KEY_EXIT,
|
KEY_EXIT,
|
||||||
KEY_ABORT,
|
KEY_ABORT,
|
||||||
KEY_DEBUG,
|
KEY_DEBUG,
|
||||||
|
KEY_FULLSCREEN,
|
||||||
KEY_MENU_UP,
|
KEY_MENU_UP,
|
||||||
KEY_MENU_DOWN,
|
KEY_MENU_DOWN,
|
||||||
KEY_MENU_LEFT,
|
KEY_MENU_LEFT,
|
||||||
|
|||||||
@@ -32,6 +32,15 @@ enum
|
|||||||
TFB_GFXDRIVER_SDL_PURE,
|
TFB_GFXDRIVER_SDL_PURE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// forced redraw
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
TFB_REDRAW_NO = 0,
|
||||||
|
TFB_REDRAW_FADING,
|
||||||
|
TFB_REDRAW_EXPOSE,
|
||||||
|
TFB_REDRAW_YES
|
||||||
|
};
|
||||||
|
|
||||||
// flags for TFB_InitGraphics
|
// flags for TFB_InitGraphics
|
||||||
#define TFB_GFXFLAGS_FULLSCREEN (1<<0)
|
#define TFB_GFXFLAGS_FULLSCREEN (1<<0)
|
||||||
#define TFB_GFXFLAGS_SHOWFPS (1<<1)
|
#define TFB_GFXFLAGS_SHOWFPS (1<<1)
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ AttemptColorDepth (int flags, int width, int height, int bpp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
TFB_GL_ConfigureVideo (int driver, int flags, int width, int height)
|
TFB_GL_ConfigureVideo (int driver, int flags, int width, int height, int togglefullscreen)
|
||||||
{
|
{
|
||||||
int i, texture_width, texture_height;
|
int i, texture_width, texture_height;
|
||||||
GraphicsDriver = driver;
|
GraphicsDriver = driver;
|
||||||
@@ -174,54 +174,60 @@ TFB_GL_ConfigureVideo (int driver, int flags, int width, int height)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_conv_surf)
|
if (!togglefullscreen)
|
||||||
SDL_FreeSurface (format_conv_surf);
|
|
||||||
format_conv_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, 0, 0, 32,
|
|
||||||
R_MASK, G_MASK, B_MASK, A_MASK);
|
|
||||||
if (format_conv_surf == NULL)
|
|
||||||
{
|
{
|
||||||
log_add (log_Error, "Couldn't create format_conv_surf: %s",
|
if (format_conv_surf)
|
||||||
SDL_GetError());
|
SDL_FreeSurface (format_conv_surf);
|
||||||
return -1;
|
format_conv_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, 0, 0, 32,
|
||||||
}
|
R_MASK, G_MASK, B_MASK, A_MASK);
|
||||||
|
if (format_conv_surf == NULL)
|
||||||
for (i = 0; i < TFB_GFX_NUMSCREENS; i++)
|
{
|
||||||
{
|
log_add (log_Error, "Couldn't create format_conv_surf: %s",
|
||||||
if (0 != ReInit_Screen (&SDL_Screens[i], format_conv_surf,
|
SDL_GetError());
|
||||||
ScreenWidth, ScreenHeight))
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Screen = SDL_Screens[0];
|
|
||||||
TransitionScreen = SDL_Screens[2];
|
|
||||||
|
|
||||||
if (first_init)
|
|
||||||
{
|
|
||||||
for (i = 0; i < TFB_GFX_NUMSCREENS; i++)
|
for (i = 0; i < TFB_GFX_NUMSCREENS; i++)
|
||||||
{
|
{
|
||||||
GL_Screens[i].scaled = NULL;
|
if (0 != ReInit_Screen (&SDL_Screens[i], format_conv_surf,
|
||||||
GL_Screens[i].dirty = TRUE;
|
ScreenWidth, ScreenHeight))
|
||||||
GL_Screens[i].active = TRUE;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Screen = SDL_Screens[0];
|
||||||
|
TransitionScreen = SDL_Screens[2];
|
||||||
|
|
||||||
|
if (first_init)
|
||||||
|
{
|
||||||
|
for (i = 0; i < TFB_GFX_NUMSCREENS; i++)
|
||||||
|
{
|
||||||
|
GL_Screens[i].scaled = NULL;
|
||||||
|
GL_Screens[i].dirty = TRUE;
|
||||||
|
GL_Screens[i].active = TRUE;
|
||||||
|
}
|
||||||
|
GL_Screens[1].active = FALSE;
|
||||||
|
first_init = FALSE;
|
||||||
}
|
}
|
||||||
GL_Screens[1].active = FALSE;
|
|
||||||
first_init = FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GfxFlags & TFB_GFXFLAGS_SCALE_SOFT_ONLY)
|
if (GfxFlags & TFB_GFXFLAGS_SCALE_SOFT_ONLY)
|
||||||
{
|
{
|
||||||
for (i = 0; i < TFB_GFX_NUMSCREENS; i++)
|
if (!togglefullscreen)
|
||||||
{
|
{
|
||||||
if (!GL_Screens[i].active)
|
for (i = 0; i < TFB_GFX_NUMSCREENS; i++)
|
||||||
continue;
|
{
|
||||||
if (0 != ReInit_Screen (&GL_Screens[i].scaled, format_conv_surf,
|
if (!GL_Screens[i].active)
|
||||||
ScreenWidth * 2, ScreenHeight * 2))
|
continue;
|
||||||
return -1;
|
if (0 != ReInit_Screen (&GL_Screens[i].scaled, format_conv_surf,
|
||||||
|
ScreenWidth * 2, ScreenHeight * 2))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
scaler = Scale_PrepPlatform (flags, SDL_Screen->format);
|
||||||
}
|
}
|
||||||
|
|
||||||
texture_width = 1024;
|
texture_width = 1024;
|
||||||
texture_height = 512;
|
texture_height = 512;
|
||||||
|
|
||||||
scaler = Scale_PrepPlatform (flags, SDL_Screen->format);
|
|
||||||
graphics_backend = &opengl_scaled_backend;
|
graphics_backend = &opengl_scaled_backend;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -233,6 +239,7 @@ TFB_GL_ConfigureVideo (int driver, int flags, int width, int height)
|
|||||||
graphics_backend = &opengl_unscaled_backend;
|
graphics_backend = &opengl_unscaled_backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (GfxFlags & TFB_GFXFLAGS_SCALE_ANY)
|
if (GfxFlags & TFB_GFXFLAGS_SCALE_ANY)
|
||||||
ScreenFilterMode = GL_LINEAR;
|
ScreenFilterMode = GL_LINEAR;
|
||||||
else
|
else
|
||||||
@@ -277,7 +284,7 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height)
|
|||||||
ScreenWidth = 320;
|
ScreenWidth = 320;
|
||||||
ScreenHeight = 240;
|
ScreenHeight = 240;
|
||||||
|
|
||||||
if (TFB_GL_ConfigureVideo (driver, flags, width, height))
|
if (TFB_GL_ConfigureVideo (driver, flags, width, height, 0))
|
||||||
{
|
{
|
||||||
log_add (log_Fatal, "Could not initialize video: "
|
log_add (log_Fatal, "Could not initialize video: "
|
||||||
"no fallback at start of program!");
|
"no fallback at start of program!");
|
||||||
@@ -367,10 +374,18 @@ TFB_GL_Preprocess (int force_full_redraw, int transition_amount, int fade_amount
|
|||||||
glOrtho (0,ScreenWidthActual,ScreenHeightActual, 0, -1, 1);
|
glOrtho (0,ScreenWidthActual,ScreenHeightActual, 0, -1, 1);
|
||||||
glMatrixMode (GL_MODELVIEW);
|
glMatrixMode (GL_MODELVIEW);
|
||||||
glLoadIdentity ();
|
glLoadIdentity ();
|
||||||
(void) force_full_redraw;
|
|
||||||
(void) transition_amount;
|
(void) transition_amount;
|
||||||
(void) fade_amount;
|
(void) fade_amount;
|
||||||
if (TFB_BBox.valid)
|
|
||||||
|
if (force_full_redraw == TFB_REDRAW_YES)
|
||||||
|
{
|
||||||
|
GL_Screens[TFB_SCREEN_MAIN].updated.x = 0;
|
||||||
|
GL_Screens[TFB_SCREEN_MAIN].updated.y = 0;
|
||||||
|
GL_Screens[TFB_SCREEN_MAIN].updated.w = ScreenWidth;
|
||||||
|
GL_Screens[TFB_SCREEN_MAIN].updated.h = ScreenHeight;
|
||||||
|
GL_Screens[TFB_SCREEN_MAIN].dirty = TRUE;
|
||||||
|
}
|
||||||
|
else if (TFB_BBox.valid)
|
||||||
{
|
{
|
||||||
GL_Screens[TFB_SCREEN_MAIN].updated.x = TFB_BBox.region.corner.x;
|
GL_Screens[TFB_SCREEN_MAIN].updated.x = TFB_BBox.region.corner.x;
|
||||||
GL_Screens[TFB_SCREEN_MAIN].updated.y = TFB_BBox.region.corner.y;
|
GL_Screens[TFB_SCREEN_MAIN].updated.y = TFB_BBox.region.corner.y;
|
||||||
|
|||||||
@@ -22,7 +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 TFB_GL_InitGraphics (int driver, int flags, int width, int height);
|
||||||
int TFB_GL_ConfigureVideo (int driver, int flags, int width, int height);
|
int TFB_GL_ConfigureVideo (int driver, int flags, int width, int height, int togglefullscreen);
|
||||||
void TFB_GL_UploadTransitionScreen (void);
|
void TFB_GL_UploadTransitionScreen (void);
|
||||||
|
|
||||||
#ifdef HAVE_OPENGL
|
#ifdef HAVE_OPENGL
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ ReInit_Screen (SDL_Surface **screen, SDL_Surface *template, int w, int h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height)
|
TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height, int togglefullscreen)
|
||||||
{
|
{
|
||||||
int i, videomode_flags;
|
int i, videomode_flags;
|
||||||
SDL_Surface *temp_surf;
|
SDL_Surface *temp_surf;
|
||||||
@@ -124,6 +124,9 @@ TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height)
|
|||||||
SDL_GetVideoSurface()->w, SDL_GetVideoSurface()->h,
|
SDL_GetVideoSurface()->w, SDL_GetVideoSurface()->h,
|
||||||
SDL_GetVideoSurface()->format->BitsPerPixel);
|
SDL_GetVideoSurface()->format->BitsPerPixel);
|
||||||
ScreenColorDepth = SDL_GetVideoSurface()->format->BitsPerPixel;
|
ScreenColorDepth = SDL_GetVideoSurface()->format->BitsPerPixel;
|
||||||
|
|
||||||
|
if (togglefullscreen)
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a 32bpp surface in a compatible format which will supply
|
// Create a 32bpp surface in a compatible format which will supply
|
||||||
@@ -210,7 +213,7 @@ TFB_Pure_InitGraphics (int driver, int flags, int width, int height)
|
|||||||
ScreenWidth = 320;
|
ScreenWidth = 320;
|
||||||
ScreenHeight = 240;
|
ScreenHeight = 240;
|
||||||
|
|
||||||
if (TFB_Pure_ConfigureVideo (driver, flags, width, height))
|
if (TFB_Pure_ConfigureVideo (driver, flags, width, height, 0))
|
||||||
{
|
{
|
||||||
log_add (log_Fatal, "Could not initialize video: "
|
log_add (log_Fatal, "Could not initialize video: "
|
||||||
"no fallback at start of program!");
|
"no fallback at start of program!");
|
||||||
@@ -286,7 +289,7 @@ TFB_Pure_Scaled_Preprocess (int force_full_redraw, int transition_amount, int fa
|
|||||||
static void
|
static void
|
||||||
TFB_Pure_Unscaled_Preprocess (int force_full_redraw, int transition_amount, int fade_amount)
|
TFB_Pure_Unscaled_Preprocess (int force_full_redraw, int transition_amount, int fade_amount)
|
||||||
{
|
{
|
||||||
if (force_full_redraw)
|
if (force_full_redraw != TFB_REDRAW_NO)
|
||||||
{
|
{
|
||||||
updated.x = updated.y = 0;
|
updated.x = updated.y = 0;
|
||||||
updated.w = ScreenWidth;
|
updated.w = ScreenWidth;
|
||||||
|
|||||||
@@ -22,6 +22,6 @@
|
|||||||
#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 TFB_Pure_InitGraphics (int driver, int flags, int width, int height);
|
||||||
int TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height);
|
int TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height, int togglefullscreen);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "libs/uio.h"
|
#include "libs/uio.h"
|
||||||
#include "libs/log.h"
|
#include "libs/log.h"
|
||||||
#include "controls.h"
|
#include "controls.h"
|
||||||
|
#include "vidlib.h"
|
||||||
// XXX: Should not be included from here.
|
// XXX: Should not be included from here.
|
||||||
#include "uqmdebug.h"
|
#include "uqmdebug.h"
|
||||||
#include SDL_INCLUDE(SDL_thread.h)
|
#include SDL_INCLUDE(SDL_thread.h)
|
||||||
@@ -82,14 +83,21 @@ int
|
|||||||
TFB_ReInitGraphics (int driver, int flags, int width, int height)
|
TFB_ReInitGraphics (int driver, int flags, int width, int height)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
int togglefullscreen = 0;
|
||||||
char caption[200];
|
char caption[200];
|
||||||
|
|
||||||
|
if (GfxFlags == (flags ^ TFB_GFXFLAGS_FULLSCREEN) && driver == GraphicsDriver &&
|
||||||
|
width == ScreenWidthActual && height == ScreenHeightActual)
|
||||||
|
{
|
||||||
|
togglefullscreen = 1;
|
||||||
|
}
|
||||||
|
|
||||||
GfxFlags = flags;
|
GfxFlags = flags;
|
||||||
|
|
||||||
if (driver == TFB_GFXDRIVER_SDL_OPENGL)
|
if (driver == TFB_GFXDRIVER_SDL_OPENGL)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_OPENGL
|
#ifdef HAVE_OPENGL
|
||||||
result = TFB_GL_ConfigureVideo (driver, flags, width, height);
|
result = TFB_GL_ConfigureVideo (driver, flags, width, height, togglefullscreen);
|
||||||
#else
|
#else
|
||||||
driver = TFB_GFXDRIVER_SDL_PURE;
|
driver = TFB_GFXDRIVER_SDL_PURE;
|
||||||
log_add (log_Warning, "OpenGL support not compiled in,"
|
log_add (log_Warning, "OpenGL support not compiled in,"
|
||||||
@@ -99,7 +107,7 @@ TFB_ReInitGraphics (int driver, int flags, int width, int height)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = TFB_Pure_ConfigureVideo (driver, flags, width, height);
|
result = TFB_Pure_ConfigureVideo (driver, flags, width, height, togglefullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf (caption, "The Ur-Quan Masters v%d.%d.%d%s",
|
sprintf (caption, "The Ur-Quan Masters v%d.%d.%d%s",
|
||||||
@@ -194,17 +202,27 @@ TFB_ProcessEvents ()
|
|||||||
// TODO
|
// TODO
|
||||||
break;
|
break;
|
||||||
case SDL_VIDEOEXPOSE: /* Screen needs to be redrawn */
|
case SDL_VIDEOEXPOSE: /* Screen needs to be redrawn */
|
||||||
TFB_SwapBuffers (1);
|
TFB_SwapBuffers (TFB_REDRAW_EXPOSE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImmediateInputState.menu[KEY_ABORT] || abortFlag)
|
if (ImmediateInputState.menu[KEY_ABORT] || abortFlag)
|
||||||
{
|
{
|
||||||
log_showBox (false, false);
|
log_showBox (false, false);
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImmediateInputState.menu[KEY_FULLSCREEN])
|
||||||
|
{
|
||||||
|
int flags = GfxFlags ^ TFB_GFXFLAGS_FULLSCREEN;
|
||||||
|
FlushInput ();
|
||||||
|
TFB_ReInitGraphics (GraphicsDriver, flags, ScreenWidthActual, ScreenHeightActual);
|
||||||
|
TFB_SwapBuffers (TFB_REDRAW_YES);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(DEBUG) || defined(USE_DEBUG_KEY)
|
#if defined(DEBUG) || defined(USE_DEBUG_KEY)
|
||||||
if (ImmediateInputState.menu[KEY_DEBUG])
|
if (ImmediateInputState.menu[KEY_DEBUG])
|
||||||
{
|
{
|
||||||
@@ -242,15 +260,15 @@ TFB_SwapBuffers (int force_full_redraw)
|
|||||||
fade_amount = FadeAmount;
|
fade_amount = FadeAmount;
|
||||||
transition_amount = TransitionAmount;
|
transition_amount = TransitionAmount;
|
||||||
|
|
||||||
if (!force_full_redraw && !TFB_BBox.valid &&
|
if (force_full_redraw == TFB_REDRAW_NO && !TFB_BBox.valid &&
|
||||||
fade_amount == 255 && transition_amount == 255 &&
|
fade_amount == 255 && transition_amount == 255 &&
|
||||||
last_fade_amount == 255 && last_transition_amount == 255)
|
last_fade_amount == 255 && last_transition_amount == 255)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fade_amount != 255 || transition_amount != 255 ||
|
if (force_full_redraw == TFB_REDRAW_NO && (fade_amount != 255 || transition_amount != 255 ||
|
||||||
last_fade_amount != 255 || last_transition_amount != 255)
|
last_fade_amount != 255 || last_transition_amount != 255))
|
||||||
{
|
{
|
||||||
force_full_redraw = 1;
|
force_full_redraw = TFB_REDRAW_FADING;
|
||||||
}
|
}
|
||||||
|
|
||||||
last_fade_amount = fade_amount;
|
last_fade_amount = fade_amount;
|
||||||
@@ -605,7 +623,7 @@ TFB_FlushGraphics () // Only call from main thread!!
|
|||||||
(current_fade == 255 && last_fade != 255) ||
|
(current_fade == 255 && last_fade != 255) ||
|
||||||
(current_transition == 255 && last_transition != 255))
|
(current_transition == 255 && last_transition != 255))
|
||||||
{
|
{
|
||||||
TFB_SwapBuffers (1); // if fading, redraw every frame
|
TFB_SwapBuffers (TFB_REDRAW_FADING); // if fading, redraw every frame
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -888,7 +906,7 @@ TFB_FlushGraphics () // Only call from main thread!!
|
|||||||
Unlock_DCQ ();
|
Unlock_DCQ ();
|
||||||
}
|
}
|
||||||
|
|
||||||
TFB_SwapBuffers (0);
|
TFB_SwapBuffers (TFB_REDRAW_NO);
|
||||||
RenderedFrames++;
|
RenderedFrames++;
|
||||||
BroadcastCondVar (RenderingCond);
|
BroadcastCondVar (RenderingCond);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ static const char *menu_res_names[] = {
|
|||||||
"exit",
|
"exit",
|
||||||
"abort",
|
"abort",
|
||||||
"debug",
|
"debug",
|
||||||
|
"fullscreen",
|
||||||
"up",
|
"up",
|
||||||
"down",
|
"down",
|
||||||
"left",
|
"left",
|
||||||
|
|||||||
Reference in New Issue
Block a user