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:
|
||||
- Added fullscreen/windowed toggle key F11 - Mika
|
||||
- Allow building without ogg vorbis support (bug #852) - SvdB
|
||||
- Reworked SuperMelee fleet loading (fixes bug #823) - SvdB
|
||||
- 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.2 = key F1
|
||||
menu.exit.1 = key F10
|
||||
menu.fullscreen.1 = key F11
|
||||
menu.special.1 = key LeftAlt
|
||||
menu.special.2 = key RightAlt
|
||||
|
||||
|
||||
@@ -656,6 +656,7 @@ the QUIT button in the lower right.
|
||||
|
||||
F1 or PAUSE Pause game
|
||||
F10 Exit game
|
||||
F11 Toggle between fullscreen and windowed mode
|
||||
|
||||
FULL GAME CONTROLS SUMMARY
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ enum {
|
||||
KEY_EXIT,
|
||||
KEY_ABORT,
|
||||
KEY_DEBUG,
|
||||
KEY_FULLSCREEN,
|
||||
KEY_MENU_UP,
|
||||
KEY_MENU_DOWN,
|
||||
KEY_MENU_LEFT,
|
||||
|
||||
@@ -32,6 +32,15 @@ enum
|
||||
TFB_GFXDRIVER_SDL_PURE,
|
||||
};
|
||||
|
||||
// forced redraw
|
||||
enum
|
||||
{
|
||||
TFB_REDRAW_NO = 0,
|
||||
TFB_REDRAW_FADING,
|
||||
TFB_REDRAW_EXPOSE,
|
||||
TFB_REDRAW_YES
|
||||
};
|
||||
|
||||
// flags for TFB_InitGraphics
|
||||
#define TFB_GFXFLAGS_FULLSCREEN (1<<0)
|
||||
#define TFB_GFXFLAGS_SHOWFPS (1<<1)
|
||||
|
||||
@@ -160,7 +160,7 @@ AttemptColorDepth (int flags, int width, int height, int bpp)
|
||||
}
|
||||
|
||||
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;
|
||||
GraphicsDriver = driver;
|
||||
@@ -174,6 +174,8 @@ TFB_GL_ConfigureVideo (int driver, int flags, int width, int height)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!togglefullscreen)
|
||||
{
|
||||
if (format_conv_surf)
|
||||
SDL_FreeSurface (format_conv_surf);
|
||||
format_conv_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, 0, 0, 32,
|
||||
@@ -206,8 +208,11 @@ TFB_GL_ConfigureVideo (int driver, int flags, int width, int height)
|
||||
GL_Screens[1].active = FALSE;
|
||||
first_init = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (GfxFlags & TFB_GFXFLAGS_SCALE_SOFT_ONLY)
|
||||
{
|
||||
if (!togglefullscreen)
|
||||
{
|
||||
for (i = 0; i < TFB_GFX_NUMSCREENS; i++)
|
||||
{
|
||||
@@ -217,11 +222,12 @@ TFB_GL_ConfigureVideo (int driver, int flags, int width, int height)
|
||||
ScreenWidth * 2, ScreenHeight * 2))
|
||||
return -1;
|
||||
}
|
||||
scaler = Scale_PrepPlatform (flags, SDL_Screen->format);
|
||||
}
|
||||
|
||||
texture_width = 1024;
|
||||
texture_height = 512;
|
||||
|
||||
scaler = Scale_PrepPlatform (flags, SDL_Screen->format);
|
||||
graphics_backend = &opengl_scaled_backend;
|
||||
}
|
||||
else
|
||||
@@ -233,6 +239,7 @@ TFB_GL_ConfigureVideo (int driver, int flags, int width, int height)
|
||||
graphics_backend = &opengl_unscaled_backend;
|
||||
}
|
||||
|
||||
|
||||
if (GfxFlags & TFB_GFXFLAGS_SCALE_ANY)
|
||||
ScreenFilterMode = GL_LINEAR;
|
||||
else
|
||||
@@ -277,7 +284,7 @@ TFB_GL_InitGraphics (int driver, int flags, int width, int height)
|
||||
ScreenWidth = 320;
|
||||
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: "
|
||||
"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);
|
||||
glMatrixMode (GL_MODELVIEW);
|
||||
glLoadIdentity ();
|
||||
(void) force_full_redraw;
|
||||
(void) transition_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.y = TFB_BBox.region.corner.y;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "libs/graphics/sdl/sdl_common.h"
|
||||
|
||||
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);
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
|
||||
@@ -74,7 +74,7 @@ ReInit_Screen (SDL_Surface **screen, SDL_Surface *template, int w, int h)
|
||||
}
|
||||
|
||||
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;
|
||||
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()->format->BitsPerPixel);
|
||||
ScreenColorDepth = SDL_GetVideoSurface()->format->BitsPerPixel;
|
||||
|
||||
if (togglefullscreen)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 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;
|
||||
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: "
|
||||
"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
|
||||
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.w = ScreenWidth;
|
||||
|
||||
@@ -22,6 +22,6 @@
|
||||
#include "libs/graphics/sdl/sdl_common.h"
|
||||
|
||||
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
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "libs/uio.h"
|
||||
#include "libs/log.h"
|
||||
#include "controls.h"
|
||||
#include "vidlib.h"
|
||||
// XXX: Should not be included from here.
|
||||
#include "uqmdebug.h"
|
||||
#include SDL_INCLUDE(SDL_thread.h)
|
||||
@@ -82,14 +83,21 @@ int
|
||||
TFB_ReInitGraphics (int driver, int flags, int width, int height)
|
||||
{
|
||||
int result;
|
||||
int togglefullscreen = 0;
|
||||
char caption[200];
|
||||
|
||||
if (GfxFlags == (flags ^ TFB_GFXFLAGS_FULLSCREEN) && driver == GraphicsDriver &&
|
||||
width == ScreenWidthActual && height == ScreenHeightActual)
|
||||
{
|
||||
togglefullscreen = 1;
|
||||
}
|
||||
|
||||
GfxFlags = flags;
|
||||
|
||||
if (driver == TFB_GFXDRIVER_SDL_OPENGL)
|
||||
{
|
||||
#ifdef HAVE_OPENGL
|
||||
result = TFB_GL_ConfigureVideo (driver, flags, width, height);
|
||||
result = TFB_GL_ConfigureVideo (driver, flags, width, height, togglefullscreen);
|
||||
#else
|
||||
driver = TFB_GFXDRIVER_SDL_PURE;
|
||||
log_add (log_Warning, "OpenGL support not compiled in,"
|
||||
@@ -99,7 +107,7 @@ TFB_ReInitGraphics (int driver, int flags, int width, int height)
|
||||
}
|
||||
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",
|
||||
@@ -194,17 +202,27 @@ TFB_ProcessEvents ()
|
||||
// TODO
|
||||
break;
|
||||
case SDL_VIDEOEXPOSE: /* Screen needs to be redrawn */
|
||||
TFB_SwapBuffers (1);
|
||||
TFB_SwapBuffers (TFB_REDRAW_EXPOSE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ImmediateInputState.menu[KEY_ABORT] || abortFlag)
|
||||
{
|
||||
log_showBox (false, false);
|
||||
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 (ImmediateInputState.menu[KEY_DEBUG])
|
||||
{
|
||||
@@ -242,15 +260,15 @@ TFB_SwapBuffers (int force_full_redraw)
|
||||
fade_amount = FadeAmount;
|
||||
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 &&
|
||||
last_fade_amount == 255 && last_transition_amount == 255)
|
||||
return;
|
||||
|
||||
if (fade_amount != 255 || transition_amount != 255 ||
|
||||
last_fade_amount != 255 || last_transition_amount != 255)
|
||||
if (force_full_redraw == TFB_REDRAW_NO && (fade_amount != 255 || 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;
|
||||
@@ -605,7 +623,7 @@ TFB_FlushGraphics () // Only call from main thread!!
|
||||
(current_fade == 255 && last_fade != 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
|
||||
{
|
||||
@@ -888,7 +906,7 @@ TFB_FlushGraphics () // Only call from main thread!!
|
||||
Unlock_DCQ ();
|
||||
}
|
||||
|
||||
TFB_SwapBuffers (0);
|
||||
TFB_SwapBuffers (TFB_REDRAW_NO);
|
||||
RenderedFrames++;
|
||||
BroadcastCondVar (RenderingCond);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ static const char *menu_res_names[] = {
|
||||
"exit",
|
||||
"abort",
|
||||
"debug",
|
||||
"fullscreen",
|
||||
"up",
|
||||
"down",
|
||||
"left",
|
||||
|
||||
Reference in New Issue
Block a user