OpenGL: OSD menu live resolution change fixes

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4212 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2009-09-06 15:11:21 +00:00
parent a3345ea942
commit 1320e21ded
8 changed files with 110 additions and 66 deletions

View File

@ -39,24 +39,32 @@ extern int OSDChoice, OSDTime, OSDInternalW, OSDInternalH;
class Renderer
{
public:
static bool Init();
static void Shutdown();
static bool Init();
static void Shutdown();
// What's the real difference between these? Too similar names.
static void ResetAPIState();
static void RestoreAPIState();
static void ResetAPIState();
static void RestoreAPIState();
static void ReinitView();
static void ReinitView();
static void SwapBuffers();
static void SetColorMask();
static void SetColorMask();
static void SetBlendMode(bool forceUpdate);
static bool SetScissorRect();
// Live resolution change
static bool Allow2x();
static bool AllowCustom();
// Render target management
static int GetTargetWidth();
static int GetTargetHeight();
static int GetFrameBufferWidth();
static int GetFrameBufferHeight();
static int GetCustomWidth();
static int GetCustomHeight();
static int GetTargetWidth();
static int GetTargetHeight();
// Multiply any 2D EFB coordinates by these when rendering.
static float GetTargetScaleX();

View File

@ -103,7 +103,6 @@ float Renderer::GetTargetScaleX()
{
return xScale;
}
float Renderer::GetTargetScaleY()
{
return yScale;

View File

@ -25,7 +25,7 @@ Config g_Config;
Config::Config()
{
bAllow2xResolution = true;
bRunning = false;
}
void Config::Load()

View File

@ -59,7 +59,7 @@ struct Config
char iFSResolution[16];
char iInternalRes[16];
bool bNativeResolution, b2xResolution, bAllow2xResolution; // Should possibly be augmented with 2x, 4x native.
bool bNativeResolution, b2xResolution, bRunning; // Should possibly be augmented with 2x, 4x native.
bool bWidescreenHack;
bool bKeepAR43, bKeepAR169, bCrop; // Aspect ratio controls.
bool bUseXFB;

View File

@ -23,14 +23,15 @@
#include <wx/mimetype.h>
#include "ConfigDlg.h"
#include "FileUtil.h"
#include "../Globals.h"
#include "../Config.h"
#include "../TextureMngr.h"
#include "VertexShaderManager.h"
#include "../PostProcessing.h"
#include "GlobalControl.h"
#include "Render.h"
#include "FileUtil.h"
BEGIN_EVENT_TABLE(GFXConfigDialogOGL,wxDialog)
EVT_CLOSE(GFXConfigDialogOGL::OnClose)
@ -176,16 +177,16 @@ void GFXConfigDialogOGL::CreateGUIControls()
// General Display Settings
sbBasic = new wxStaticBoxSizer(wxVERTICAL, m_PageGeneral, wxT("Basic Display Settings"));
m_RenderToMainWindow = new wxCheckBox(m_PageGeneral, ID_RENDERTOMAINWINDOW, wxT("Render to main window"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_RenderToMainWindow = new wxCheckBox(m_PageGeneral, ID_RENDERTOMAINWINDOW, wxT("Child window"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_RenderToMainWindow->SetValue(g_Config.RenderToMainframe);
m_NativeResolution = new wxCheckBox(m_PageGeneral, ID_NATIVERESOLUTION, wxT("Native"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_2xResolution = new wxCheckBox(m_PageGeneral, ID_2X_RESOLUTION, wxT("2x"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_WidescreenHack = new wxCheckBox(m_PageGeneral, ID_WIDESCREEN_HACK, wxT("Wide Screen Hack"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_WidescreenHack = new wxCheckBox(m_PageGeneral, ID_WIDESCREEN_HACK, wxT("Wide screen hack"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
wxStaticText *IRText = new wxStaticText(m_PageGeneral, ID_IRTEXT, wxT("Native resolution:"), wxDefaultPosition, wxDefaultSize, 0);
wxStaticText *RText = new wxStaticText(m_PageGeneral, ID_RTEXT, wxT("Custom resolution:"), wxDefaultPosition, wxDefaultSize, 0);
wxStaticText *WMText = new wxStaticText(m_PageGeneral, ID_WMTEXT, wxT("Window mode:"), wxDefaultPosition, wxDefaultSize , 0 );
wxStaticText *WM2Text = new wxStaticText(m_PageGeneral, ID_WM2TEXT, wxT("Window mode:"), wxDefaultPosition, wxDefaultSize , 0 );
wxStaticText *FMText = new wxStaticText(m_PageGeneral, ID_FMTEXT, wxT("Fullscreen mode:"), wxDefaultPosition, wxDefaultSize , 0 );
wxStaticText *FMText = new wxStaticText(m_PageGeneral, ID_FMTEXT, wxT("Separate window:"), wxDefaultPosition, wxDefaultSize , 0 );
m_WindowResolutionCB = new wxComboBox(m_PageGeneral, ID_WINDOWRESOLUTIONCB, arrayStringFor_WindowResolutionCB[0], wxDefaultPosition, wxDefaultSize, arrayStringFor_WindowResolutionCB, wxCB_READONLY, wxDefaultValidator);
m_WindowResolutionCB->SetValue(wxString::FromAscii(g_Config.iInternalRes));
m_WindowFSResolutionCB = new wxComboBox(m_PageGeneral, ID_WINDOWFSRESOLUTIONCB, arrayStringFor_FullscreenCB[0], wxDefaultPosition, wxDefaultSize, arrayStringFor_FullscreenCB, wxCB_READONLY, wxDefaultValidator);
@ -210,8 +211,6 @@ void GFXConfigDialogOGL::CreateGUIControls()
m_Crop->SetValue(g_Config.bCrop);
m_UseXFB->SetValue(g_Config.bUseXFB);
m_AutoScale->SetValue(g_Config.bAutoScale);
// Enabled
m_2xResolution->Enable(g_Config.bAllow2xResolution);
#ifndef _WIN32
m_HideCursor = new wxCheckBox(m_PageGeneral, ID_HIDECURSOR, wxT("Hide mouse cursor"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
@ -244,8 +243,8 @@ void GFXConfigDialogOGL::CreateGUIControls()
// Tool tips
m_Fullscreen->SetToolTip(
wxT("This will create a Fullscreen window using the chosen Fullscreen resolution.")
wxT("\nPress Alt+Enter to switch between Fullscreen and Windowed mode.")
wxT("Start the separate window in fullscreen mode.")
wxT(" Press Alt+Enter to switch between Fullscreen and Windowed mode.")
wxT("\n\nApplies instanty during gameplay: <No>"));
m_NativeResolution->SetToolTip(
wxT("This will use the game's native resolution and stretch it to fill the")
@ -317,7 +316,8 @@ void GFXConfigDialogOGL::CreateGUIControls()
shader = wxT("(off)");
m_PostShaderCB->SetStringSelection(shader);
// How to use the wxGridBagSizer: The wxGBPosition() must have a column and row
// Sizers
sGeneral = new wxBoxSizer(wxVERTICAL);
sBasic = new wxGridBagSizer(0, 0);
@ -337,22 +337,23 @@ void GFXConfigDialogOGL::CreateGUIControls()
sBasic->Add(m_Crop, wxGBPosition(3, 3), wxGBSpan(1, 1), wxALL, 5);
sBasic->Add(m_WidescreenHack, wxGBPosition(4, 1), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5);
sBasic->Add(WM2Text, wxGBPosition(5, 0), wxGBSpan(1, 1), wxALL, 5);
sBasic->Add(m_Fullscreen, wxGBPosition(5, 1), wxGBSpan(1, 1), wxALL, 5);
// This option is configured from the main Dolphin.exe settings for _WIN32
#ifndef _WIN32
sBasic->Add(m_HideCursor, wxGBPosition(3, 0), wxGBSpan(1, 4), wxALL, 5);
sBasic->Add(m_HideCursor, wxGBPosition(5, 0), wxGBSpan(1, 4), wxALL, 5);
#endif
sbBasic->Add(sBasic);
sGeneral->Add(sbBasic, 0, wxEXPAND|wxALL, 5);
sBasicAdvanced = new wxGridBagSizer(0, 0);
sBasicAdvanced->Add(m_EFBCopyDisableHotKey, wxGBPosition(0, 0), wxGBSpan(1, 3), wxALL, 5);
sBasicAdvanced->Add(m_VSync, wxGBPosition(1, 0), wxGBSpan(1, 3), wxALL, 5);
sBasicAdvanced->Add(m_UseXFB, wxGBPosition(2, 0), wxGBSpan(1, 3), wxALL, 5);
sBasicAdvanced->Add(m_RenderToMainWindow, wxGBPosition(3, 0), wxGBSpan(1, 3), wxALL, 5);
sBasicAdvanced->Add(WM2Text, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 5);
sBasicAdvanced->Add(m_RenderToMainWindow, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALL, 5);
sBasicAdvanced->Add(m_Fullscreen, wxGBPosition(0, 2), wxGBSpan(1, 1), wxALL, 5);
sBasicAdvanced->Add(m_EFBCopyDisableHotKey, wxGBPosition(1, 0), wxGBSpan(1, 3), wxALL, 5);
sBasicAdvanced->Add(m_VSync, wxGBPosition(2, 0), wxGBSpan(1, 3), wxALL, 5);
sBasicAdvanced->Add(m_UseXFB, wxGBPosition(3, 0), wxGBSpan(1, 3), wxALL, 5);
sBasicAdvanced->Add(m_AutoScale, wxGBPosition(4, 0), wxGBSpan(1, 3), wxALL, 5);
sbBasicAdvanced->Add(sBasicAdvanced);
@ -775,14 +776,14 @@ void GFXConfigDialogOGL::UpdateGUI()
m_Fullscreen->Enable(!g_Config.RenderToMainframe);
if (g_Config.RenderToMainframe) m_Fullscreen->SetValue(false);
// Disable the internal resolution option if it's set to native
m_WindowResolutionCB->Enable(!(g_Config.bNativeResolution || g_Config.b2xResolution));
m_WindowFSResolutionCB->Enable(!(g_Config.bNativeResolution || g_Config.b2xResolution));
// Resolution settings
m_2xResolution->Enable(!g_Config.bRunning || Renderer::Allow2x());
m_WindowResolutionCB->Enable(!g_Config.bRunning && !(g_Config.bNativeResolution || g_Config.b2xResolution));
m_WindowFSResolutionCB->Enable(!g_Config.bRunning && !(g_Config.RenderToMainframe || g_Config.bNativeResolution || g_Config.b2xResolution));
//Disable the Copy to options when EFBCopy is disabled
// Disable the Copy to options when EFBCopy is disabled
m_Radio_CopyEFBToRAM->Enable(!(g_Config.bEFBCopyDisable));
m_Radio_CopyEFBToGL->Enable(!(g_Config.bEFBCopyDisable));
}

View File

@ -29,6 +29,7 @@
#include "Win32.h"
#include "OnScreenDisplay.h"
#include "VertexShaderManager.h"
#include "Render.h"
#include "StringUtil.h"
@ -101,9 +102,9 @@ void OSDMenu(WPARAM wParam)
// Toggle native resolution
if (!(g_Config.bNativeResolution || g_Config.b2xResolution))
g_Config.bNativeResolution = true;
else if (g_Config.bNativeResolution)
{ g_Config.bNativeResolution = false; if (g_Config.bAllow2xResolution) {g_Config.b2xResolution = true;} }
else
else if (g_Config.bNativeResolution && Renderer::AllowCustom())
{ g_Config.bNativeResolution = false; if (Renderer::Allow2x()) {g_Config.b2xResolution = true;} }
else if (Renderer::AllowCustom())
g_Config.b2xResolution = false;
break;
case '4':

View File

@ -108,10 +108,13 @@ static std::string s_sScreenshotName;
int frameCount;
static int s_fps = 0;
// These STAY CONSTANT during execution, no matter how much you resize the game window.
// The custom resolution
// TODO: Add functionality to reinit all the render targets when the window is resized.
static int s_targetwidth; // Size of render buffer FBO.
static int s_targetheight;
static int m_CustomWidth;
static int m_CustomHeight;
// The framebuffer size
static int m_FrameBufferWidth;
static int m_FrameBufferHeight;
static GLuint s_tempScreenshotFramebuffer = 0;
@ -290,42 +293,42 @@ bool Renderer::Init()
int W = (int)OpenGL_GetBackbufferWidth(), H = (int)OpenGL_GetBackbufferHeight();
if (g_Config.bNativeResolution)
{
s_targetwidth = EFB_WIDTH;
s_targetheight = EFB_HEIGHT;
m_FrameBufferWidth = EFB_WIDTH;
m_FrameBufferHeight = EFB_HEIGHT;
}
else if (g_Config.b2xResolution)
{
s_targetwidth = 2 * EFB_WIDTH;
s_targetheight = 2 * EFB_HEIGHT;
m_FrameBufferWidth = 2 * EFB_WIDTH;
m_FrameBufferHeight = 2 * EFB_HEIGHT;
}
else
{
// The size of the framebuffer targets should really NOT be the size of the OpenGL viewport.
// The EFB is larger than 640x480 - in fact, it's 640x528, give or take a couple of lines.
s_targetwidth = (EFB_WIDTH >= W) ? EFB_WIDTH : W;
s_targetheight = (480 >= H) ? 480 : H;
m_FrameBufferWidth = (EFB_WIDTH >= W) ? EFB_WIDTH : W;
m_FrameBufferHeight = (480 >= H) ? 480 : H;
// Adjust all heights with this ratio, the resulting height will be the same as H or EFB_HEIGHT. I.e.
// 768 (-1) for 1024x768 etc.
s_targetheight *= 528.0 / 480.0;
m_FrameBufferHeight *= 528.0 / 480.0;
// Ensure a minimum target size so that the native res target always fits
if (s_targetwidth < EFB_WIDTH) s_targetwidth = EFB_WIDTH;
if (s_targetheight < EFB_HEIGHT) s_targetheight = EFB_HEIGHT;
if (m_FrameBufferWidth < EFB_WIDTH) m_FrameBufferWidth = EFB_WIDTH;
if (m_FrameBufferHeight < EFB_HEIGHT) m_FrameBufferHeight = EFB_HEIGHT;
}
// Disable the 2x option
if (!g_Config.b2xResolution && (W < 1280 || H < 960)) g_Config.bAllow2xResolution = false;
// Save the custom resolution
m_CustomWidth = (int)OpenGL_GetBackbufferWidth();
m_CustomHeight = (int)OpenGL_GetBackbufferHeight();
// Because of the fixed framebuffer size we need to disable the resolution options while running
g_Config.bRunning = true;
if (GL_REPORT_ERROR() != GL_NO_ERROR)
bSuccess = false;
// Initialize the FramebufferManager
g_framebufferManager.Init(s_targetwidth, s_targetheight, s_MSAASamples, s_MSAACoverageSamples);
// Save the custom resolution
s_targetwidth = (int)OpenGL_GetBackbufferWidth();
s_targetheight = (int)OpenGL_GetBackbufferHeight();
g_framebufferManager.Init(m_FrameBufferWidth, m_FrameBufferHeight, s_MSAASamples, s_MSAACoverageSamples);
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
@ -407,7 +410,7 @@ bool Renderer::Init()
void Renderer::Shutdown(void)
{
g_Config.bAllow2xResolution = true;
g_Config.bRunning = false;
delete s_pfont;
s_pfont = 0;
@ -432,19 +435,51 @@ void Renderer::Shutdown(void)
#endif
}
// Return the rendering window width and height
// For the OSD menu's live resolution change
bool Renderer::Allow2x()
{
if (GetFrameBufferWidth() >= 1280 && GetFrameBufferHeight() >= 960)
return true;
else
return false;
}
bool Renderer::AllowCustom()
{
if (GetCustomWidth() <= GetFrameBufferWidth() && GetCustomHeight() <= GetFrameBufferHeight())
return true;
else
return false;
}
// Return the framebuffer size
int Renderer::GetFrameBufferWidth()
{
return m_FrameBufferWidth;
}
int Renderer::GetFrameBufferHeight()
{
return m_FrameBufferHeight;
}
// Return the custom resolution
int Renderer::GetCustomWidth()
{
return m_CustomWidth;
}
int Renderer::GetCustomHeight()
{
return m_CustomHeight;
}
// Return the rendering target width and height
int Renderer::GetTargetWidth()
{
return (g_Config.bNativeResolution || g_Config.b2xResolution) ?
(g_Config.bNativeResolution ? EFB_WIDTH : EFB_WIDTH * 2) : s_targetwidth;
(g_Config.bNativeResolution ? EFB_WIDTH : EFB_WIDTH * 2) : m_CustomWidth;
}
int Renderer::GetTargetHeight()
{
return (g_Config.bNativeResolution || g_Config.b2xResolution) ?
(g_Config.bNativeResolution ? EFB_HEIGHT : EFB_HEIGHT * 2) : s_targetheight;
(g_Config.bNativeResolution ? EFB_HEIGHT : EFB_HEIGHT * 2) : m_CustomHeight;
}
float Renderer::GetTargetScaleX()
{
return (float)GetTargetWidth() / (float)EFB_WIDTH;

View File

@ -22,14 +22,14 @@
1.1 Display settings
Internal and fullscreen resolution: Since the only internal resolutions allowed are also
fullscreen resolution allowed by the system there is only need for one resolution setting
that applies to both the internal resolution and the fullscreen resolution.
- Apparently no, someone else doesn't agree
Todo: Make the internal resolution option apply instantly, currently only the native and 2x option
applies instantly. To do this we need to enumerate all avaliable display resolutions before
Renderer:Init().
applies instantly. To do this we need to be able to change the reinitialize FramebufferManager:Init()
while a game is running.
1.2 Screenshots