mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
- removed the hard screen resolution switch that still was present on Windows and cleaned up the entire video backend code from the remaining support code for this.
Like Linux and macOS this will only support borderless fullscreen in the active desktop resolution now, which is what modern systems need. The list of discrete resolutions has been removed as it makes no sense anymore with a fixed video mode - all the other scaling options remain active, though.
This commit is contained in:
parent
322488d1d1
commit
b65b83edb3
28 changed files with 145 additions and 1828 deletions
|
@ -1069,7 +1069,6 @@ set (PCH_SOURCES
|
|||
menu/messagebox.cpp
|
||||
menu/optionmenu.cpp
|
||||
menu/playermenu.cpp
|
||||
menu/videomenu.cpp
|
||||
resourcefiles/ancientzip.cpp
|
||||
resourcefiles/file_7z.cpp
|
||||
resourcefiles/file_grp.cpp
|
||||
|
|
|
@ -111,7 +111,6 @@ void D_DoAnonStats();
|
|||
|
||||
extern void I_SetWindowTitle(const char* caption);
|
||||
extern void ReadStatistics();
|
||||
extern void M_RestoreMode ();
|
||||
extern void M_SetDefaultMode ();
|
||||
extern void G_NewInit ();
|
||||
extern void SetupPlayerClasses ();
|
||||
|
@ -147,9 +146,7 @@ EXTERN_CVAR (Bool, sv_cheats)
|
|||
EXTERN_CVAR (Bool, sv_unlimited_pickup)
|
||||
EXTERN_CVAR (Bool, I_FriendlyWindowTitle)
|
||||
|
||||
extern int testingmode;
|
||||
extern bool setmodeneeded;
|
||||
extern int NewWidth, NewHeight, NewBits, DisplayBits;
|
||||
extern bool gameisdead;
|
||||
extern bool demorecording;
|
||||
extern bool M_DemoNoPlay; // [RH] if true, then skip any demos in the loop
|
||||
|
@ -258,20 +255,6 @@ void D_ProcessEvents (void)
|
|||
{
|
||||
event_t *ev;
|
||||
|
||||
// [RH] If testing mode, do not accept input until test is over
|
||||
if (testingmode)
|
||||
{
|
||||
if (testingmode == 1)
|
||||
{
|
||||
M_SetDefaultMode ();
|
||||
}
|
||||
else if (testingmode <= I_GetTime())
|
||||
{
|
||||
M_RestoreMode ();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (; eventtail != eventhead ; eventtail = (eventtail+1)&(MAXEVENTS-1))
|
||||
{
|
||||
ev = &events[eventtail];
|
||||
|
@ -687,27 +670,16 @@ void D_Display ()
|
|||
R_SetFOV(r_viewpoint, fov);
|
||||
}
|
||||
|
||||
// [RH] change the screen mode if needed
|
||||
// fullscreen toggle has been requested
|
||||
if (setmodeneeded)
|
||||
{
|
||||
// Change screen mode.
|
||||
if (Video->SetResolution (NewWidth, NewHeight, NewBits))
|
||||
/*
|
||||
if (Video->ToggleFullscreen())
|
||||
{
|
||||
// Recalculate various view parameters.
|
||||
setsizeneeded = true;
|
||||
// Let the status bar know the screen size changed
|
||||
if (StatusBar != NULL)
|
||||
{
|
||||
StatusBar->CallScreenSizeChanged ();
|
||||
}
|
||||
// Refresh the console.
|
||||
C_NewModeAdjust ();
|
||||
// Reload crosshair if transitioned to a different size
|
||||
ST_LoadCrosshair (true);
|
||||
AM_NewResolution ();
|
||||
// Reset the mouse cursor in case the bit depth changed
|
||||
vid_cursor.Callback();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// change the view size if needed
|
||||
|
@ -2710,7 +2682,6 @@ void D_DoomMain (void)
|
|||
screen->InitPalette();
|
||||
// These calls from inside V_Init2 are still necessary
|
||||
C_NewModeAdjust();
|
||||
M_InitVideoModesMenu();
|
||||
D_StartTitle (); // start up intro loop
|
||||
setmodeneeded = false; // This may be set to true here, but isn't needed for a restart
|
||||
}
|
||||
|
|
|
@ -190,7 +190,6 @@ extern bool precache;
|
|||
//-------
|
||||
|
||||
extern bool setsizeneeded;
|
||||
extern bool setmodeneeded;
|
||||
|
||||
|
||||
EXTERN_CVAR (Float, mouse_sensitivity)
|
||||
|
|
|
@ -64,8 +64,8 @@ CUSTOM_CVAR(Int, vid_hwgamma, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITC
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) :
|
||||
Super(hMonitor, width, height, bits, refreshHz, fullscreen, false)
|
||||
OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, bool fullscreen) :
|
||||
Super(hMonitor, fullscreen)
|
||||
{
|
||||
// SetVSync needs to be at the very top to workaround a bug in Nvidia's OpenGL driver.
|
||||
// If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed!
|
||||
|
@ -161,16 +161,15 @@ void OpenGLFrameBuffer::Update()
|
|||
Swap();
|
||||
CheckBench();
|
||||
|
||||
int initialWidth = IsFullscreen() ? VideoWidth : GetClientWidth();
|
||||
int initialHeight = IsFullscreen() ? VideoHeight : GetClientHeight();
|
||||
int initialWidth = GetClientWidth();
|
||||
int initialHeight = GetClientHeight();
|
||||
int clientWidth = ViewportScaledWidth(initialWidth, initialHeight);
|
||||
int clientHeight = ViewportScaledHeight(initialWidth, initialHeight);
|
||||
if (clientWidth > 0 && clientHeight > 0 && (Width != clientWidth || Height != clientHeight))
|
||||
if (clientWidth > 0 && clientHeight > 0 && (GetWidth() != clientWidth || GetHeight() != clientHeight))
|
||||
{
|
||||
Width = clientWidth;
|
||||
Height = clientHeight;
|
||||
V_OutputResized(Width, Height);
|
||||
GLRenderer->mVBO->OutputResized(Width, Height);
|
||||
SetVirtualSize(clientWidth, clientHeight);
|
||||
V_OutputResized(clientWidth, clientHeight);
|
||||
GLRenderer->mVBO->OutputResized(clientWidth, clientHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class OpenGLFrameBuffer : public SystemFrameBuffer
|
|||
public:
|
||||
|
||||
explicit OpenGLFrameBuffer() {}
|
||||
OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) ;
|
||||
OpenGLFrameBuffer(void *hMonitor, bool fullscreen) ;
|
||||
~OpenGLFrameBuffer();
|
||||
|
||||
void InitializeState();
|
||||
|
|
|
@ -251,11 +251,11 @@ void OpenGLFrameBuffer::Wiper::MakeVBO(OpenGLFrameBuffer *fb)
|
|||
|
||||
ptr->Set(0, 0, 0, 0, vb);
|
||||
ptr++;
|
||||
ptr->Set(0, fb->Height, 0, 0, 0);
|
||||
ptr->Set(0, fb->GetHeight(), 0, 0, 0);
|
||||
ptr++;
|
||||
ptr->Set(fb->Width, 0, 0, ur, vb);
|
||||
ptr->Set(fb->GetWidth(), 0, 0, ur, vb);
|
||||
ptr++;
|
||||
ptr->Set(fb->Width, fb->Height, 0, ur, 0);
|
||||
ptr->Set(fb->GetWidth(), fb->GetHeight(), 0, ur, 0);
|
||||
mVertexBuf->set(make, 4);
|
||||
}
|
||||
|
||||
|
@ -344,11 +344,11 @@ int OpenGLFrameBuffer::Wiper_Melt::MakeVBO(int ticks, OpenGLFrameBuffer *fb, boo
|
|||
|
||||
ptr->Set(0, 0, 0, 0, vb);
|
||||
ptr++;
|
||||
ptr->Set(0, fb->Height, 0, 0, 0);
|
||||
ptr->Set(0, fb->GetHeight(), 0, 0, 0);
|
||||
ptr++;
|
||||
ptr->Set(fb->Width, 0, 0, ur, vb);
|
||||
ptr->Set(fb->GetWidth(), 0, 0, ur, vb);
|
||||
ptr++;
|
||||
ptr->Set(fb->Width, fb->Height, 0, ur, 0);
|
||||
ptr->Set(fb->GetWidth(), fb->GetHeight(), 0, ur, 0);
|
||||
ptr++;
|
||||
|
||||
// Copy the old screen in vertical strips on top of the new one.
|
||||
|
@ -384,18 +384,18 @@ int OpenGLFrameBuffer::Wiper_Melt::MakeVBO(int ticks, OpenGLFrameBuffer *fb, boo
|
|||
// Only draw for the final tick.
|
||||
// No need for optimization. Wipes won't ever be drawn with anything else.
|
||||
|
||||
dpt.x = i * fb->Width / WIDTH;
|
||||
dpt.y = MAX(0, y[i] * fb->Height / HEIGHT);
|
||||
dpt.x = i * fb->GetWidth() / WIDTH;
|
||||
dpt.y = MAX(0, y[i] * fb->GetHeight() / HEIGHT);
|
||||
rect.left = dpt.x;
|
||||
rect.top = 0;
|
||||
rect.right = (i + 1) * fb->Width / WIDTH;
|
||||
rect.bottom = fb->Height - dpt.y;
|
||||
rect.right = (i + 1) * fb->GetWidth() / WIDTH;
|
||||
rect.bottom = fb->GetHeight() - dpt.y;
|
||||
if (rect.bottom > rect.top)
|
||||
{
|
||||
float tw = (float)FHardwareTexture::GetTexDimension(fb->Width);
|
||||
float th = (float)FHardwareTexture::GetTexDimension(fb->Height);
|
||||
rect.bottom = fb->Height - rect.bottom;
|
||||
rect.top = fb->Height - rect.top;
|
||||
float tw = (float)FHardwareTexture::GetTexDimension(fb->GetWidth());
|
||||
float th = (float)FHardwareTexture::GetTexDimension(fb->GetHeight());
|
||||
rect.bottom = fb->GetHeight() - rect.bottom;
|
||||
rect.top = fb->GetHeight() - rect.top;
|
||||
|
||||
ptr->Set(rect.left, rect.bottom, 0, rect.left / tw, rect.top / th);
|
||||
ptr++;
|
||||
|
|
|
@ -5,8 +5,23 @@
|
|||
class DFrameBuffer;
|
||||
|
||||
|
||||
// [RH] Set the display mode
|
||||
DFrameBuffer *I_SetMode (int &width, int &height, DFrameBuffer *old);
|
||||
class IVideo
|
||||
{
|
||||
public:
|
||||
virtual ~IVideo() {}
|
||||
|
||||
virtual DFrameBuffer *CreateFrameBuffer() = 0;
|
||||
|
||||
bool SetResolution();
|
||||
|
||||
virtual void DumpAdapters();
|
||||
};
|
||||
|
||||
void I_InitGraphics();
|
||||
void I_ShutdownGraphics();
|
||||
|
||||
extern IVideo *Video;
|
||||
|
||||
|
||||
// Pause a bit.
|
||||
// [RH] Despite the name, it apparently never waited for the VBL, even in
|
||||
|
@ -14,11 +29,4 @@ DFrameBuffer *I_SetMode (int &width, int &height, DFrameBuffer *old);
|
|||
void I_WaitVBL(int count);
|
||||
|
||||
|
||||
enum EDisplayType
|
||||
{
|
||||
DISPLAY_WindowOnly,
|
||||
DISPLAY_FullscreenOnly,
|
||||
DISPLAY_Both
|
||||
};
|
||||
|
||||
#endif // __I_VIDEO_H__
|
||||
|
|
|
@ -105,7 +105,6 @@ static bool MenuEnabled = true;
|
|||
DMenu *CurrentMenu;
|
||||
int MenuTime;
|
||||
|
||||
void M_InitVideoModes();
|
||||
extern PClass *DefaultListMenuClass;
|
||||
extern PClass *DefaultOptionMenuClass;
|
||||
|
||||
|
@ -437,7 +436,6 @@ void M_SetMenu(FName menu, int param)
|
|||
}
|
||||
|
||||
case NAME_VideoModeMenu:
|
||||
M_InitVideoModes();
|
||||
break;
|
||||
|
||||
case NAME_Quitmenu:
|
||||
|
|
|
@ -342,8 +342,6 @@ void M_StartControlPanel (bool makeSound);
|
|||
void M_SetMenu(FName menu, int param = -1);
|
||||
void M_StartMessage(const char *message, int messagemode, FName action = NAME_None);
|
||||
DMenu *StartPickerMenu(DMenu *parent, const char *name, FColorCVar *cvar);
|
||||
void M_RefreshModesList ();
|
||||
void M_InitVideoModesMenu ();
|
||||
void M_MarkMenus();
|
||||
|
||||
|
||||
|
|
|
@ -1,386 +0,0 @@
|
|||
/*
|
||||
** videomenu.cpp
|
||||
** The video modes menu
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2001-2010 Randy Heit
|
||||
** Copyright 2010 Christoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
#include "menu/menu.h"
|
||||
#include "sbar.h"
|
||||
#include "hardware.h"
|
||||
#include "vm.h"
|
||||
#include "i_time.h"
|
||||
|
||||
/*=======================================
|
||||
*
|
||||
* Video Modes Menu
|
||||
*
|
||||
*=======================================*/
|
||||
static void BuildModesList (int hiwidth, int hiheight, int hi_id);
|
||||
static bool GetSelectedSize (int *width, int *height);
|
||||
static void SetModesMenu (int w, int h, int bits);
|
||||
DOptionMenuDescriptor *GetVideoModeMenu();
|
||||
|
||||
extern bool setmodeneeded;
|
||||
extern int NewWidth, NewHeight, NewBits;
|
||||
extern int DisplayBits;
|
||||
|
||||
EXTERN_CVAR (Int, vid_defwidth)
|
||||
EXTERN_CVAR (Int, vid_defheight)
|
||||
EXTERN_CVAR (Int, vid_defbits)
|
||||
EXTERN_CVAR (Bool, fullscreen)
|
||||
|
||||
int testingmode; // Holds time to revert to old mode
|
||||
int OldWidth, OldHeight, OldBits;
|
||||
static FIntCVar DummyDepthCvar (NULL, 0, 0);
|
||||
static uint8_t BitTranslate[32];
|
||||
|
||||
CUSTOM_CVAR (Int, menu_screenratios, -1, CVAR_ARCHIVE)
|
||||
{
|
||||
if (self < -1 || self > 6)
|
||||
{
|
||||
self = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildModesList (screen->VideoWidth, screen->VideoHeight, DisplayBits);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
struct OptionMenuItemScreenResolution // temporary workaround
|
||||
{
|
||||
enum EValues
|
||||
{
|
||||
SRL_INDEX = 0x30000,
|
||||
SRL_SELECTION = 0x30003,
|
||||
SRL_HIGHLIGHT = 0x30004,
|
||||
};
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
DOptionMenuDescriptor *GetVideoModeMenu()
|
||||
{
|
||||
DMenuDescriptor **desc = MenuDescriptors.CheckKey(NAME_VideoModeMenu);
|
||||
if (desc != NULL && (*desc)->IsKindOf(RUNTIME_CLASS(DOptionMenuDescriptor)))
|
||||
{
|
||||
return (DOptionMenuDescriptor *)*desc;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// Set some stuff up for the video modes menu
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
static void BuildModesList (int hiwidth, int hiheight, int hi_bits)
|
||||
{
|
||||
char strtemp[32];
|
||||
int i, c;
|
||||
int width, height, showbits;
|
||||
bool letterbox=false;
|
||||
int ratiomatch;
|
||||
|
||||
if (menu_screenratios >= 0 && menu_screenratios <= 6)
|
||||
{
|
||||
ratiomatch = menu_screenratios;
|
||||
}
|
||||
else
|
||||
{
|
||||
ratiomatch = -1;
|
||||
}
|
||||
showbits = BitTranslate[DummyDepthCvar];
|
||||
|
||||
if (Video != NULL)
|
||||
{
|
||||
Video->StartModeIterator (showbits, screen->IsFullscreen());
|
||||
}
|
||||
|
||||
DOptionMenuDescriptor *opt = GetVideoModeMenu();
|
||||
if (opt != NULL)
|
||||
{
|
||||
for (i = NAME_res_0; i<= NAME_res_9; i++)
|
||||
{
|
||||
DMenuItemBase *it = opt->GetItem((ENamedName)i);
|
||||
if (it != NULL)
|
||||
{
|
||||
it->SetValue(OptionMenuItemScreenResolution::SRL_HIGHLIGHT, -1);
|
||||
for (c = 0; c < 3; c++)
|
||||
{
|
||||
bool haveMode = false;
|
||||
|
||||
if (Video != NULL)
|
||||
{
|
||||
while ((haveMode = Video->NextMode (&width, &height, &letterbox)) &&
|
||||
ratiomatch >= 0)
|
||||
{
|
||||
int ratio;
|
||||
CheckRatio (width, height, &ratio);
|
||||
if (ratio == ratiomatch)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (haveMode)
|
||||
{
|
||||
if (width == hiwidth && height == hiheight)
|
||||
{
|
||||
it->SetValue(OptionMenuItemScreenResolution::SRL_SELECTION, c);
|
||||
it->SetValue(OptionMenuItemScreenResolution::SRL_HIGHLIGHT, c);
|
||||
}
|
||||
|
||||
mysnprintf (strtemp, countof(strtemp), "%dx%d%s", width, height, letterbox?TEXTCOLOR_BROWN" LB":"");
|
||||
it->SetString(OptionMenuItemScreenResolution::SRL_INDEX+c, strtemp);
|
||||
}
|
||||
else
|
||||
{
|
||||
it->SetString(OptionMenuItemScreenResolution::SRL_INDEX+c, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
void M_RestoreMode ()
|
||||
{
|
||||
NewWidth = OldWidth;
|
||||
NewHeight = OldHeight;
|
||||
NewBits = OldBits;
|
||||
setmodeneeded = true;
|
||||
testingmode = 0;
|
||||
SetModesMenu (OldWidth, OldHeight, OldBits);
|
||||
}
|
||||
|
||||
void M_SetDefaultMode ()
|
||||
{
|
||||
// Make current resolution the default
|
||||
vid_defwidth = screen->VideoWidth;
|
||||
vid_defheight = screen->VideoHeight;
|
||||
vid_defbits = DisplayBits;
|
||||
testingmode = 0;
|
||||
SetModesMenu (screen->VideoWidth, screen->VideoHeight, DisplayBits);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
void M_RefreshModesList ()
|
||||
{
|
||||
BuildModesList (screen->VideoWidth, screen->VideoHeight, DisplayBits);
|
||||
}
|
||||
|
||||
void M_InitVideoModesMenu ()
|
||||
{
|
||||
int dummy1, dummy2;
|
||||
size_t currval = 0;
|
||||
|
||||
M_RefreshModesList();
|
||||
|
||||
for (unsigned int i = 1; i <= 32 && currval < countof(BitTranslate); i++)
|
||||
{
|
||||
Video->StartModeIterator (i, screen->IsFullscreen());
|
||||
if (Video->NextMode (&dummy1, &dummy2, NULL))
|
||||
{
|
||||
BitTranslate[currval++] = i;
|
||||
}
|
||||
}
|
||||
|
||||
/* It doesn't look like this can be anything but DISPLAY_Both, regardless of any other settings.
|
||||
switch (Video->GetDisplayType ())
|
||||
{
|
||||
case DISPLAY_FullscreenOnly:
|
||||
case DISPLAY_WindowOnly:
|
||||
// todo: gray out fullscreen option
|
||||
default:
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
static bool GetSelectedSize (int *width, int *height)
|
||||
{
|
||||
DOptionMenuDescriptor *opt = GetVideoModeMenu();
|
||||
if (opt != NULL && (unsigned)opt->mSelectedItem < opt->mItems.Size())
|
||||
{
|
||||
int line = opt->mSelectedItem;
|
||||
int hsel;
|
||||
DMenuItemBase *it = opt->mItems[line];
|
||||
if (it->GetValue(OptionMenuItemScreenResolution::SRL_SELECTION, &hsel))
|
||||
{
|
||||
char buffer[32];
|
||||
char *breakpt;
|
||||
if (it->GetString(OptionMenuItemScreenResolution::SRL_INDEX+hsel, buffer, sizeof(buffer)))
|
||||
{
|
||||
*width = (int)strtoll (buffer, &breakpt, 10);
|
||||
*height = (int)strtoll (breakpt+1, NULL, 10);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DVideoModeMenu, SetSelectedSize)
|
||||
{
|
||||
if (!GetSelectedSize (&NewWidth, &NewHeight))
|
||||
{
|
||||
NewWidth = screen->VideoWidth;
|
||||
NewHeight = screen->VideoHeight;
|
||||
ACTION_RETURN_BOOL(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
OldWidth = screen->VideoWidth;
|
||||
OldHeight = screen->VideoHeight;
|
||||
OldBits = DisplayBits;
|
||||
NewBits = BitTranslate[DummyDepthCvar];
|
||||
setmodeneeded = true;
|
||||
testingmode = I_GetTime() + 5 * TICRATE;
|
||||
SetModesMenu (NewWidth, NewHeight, NewBits);
|
||||
ACTION_RETURN_BOOL(true);
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
void M_SetVideoMode()
|
||||
{
|
||||
if (!GetSelectedSize (&NewWidth, &NewHeight))
|
||||
{
|
||||
NewWidth = screen->VideoWidth;
|
||||
NewHeight = screen->VideoHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
testingmode = 1;
|
||||
setmodeneeded = true;
|
||||
NewBits = BitTranslate[DummyDepthCvar];
|
||||
}
|
||||
SetModesMenu (NewWidth, NewHeight, NewBits);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DMenu, SetVideoMode)
|
||||
{
|
||||
M_SetVideoMode();
|
||||
return 0;
|
||||
}
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
static int FindBits (int bits)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 22; i++)
|
||||
{
|
||||
if (BitTranslate[i] == bits)
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SetModesMenu (int w, int h, int bits)
|
||||
{
|
||||
DummyDepthCvar = FindBits (bits);
|
||||
|
||||
DOptionMenuDescriptor *opt = GetVideoModeMenu();
|
||||
if (opt != NULL)
|
||||
{
|
||||
DMenuItemBase *it;
|
||||
if (testingmode <= 1)
|
||||
{
|
||||
it = opt->GetItem(NAME_VMEnterText);
|
||||
if (it != NULL) it->SetValue(0, 0);
|
||||
it = opt->GetItem(NAME_VMTestText);
|
||||
if (it != NULL) it->SetValue(0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
it = opt->GetItem(NAME_VMTestText);
|
||||
if (it != NULL) it->SetValue(0, 1);
|
||||
it = opt->GetItem(NAME_VMEnterText);
|
||||
if (it != NULL)
|
||||
{
|
||||
char strtemp[64];
|
||||
mysnprintf (strtemp, countof(strtemp), "TESTING %dx%dx%d", w, h, bits);
|
||||
it->SetValue(0, 1);
|
||||
it->SetString(0, strtemp);
|
||||
}
|
||||
}
|
||||
}
|
||||
BuildModesList (w, h, bits);
|
||||
}
|
||||
|
||||
void M_InitVideoModes()
|
||||
{
|
||||
SetModesMenu (screen->VideoWidth, screen->VideoHeight, DisplayBits);
|
||||
}
|
|
@ -40,7 +40,7 @@ class SystemFrameBuffer : public DFrameBuffer
|
|||
{
|
||||
public:
|
||||
// This must have the same parameters as the Windows version, even if they are not used!
|
||||
SystemFrameBuffer(void *hMonitor, int width, int height, int, int, bool fullscreen, bool bgra);
|
||||
SystemFrameBuffer(void *hMonitor, bool fullscreen);
|
||||
~SystemFrameBuffer();
|
||||
|
||||
virtual bool IsFullscreen();
|
||||
|
@ -49,8 +49,6 @@ public:
|
|||
int GetClientWidth();
|
||||
int GetClientHeight();
|
||||
|
||||
virtual int GetTrueHeight() { return GetClientHeight(); }
|
||||
|
||||
protected:
|
||||
bool UpdatePending;
|
||||
|
||||
|
|
|
@ -489,7 +489,8 @@ void NSEventToGameMousePosition(NSEvent* inEvent, event_t* outEvent)
|
|||
|
||||
// Compensate letterbox adjustment done by cross-platform code
|
||||
// More elegant solution is a bit problematic due to HiDPI/Retina support
|
||||
outEvent->data2 += (screen->GetTrueHeight() - screen->VideoHeight) / 2;
|
||||
// What does this do? Add 0?
|
||||
//outEvent->data2 += (screen->GetTrueHeight() - screen->ClientHeight()) / 2;
|
||||
|
||||
screen->ScaleCoordsFromWindow(outEvent->data1, outEvent->data2);
|
||||
}
|
||||
|
|
|
@ -92,20 +92,9 @@
|
|||
|
||||
DFrameBuffer *CreateGLSWFrameBuffer(int width, int height, bool bgra, bool fullscreen);
|
||||
|
||||
EXTERN_CVAR(Bool, ticker )
|
||||
EXTERN_CVAR(Bool, vid_vsync)
|
||||
EXTERN_CVAR(Bool, vid_hidpi)
|
||||
|
||||
CUSTOM_CVAR(Bool, fullscreen, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
extern int NewWidth, NewHeight, NewBits, DisplayBits;
|
||||
|
||||
NewWidth = screen->VideoWidth;
|
||||
NewHeight = screen->VideoHeight;
|
||||
NewBits = DisplayBits;
|
||||
setmodeneeded = true;
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, vid_autoswitch, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||
{
|
||||
Printf("You must restart " GAMENAME " to apply graphics switching mode\n");
|
||||
|
@ -215,13 +204,7 @@ class CocoaVideo : public IVideo
|
|||
public:
|
||||
CocoaVideo();
|
||||
|
||||
virtual EDisplayType GetDisplayType() { return DISPLAY_Both; }
|
||||
virtual void SetWindowedScale(float scale);
|
||||
|
||||
virtual DFrameBuffer* CreateFrameBuffer(int width, int height, bool bgra, bool fs, DFrameBuffer* old);
|
||||
|
||||
virtual void StartModeIterator(int bits, bool fullscreen);
|
||||
virtual bool NextMode(int* width, int* height, bool* letterbox);
|
||||
virtual DFrameBuffer* CreateFrameBuffer();
|
||||
|
||||
static bool IsFullscreen();
|
||||
static void UseHiDPI(bool hiDPI);
|
||||
|
@ -230,15 +213,6 @@ public:
|
|||
static void SetWindowTitle(const char* title);
|
||||
|
||||
private:
|
||||
struct ModeIterator
|
||||
{
|
||||
size_t index;
|
||||
int bits;
|
||||
bool fullscreen;
|
||||
};
|
||||
|
||||
ModeIterator m_modeIterator;
|
||||
|
||||
CocoaWindow* m_window;
|
||||
|
||||
int m_width;
|
||||
|
@ -394,75 +368,14 @@ CocoaVideo::CocoaVideo()
|
|||
FConsoleWindow::GetInstance().Show(false);
|
||||
}
|
||||
|
||||
void CocoaVideo::StartModeIterator(const int bits, const bool fullscreen)
|
||||
{
|
||||
m_modeIterator.index = 0;
|
||||
m_modeIterator.bits = bits;
|
||||
m_modeIterator.fullscreen = fullscreen;
|
||||
}
|
||||
|
||||
bool CocoaVideo::NextMode(int* const width, int* const height, bool* const letterbox)
|
||||
{
|
||||
assert(NULL != width);
|
||||
assert(NULL != height);
|
||||
|
||||
const int bits = m_modeIterator.bits;
|
||||
|
||||
if (8 != bits && 16 != bits && 24 != bits && 32 != bits)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t& index = m_modeIterator.index;
|
||||
|
||||
if (index < sizeof(VideoModes) / sizeof(VideoModes[0]))
|
||||
{
|
||||
*width = VideoModes[index].width;
|
||||
*height = VideoModes[index].height;
|
||||
|
||||
if (m_modeIterator.fullscreen && NULL != letterbox)
|
||||
{
|
||||
const NSSize screenSize = [[m_window screen] frame].size;
|
||||
const float screenRatio = screenSize.width / screenSize.height;
|
||||
const float modeRatio = float(*width) / *height;
|
||||
|
||||
*letterbox = fabs(screenRatio - modeRatio) > 0.001f;
|
||||
}
|
||||
|
||||
++index;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
DFrameBuffer* CocoaVideo::CreateFrameBuffer(const int width, const int height, const bool bgra, const bool fullscreen, DFrameBuffer* const old)
|
||||
DFrameBuffer* CocoaVideo::CreateFrameBuffer()
|
||||
{
|
||||
PalEntry flashColor = 0;
|
||||
int flashAmount = 0;
|
||||
|
||||
if (NULL != old)
|
||||
{
|
||||
if (width == m_width && height == m_height && bgra == m_bgra)
|
||||
{
|
||||
SetMode(width, height, fullscreen, bgra, vid_hidpi);
|
||||
return old;
|
||||
}
|
||||
|
||||
old->GetFlash(flashColor, flashAmount);
|
||||
|
||||
if (old == screen)
|
||||
{
|
||||
screen = NULL;
|
||||
}
|
||||
|
||||
delete old;
|
||||
}
|
||||
|
||||
DFrameBuffer* fb = NULL;
|
||||
|
||||
fb = new OpenGLFrameBuffer(NULL, width, height, 32, 60, fullscreen);
|
||||
fb = new OpenGLFrameBuffer(NULL, fullscreen);
|
||||
|
||||
fb->SetFlash(flashColor, flashAmount);
|
||||
|
||||
|
@ -471,11 +384,6 @@ DFrameBuffer* CocoaVideo::CreateFrameBuffer(const int width, const int height, c
|
|||
return fb;
|
||||
}
|
||||
|
||||
void CocoaVideo::SetWindowedScale(float scale)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool CocoaVideo::IsFullscreen()
|
||||
{
|
||||
CocoaVideo* const video = GetInstance();
|
||||
|
@ -628,8 +536,8 @@ CocoaVideo* CocoaVideo::GetInstance()
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
SystemFrameBuffer::SystemFrameBuffer(void*, const int width, const int height, int, int, const bool fullscreen, bool bgra)
|
||||
: DFrameBuffer(width, height, bgra)
|
||||
SystemFrameBuffer::SystemFrameBuffer(void*, const bool fullscreen)
|
||||
: DFrameBuffer(vid_defwidth, vid_defheight)
|
||||
, UpdatePending(false)
|
||||
{
|
||||
CGGammaValue gammaTable[GAMMA_TABLE_SIZE];
|
||||
|
@ -743,21 +651,11 @@ void I_ShutdownGraphics()
|
|||
|
||||
void I_InitGraphics()
|
||||
{
|
||||
UCVarValue val;
|
||||
|
||||
val.Bool = !!Args->CheckParm("-devparm");
|
||||
ticker.SetGenericRepDefault(val, CVAR_Bool);
|
||||
|
||||
Video = new CocoaVideo;
|
||||
atterm(I_ShutdownGraphics);
|
||||
}
|
||||
|
||||
|
||||
DFrameBuffer* I_SetMode(int &width, int &height, DFrameBuffer* old)
|
||||
{
|
||||
return Video->CreateFrameBuffer(width, height, false, fullscreen, old);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
@ -779,40 +677,6 @@ CUSTOM_CVAR(Bool, vid_hidpi, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
CCMD(vid_listmodes)
|
||||
{
|
||||
if (Video == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static const char* const ratios[7] = { "", " - 16:9", " - 16:10", " - 17:10", " - 5:4", "", " - 21:9" };
|
||||
int width, height;
|
||||
bool letterbox;
|
||||
|
||||
Video->StartModeIterator(32, screen->IsFullscreen());
|
||||
|
||||
while (Video->NextMode(&width, &height, &letterbox))
|
||||
{
|
||||
const bool current = width == DisplayWidth && height == DisplayHeight;
|
||||
const int ratio = CheckRatio(width, height);
|
||||
|
||||
Printf(current ? PRINT_BOLD : PRINT_HIGH, "%s%4d x%5d x%3d%s%s\n",
|
||||
current || !(ratio & 3) ? "" : TEXTCOLOR_GOLD,
|
||||
width, height, 32, ratios[ratio],
|
||||
current || !letterbox ? "" : TEXTCOLOR_BROWN " LB");
|
||||
}
|
||||
}
|
||||
|
||||
CCMD(vid_currentmode)
|
||||
{
|
||||
Printf("%dx%dx%d\n", DisplayWidth, DisplayHeight, DisplayBits);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
bool I_SetCursor(FTexture* cursorpic)
|
||||
{
|
||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||
|
|
|
@ -66,30 +66,8 @@ typedef sem_t Semaphore;
|
|||
sem_init(&sem, shared, value);
|
||||
#endif
|
||||
|
||||
class IVideo
|
||||
{
|
||||
public:
|
||||
virtual ~IVideo () {}
|
||||
|
||||
virtual EDisplayType GetDisplayType () = 0;
|
||||
virtual void SetWindowedScale (float scale) = 0;
|
||||
|
||||
virtual DFrameBuffer *CreateFrameBuffer (int width, int height, bool bgra, bool fs, DFrameBuffer *old) = 0;
|
||||
|
||||
virtual void StartModeIterator (int bits, bool fs) = 0;
|
||||
virtual bool NextMode (int *width, int *height, bool *letterbox) = 0;
|
||||
|
||||
virtual bool SetResolution (int width, int height, int bits);
|
||||
|
||||
virtual void DumpAdapters();
|
||||
};
|
||||
|
||||
void I_InitGraphics ();
|
||||
void I_ShutdownGraphics ();
|
||||
|
||||
extern Semaphore FPSLimitSemaphore;
|
||||
void I_SetFPSLimit(int limit);
|
||||
|
||||
extern IVideo *Video;
|
||||
|
||||
#endif // __HARDWARE_H__
|
||||
|
|
|
@ -11,7 +11,7 @@ class SystemFrameBuffer : public DFrameBuffer
|
|||
|
||||
public:
|
||||
// this must have the same parameters as the Windows version, even if they are not used!
|
||||
SystemFrameBuffer (void *hMonitor, int width, int height, int, int, bool fullscreen, bool bgra);
|
||||
SystemFrameBuffer (void *hMonitor, bool fullscreen);
|
||||
~SystemFrameBuffer ();
|
||||
|
||||
void ForceBuffering (bool force);
|
||||
|
@ -21,8 +21,6 @@ public:
|
|||
virtual void SetVSync( bool vsync );
|
||||
void SwapBuffers();
|
||||
|
||||
void NewRefreshRate ();
|
||||
|
||||
friend class SDLGLVideo;
|
||||
|
||||
int GetClientWidth();
|
||||
|
@ -30,8 +28,6 @@ public:
|
|||
|
||||
SDL_Window *GetSDLWindow() { return Screen; }
|
||||
|
||||
virtual int GetTrueHeight() { return GetClientHeight(); }
|
||||
|
||||
protected:
|
||||
void SetGammaTable(uint16_t *tbl);
|
||||
void ResetGammaTable();
|
||||
|
|
|
@ -42,14 +42,10 @@
|
|||
#include "m_argv.h"
|
||||
#include "swrenderer/r_swrenderer.h"
|
||||
|
||||
EXTERN_CVAR (Bool, ticker)
|
||||
EXTERN_CVAR (Bool, fullscreen)
|
||||
EXTERN_CVAR (Float, vid_winscale)
|
||||
|
||||
IVideo *Video;
|
||||
|
||||
extern int NewWidth, NewHeight, NewBits, DisplayBits;
|
||||
bool V_DoModeSetup (int width, int height, int bits);
|
||||
void I_RestartRenderer();
|
||||
|
||||
|
||||
|
@ -77,11 +73,6 @@ void I_InitGraphics ()
|
|||
|
||||
Printf("Using video driver %s\n", SDL_GetCurrentVideoDriver());
|
||||
|
||||
UCVarValue val;
|
||||
|
||||
val.Bool = !!Args->CheckParm ("-devparm");
|
||||
ticker.SetGenericRepDefault (val, CVAR_Bool);
|
||||
|
||||
extern IVideo *gl_CreateVideo();
|
||||
Video = gl_CreateVideo();
|
||||
|
||||
|
@ -89,40 +80,12 @@ void I_InitGraphics ()
|
|||
I_FatalError ("Failed to initialize display");
|
||||
|
||||
atterm (I_ShutdownGraphics);
|
||||
|
||||
Video->SetWindowedScale (vid_winscale);
|
||||
}
|
||||
|
||||
/** Remaining code is common to Win32 and Linux **/
|
||||
|
||||
// VIDEO WRAPPERS ---------------------------------------------------------
|
||||
|
||||
DFrameBuffer *I_SetMode (int &width, int &height, DFrameBuffer *old)
|
||||
{
|
||||
bool fs = false;
|
||||
switch (Video->GetDisplayType ())
|
||||
{
|
||||
case DISPLAY_WindowOnly:
|
||||
fs = false;
|
||||
break;
|
||||
case DISPLAY_FullscreenOnly:
|
||||
fs = true;
|
||||
break;
|
||||
case DISPLAY_Both:
|
||||
fs = fullscreen;
|
||||
break;
|
||||
}
|
||||
DFrameBuffer *res = Video->CreateFrameBuffer (width, height, false, fs, old);
|
||||
|
||||
/* Right now, CreateFrameBuffer cannot return NULL
|
||||
if (res == NULL)
|
||||
{
|
||||
I_FatalError ("Mode %dx%d is unavailable\n", width, height);
|
||||
}
|
||||
*/
|
||||
return res;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// SetFPSLimit
|
||||
|
@ -197,62 +160,3 @@ void I_SetFPSLimit(int limit)
|
|||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
extern int NewWidth, NewHeight, NewBits, DisplayBits;
|
||||
|
||||
CUSTOM_CVAR (Bool, fullscreen, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL)
|
||||
{
|
||||
NewWidth = screen->VideoWidth;
|
||||
NewHeight = screen->VideoHeight;
|
||||
NewBits = DisplayBits;
|
||||
setmodeneeded = true;
|
||||
}
|
||||
|
||||
CUSTOM_CVAR (Float, vid_winscale, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 1.f)
|
||||
{
|
||||
self = 1.f;
|
||||
}
|
||||
else if (Video)
|
||||
{
|
||||
Video->SetWindowedScale (self);
|
||||
NewWidth = screen->VideoWidth;
|
||||
NewHeight = screen->VideoHeight;
|
||||
NewBits = DisplayBits;
|
||||
setmodeneeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
CCMD (vid_listmodes)
|
||||
{
|
||||
static const char *ratios[7] = { "", " - 16:9", " - 16:10", "", " - 5:4", "", " - 21:9" };
|
||||
int width, height, bits;
|
||||
bool letterbox;
|
||||
|
||||
if (Video == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (bits = 1; bits <= 32; bits++)
|
||||
{
|
||||
Video->StartModeIterator (bits, screen->IsFullscreen());
|
||||
while (Video->NextMode (&width, &height, &letterbox))
|
||||
{
|
||||
bool thisMode = (width == DisplayWidth && height == DisplayHeight && bits == DisplayBits);
|
||||
int ratio = CheckRatio (width, height);
|
||||
Printf (thisMode ? PRINT_BOLD : PRINT_HIGH,
|
||||
"%s%4d x%5d x%3d%s%s\n",
|
||||
thisMode || !IsRatioWidescreen(ratio) ? "" : TEXTCOLOR_GOLD,
|
||||
width, height, bits,
|
||||
ratios[ratio],
|
||||
thisMode || !letterbox ? "" : TEXTCOLOR_BROWN " LB"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CCMD (vid_currentmode)
|
||||
{
|
||||
Printf ("%dx%dx%d\n", DisplayWidth, DisplayHeight, DisplayBits);
|
||||
}
|
||||
|
|
|
@ -93,20 +93,9 @@ public:
|
|||
SDLGLVideo (int parm);
|
||||
~SDLGLVideo ();
|
||||
|
||||
EDisplayType GetDisplayType () { return DISPLAY_Both; }
|
||||
void SetWindowedScale (float scale);
|
||||
|
||||
DFrameBuffer *CreateFrameBuffer (int width, int height, bool bgra, bool fs, DFrameBuffer *old);
|
||||
|
||||
void StartModeIterator (int bits, bool fs);
|
||||
bool NextMode (int *width, int *height, bool *letterbox);
|
||||
bool SetResolution (int width, int height, int bits);
|
||||
DFrameBuffer *CreateFrameBuffer ();
|
||||
|
||||
void SetupPixelFormat(bool allowsoftware, int multisample, const int *glver);
|
||||
|
||||
private:
|
||||
int IteratorMode;
|
||||
int IteratorBits;
|
||||
};
|
||||
|
||||
// CODE --------------------------------------------------------------------
|
||||
|
@ -125,132 +114,13 @@ SDLGLVideo::~SDLGLVideo ()
|
|||
if (GLRenderer != NULL) GLRenderer->FlushTextures();
|
||||
}
|
||||
|
||||
void SDLGLVideo::StartModeIterator (int bits, bool fs)
|
||||
DFrameBuffer *SDLGLVideo::CreateFrameBuffer ()
|
||||
{
|
||||
IteratorMode = 0;
|
||||
IteratorBits = bits;
|
||||
}
|
||||
SystemFrameBuffer *fb = new OpenGLFrameBuffer(0, fullscreen);
|
||||
|
||||
bool SDLGLVideo::NextMode (int *width, int *height, bool *letterbox)
|
||||
{
|
||||
if (IteratorBits != 8)
|
||||
return false;
|
||||
|
||||
if ((unsigned)IteratorMode < sizeof(VideoModes)/sizeof(VideoModes[0]))
|
||||
{
|
||||
*width = VideoModes[IteratorMode].width;
|
||||
*height = VideoModes[IteratorMode].height;
|
||||
++IteratorMode;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DFrameBuffer *SDLGLVideo::CreateFrameBuffer (int width, int height, bool bgra, bool fullscreen, DFrameBuffer *old)
|
||||
{
|
||||
static int retry = 0;
|
||||
static int owidth, oheight;
|
||||
|
||||
PalEntry flashColor;
|
||||
// int flashAmount;
|
||||
|
||||
if (old != NULL)
|
||||
{ // Reuse the old framebuffer if its attributes are the same
|
||||
SystemFrameBuffer *fb = static_cast<SystemFrameBuffer *> (old);
|
||||
if (fb->Width == width &&
|
||||
fb->Height == height)
|
||||
{
|
||||
bool fsnow = (SDL_GetWindowFlags (fb->GetSDLWindow()) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0;
|
||||
|
||||
if (fsnow != fullscreen)
|
||||
{
|
||||
SDL_SetWindowFullscreen (fb->GetSDLWindow(), fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||
}
|
||||
return old;
|
||||
}
|
||||
// old->GetFlash (flashColor, flashAmount);
|
||||
delete old;
|
||||
}
|
||||
else
|
||||
{
|
||||
flashColor = 0;
|
||||
// flashAmount = 0;
|
||||
}
|
||||
|
||||
SystemFrameBuffer *fb = new OpenGLFrameBuffer(0, width, height, 32, 60, fullscreen);
|
||||
|
||||
retry = 0;
|
||||
|
||||
// If we could not create the framebuffer, try again with slightly
|
||||
// different parameters in this order:
|
||||
// 1. Try with the closest size
|
||||
// 2. Try in the opposite screen mode with the original size
|
||||
// 3. Try in the opposite screen mode with the closest size
|
||||
// This is a somewhat confusing mass of recursion here.
|
||||
|
||||
while (fb == NULL)
|
||||
{
|
||||
switch (retry)
|
||||
{
|
||||
case 0:
|
||||
owidth = width;
|
||||
oheight = height;
|
||||
case 2:
|
||||
// Try a different resolution. Hopefully that will work.
|
||||
void V_ClosestResolution(int *, int *, int);
|
||||
V_ClosestResolution (&width, &height, 8);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// Try changing fullscreen mode. Maybe that will work.
|
||||
width = owidth;
|
||||
height = oheight;
|
||||
fullscreen = !fullscreen;
|
||||
break;
|
||||
|
||||
default:
|
||||
// I give up!
|
||||
I_FatalError ("Could not create new screen (%d x %d)", owidth, oheight);
|
||||
|
||||
fprintf( stderr, "!!! [SDLGLVideo::CreateFrameBuffer] Got beyond I_FatalError !!!" );
|
||||
return NULL; //[C] actually this shouldn't be reached; probably should be replaced with an ASSERT
|
||||
}
|
||||
|
||||
++retry;
|
||||
fb = static_cast<SystemFrameBuffer *>(CreateFrameBuffer (width, height, false, fullscreen, NULL));
|
||||
}
|
||||
|
||||
// fb->SetFlash (flashColor, flashAmount);
|
||||
return fb;
|
||||
}
|
||||
|
||||
void SDLGLVideo::SetWindowedScale (float scale)
|
||||
{
|
||||
}
|
||||
|
||||
bool SDLGLVideo::SetResolution (int width, int height, int bits)
|
||||
{
|
||||
// FIXME: Is it possible to do this without completely destroying the old
|
||||
// interface?
|
||||
#ifndef NO_GL
|
||||
|
||||
if (GLRenderer != NULL) GLRenderer->FlushTextures();
|
||||
I_ShutdownGraphics();
|
||||
|
||||
Video = new SDLGLVideo(0);
|
||||
if (Video == NULL) I_FatalError ("Failed to initialize display");
|
||||
|
||||
#if (defined(WINDOWS)) || defined(WIN32)
|
||||
bits=32;
|
||||
#else
|
||||
bits=24;
|
||||
#endif
|
||||
|
||||
V_DoModeSetup(width, height, bits);
|
||||
#endif
|
||||
return true; // We must return true because the old video context no longer exists.
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -302,8 +172,8 @@ IVideo *gl_CreateVideo()
|
|||
|
||||
// FrameBuffer implementation -----------------------------------------------
|
||||
|
||||
SystemFrameBuffer::SystemFrameBuffer (void *, int width, int height, int, int, bool fullscreen, bool bgra)
|
||||
: DFrameBuffer (width, height, bgra)
|
||||
SystemFrameBuffer::SystemFrameBuffer (void *, bool fullscreen)
|
||||
: DFrameBuffer (vid_defwidth, vid_defheight)
|
||||
{
|
||||
// NOTE: Core profiles were added with GL 3.2, so there's no sense trying
|
||||
// to set core 3.1 or 3.0. We could try a forward-compatible context
|
||||
|
@ -427,10 +297,6 @@ void SystemFrameBuffer::SetVSync( bool vsync )
|
|||
#endif
|
||||
}
|
||||
|
||||
void SystemFrameBuffer::NewRefreshRate ()
|
||||
{
|
||||
}
|
||||
|
||||
void SystemFrameBuffer::SwapBuffers()
|
||||
{
|
||||
#if !defined(__APPLE__) && !defined(__OpenBSD__)
|
||||
|
|
232
src/v_video.cpp
232
src/v_video.cpp
|
@ -46,6 +46,7 @@
|
|||
#include "x86.h"
|
||||
#include "i_video.h"
|
||||
#include "r_state.h"
|
||||
#include "am_map.h"
|
||||
|
||||
#include "doomstat.h"
|
||||
|
||||
|
@ -123,10 +124,9 @@ class DDummyFrameBuffer : public DFrameBuffer
|
|||
typedef DFrameBuffer Super;
|
||||
public:
|
||||
DDummyFrameBuffer (int width, int height)
|
||||
: DFrameBuffer (0, 0, false)
|
||||
: DFrameBuffer (0, 0)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
SetVirtualSize(width, height);
|
||||
}
|
||||
// These methods should never be called.
|
||||
void Update() { DBGBREAK; }
|
||||
|
@ -137,7 +137,7 @@ public:
|
|||
float Gamma;
|
||||
};
|
||||
|
||||
int DisplayWidth, DisplayHeight, DisplayBits;
|
||||
int DisplayWidth, DisplayHeight;
|
||||
|
||||
FFont *SmallFont, *SmallFont2, *BigFont, *ConFont, *IntermissionFont;
|
||||
|
||||
|
@ -169,14 +169,6 @@ CUSTOM_CVAR (Bool, vid_vsync, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|||
}
|
||||
}
|
||||
|
||||
CUSTOM_CVAR (Int, vid_refreshrate, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (screen != NULL)
|
||||
{
|
||||
screen->NewRefreshRate();
|
||||
}
|
||||
}
|
||||
|
||||
// [RH] Set true when vid_setmode command has been executed
|
||||
bool setmodeneeded = false;
|
||||
// [RH] Resolution to change to when setmodeneeded is true
|
||||
|
@ -598,17 +590,15 @@ DSimpleCanvas::~DSimpleCanvas ()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
DFrameBuffer::DFrameBuffer (int width, int height, bool bgra)
|
||||
//: DCanvas
|
||||
DFrameBuffer::DFrameBuffer (int width, int height)
|
||||
{
|
||||
SetSize(width, height);
|
||||
}
|
||||
|
||||
void DFrameBuffer::SetSize(int width, int height)
|
||||
{
|
||||
Width = ViewportScaledWidth(width, height);
|
||||
Height = ViewportScaledHeight(width, height);
|
||||
Bgra = bgra;
|
||||
|
||||
LastMS = LastSec = FrameCount = LastCount = LastTic = 0;
|
||||
|
||||
VideoWidth = width;
|
||||
VideoHeight = height;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -717,19 +707,6 @@ void DFrameBuffer::SetVSync (bool vsync)
|
|||
{
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DFrameBuffer :: NewRefreshRate
|
||||
//
|
||||
// Sets the fullscreen display to the new refresh rate in vid_refreshrate,
|
||||
// if possible.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void DFrameBuffer::NewRefreshRate ()
|
||||
{
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DFrameBuffer :: WipeStartScreen
|
||||
|
@ -967,10 +944,6 @@ void DFrameBuffer::ScaleCoordsFromWindow(int16_t &x, int16_t &y)
|
|||
int letterboxWidth = mOutputLetterbox.width;
|
||||
int letterboxHeight = mOutputLetterbox.height;
|
||||
|
||||
// Subtract the LB video mode letterboxing
|
||||
if (IsFullscreen())
|
||||
y -= (GetTrueHeight() - VideoHeight) / 2;
|
||||
|
||||
x = int16_t((x - letterboxX) * Width / letterboxWidth);
|
||||
y = int16_t((y - letterboxY) * Height / letterboxHeight);
|
||||
}
|
||||
|
@ -983,28 +956,6 @@ CCMD(clean)
|
|||
Printf ("CleanXfac: %d\nCleanYfac: %d\n", CleanXfac, CleanYfac);
|
||||
}
|
||||
|
||||
//
|
||||
// V_SetResolution
|
||||
//
|
||||
bool V_DoModeSetup (int width, int height, int bits)
|
||||
{
|
||||
DFrameBuffer *buff = I_SetMode (width, height, screen);
|
||||
|
||||
if (buff == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
screen = buff;
|
||||
screen->SetGamma ();
|
||||
|
||||
DisplayBits = bits;
|
||||
V_UpdateModeSize(screen->GetWidth(), screen->GetHeight());
|
||||
|
||||
M_RefreshModesList ();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void V_UpdateModeSize (int width, int height)
|
||||
{
|
||||
|
@ -1062,6 +1013,9 @@ void V_OutputResized (int width, int height)
|
|||
StatusBar->CallScreenSizeChanged();
|
||||
}
|
||||
C_NewModeAdjust();
|
||||
// Reload crosshair if transitioned to a different size
|
||||
ST_LoadCrosshair(true);
|
||||
AM_NewResolution();
|
||||
}
|
||||
|
||||
void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int realheight, int *cleanx, int *cleany, int *_cx1, int *_cx2)
|
||||
|
@ -1114,142 +1068,21 @@ void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int real
|
|||
if (_cx2 != NULL) *_cx2 = cx2;
|
||||
}
|
||||
|
||||
bool V_CheckResolution(const int width, const int height, const int bits)
|
||||
bool IVideo::SetResolution ()
|
||||
{
|
||||
int twidth, theight;
|
||||
DFrameBuffer *buff = CreateFrameBuffer();
|
||||
|
||||
Video->StartModeIterator(bits, fullscreen);
|
||||
|
||||
while (Video->NextMode(&twidth, &theight, NULL))
|
||||
if (buff == NULL) // this cannot really happen
|
||||
{
|
||||
if (width == twidth && height == theight)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
screen = buff;
|
||||
screen->SetGamma();
|
||||
|
||||
void V_ClosestResolution(int *width, int *height, int bits)
|
||||
{
|
||||
int twidth, theight;
|
||||
int cwidth = 0, cheight = 0;
|
||||
int iteration;
|
||||
uint32_t closest = uint32_t(-1);
|
||||
V_UpdateModeSize(screen->GetWidth(), screen->GetHeight());
|
||||
|
||||
for (iteration = 0; iteration < 2; ++iteration)
|
||||
{
|
||||
Video->StartModeIterator(bits, fullscreen);
|
||||
|
||||
while (Video->NextMode(&twidth, &theight, NULL))
|
||||
{
|
||||
if (twidth == *width && theight == *height)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (iteration == 0 && (twidth < *width || theight < *height))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const uint32_t dist = (twidth - *width) * (twidth - *width)
|
||||
+ (theight - *height) * (theight - *height);
|
||||
|
||||
if (dist < closest)
|
||||
{
|
||||
closest = dist;
|
||||
cwidth = twidth;
|
||||
cheight = theight;
|
||||
}
|
||||
}
|
||||
|
||||
if (closest != uint32_t(-1))
|
||||
{
|
||||
*width = cwidth;
|
||||
*height = cheight;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool IVideo::SetResolution (int width, int height, int bits)
|
||||
{
|
||||
int oldwidth, oldheight;
|
||||
int oldbits;
|
||||
|
||||
if (screen)
|
||||
{
|
||||
oldwidth = SCREENWIDTH;
|
||||
oldheight = SCREENHEIGHT;
|
||||
oldbits = DisplayBits;
|
||||
}
|
||||
else
|
||||
{ // Harmless if screen wasn't allocated
|
||||
oldwidth = width;
|
||||
oldheight = height;
|
||||
oldbits = bits;
|
||||
}
|
||||
|
||||
V_ClosestResolution (&width, &height, bits);
|
||||
if (!V_CheckResolution (width, height, bits))
|
||||
{ // Try specified resolution
|
||||
if (!V_CheckResolution (oldwidth, oldheight, oldbits))
|
||||
{ // Try previous resolution (if any)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = oldwidth;
|
||||
height = oldheight;
|
||||
bits = oldbits;
|
||||
}
|
||||
}
|
||||
return V_DoModeSetup (width, height, bits);
|
||||
}
|
||||
|
||||
CCMD (vid_setmode)
|
||||
{
|
||||
int width = 0, height = SCREENHEIGHT;
|
||||
int bits = DisplayBits;
|
||||
|
||||
if (argv.argc() > 1)
|
||||
{
|
||||
width = atoi (argv[1]);
|
||||
if (argv.argc() > 2)
|
||||
{
|
||||
height = atoi (argv[2]);
|
||||
if (argv.argc() > 3)
|
||||
{
|
||||
bits = atoi (argv[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const bool goodmode = (width > 0 && height > 0)
|
||||
&& (!fullscreen || (Video != nullptr && V_CheckResolution(width, height, bits)));
|
||||
|
||||
if (goodmode)
|
||||
{
|
||||
// The actual change of resolution will take place
|
||||
// near the beginning of D_Display().
|
||||
if (gamestate != GS_STARTUP)
|
||||
{
|
||||
setmodeneeded = true;
|
||||
NewWidth = width;
|
||||
NewHeight = height;
|
||||
NewBits = bits;
|
||||
}
|
||||
}
|
||||
else if (width)
|
||||
{
|
||||
Printf ("Unknown resolution %d x %d x %d\n", width, height, bits);
|
||||
}
|
||||
else
|
||||
{
|
||||
Printf ("Usage: vid_setmode <width> <height> <mode>\n");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -1316,8 +1149,6 @@ void V_Init (bool restart)
|
|||
|
||||
void V_Init2()
|
||||
{
|
||||
int width = screen->GetWidth();
|
||||
int height = screen->GetHeight();
|
||||
float gamma = static_cast<DDummyFrameBuffer *>(screen)->Gamma;
|
||||
|
||||
{
|
||||
|
@ -1326,18 +1157,20 @@ void V_Init2()
|
|||
delete s;
|
||||
}
|
||||
|
||||
I_InitGraphics();
|
||||
V_ClosestResolution (&width, &height, 8);
|
||||
UCVarValue val;
|
||||
|
||||
if (!Video->SetResolution (width, height, 8))
|
||||
I_FatalError ("Could not set resolution to %d x %d x %d", width, height, 8);
|
||||
else
|
||||
Printf ("Resolution: %d x %d\n", SCREENWIDTH, SCREENHEIGHT);
|
||||
val.Bool = !!Args->CheckParm("-devparm");
|
||||
ticker.SetGenericRepDefault(val, CVAR_Bool);
|
||||
|
||||
|
||||
I_InitGraphics();
|
||||
|
||||
Video->SetResolution(); // this only fails via exceptions.
|
||||
Printf ("Resolution: %d x %d\n", SCREENWIDTH, SCREENHEIGHT);
|
||||
|
||||
screen->SetGamma ();
|
||||
FBaseCVar::ResetColors ();
|
||||
C_NewModeAdjust();
|
||||
M_InitVideoModesMenu();
|
||||
setsizeneeded = true;
|
||||
}
|
||||
|
||||
|
@ -1522,6 +1355,11 @@ void IVideo::DumpAdapters ()
|
|||
Printf("Multi-monitor support unavailable.\n");
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, fullscreen, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||
{
|
||||
setmodeneeded = true;
|
||||
}
|
||||
|
||||
CCMD(vid_listadapters)
|
||||
{
|
||||
if (Video != NULL)
|
||||
|
|
|
@ -81,9 +81,8 @@ struct IntRect
|
|||
|
||||
extern int CleanWidth, CleanHeight, CleanXfac, CleanYfac;
|
||||
extern int CleanWidth_1, CleanHeight_1, CleanXfac_1, CleanYfac_1;
|
||||
extern int DisplayWidth, DisplayHeight, DisplayBits;
|
||||
extern int DisplayWidth, DisplayHeight;
|
||||
|
||||
bool V_DoModeSetup (int width, int height, int bits);
|
||||
void V_UpdateModeSize (int width, int height);
|
||||
void V_OutputResized (int width, int height);
|
||||
void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int realheight, int *cleanx, int *cleany, int *cx1=NULL, int *cx2=NULL);
|
||||
|
@ -339,9 +338,10 @@ protected:
|
|||
void BuildGammaTable(uint16_t *gt);
|
||||
|
||||
F2DDrawer m2DDrawer;
|
||||
private:
|
||||
int Width = 0;
|
||||
int Height = 0;
|
||||
bool Bgra = 0;
|
||||
protected:
|
||||
int clipleft = 0, cliptop = 0, clipwidth = -1, clipheight = -1;
|
||||
|
||||
PalEntry Flash; // Only needed to support some cruft in the interface that only makes sense for the software renderer
|
||||
|
@ -358,9 +358,15 @@ public:
|
|||
IntRect mOutputLetterbox;
|
||||
|
||||
public:
|
||||
DFrameBuffer (int width, int height, bool bgra);
|
||||
DFrameBuffer (int width=1, int height=1);
|
||||
virtual ~DFrameBuffer() {}
|
||||
|
||||
void SetSize(int width, int height);
|
||||
void SetVirtualSize(int width, int height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
inline int GetWidth() const { return Width; }
|
||||
inline int GetHeight() const { return Height; }
|
||||
|
||||
|
@ -406,9 +412,6 @@ public:
|
|||
// Changes the vsync setting, if supported by the device.
|
||||
virtual void SetVSync (bool vsync);
|
||||
|
||||
// Tells the device to recreate itself with the new setting from vid_refreshrate.
|
||||
virtual void NewRefreshRate ();
|
||||
|
||||
// Delete any resources that need to be deleted after restarting with a different IWAD
|
||||
virtual void CleanForRestart() {}
|
||||
virtual void SetTextureFilterMode() {}
|
||||
|
@ -451,7 +454,6 @@ public:
|
|||
virtual bool WipeDo(int ticks);
|
||||
virtual void WipeCleanup();
|
||||
|
||||
virtual int GetTrueHeight() { return GetHeight(); }
|
||||
void ScaleCoordsFromWindow(int16_t &x, int16_t &y);
|
||||
|
||||
uint64_t GetLastFPS() const { return LastCount; }
|
||||
|
@ -526,17 +528,15 @@ public:
|
|||
virtual void GetScreenshotBuffer(const uint8_t *&buffer, int &pitch, ESSType &color_type, float &gamma) {}
|
||||
|
||||
// The original size of the framebuffer as selected in the video menu.
|
||||
int VideoWidth = 0;
|
||||
int VideoHeight = 0;
|
||||
uint64_t FrameTime = 0;
|
||||
|
||||
protected:
|
||||
void DrawRateStuff ();
|
||||
|
||||
DFrameBuffer () {}
|
||||
|
||||
private:
|
||||
uint64_t LastMS, LastSec, FrameCount, LastCount, LastTic;
|
||||
|
||||
uint64_t LastMS = 0, LastSec = 0, FrameCount = 0, LastCount = 0, LastTic = 0;
|
||||
|
||||
bool isIn2D = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -11,35 +11,33 @@ public:
|
|||
SystemFrameBuffer() {}
|
||||
// Actually, hMonitor is a HMONITOR, but it's passed as a void * as there
|
||||
// look to be some cross-platform bits in the way.
|
||||
SystemFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen, bool bgra);
|
||||
SystemFrameBuffer(void *hMonitor, bool fullscreen);
|
||||
virtual ~SystemFrameBuffer();
|
||||
|
||||
void SetVSync (bool vsync);
|
||||
void SwapBuffers();
|
||||
void NewRefreshRate ();
|
||||
|
||||
int GetClientWidth();
|
||||
int GetClientHeight();
|
||||
|
||||
int GetTrueHeight();
|
||||
|
||||
|
||||
bool IsFullscreen();
|
||||
|
||||
void InitializeState();
|
||||
|
||||
protected:
|
||||
|
||||
void PositionWindow();
|
||||
|
||||
void ResetGammaTable();
|
||||
void SetGammaTable(uint16_t * tbl);
|
||||
|
||||
float m_Gamma, m_Brightness, m_Contrast;
|
||||
uint16_t m_origGamma[768];
|
||||
bool m_supportsGamma;
|
||||
bool m_Fullscreen, m_Bgra;
|
||||
int m_Width, m_Height, m_Bits, m_RefreshHz;
|
||||
bool m_Fullscreen;
|
||||
char m_displayDeviceNameBuffer[32/*CCHDEVICENAME*/]; // do not use windows.h constants here!
|
||||
char *m_displayDeviceName;
|
||||
void *m_Monitor;
|
||||
int SwapInterval;
|
||||
|
||||
friend class Win32GLVideo;
|
||||
|
|
|
@ -43,10 +43,7 @@
|
|||
#include "version.h"
|
||||
#include "swrenderer/r_swrenderer.h"
|
||||
|
||||
EXTERN_CVAR (Bool, ticker)
|
||||
EXTERN_CVAR (Bool, fullscreen)
|
||||
EXTERN_CVAR (Float, vid_winscale)
|
||||
EXTERN_CVAR (Bool, win_borderless)
|
||||
|
||||
CVAR(Int, win_x, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Int, win_y, -1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
|
@ -54,8 +51,6 @@ CVAR(Bool, win_maximized, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
|||
|
||||
extern HWND Window;
|
||||
|
||||
bool ForceWindowed;
|
||||
|
||||
IVideo *Video;
|
||||
|
||||
// do not include GL headers here, only declare the necessary functions.
|
||||
|
@ -111,8 +106,6 @@ void I_ShutdownGraphics ()
|
|||
|
||||
void I_InitGraphics ()
|
||||
{
|
||||
UCVarValue val;
|
||||
|
||||
// todo: implement ATI version of this. this only works for nvidia notebooks, for now.
|
||||
currentgpuswitch = vid_gpuswitch;
|
||||
if (currentgpuswitch == 1)
|
||||
|
@ -135,8 +128,6 @@ void I_InitGraphics ()
|
|||
// not receive a WM_ACTIVATEAPP message, so both games think they
|
||||
// are the active app. Huh?
|
||||
}
|
||||
val.Bool = !!Args->CheckParm ("-devparm");
|
||||
ticker.SetGenericRepDefault (val, CVAR_Bool);
|
||||
|
||||
Video = gl_CreateVideo();
|
||||
|
||||
|
@ -144,46 +135,12 @@ void I_InitGraphics ()
|
|||
I_FatalError ("Failed to initialize display");
|
||||
|
||||
atterm (I_ShutdownGraphics);
|
||||
|
||||
Video->SetWindowedScale (vid_winscale);
|
||||
}
|
||||
|
||||
/** Remaining code is common to Win32 and Linux **/
|
||||
|
||||
// VIDEO WRAPPERS ---------------------------------------------------------
|
||||
|
||||
DFrameBuffer *I_SetMode (int &width, int &height, DFrameBuffer *old)
|
||||
{
|
||||
bool fs = false;
|
||||
switch (Video->GetDisplayType ())
|
||||
{
|
||||
case DISPLAY_WindowOnly:
|
||||
fs = false;
|
||||
break;
|
||||
case DISPLAY_FullscreenOnly:
|
||||
fs = true;
|
||||
break;
|
||||
case DISPLAY_Both:
|
||||
if (ForceWindowed)
|
||||
{
|
||||
fs = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
fs = fullscreen;
|
||||
}
|
||||
break;
|
||||
}
|
||||
DFrameBuffer *res = Video->CreateFrameBuffer (width, height, false, fs, old);
|
||||
|
||||
//* Right now, CreateFrameBuffer cannot return NULL
|
||||
if (res == NULL)
|
||||
{
|
||||
I_FatalError ("Mode %dx%d is unavailable\n", width, height);
|
||||
}
|
||||
//*/
|
||||
return res;
|
||||
}
|
||||
|
||||
static void GetCenteredPos (int &winx, int &winy, int &winw, int &winh, int &scrwidth, int &scrheight)
|
||||
{
|
||||
|
@ -290,85 +247,6 @@ void I_RestoreWindowedPos ()
|
|||
}
|
||||
MoveWindow (Window, winx, winy, winw, winh, TRUE);
|
||||
|
||||
if (win_borderless && !Args->CheckParm("-0"))
|
||||
{
|
||||
LONG lStyle = GetWindowLong(Window, GWL_STYLE);
|
||||
lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
|
||||
SetWindowLong(Window, GWL_STYLE, lStyle);
|
||||
SetWindowPos(Window, HWND_TOP, 0, 0, scrwidth, scrheight, 0);
|
||||
}
|
||||
if (win_maximized && !Args->CheckParm("-0"))
|
||||
ShowWindow(Window, SW_MAXIMIZE);
|
||||
}
|
||||
|
||||
extern int NewWidth, NewHeight, NewBits, DisplayBits;
|
||||
|
||||
CUSTOM_CVAR(Bool, win_borderless, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
|
||||
{
|
||||
// Just reinit the window. Saves a lot of trouble.
|
||||
if (!fullscreen)
|
||||
{
|
||||
NewWidth = screen->VideoWidth;
|
||||
NewHeight = screen->VideoHeight;
|
||||
NewBits = DisplayBits;
|
||||
setmodeneeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_CVAR (Bool, fullscreen, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL)
|
||||
{
|
||||
NewWidth = screen->VideoWidth;
|
||||
NewHeight = screen->VideoHeight;
|
||||
NewBits = DisplayBits;
|
||||
setmodeneeded = true;
|
||||
}
|
||||
|
||||
CUSTOM_CVAR (Float, vid_winscale, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (self < 1.f)
|
||||
{
|
||||
self = 1.f;
|
||||
}
|
||||
else if (Video)
|
||||
{
|
||||
Video->SetWindowedScale (self);
|
||||
NewWidth = screen->VideoWidth;
|
||||
NewHeight = screen->VideoHeight;
|
||||
NewBits = DisplayBits;
|
||||
//setmodeneeded = true; // This CVAR doesn't do anything and only causes problems!
|
||||
}
|
||||
}
|
||||
|
||||
CCMD (vid_listmodes)
|
||||
{
|
||||
static const char *ratios[7] = { "", " - 16:9", " - 16:10", " - 17:10", " - 5:4", " - 17:10", " - 21:9" };
|
||||
int width, height, bits;
|
||||
bool letterbox;
|
||||
|
||||
if (Video == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (bits = 1; bits <= 32; bits++)
|
||||
{
|
||||
Video->StartModeIterator (bits, screen->IsFullscreen());
|
||||
while (Video->NextMode (&width, &height, &letterbox))
|
||||
{
|
||||
bool thisMode = (width == DisplayWidth && height == DisplayHeight && bits == DisplayBits);
|
||||
int ratio = CheckRatio (width, height);
|
||||
Printf (thisMode ? PRINT_BOLD : PRINT_HIGH,
|
||||
"%s%4d x%5d x%3d%s%s\n",
|
||||
thisMode || !IsRatioWidescreen(ratio) ? "" : TEXTCOLOR_GOLD,
|
||||
width, height, bits,
|
||||
ratios[ratio],
|
||||
thisMode || !letterbox ? "" : TEXTCOLOR_BROWN " LB"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CCMD (vid_currentmode)
|
||||
{
|
||||
Printf ("%dx%dx%d\n", DisplayWidth, DisplayHeight, DisplayBits);
|
||||
}
|
||||
|
|
|
@ -37,27 +37,6 @@
|
|||
#include "i_video.h"
|
||||
#include "v_video.h"
|
||||
|
||||
class IVideo
|
||||
{
|
||||
public:
|
||||
virtual ~IVideo () {}
|
||||
|
||||
virtual EDisplayType GetDisplayType () = 0;
|
||||
virtual void SetWindowedScale (float scale) = 0;
|
||||
|
||||
virtual DFrameBuffer *CreateFrameBuffer (int width, int height, bool bgra, bool fs, DFrameBuffer *old) = 0;
|
||||
|
||||
virtual void StartModeIterator (int bits, bool fs) = 0;
|
||||
virtual bool NextMode (int *width, int *height, bool *letterbox) = 0;
|
||||
|
||||
virtual bool SetResolution (int width, int height, int bits);
|
||||
|
||||
virtual void DumpAdapters();
|
||||
};
|
||||
|
||||
void I_InitGraphics ();
|
||||
void I_ShutdownGraphics ();
|
||||
|
||||
void I_SaveWindowedPos ();
|
||||
void I_RestoreWindowedPos ();
|
||||
|
||||
|
@ -65,6 +44,4 @@ void I_SetFPSLimit(int limit);
|
|||
void I_FPSLimit();
|
||||
|
||||
|
||||
extern IVideo *Video;
|
||||
|
||||
#endif // __HARDWARE_H__
|
||||
|
|
|
@ -61,8 +61,6 @@ extern "C" {
|
|||
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
|
||||
}
|
||||
|
||||
extern int NewWidth, NewHeight, NewBits, DisplayBits;
|
||||
|
||||
// these get used before GLEW is initialized so we have to use separate pointers with different names
|
||||
PFNWGLCHOOSEPIXELFORMATARBPROC myWglChoosePixelFormatARB; // = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC myWglCreateContextAttribsARB;
|
||||
|
@ -83,10 +81,10 @@ CUSTOM_CVAR(Bool, vr_enable_quadbuffered, false, CVAR_ARCHIVE | CVAR_GLOBALCONFI
|
|||
Printf("You must restart " GAMENAME " to switch quad stereo mode\n");
|
||||
}
|
||||
|
||||
EXTERN_CVAR(Int, vid_refreshrate)
|
||||
EXTERN_CVAR(Int, vid_defwidth)
|
||||
EXTERN_CVAR(Int, vid_defheight)
|
||||
EXTERN_CVAR(Int, vid_adapter)
|
||||
EXTERN_CVAR(Bool, fullscreen)
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
@ -101,41 +99,14 @@ public:
|
|||
Win32GLVideo(int parm);
|
||||
virtual ~Win32GLVideo();
|
||||
|
||||
EDisplayType GetDisplayType() { return DISPLAY_Both; }
|
||||
void SetWindowedScale(float scale);
|
||||
void StartModeIterator(int bits, bool fs);
|
||||
bool NextMode(int *width, int *height, bool *letterbox);
|
||||
bool GoFullscreen(bool yes);
|
||||
DFrameBuffer *CreateFrameBuffer (int width, int height, bool bgra, bool fs, DFrameBuffer *old);
|
||||
virtual bool SetResolution(int width, int height, int bits);
|
||||
DFrameBuffer *CreateFrameBuffer ();
|
||||
void DumpAdapters();
|
||||
bool InitHardware(HWND Window, int multisample);
|
||||
void Shutdown();
|
||||
bool SetFullscreen(const char *devicename, int w, int h, int bits, int hz);
|
||||
|
||||
HDC m_hDC;
|
||||
|
||||
protected:
|
||||
struct ModeInfo
|
||||
{
|
||||
ModeInfo(int inX, int inY, int inBits, int inRealY, int inRefresh)
|
||||
: next(NULL),
|
||||
width(inX),
|
||||
height(inY),
|
||||
bits(inBits),
|
||||
refreshHz(inRefresh),
|
||||
realheight(inRealY)
|
||||
{}
|
||||
ModeInfo *next;
|
||||
int width, height, bits, refreshHz, realheight;
|
||||
} *m_Modes;
|
||||
|
||||
ModeInfo *m_IteratorMode;
|
||||
int m_IteratorBits;
|
||||
bool m_IteratorFS;
|
||||
bool m_IsFullscreen;
|
||||
int m_trueHeight;
|
||||
int m_DisplayWidth, m_DisplayHeight, m_DisplayBits, m_DisplayHz;
|
||||
HMODULE hmRender;
|
||||
|
||||
char m_DisplayDeviceBuffer[CCHDEVICENAME];
|
||||
|
@ -151,11 +122,7 @@ protected:
|
|||
bool SetupPixelFormat(int multisample);
|
||||
|
||||
void GetDisplayDeviceName();
|
||||
void MakeModesList();
|
||||
void AddMode(int x, int y, int bits, int baseHeight, int refreshHz);
|
||||
void FreeModes();
|
||||
public:
|
||||
int GetTrueHeight() { return m_trueHeight; }
|
||||
|
||||
};
|
||||
|
||||
|
@ -165,16 +132,11 @@ public:
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
Win32GLVideo::Win32GLVideo(int parm) : m_Modes(NULL), m_IsFullscreen(false)
|
||||
Win32GLVideo::Win32GLVideo(int parm)
|
||||
{
|
||||
I_SetWndProc();
|
||||
m_DisplayWidth = vid_defwidth;
|
||||
m_DisplayHeight = vid_defheight;
|
||||
m_DisplayBits = 32;
|
||||
m_DisplayHz = 60;
|
||||
|
||||
GetDisplayDeviceName();
|
||||
MakeModesList();
|
||||
SetPixelFormat();
|
||||
|
||||
}
|
||||
|
@ -187,7 +149,6 @@ Win32GLVideo::Win32GLVideo(int parm) : m_Modes(NULL), m_IsFullscreen(false)
|
|||
|
||||
Win32GLVideo::~Win32GLVideo()
|
||||
{
|
||||
FreeModes();
|
||||
if (GLRenderer != NULL) GLRenderer->FlushTextures();
|
||||
}
|
||||
|
||||
|
@ -197,16 +158,6 @@ Win32GLVideo::~Win32GLVideo()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void Win32GLVideo::SetWindowedScale(float scale)
|
||||
{
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
struct MonitorEnumState
|
||||
{
|
||||
int curIdx;
|
||||
|
@ -280,227 +231,11 @@ void Win32GLVideo::GetDisplayDeviceName()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void Win32GLVideo::MakeModesList()
|
||||
{
|
||||
ModeInfo *pMode, *nextmode;
|
||||
DEVMODE dm;
|
||||
int mode = 0;
|
||||
|
||||
memset(&dm, 0, sizeof(DEVMODE));
|
||||
dm.dmSize = sizeof(DEVMODE);
|
||||
|
||||
while (EnumDisplaySettings(m_DisplayDeviceName, mode, &dm))
|
||||
{
|
||||
this->AddMode(dm.dmPelsWidth, dm.dmPelsHeight, dm.dmBitsPerPel, dm.dmPelsHeight, dm.dmDisplayFrequency);
|
||||
++mode;
|
||||
}
|
||||
|
||||
for (pMode = m_Modes; pMode != NULL; pMode = nextmode)
|
||||
{
|
||||
nextmode = pMode->next;
|
||||
if (pMode->realheight == pMode->height && pMode->height * 4/3 == pMode->width)
|
||||
{
|
||||
if (pMode->width >= 360)
|
||||
{
|
||||
AddMode (pMode->width, pMode->width * 9/16, pMode->bits, pMode->height, pMode->refreshHz);
|
||||
}
|
||||
if (pMode->width > 640)
|
||||
{
|
||||
AddMode (pMode->width, pMode->width * 10/16, pMode->bits, pMode->height, pMode->refreshHz);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void Win32GLVideo::StartModeIterator(int bits, bool fs)
|
||||
{
|
||||
m_IteratorMode = m_Modes;
|
||||
// I think it's better to ignore the game-side settings of bit depth.
|
||||
// The GL renderer will always default to 32 bits because 16 bit modes cannot have a stencil buffer.
|
||||
m_IteratorBits = 32;
|
||||
m_IteratorFS = fs;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool Win32GLVideo::NextMode(int *width, int *height, bool *letterbox)
|
||||
{
|
||||
if (m_IteratorMode)
|
||||
{
|
||||
while (m_IteratorMode && m_IteratorMode->bits != m_IteratorBits)
|
||||
{
|
||||
m_IteratorMode = m_IteratorMode->next;
|
||||
}
|
||||
|
||||
if (m_IteratorMode)
|
||||
{
|
||||
*width = m_IteratorMode->width;
|
||||
*height = m_IteratorMode->height;
|
||||
if (letterbox != NULL) *letterbox = m_IteratorMode->realheight != m_IteratorMode->height;
|
||||
m_IteratorMode = m_IteratorMode->next;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void Win32GLVideo::AddMode(int x, int y, int bits, int baseHeight, int refreshHz)
|
||||
{
|
||||
ModeInfo **probep = &m_Modes;
|
||||
ModeInfo *probe = m_Modes;
|
||||
|
||||
// This mode may have been already added to the list because it is
|
||||
// enumerated multiple times at different refresh rates. If it's
|
||||
// not present, add it to the right spot in the list; otherwise, do nothing.
|
||||
// Modes are sorted first by width, then by height, then by depth. In each
|
||||
// case the order is ascending.
|
||||
if (bits < 32) return;
|
||||
for (; probe != 0; probep = &probe->next, probe = probe->next)
|
||||
{
|
||||
if (probe->width != x) continue;
|
||||
// Width is equal
|
||||
if (probe->height != y) continue;
|
||||
// Width is equal
|
||||
if (probe->realheight != baseHeight) continue;
|
||||
// Height is equal
|
||||
if (probe->bits != bits) continue;
|
||||
// Bits is equal
|
||||
if (probe->refreshHz > refreshHz) return;
|
||||
probe->refreshHz = refreshHz;
|
||||
return;
|
||||
}
|
||||
|
||||
*probep = new ModeInfo (x, y, bits, baseHeight, refreshHz);
|
||||
(*probep)->next = probe;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void Win32GLVideo::FreeModes()
|
||||
{
|
||||
ModeInfo *mode = m_Modes;
|
||||
|
||||
while (mode)
|
||||
{
|
||||
ModeInfo *tempmode = mode;
|
||||
mode = mode->next;
|
||||
delete tempmode;
|
||||
}
|
||||
|
||||
m_Modes = NULL;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool Win32GLVideo::GoFullscreen(bool yes)
|
||||
{
|
||||
m_IsFullscreen = yes;
|
||||
|
||||
m_trueHeight = m_DisplayHeight;
|
||||
|
||||
if (yes)
|
||||
{
|
||||
// If in windowed mode, any height is good.
|
||||
for (ModeInfo *mode = m_Modes; mode != NULL; mode = mode->next)
|
||||
{
|
||||
if (mode->width == m_DisplayWidth && mode->height == m_DisplayHeight)
|
||||
{
|
||||
m_trueHeight = mode->realheight;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (yes)
|
||||
{
|
||||
SetFullscreen(m_DisplayDeviceName, m_DisplayWidth, m_trueHeight, m_DisplayBits, m_DisplayHz);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFullscreen(m_DisplayDeviceName, 0,0,0,0);
|
||||
}
|
||||
return yes;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
void V_ClosestResolution(int *width, int *height, int bits);
|
||||
|
||||
|
||||
DFrameBuffer *Win32GLVideo::CreateFrameBuffer(int width, int height, bool bgra, bool fs, DFrameBuffer *old)
|
||||
DFrameBuffer *Win32GLVideo::CreateFrameBuffer()
|
||||
{
|
||||
SystemFrameBuffer *fb;
|
||||
|
||||
if (fs)
|
||||
{
|
||||
V_ClosestResolution(&width, &height, 32);
|
||||
}
|
||||
|
||||
m_DisplayWidth = width;
|
||||
m_DisplayHeight = height;
|
||||
m_DisplayBits = 32;
|
||||
m_DisplayHz = 60;
|
||||
|
||||
if (vid_refreshrate == 0)
|
||||
{
|
||||
for (ModeInfo *mode = m_Modes; mode != NULL; mode = mode->next)
|
||||
{
|
||||
if (mode->width == m_DisplayWidth && mode->height == m_DisplayHeight && mode->bits == m_DisplayBits)
|
||||
{
|
||||
m_DisplayHz = MAX<int>(m_DisplayHz, mode->refreshHz);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_DisplayHz = vid_refreshrate;
|
||||
}
|
||||
|
||||
if (old != NULL)
|
||||
{ // Reuse the old framebuffer if its attributes are the same
|
||||
fb = static_cast<SystemFrameBuffer *> (old);
|
||||
if (fb->m_Width == m_DisplayWidth &&
|
||||
fb->m_Height == m_DisplayHeight &&
|
||||
fb->m_Bits == m_DisplayBits &&
|
||||
fb->m_RefreshHz == m_DisplayHz &&
|
||||
fb->m_Fullscreen == fs &&
|
||||
fb->m_Bgra == bgra)
|
||||
{
|
||||
return old;
|
||||
}
|
||||
//old->GetFlash(flashColor, flashAmount);
|
||||
delete old;
|
||||
}
|
||||
fb = new OpenGLFrameBuffer(m_hMonitor, m_DisplayWidth, m_DisplayHeight, m_DisplayBits, m_DisplayHz, fs);
|
||||
fb = new OpenGLFrameBuffer(m_hMonitor, fullscreen);
|
||||
return fb;
|
||||
}
|
||||
|
||||
|
@ -510,26 +245,6 @@ DFrameBuffer *Win32GLVideo::CreateFrameBuffer(int width, int height, bool bgra,
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool Win32GLVideo::SetResolution (int width, int height, int bits)
|
||||
{
|
||||
if (GLRenderer != NULL) GLRenderer->FlushTextures();
|
||||
I_ShutdownGraphics();
|
||||
|
||||
Video = new Win32GLVideo(0);
|
||||
if (Video == NULL) I_FatalError ("Failed to initialize display");
|
||||
|
||||
bits=32;
|
||||
|
||||
V_DoModeSetup(width, height, bits);
|
||||
return true; // We must return true because the old video context no longer exists.
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
struct DumpAdaptersState
|
||||
{
|
||||
unsigned index;
|
||||
|
@ -936,84 +651,35 @@ void Win32GLVideo::Shutdown()
|
|||
if (m_hDC) ReleaseDC(m_Window, m_hDC);
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool Win32GLVideo::SetFullscreen(const char *devicename, int w, int h, int bits, int hz)
|
||||
void SystemFrameBuffer::PositionWindow()
|
||||
{
|
||||
DEVMODE dm;
|
||||
|
||||
if (w==0)
|
||||
{
|
||||
ChangeDisplaySettingsEx(devicename, 0, 0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
dm.dmSize = sizeof(DEVMODE);
|
||||
dm.dmSpecVersion = DM_SPECVERSION;//Somebody owes me...
|
||||
dm.dmDriverExtra = 0;//...1 hour of my life back
|
||||
dm.dmPelsWidth = w;
|
||||
dm.dmPelsHeight = h;
|
||||
dm.dmBitsPerPel = bits;
|
||||
dm.dmDisplayFrequency = hz;
|
||||
dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY;
|
||||
if (DISP_CHANGE_SUCCESSFUL != ChangeDisplaySettingsEx(devicename, &dm, 0, CDS_FULLSCREEN, 0))
|
||||
{
|
||||
dm.dmFields &= ~DM_DISPLAYFREQUENCY;
|
||||
return DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettingsEx(devicename, &dm, 0, CDS_FULLSCREEN, 0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
SystemFrameBuffer::SystemFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen, bool bgra) : DFrameBuffer(width, height, bgra)
|
||||
{
|
||||
m_Width = width;
|
||||
m_Height = height;
|
||||
m_Bits = bits;
|
||||
m_RefreshHz = refreshHz;
|
||||
m_Fullscreen = fullscreen;
|
||||
m_Bgra = bgra;
|
||||
|
||||
RECT r;
|
||||
LONG style, exStyle;
|
||||
|
||||
static_cast<Win32GLVideo *>(Video)->GoFullscreen(fullscreen);
|
||||
RECT monRect;
|
||||
|
||||
m_displayDeviceName = 0;
|
||||
int monX = 0, monY = 0;
|
||||
|
||||
if (hMonitor)
|
||||
if (m_Monitor)
|
||||
{
|
||||
MONITORINFOEX mi;
|
||||
mi.cbSize = sizeof mi;
|
||||
|
||||
if (GetMonitorInfo(HMONITOR(hMonitor), &mi))
|
||||
if (GetMonitorInfo(HMONITOR(m_Monitor), &mi))
|
||||
{
|
||||
strcpy(m_displayDeviceNameBuffer, mi.szDevice);
|
||||
m_displayDeviceName = m_displayDeviceNameBuffer;
|
||||
|
||||
monX = int(mi.rcMonitor.left);
|
||||
monY = int(mi.rcMonitor.top);
|
||||
monRect = mi.rcMonitor;
|
||||
}
|
||||
}
|
||||
|
||||
ShowWindow (Window, SW_SHOW);
|
||||
ShowWindow(Window, SW_SHOW);
|
||||
|
||||
GetWindowRect(Window, &r);
|
||||
style = WS_VISIBLE | WS_CLIPSIBLINGS;
|
||||
exStyle = 0;
|
||||
|
@ -1032,7 +698,7 @@ SystemFrameBuffer::SystemFrameBuffer(void *hMonitor, int width, int height, int
|
|||
|
||||
if (fullscreen)
|
||||
{
|
||||
MoveWindow(Window, monX, monY, width, GetTrueHeight(), FALSE);
|
||||
MoveWindow(Window, monRect.left, monRect.top, monRect.right-monRect.left, monRect.bottom-monRect.top, FALSE);
|
||||
|
||||
// And now, seriously, it IS in the right place. Promise.
|
||||
}
|
||||
|
@ -1041,13 +707,31 @@ SystemFrameBuffer::SystemFrameBuffer(void *hMonitor, int width, int height, int
|
|||
RECT windowRect;
|
||||
windowRect.left = r.left;
|
||||
windowRect.top = r.top;
|
||||
windowRect.right = windowRect.left + width;
|
||||
windowRect.bottom = windowRect.top + height;
|
||||
windowRect.right = windowRect.left + vid_defwidth;
|
||||
windowRect.bottom = windowRect.top + vid_defheight;
|
||||
AdjustWindowRectEx(&windowRect, style, FALSE, exStyle);
|
||||
MoveWindow(Window, windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, FALSE);
|
||||
|
||||
I_RestoreWindowedPos();
|
||||
}
|
||||
SetSize(GetClientWidth(), GetClientHeight());
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
SystemFrameBuffer::SystemFrameBuffer(void *hMonitor, bool fullscreen) : DFrameBuffer(vid_defwidth, vid_defheight)
|
||||
{
|
||||
m_Monitor = hMonitor;
|
||||
m_Fullscreen = fullscreen;
|
||||
|
||||
|
||||
m_displayDeviceName = 0;
|
||||
PositionWindow();
|
||||
|
||||
|
||||
if (!static_cast<Win32GLVideo *>(Video)->InitHardware(Window, 0))
|
||||
{
|
||||
|
@ -1096,8 +780,6 @@ SystemFrameBuffer::~SystemFrameBuffer()
|
|||
ResetGammaTable();
|
||||
I_SaveWindowedPos();
|
||||
|
||||
static_cast<Win32GLVideo *>(Video)->SetFullscreen(m_displayDeviceName, 0,0,0,0);
|
||||
|
||||
ShowWindow (Window, SW_SHOW);
|
||||
SetWindowLong(Window, GWL_STYLE, WS_VISIBLE | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW);
|
||||
SetWindowLong(Window, GWL_EXSTYLE, WS_EX_WINDOWEDGE);
|
||||
|
@ -1184,17 +866,6 @@ void SystemFrameBuffer::SwapBuffers()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void SystemFrameBuffer::NewRefreshRate ()
|
||||
{
|
||||
if (m_Fullscreen)
|
||||
{
|
||||
setmodeneeded = true;
|
||||
NewWidth = screen->VideoWidth;
|
||||
NewHeight = screen->VideoHeight;
|
||||
NewBits = DisplayBits;
|
||||
}
|
||||
}
|
||||
|
||||
int SystemFrameBuffer::GetClientWidth()
|
||||
{
|
||||
RECT rect = { 0 };
|
||||
|
@ -1209,11 +880,6 @@ int SystemFrameBuffer::GetClientHeight()
|
|||
return rect.bottom - rect.top;
|
||||
}
|
||||
|
||||
int SystemFrameBuffer::GetTrueHeight()
|
||||
{
|
||||
return static_cast<Win32GLVideo *>(Video)->GetTrueHeight();
|
||||
}
|
||||
|
||||
IVideo *gl_CreateVideo()
|
||||
{
|
||||
return new Win32GLVideo(0);
|
||||
|
|
|
@ -1904,31 +1904,10 @@ OptionMenu VideoModeMenu protected
|
|||
Option "$VIDMNU_HIDPI", "vid_hidpi", "YesNo"
|
||||
}
|
||||
|
||||
IfOption(Windows)
|
||||
{
|
||||
Option "$VIDMNU_BRDLSS", "win_borderless", "YesNo"
|
||||
}
|
||||
|
||||
Option "$VIDMNU_ASPECTRATIO", "menu_screenratios", "Ratios"
|
||||
Option "$VIDMNU_FORCEASPECT", "vid_aspect", "ForceRatios"
|
||||
Option "$VIDMNU_CROPASPECT", "vid_cropaspect", "CropAspect"
|
||||
Option "$VIDMNU_SCALEMODE", "vid_scalemode", "ScaleModes"
|
||||
Slider "$VIDMNU_SCALEFACTOR", "vid_scalefactor", 0.25, 2.0, 0.25, 2
|
||||
StaticText " "
|
||||
ScreenResolution "res_0"
|
||||
ScreenResolution "res_1"
|
||||
ScreenResolution "res_2"
|
||||
ScreenResolution "res_3"
|
||||
ScreenResolution "res_4"
|
||||
ScreenResolution "res_5"
|
||||
ScreenResolution "res_6"
|
||||
ScreenResolution "res_7"
|
||||
ScreenResolution "res_8"
|
||||
ScreenResolution "res_9"
|
||||
StaticTextSwitchable "$VIDMNU_ENTERTEXT", "", "VMEnterText"
|
||||
StaticText " "
|
||||
StaticTextSwitchable "$VIDMNU_TESTTEXT1", "$VIDMNU_TESTTEXT2", "VMTestText"
|
||||
class VideoModeMenu
|
||||
}
|
||||
|
||||
/*=======================================
|
||||
|
|
|
@ -23,7 +23,6 @@ version "3.4"
|
|||
#include "zscript/menu/playerdisplay.txt"
|
||||
#include "zscript/menu/playercontrols.txt"
|
||||
#include "zscript/menu/textentermenu.txt"
|
||||
#include "zscript/menu/videomenu.txt"
|
||||
#include "zscript/menu/readthis.txt"
|
||||
#include "zscript/menu/conversationmenu.txt"
|
||||
#include "zscript/menu/reverbedit.txt"
|
||||
|
|
|
@ -92,7 +92,6 @@ class Menu : Object native ui version("2.4")
|
|||
native bool DontDim;
|
||||
|
||||
native static int MenuTime();
|
||||
native static void SetVideoMode();
|
||||
native static Menu GetCurrentMenu();
|
||||
native static clearscope void SetMenu(Name mnu, int param = 0); // This is not 100% safe but needs to be available - but always make sure to check that only the desired player opens it!
|
||||
native static void StartMessage(String msg, int mode = 0, Name command = 'none');
|
||||
|
|
|
@ -937,143 +937,6 @@ class OptionMenuItemColorPicker : OptionMenuItem
|
|||
}
|
||||
}
|
||||
|
||||
class OptionMenuItemScreenResolution : OptionMenuItem
|
||||
{
|
||||
String mResTexts[3];
|
||||
int mSelection;
|
||||
int mHighlight;
|
||||
int mMaxValid;
|
||||
|
||||
enum EValues
|
||||
{
|
||||
SRL_INDEX = 0x30000,
|
||||
SRL_SELECTION = 0x30003,
|
||||
SRL_HIGHLIGHT = 0x30004,
|
||||
};
|
||||
|
||||
OptionMenuItemScreenResolution Init(String command)
|
||||
{
|
||||
Super.Init("", command);
|
||||
mSelection = 0;
|
||||
mHighlight = -1;
|
||||
return self;
|
||||
}
|
||||
|
||||
override bool SetValue(int i, int v)
|
||||
{
|
||||
if (i == SRL_SELECTION)
|
||||
{
|
||||
mSelection = v;
|
||||
return true;
|
||||
}
|
||||
else if (i == SRL_HIGHLIGHT)
|
||||
{
|
||||
mHighlight = v;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override bool, int GetValue(int i)
|
||||
{
|
||||
if (i == SRL_SELECTION)
|
||||
{
|
||||
return true, mSelection;
|
||||
}
|
||||
return false, 0;
|
||||
}
|
||||
|
||||
override bool SetString(int i, String newtext)
|
||||
{
|
||||
if (i >= SRL_INDEX && i <= SRL_INDEX+2)
|
||||
{
|
||||
mResTexts[i-SRL_INDEX] = newtext;
|
||||
if (mResTexts[0].Length() == 0) mMaxValid = -1;
|
||||
else if (mResTexts[1].Length() == 0) mMaxValid = 0;
|
||||
else if (mResTexts[2].Length() == 0) mMaxValid = 1;
|
||||
else mMaxValid = 2;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override bool, String GetString(int i)
|
||||
{
|
||||
if (i >= SRL_INDEX && i <= SRL_INDEX+2)
|
||||
{
|
||||
return true, mResTexts[i-SRL_INDEX];
|
||||
}
|
||||
return false, "";
|
||||
}
|
||||
|
||||
override bool MenuEvent (int mkey, bool fromcontroller)
|
||||
{
|
||||
if (mkey == Menu.MKEY_Left)
|
||||
{
|
||||
if (--mSelection < 0) mSelection = mMaxValid;
|
||||
Menu.MenuSound ("menu/cursor");
|
||||
return true;
|
||||
}
|
||||
else if (mkey == Menu.MKEY_Right)
|
||||
{
|
||||
if (++mSelection > mMaxValid) mSelection = 0;
|
||||
Menu.MenuSound ("menu/cursor");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Super.MenuEvent(mkey, fromcontroller);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override bool MouseEvent(int type, int x, int y)
|
||||
{
|
||||
int colwidth = screen.GetWidth() / 3;
|
||||
mSelection = x / colwidth;
|
||||
return Super.MouseEvent(type, x, y);
|
||||
}
|
||||
|
||||
override bool Activate()
|
||||
{
|
||||
Menu.MenuSound("menu/choose");
|
||||
Menu.SetVideoMode();
|
||||
return true;
|
||||
}
|
||||
|
||||
override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected)
|
||||
{
|
||||
int colwidth = screen.GetWidth() / 3;
|
||||
int col;
|
||||
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
if (selected && mSelection == x)
|
||||
col = OptionMenuSettings.mFontColorSelection;
|
||||
else if (x == mHighlight)
|
||||
col = OptionMenuSettings.mFontColorHighlight;
|
||||
else
|
||||
col = OptionMenuSettings.mFontColorValue;
|
||||
|
||||
screen.DrawText (SmallFont, col, colwidth * x + 20 * CleanXfac_1, y, mResTexts[x], DTA_CleanNoMove_1, true);
|
||||
}
|
||||
return colwidth * mSelection + 20 * CleanXfac_1 - CursorSpace();
|
||||
}
|
||||
|
||||
override bool Selectable()
|
||||
{
|
||||
return mMaxValid >= 0;
|
||||
}
|
||||
|
||||
override void Ticker()
|
||||
{
|
||||
if (Selectable() && mSelection > mMaxValid)
|
||||
{
|
||||
mSelection = mMaxValid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// [TP] OptionMenuFieldBase
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
** videomenu.txt
|
||||
** The video modes menu
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2001-2010 Randy Heit
|
||||
** Copyright 2010-2017 Christoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
class VideoModeMenu : OptionMenu
|
||||
{
|
||||
native static bool SetSelectedSize();
|
||||
|
||||
override bool MenuEvent(int mkey, bool fromcontroller)
|
||||
{
|
||||
if ((mkey == MKEY_Up || mkey == MKEY_Down) && mDesc.mSelectedItem >= 0 && mDesc.mSelectedItem < mDesc.mItems.Size())
|
||||
{
|
||||
int sel;
|
||||
bool selected;
|
||||
[selected, sel] = mDesc.mItems[mDesc.mSelectedItem].GetValue(OptionMenuItemScreenResolution.SRL_SELECTION);
|
||||
bool res = Super.MenuEvent(mkey, fromcontroller);
|
||||
if (selected) mDesc.mItems[mDesc.mSelectedItem].SetValue(OptionMenuItemScreenResolution.SRL_SELECTION, sel);
|
||||
return res;
|
||||
}
|
||||
return Super.MenuEvent(mkey, fromcontroller);
|
||||
}
|
||||
|
||||
override bool OnUIEvent(UIEvent ev)
|
||||
{
|
||||
if (ev.Type == UIEvent.Type_KeyDown && (ev.KeyChar == 0x54 || ev.KeyChar == 0x74))
|
||||
{
|
||||
if (SetSelectedSize())
|
||||
{
|
||||
MenuSound ("menu/choose");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return Super.OnUIEvent(ev);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in a new issue