Fixed various OGL fullscreen issues, screen shaking, esc key not working, misplaced fullscreen window.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2858 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
sl1nk3.s 2009-04-03 20:12:59 +00:00
parent e1c3d1bfd4
commit efb0a11201
6 changed files with 89 additions and 24 deletions

View File

@ -1,4 +1,4 @@
// Copyright (C) 2003-2008 Dolphin Project. // Copyright (C) 2003-2009 Dolphin Project.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by

View File

@ -1,4 +1,4 @@
// Copyright (C) 2003-2008 Dolphin Project. // Copyright (C) 2003-2009 Dolphin Project.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by

View File

@ -1,3 +1,20 @@
// Copyright (C) 2003-2009 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Config.h" // Local #include "Config.h" // Local
#include "Globals.h" #include "Globals.h"
#include "DSPHandler.h" #include "DSPHandler.h"

View File

@ -283,15 +283,18 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
dwStyle = WS_OVERLAPPEDWINDOW; dwStyle = WS_OVERLAPPEDWINDOW;
} }
RECT rc; RECT rc = {0, 0, s_backbuffer_width, s_backbuffer_height};
rc.left = 0; rc.top = 0;
rc.right = s_backbuffer_width; rc.bottom = s_backbuffer_height;
AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle); AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle);
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2; int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2; int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
// EmuWindow::GetWnd() is either the new child window or the new separate window // EmuWindow::GetWnd() is either the new child window or the new separate window
SetWindowPos(EmuWindow::GetWnd(), NULL, X, Y, rc.right-rc.left, rc.bottom-rc.top, SWP_NOREPOSITION | SWP_NOZORDER); if (g_Config.bFullscreen)
// We put the window at the upper left corner of the screen, so x = y = 0
SetWindowPos(EmuWindow::GetWnd(), NULL, 0, 0, rc.right-rc.left, rc.bottom-rc.top, SWP_NOREPOSITION | SWP_NOZORDER);
else
SetWindowPos(EmuWindow::GetWnd(), NULL, X, Y, rc.right-rc.left, rc.bottom-rc.top, SWP_NOREPOSITION | SWP_NOZORDER);
PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{ {

View File

@ -448,6 +448,7 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
break; break;
case ID_RENDERTOMAINWINDOW: case ID_RENDERTOMAINWINDOW:
g_Config.renderToMainframe = m_RenderToMainWindow->IsChecked(); g_Config.renderToMainframe = m_RenderToMainWindow->IsChecked();
g_Config.bFullscreen = false;
break; break;
case ID_NATIVERESOLUTION: case ID_NATIVERESOLUTION:
g_Config.bNativeResolution = m_NativeResolution->IsChecked(); g_Config.bNativeResolution = m_NativeResolution->IsChecked();
@ -605,6 +606,8 @@ void ConfigDialog::UpdateGUI()
// These options are for the separate rendering window // These options are for the separate rendering window
m_Fullscreen->Enable(!g_Config.renderToMainframe); m_Fullscreen->Enable(!g_Config.renderToMainframe);
if (g_Config.renderToMainframe)
m_Fullscreen->SetValue(false);
m_FullscreenCB->Enable(!g_Config.renderToMainframe); m_FullscreenCB->Enable(!g_Config.renderToMainframe);
m_WindowResolutionCB->Enable(!g_Config.renderToMainframe); m_WindowResolutionCB->Enable(!g_Config.renderToMainframe);
} }

View File

@ -156,27 +156,69 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
case WM_KEYDOWN: case WM_KEYDOWN:
switch( LOWORD( wParam )) switch( LOWORD( wParam ))
{ {
case VK_ESCAPE: // Pressing Esc Stop or Maximize case VK_ESCAPE:
//DestroyWindow(hWnd); // Pressing Esc switch FullScreen/Windowed
//PostQuitMessage(0);
/* The fullscreen option for Windows users is not very user friendly. With this the user
can only get out of the fullscreen mode by pressing Esc or Alt + F4. Esc also stops
the emulation. Todo: But currently it hangs, so I have disabled the shutdown. */
//if (m_hParent == NULL) ExitProcess(0);
if (m_hParent == NULL) if (m_hParent == NULL)
{ {
int w_fs = 640, h_fs = 480;
if (g_Config.bFullscreen) if (g_Config.bFullscreen)
{ {
//PostMessage(m_hMain, WM_USER, OPENGL_WM_USER_STOP, 0); // Stop // Get out of fullscreen
g_Config.bFullscreen = false;
if (strlen(g_Config.iWindowedRes) > 1)
sscanf(g_Config.iWindowedRes, "%dx%d", &w_fs, &h_fs);
// FullScreen - > Desktop
ChangeDisplaySettings(NULL, 0);
// Set new window style FS -> Windowed
SetWindowLong(hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
// Re-Enable the cursor
ShowCursor(TRUE);
RECT rcdesktop;
RECT rc = {0, 0, w_fs, h_fs};
GetWindowRect(GetDesktopWindow(), &rcdesktop);
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
// SetWindowPos to the center of the screen
SetWindowPos(hWnd, NULL, X, Y, w_fs, h_fs, SWP_NOREPOSITION | SWP_NOZORDER);
// Eventually show the window!
EmuWindow::Show();
} }
else else
{ {
// Toggle maximize and restore // Get into fullscreen
if (IsZoomed(hWnd)) g_Config.bFullscreen = true;
ShowWindow(hWnd, SW_RESTORE); DEVMODE dmScreenSettings;
else memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
ShowWindow(hWnd, SW_MAXIMIZE);
if (strlen(g_Config.iFSResolution) > 1)
sscanf(g_Config.iFSResolution, "%dx%d", &w_fs, &h_fs);
// Desktop -> FullScreen
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
dmScreenSettings.dmPelsWidth = w_fs;
dmScreenSettings.dmPelsHeight = h_fs;
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
return 0;
// Set new window style -> PopUp
SetWindowLong(hWnd, GWL_STYLE, WS_POPUP);
// Disable the cursor
ShowCursor(FALSE);
// SetWindowPos to the upper-left corner of the screen
SetWindowPos(hWnd, NULL, 0, 0, w_fs, h_fs, SWP_NOREPOSITION | SWP_NOZORDER);
// Eventually show the window!
EmuWindow::Show();
} }
return 0; return 0;
} }
@ -210,7 +252,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
break; break;
/* To support the separate window rendering we get the message back here. So we basically /* To support the separate window rendering we get the message back here. So we basically
only let it pass through DolphinWX > Frame.cpp to determine if it should be on or off 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 */ and coordinate it with the other settings if nessesary */
case WM_USER: case WM_USER:
/* I set wParam to 10 just in case there are other WM_USER events. If we want more /* I set wParam to 10 just in case there are other WM_USER events. If we want more
@ -372,7 +414,7 @@ void SetSize(int width, int height)
rc.right = rc.left + w; rc.right = rc.left + w;
rc.top = (1024 - h)/2; rc.top = (1024 - h)/2;
rc.bottom = rc.top + h; rc.bottom = rc.top + h;
::MoveWindow(m_hWnd, rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top, TRUE); MoveWindow(m_hWnd, rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top, TRUE);
} }
} // EmuWindow } // EmuWindow