GUI: Fixed a double keydown event in the main frame, the double click in the video window (didn't know about CS_DBLCLKS)

OpenGL: Fixed the live resolution setting

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4211 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson
2009-09-06 13:36:05 +00:00
parent 49e849dc94
commit a3345ea942
11 changed files with 128 additions and 164 deletions

View File

@ -42,7 +42,7 @@ void Config::Load()
iniFile.Get("Hardware", "Fullscreen", &bFullscreen, 0); // Hardware
iniFile.Get("Hardware", "VSync", &bVSync, 0); // Hardware
iniFile.Get("Hardware", "RenderToMainframe", &renderToMainframe, false);
iniFile.Get("Hardware", "RenderToMainframe", &RenderToMainframe, false);
iniFile.Get("Settings", "StretchToFit", &bNativeResolution, true);
iniFile.Get("Settings", "2xResolution", &b2xResolution, false);
iniFile.Get("Settings", "wideScreenHack", &bWidescreenHack, false);
@ -136,7 +136,7 @@ void Config::Save()
iniFile.Set("Hardware", "FullscreenRes", iFSResolution);
iniFile.Set("Hardware", "Fullscreen", bFullscreen);
iniFile.Set("Hardware", "VSync", bVSync);
iniFile.Set("Hardware", "RenderToMainframe", renderToMainframe);
iniFile.Set("Hardware", "RenderToMainframe", RenderToMainframe);
iniFile.Set("Settings", "StretchToFit", bNativeResolution);
iniFile.Set("Settings", "2xResolution", b2xResolution);
iniFile.Set("Settings", "KeepAR_4_3", bKeepAR43);

View File

@ -52,7 +52,7 @@ struct Config
// General
bool bFullscreen;
bool bHideCursor;
bool renderToMainframe;
bool RenderToMainframe;
bool bVSync;
// Resolution control

View File

@ -20,6 +20,7 @@
#include "TextureConverter.h"
#include "XFB.h"
#include "Render.h"
extern bool s_bHaveFramebufferBlit; // comes from Render.cpp
@ -264,10 +265,10 @@ GLuint FramebufferManager::GetEFBDepthTexture(const EFBRectangle& sourceRc) cons
TargetRectangle FramebufferManager::ConvertEFBRectangle(const EFBRectangle& rc) const
{
TargetRectangle result;
result.left = rc.left * m_targetWidth / EFB_WIDTH;
result.top = m_targetHeight - (rc.top * m_targetHeight / EFB_HEIGHT);
result.right = rc.right * m_targetWidth / EFB_WIDTH;
result.bottom = m_targetHeight - (rc.bottom * m_targetHeight / EFB_HEIGHT);
result.left = rc.left * Renderer::GetTargetWidth() / EFB_WIDTH;
result.top = Renderer::GetTargetHeight() - (rc.top * Renderer::GetTargetHeight() / EFB_HEIGHT);
result.right = rc.right * Renderer::GetTargetWidth() / EFB_WIDTH;
result.bottom = Renderer::GetTargetHeight() - (rc.bottom * Renderer::GetTargetHeight() / EFB_HEIGHT);
return result;
}
@ -317,8 +318,8 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
it->xfbWidth = fbWidth;
it->xfbHeight = fbHeight;
it->xfbSource.texWidth = m_targetWidth;
it->xfbSource.texHeight = m_targetHeight;
it->xfbSource.texWidth = Renderer::GetTargetWidth();
it->xfbSource.texHeight = Renderer::GetTargetHeight();
it->xfbSource.sourceRc = ConvertEFBRectangle(sourceRc);
xfbTexture = it->xfbSource.texture;

View File

@ -199,7 +199,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
int args[] = {WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE, 16, 0};
wxSize size(_iwidth, _iheight);
if (!g_Config.renderToMainframe ||
if (!g_Config.RenderToMainframe ||
g_VideoInitialize.pWindowHandle == NULL) {
GLWin.frame = new wxFrame((wxWindow *)g_VideoInitialize.pWindowHandle,
-1, _("Dolphin"), wxPoint(50,50), size);
@ -233,7 +233,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
// ----------------------
// Create a separate window
if (!g_Config.renderToMainframe || g_VideoInitialize.pWindowHandle == NULL)
if (!g_Config.RenderToMainframe || g_VideoInitialize.pWindowHandle == NULL)
g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create(NULL, g_hInstance, _T("Please wait..."));
// Create a child window
else
@ -282,7 +282,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
ChangeDisplaySettings(NULL, 0);
}
if (g_Config.bFullscreen && !g_Config.renderToMainframe)
if (g_Config.bFullscreen && !g_Config.RenderToMainframe)
{
// Hide the cursor
ShowCursor(FALSE);

View File

@ -177,7 +177,7 @@ 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->SetValue(g_Config.renderToMainframe);
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);
@ -582,7 +582,7 @@ void GFXConfigDialogOGL::GeneralSettingsChanged(wxCommandEvent& event)
g_Config.bFullscreen = m_Fullscreen->IsChecked();
break;
case ID_RENDERTOMAINWINDOW:
g_Config.renderToMainframe = m_RenderToMainWindow->IsChecked();
g_Config.RenderToMainframe = m_RenderToMainWindow->IsChecked();
g_Config.bFullscreen = false;
break;
case ID_NATIVERESOLUTION:
@ -772,8 +772,8 @@ void GFXConfigDialogOGL::UpdateGUI()
m_AutoScale->Enable(!g_Config.bUseXFB);
// These options are for the separate rendering window
m_Fullscreen->Enable(!g_Config.renderToMainframe);
if (g_Config.renderToMainframe) m_Fullscreen->SetValue(false);
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));

View File

@ -86,6 +86,7 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
extern bool gShowDebugger;
int OSDChoice = 0, OSDTime = 0, OSDInternalW = 0, OSDInternalH = 0;
// ---------------------------------------------------------------------
// OSD Menu
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@ -100,8 +101,8 @@ 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.bAllow2xResolution)
{ g_Config.bNativeResolution = false; g_Config.b2xResolution = true; }
else if (g_Config.bNativeResolution)
{ g_Config.bNativeResolution = false; if (g_Config.bAllow2xResolution) {g_Config.b2xResolution = true;} }
else
g_Config.b2xResolution = false;
break;
@ -139,7 +140,7 @@ namespace EmuWindow
{
HWND m_hWnd = NULL; // The new window that is created here
HWND m_hParent = NULL;
HWND m_hParent = NULL; // The main wxFrame
HWND m_hMain = NULL; // The main CPanel
HINSTANCE m_hInstance = NULL;
@ -165,12 +166,10 @@ HWND GetWnd()
{
return m_hWnd;
}
HWND GetParentWnd()
{
return m_hParent;
}
HWND GetChildParentWnd()
{
return m_hMain;
@ -235,7 +234,38 @@ void FreeLookInput( UINT iMsg, WPARAM wParam )
}
}
LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
// ---------------------------------------------------------------------
// KeyDown events
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void OnKeyDown(WPARAM wParam)
{
switch (LOWORD( wParam ))
{
case VK_ESCAPE:
if (g_Config.bFullscreen && !g_Config.RenderToMainframe)
{
// Pressing Esc switch to Windowed in Fullscreen mode
ToggleFullscreen(m_hWnd);
return;
}
else if (!g_Config.RenderToMainframe)
{
// And stops the emulation when already in Windowed mode
PostMessage(m_hMain, WM_USER, OPENGL_WM_USER_STOP, 0);
}
break;
case '3': // OSD keys
case '4':
case '5':
case '6':
OSDMenu(wParam);
break;
}
g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
}
// ---------------------------------------------------------------------
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
@ -255,7 +285,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
{
case VK_RETURN:
// Pressing Alt+Enter switch FullScreen/Windowed
if (m_hParent == NULL && !g_Config.renderToMainframe)
if (m_hParent == NULL && !g_Config.RenderToMainframe)
{
ToggleFullscreen(hWnd);
return 0;
@ -265,31 +295,18 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
break;
case WM_KEYDOWN:
switch( LOWORD( wParam ))
{
case VK_ESCAPE:
if (g_Config.bFullscreen)
{
// Pressing Esc switch to Windowed in Fullscreen mode
ToggleFullscreen(hWnd);
return 0;
}
else if (!g_Config.renderToMainframe)
{
// And stops the emulation when already in Windowed mode
PostMessage(m_hMain, WM_USER, OPENGL_WM_USER_STOP, 0);
}
break;
case '3': // OSD keys
case '4':
case '5':
case '6':
OSDMenu(wParam);
break;
}
g_VideoInitialize.pKeyPress(LOWORD(wParam), GetAsyncKeyState(VK_SHIFT) != 0, GetAsyncKeyState(VK_CONTROL) != 0);
// Don't process this as a child window to avoid double events
if (!g_Config.RenderToMainframe) OnKeyDown(wParam);
break;
/* Post thes mouse events to the main window, it's nessesary becase in difference to the
keyboard inputs these events only appear here, not in the parent window or any other WndProc()*/
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
PostMessage(GetChildParentWnd(), iMsg, wParam, lParam);
break;
/* The reason we pick up the WM_MOUSEMOVE is to be able to change this option
during gameplay. The alternative is to load one of the cursors when the plugin
is loaded and go with that. This should only produce a minimal performance hit
@ -309,25 +326,16 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
only let it pass through Dolphin > Frame.cpp to determine if it should be on or off
and coordinate it with the other settings if nessesary */
case WM_USER:
/* I set wParam to 10 just in case there are other WM_USER events. If we want more
WM_USER cases we would start making wParam or lParam cases */
if (wParam == 10)
if (wParam == OPENGL_WM_USER_STOP)
{
if (lParam)
SetCursor(hCursor);
else
SetCursor(hCursorBlank);
}
if (wParam == OPENGL_WM_USER_KEYDOWN) OnKeyDown(lParam);
break;
/* Post thes mouse events to the main window, it's nessesary becase in difference to the
keyboard inputs these events only appear here, not in the main WndProc() */
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
PostMessage(GetParentWnd(), iMsg, wParam, lParam);
break;
// This is called when we close the window when we render to a separate window
case WM_CLOSE:
if (m_hParent == NULL)
@ -364,7 +372,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const TCHAR *title)
{
wndClass.cbSize = sizeof( wndClass );
wndClass.style = CS_HREDRAW | CS_VREDRAW;
wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wndClass.lpfnWndProc = WndProc;
wndClass.cbClsExtra = 0;
wndClass.cbWndExtra = 0;

View File

@ -99,7 +99,6 @@ static int s_MSAACoverageSamples = 0;
bool s_bHaveFramebufferBlit = false; // export to FramebufferManager.cpp
static bool s_bHaveCoverageMSAA = false;
static u32 s_blendMode;
static bool s_bNativeResolution = false;
static volatile bool s_bScreenshot = false;
static Common::Thread *scrshotThread = 0;
@ -183,7 +182,6 @@ bool Renderer::Init()
bool bSuccess = true;
s_blendMode = 0;
s_MSAACoverageSamples = 0;
s_bNativeResolution = g_Config.bNativeResolution;
switch (g_Config.iMultisampleMode)
{
case MULTISAMPLE_OFF: s_MSAASamples = 1; break;
@ -304,16 +302,14 @@ bool Renderer::Init()
{
// 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.
// So the below is wrong.
// This should really be grabbed from config rather than from OpenGL.
s_targetwidth = (640 >= W) ? 640 : W;
s_targetwidth = (EFB_WIDTH >= W) ? EFB_WIDTH : W;
s_targetheight = (480 >= H) ? 480 : H;
// Compensate height of render target for scaling, so that we get something close to the correct number of
// vertical pixels.
// 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;
// Ensure a minimum target size so that the native res target always fits.
// 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;
}
@ -327,6 +323,10 @@ bool Renderer::Init()
// 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();
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
if (GL_REPORT_ERROR() != GL_NO_ERROR)
@ -435,12 +435,14 @@ void Renderer::Shutdown(void)
// Return the rendering window width and height
int Renderer::GetTargetWidth()
{
return s_targetwidth;
return (g_Config.bNativeResolution || g_Config.b2xResolution) ?
(g_Config.bNativeResolution ? EFB_WIDTH : EFB_WIDTH * 2) : s_targetwidth;
}
int Renderer::GetTargetHeight()
{
return s_targetheight;
return (g_Config.bNativeResolution || g_Config.b2xResolution) ?
(g_Config.bNativeResolution ? EFB_HEIGHT : EFB_HEIGHT * 2) : s_targetheight;
}
float Renderer::GetTargetScaleX()
@ -1018,9 +1020,6 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
// Place messages on the picture, then copy it to the screen
SwapBuffers();
// Why save this as s_bNativeResolution if we updated it every frame?
s_bNativeResolution = g_Config.bNativeResolution;
RestoreAPIState();
GL_REPORT_ERRORD();