From 14b6cadf4643be4b9bc19dc6abe58d119ba49ebd Mon Sep 17 00:00:00 2001 From: John Peterson Date: Thu, 19 Feb 2009 02:58:29 +0000 Subject: [PATCH] OpenGL: Added option to adjust the screen size and position. I need this to calibrate the Wiimote. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2307 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/CoreRerecording.cpp | 2 +- Source/MusicMod.sln | 12 +- Source/Plugins/Plugin_VideoOGL/Src/Config.cpp | 12 +- Source/Plugins/Plugin_VideoOGL/Src/Config.h | 4 + .../Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp | 160 +++++++++++++++--- .../Plugin_VideoOGL/Src/GUI/ConfigDlg.h | 14 +- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 67 ++++++-- 7 files changed, 224 insertions(+), 47 deletions(-) diff --git a/Source/Core/Core/Src/CoreRerecording.cpp b/Source/Core/Core/Src/CoreRerecording.cpp index 5f31837f77..eff0df6c22 100644 --- a/Source/Core/Core/Src/CoreRerecording.cpp +++ b/Source/Core/Core/Src/CoreRerecording.cpp @@ -116,7 +116,7 @@ void RerecordingStart() ReRecTimer.Start(); // Logging - Console::Print("RerecordingStart: %i\n", g_FrameCounter); + //Console::Print("RerecordingStart: %i\n", g_FrameCounter); } // Reset the frame counter diff --git a/Source/MusicMod.sln b/Source/MusicMod.sln index 28cc39824f..e4c8463497 100644 --- a/Source/MusicMod.sln +++ b/Source/MusicMod.sln @@ -54,18 +54,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoOGL", "Plugins\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Common", "Core\Common\Common.vcproj", "{C573CAF7-EE6A-458E-8049-16C0BF34C2E9}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DolphinWX", "Core\DolphinWX\DolphinWX.vcproj", "{A72606EF-C5C1-4954-90AD-F0F93A8D97D9}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Dolphin", "Core\DolphinWX\DolphinWX.vcproj", "{A72606EF-C5C1-4954-90AD-F0F93A8D97D9}" ProjectSection(ProjectDependencies) = postProject {48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F} + {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160} = {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160} {D6E56527-BBB9-4EAD-A6EC-49D4BF6AFCD8} = {D6E56527-BBB9-4EAD-A6EC-49D4BF6AFCD8} {0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0} - {8D612734-FAA5-4B8A-804F-4DEA2367D495} = {8D612734-FAA5-4B8A-804F-4DEA2367D495} {71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {71B16F46-0B00-4EDA-B253-D6D9D03A215C} - {9A183B48-ECC2-4121-876A-9B3793686073} = {9A183B48-ECC2-4121-876A-9B3793686073} {33546D62-7F34-4EA6-A88E-D538B36E16BF} = {33546D62-7F34-4EA6-A88E-D538B36E16BF} {3E03C179-8251-46E4-81F4-466F114BAC63} = {3E03C179-8251-46E4-81F4-466F114BAC63} {95CCAABC-7062-47C4-B8C1-A064DD5F16FF} = {95CCAABC-7062-47C4-B8C1-A064DD5F16FF} - {521498BE-6089-4780-8223-E67C22F4E068} = {521498BE-6089-4780-8223-E67C22F4E068} {29C2ABC1-ADA5-42CD-A5FC-96022D52A510} = {29C2ABC1-ADA5-42CD-A5FC-96022D52A510} {4D3CD4C5-412B-4B49-9B1B-A68A2A129C77} = {4D3CD4C5-412B-4B49-9B1B-A68A2A129C77} {F0B874CB-4476-4199-9315-8343D05AE684} = {F0B874CB-4476-4199-9315-8343D05AE684} @@ -76,7 +74,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxBase28", "..\Externals\wx EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxCore28", "..\Externals\wxWidgets\build\msw\wx_core.vcproj", "{0318BA30-EF48-441A-9E10-DC85EFAE39F0}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DebuggerWX", "Core\DebuggerWX\DebuggerWX.vcproj", "{4D3CD4C5-412B-4B49-9B1B-A68A2A129C77}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Debugger", "Core\DebuggerWX\DebuggerWX.vcproj", "{4D3CD4C5-412B-4B49-9B1B-A68A2A129C77}" ProjectSection(ProjectDependencies) = postProject {48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F} {0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0} @@ -201,7 +199,6 @@ Global {9A183B48-ECC2-4121-876A-9B3793686073}.Release JITIL|x64.ActiveCfg = Release|x64 {9A183B48-ECC2-4121-876A-9B3793686073}.Release JITIL|x64.Build.0 = Release|x64 {9A183B48-ECC2-4121-876A-9B3793686073}.Release|Win32.ActiveCfg = Release|Win32 - {9A183B48-ECC2-4121-876A-9B3793686073}.Release|Win32.Build.0 = Release|Win32 {9A183B48-ECC2-4121-876A-9B3793686073}.Release|x64.ActiveCfg = Release|x64 {9A183B48-ECC2-4121-876A-9B3793686073}.Release|x64.Build.0 = Release|x64 {29C2ABC1-ADA5-42CD-A5FC-96022D52A510}.Debug|Win32.ActiveCfg = Debug|Win32 @@ -262,6 +259,7 @@ Global {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release JITIL|x64.ActiveCfg = Release|x64 {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release JITIL|x64.Build.0 = Release|x64 {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release|Win32.ActiveCfg = Release|Win32 + {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release|Win32.Build.0 = Release|Win32 {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release|x64.ActiveCfg = Release|x64 {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release|x64.Build.0 = Release|x64 {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}.Debug|Win32.ActiveCfg = Debug|Win32 @@ -373,7 +371,6 @@ Global {8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release JITIL|x64.ActiveCfg = Release|x64 {8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release JITIL|x64.Build.0 = Release|x64 {8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|Win32.ActiveCfg = Release|Win32 - {8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|Win32.Build.0 = Release|Win32 {8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|x64.ActiveCfg = Release|x64 {8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|x64.Build.0 = Release|x64 {ADF64291-57ED-4B7A-AB76-37B4A991504B}.Debug|Win32.ActiveCfg = Debug|Win32 @@ -408,7 +405,6 @@ Global {521498BE-6089-4780-8223-E67C22F4E068}.Release JITIL|x64.ActiveCfg = Release|x64 {521498BE-6089-4780-8223-E67C22F4E068}.Release JITIL|x64.Build.0 = Release|x64 {521498BE-6089-4780-8223-E67C22F4E068}.Release|Win32.ActiveCfg = Release|Win32 - {521498BE-6089-4780-8223-E67C22F4E068}.Release|Win32.Build.0 = Release|Win32 {521498BE-6089-4780-8223-E67C22F4E068}.Release|x64.ActiveCfg = Release|x64 {521498BE-6089-4780-8223-E67C22F4E068}.Release|x64.Build.0 = Release|x64 {C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Debug|Win32.ActiveCfg = Debug|Win32 diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp index d08fef5d3f..7763069f4c 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp @@ -85,6 +85,11 @@ void Config::Load() iniFile.Get("Hacks", "ProjectionHax1", &bProjectionHax1, 0); iniFile.Get("Hacks", "ProjectionHax2", &bProjectionHax2, 0); iniFile.Get("Hacks", "EFBToTextureEnable", &bCopyEFBToRAM, 0); + iniFile.Get("Hacks", "ScreenSize", &bScreenSize, false); + iniFile.Get("Hacks", "ScreenWidth", &iScreenWidth, 1000); + iniFile.Get("Hacks", "ScreenHeight", &iScreenHeight, 1000); + iniFile.Get("Hacks", "ScreenLeft", &iScreenLeft, 0); + iniFile.Get("Hacks", "ScreenTop", &iScreenTop, 0); } void Config::Save() @@ -126,6 +131,11 @@ void Config::Save() iniFile.Set("Hacks", "ProjectionHax1", bProjectionHax1); iniFile.Set("Hacks", "ProjectionHax2", bProjectionHax2); iniFile.Set("Hacks", "EFBToTextureEnable", bCopyEFBToRAM); - + iniFile.Set("Hacks", "ScreenSize", bScreenSize); + iniFile.Set("Hacks", "ScreenWidth", iScreenWidth); + iniFile.Set("Hacks", "ScreenHeight", iScreenHeight); + iniFile.Set("Hacks", "ScreenLeft", iScreenLeft); + iniFile.Set("Hacks", "ScreenTop", iScreenTop); + iniFile.Save(FULL_CONFIG_DIR "gfx_opengl.ini"); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Config.h b/Source/Plugins/Plugin_VideoOGL/Src/Config.h index 1c9d279135..f392f4b7d3 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Config.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Config.h @@ -71,6 +71,10 @@ struct Config bool bProjectionHax1; bool bProjectionHax2; bool bCopyEFBToRAM; + + // Screen size + int iScreenWidth, iScreenHeight, iScreenLeft, iScreenTop; + bool bScreenSize; int iLog; // CONF_ bits int iSaveTargetId; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp index 2aecb8da83..dbb60ead63 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp @@ -54,6 +54,14 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog) EVT_CHECKBOX(ID_EFBCOPYDISABLEHOTKEY, ConfigDialog::AdvancedSettingsChanged) EVT_CHECKBOX(ID_PROJECTIONHACK1,ConfigDialog::AdvancedSettingsChanged) EVT_CHECKBOX(ID_PROJECTIONHACK2,ConfigDialog::AdvancedSettingsChanged) + + // Screen size + EVT_COMMAND_SCROLL(IDS_WIDTH, ConfigDialog::AdvancedSettingsChanged) + EVT_COMMAND_SCROLL(IDS_HEIGHT, ConfigDialog::AdvancedSettingsChanged) + EVT_COMMAND_SCROLL(IDS_LEFT, ConfigDialog::AdvancedSettingsChanged) + EVT_COMMAND_SCROLL(IDS_TOP, ConfigDialog::AdvancedSettingsChanged) + EVT_CHECKBOX(IDC_SCREEN_SIZE, ConfigDialog::AdvancedSettingsChanged) + EVT_CHECKBOX(ID_SAFETEXTURECACHE,ConfigDialog::AdvancedSettingsChanged) EVT_CHECKBOX(ID_CHECKBOX_DISABLECOPYEFB, ConfigDialog::AdvancedSettingsChanged) EVT_DIRPICKER_CHANGED(ID_TEXTUREPATH, ConfigDialog::TexturePathChange) @@ -252,26 +260,92 @@ void ConfigDialog::CreateGUIControls() m_TexturePath->SetPath(wxString::FromAscii(g_Config.texDumpPath)); m_TexturePath->Enable(m_DumpTextures->IsChecked()); - // Hacks - sbHacks = new wxStaticBoxSizer(wxVERTICAL, m_PageAdvanced, wxT("Hacks")); - + // Hacks controls m_SafeTextureCache = new wxCheckBox(m_PageAdvanced, ID_SAFETEXTURECACHE, wxT("Use Safe texture cache"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_ProjectionHax1 = new wxCheckBox(m_PageAdvanced, ID_PROJECTIONHACK1, wxT("Projection before R945"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_ProjectionHax2 = new wxCheckBox(m_PageAdvanced, ID_PROJECTIONHACK2, wxT("Projection hack of R844"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + + // Disabled or enabled + m_SafeTextureCache->Enable(true); + m_ProjectionHax1->Enable(true); + m_ProjectionHax2->Enable(true); + + // Default values + m_SafeTextureCache->SetValue(g_Config.bSafeTextureCache); + m_ProjectionHax1->SetValue(g_Config.bProjectionHax1); + m_ProjectionHax2->SetValue(g_Config.bProjectionHax2); + + // Tool tips m_SafeTextureCache->SetToolTip(wxT("This is useful to prevent Metroid Prime from crashing, but can cause problems in other games." " [This option will apply immediately and does not require a restart. However it may not" " be entirely safe to change it midgames.]")); - m_SafeTextureCache->Enable(true); - m_SafeTextureCache->SetValue(g_Config.bSafeTextureCache); - - m_ProjectionHax1 = new wxCheckBox(m_PageAdvanced, ID_PROJECTIONHACK1, wxT("Projection before R945"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_ProjectionHax1->SetToolTip(wxT("This may reveal otherwise invisible graphics" " in\ngames like Mario Galaxy or Ikaruga.")); - m_ProjectionHax1->Enable(true); - m_ProjectionHax1->SetValue(g_Config.bProjectionHax1); - m_ProjectionHax2 = new wxCheckBox(m_PageAdvanced, ID_PROJECTIONHACK2, wxT("Projection hack of R844"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - m_ProjectionHax2->Enable(true); - m_ProjectionHax2->SetValue(g_Config.bProjectionHax2); + // Sizers + sHacks = new wxGridBagSizer(0, 0); + sHacks->Add(m_ProjectionHax1, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 5); + sHacks->Add(m_ProjectionHax2, wxGBPosition(1, 0), wxGBSpan(1, 2), wxALL, 5); + sHacks->Add(m_SafeTextureCache, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALL, 5); + sbHacks = new wxStaticBoxSizer(wxVERTICAL, m_PageAdvanced, wxT("Hacks")); + sbHacks->Add(sHacks); + + + // ----------------------------------------------- + // Screen size + // --------------------- + // Controls + m_TextScreenWidth = new wxStaticText(m_PageAdvanced, wxID_ANY, wxT("Width: 000")); + m_TextScreenHeight = new wxStaticText(m_PageAdvanced, wxID_ANY, wxT("Height: 000")); + m_TextScreenLeft = new wxStaticText(m_PageAdvanced, wxID_ANY, wxT("Left: -000")); + m_TextScreenTop = new wxStaticText(m_PageAdvanced, wxID_ANY, wxT("Top: -000")); + + m_SliderWidth = new wxSlider(m_PageAdvanced, IDS_WIDTH, 100, 50, 150, wxDefaultPosition, wxSize(75, -1)); + m_SliderHeight = new wxSlider(m_PageAdvanced, IDS_HEIGHT, 100, 50, 150, wxDefaultPosition, wxSize(75, -1)); + m_SliderLeft = new wxSlider(m_PageAdvanced, IDS_LEFT, 0, -100, 100, wxDefaultPosition, wxSize(75, -1)); + m_SliderTop = new wxSlider(m_PageAdvanced, IDS_TOP, 0, -100, 100, wxDefaultPosition, wxSize(75, -1)); + m_ScreenSize = new wxCheckBox(m_PageAdvanced, IDC_SCREEN_SIZE, wxT("Adjust screen size and position"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + + // Default values + m_SliderWidth->SetValue(g_Config.iScreenWidth); + m_SliderHeight->SetValue(g_Config.iScreenHeight); + m_SliderLeft->SetValue(g_Config.iScreenLeft); + m_SliderTop->SetValue(g_Config.iScreenTop); + m_ScreenSize->SetValue(g_Config.bScreenSize); + + // Sizers + wxBoxSizer *m_SizerScreenSizeWidth = new wxBoxSizer(wxHORIZONTAL); + m_SizerScreenSizeWidth->Add(m_TextScreenWidth, 0, wxEXPAND | (wxTOP), 3); + m_SizerScreenSizeWidth->Add(m_SliderWidth, 0, wxEXPAND | (wxLEFT), 0); + m_SizerScreenSizeWidth->Add(m_TextScreenLeft, 0, wxEXPAND | (wxLEFT), 5); + m_SizerScreenSizeWidth->Add(m_SliderLeft, 0, wxEXPAND | (wxLEFT), 0); + + wxBoxSizer *m_SizerScreenSizeHeight = new wxBoxSizer(wxHORIZONTAL); + m_SizerScreenSizeHeight->Add(m_TextScreenHeight, 0, wxEXPAND | (wxTOP), 3); + m_SizerScreenSizeHeight->Add(m_SliderHeight, 0, wxEXPAND | (wxLEFT), 0); + m_SizerScreenSizeHeight->Add(m_TextScreenTop, 0, wxEXPAND | (wxLEFT), 5); + m_SizerScreenSizeHeight->Add(m_SliderTop, 0, wxEXPAND | (wxLEFT), 0); + + wxStaticBoxSizer * m_SizerScreenSize = new wxStaticBoxSizer(wxVERTICAL, m_PageAdvanced, wxT("Screen size and position")); + m_SizerScreenSize->Add(m_ScreenSize, 0, wxEXPAND | (wxALL), 5); + m_SizerScreenSize->Add(m_SizerScreenSizeWidth, 0, wxEXPAND | (wxLEFT | wxDOWN | wxRIGHT), 5); + m_SizerScreenSize->Add(m_SizerScreenSizeHeight, 0, wxEXPAND | (wxLEFT | wxDOWN | wxRIGHT), 5); + + // Tool tips + m_ScreenSize->SetToolTip(wxT( + "Use the adjusted screen size.")); + // ------------------------------- + + // ----------------------------------------------- + // Row 4: Hacks and Screen size + // --------------------- + wxBoxSizer *m_SizerHacksScreenSize = new wxBoxSizer(wxHORIZONTAL); + m_SizerHacksScreenSize->Add(sbHacks, 0, wxEXPAND | (wxTOP), 0); + m_SizerHacksScreenSize->Add(m_SizerScreenSize, 0, wxEXPAND | (wxLEFT), 7); + // ------------------------------- + + // Sizers sAdvanced = new wxBoxSizer(wxVERTICAL); sInfo = new wxGridBagSizer(0, 0); sInfo->Add(m_ShowFPS, wxGBPosition(0, 0), wxGBSpan(1, 2), wxALL, 5); @@ -282,8 +356,7 @@ void ConfigDialog::CreateGUIControls() sInfo->Add(m_TexFmtOverlay, wxGBPosition(5, 0), wxGBSpan(1, 1), wxALL, 5); sInfo->Add(m_TexFmtCenter, wxGBPosition(5, 1), wxGBSpan(1, 1), wxALL, 5); sbInfo->Add(sInfo); - sAdvanced->Add(sbInfo, 0, wxEXPAND|wxALL, 5); - + wxBoxSizer *sRenderBoxRow1 = new wxBoxSizer(wxHORIZONTAL); sRendering = new wxGridBagSizer(0, 0); sRendering->Add(m_UseXFB, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 5); @@ -300,25 +373,24 @@ void ConfigDialog::CreateGUIControls() sSBox->Add(m_Radio_CopyEFBToGL, 0, wxALL|wxEXPAND, 5); sRenderBoxRow1->Add(sSBox, 0, wxALL|wxEXPAND, 5); sbRendering->Add(sRenderBoxRow1); - sAdvanced->Add(sbRendering, 0, wxEXPAND|wxALL, 5); - + sUtilities = new wxBoxSizer(wxHORIZONTAL); sUtilities->Add(m_DumpTextures, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); sUtilities->Add(m_TexturePath, 1, wxALL|wxEXPAND, 5); sbUtilities->Add(sUtilities, 1, wxEXPAND); - sAdvanced->Add(sbUtilities, 1, wxEXPAND|wxALL, 5); - sHacks = new wxGridBagSizer(0, 0); - sHacks->Add(m_ProjectionHax1, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALL, 5); - sHacks->Add(m_ProjectionHax2, wxGBPosition(1, 0), wxGBSpan(1, 2), wxALL, 5); - sHacks->Add(m_SafeTextureCache, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALL, 5); - sbHacks->Add(sHacks); - sAdvanced->Add(sbHacks, 0, wxEXPAND|wxALL, 5); + // Sizers + sAdvanced->Add(sbInfo, 0, wxEXPAND | wxALL, 5); + sAdvanced->Add(sbRendering, 0, wxEXPAND | (wxLEFT | wxDOWN | wxRIGHT), 5); + sAdvanced->Add(sbUtilities, 1, wxEXPAND | (wxLEFT | wxDOWN | wxRIGHT), 5); + sAdvanced->Add(m_SizerHacksScreenSize, 0, wxEXPAND | (wxLEFT | wxDOWN | wxRIGHT), 5); + m_PageAdvanced->SetSizer(sAdvanced); sAdvanced->Layout(); Fit(); Center(); + UpdateGUI(); } void ConfigDialog::OnClose(wxCloseEvent& WXUNUSED (event)) @@ -405,6 +477,31 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event) g_Config.iMultisampleMode = atoi(m_AliasModeCB->GetValue().mb_str()); break; } + + UpdateGUI(); +} + +// Apparently we need a scroll event version of this for the sliders +void ConfigDialog::AdvancedSettingsChanged(wxScrollEvent& event) +{ + switch (event.GetId()) + { + // Screen size + case IDS_WIDTH: + g_Config.iScreenWidth = m_SliderWidth->GetValue(); + break; + case IDS_HEIGHT: + g_Config.iScreenHeight = m_SliderHeight->GetValue(); + break; + case IDS_LEFT: + g_Config.iScreenLeft = m_SliderLeft->GetValue(); + break; + case IDS_TOP: + g_Config.iScreenTop = m_SliderTop->GetValue(); + break; + } + + UpdateGUI(); } void ConfigDialog::AdvancedSettingsChanged(wxCommandEvent& event) @@ -453,6 +550,7 @@ void ConfigDialog::AdvancedSettingsChanged(wxCommandEvent& event) case ID_EFBCOPYDISABLEHOTKEY: g_Config.bEFBCopyDisableHotKey = m_EFBCopyDisableHotKey->IsChecked(); break; + // Hacks case ID_PROJECTIONHACK1: g_Config.bProjectionHax1 = m_ProjectionHax1->IsChecked(); break; @@ -462,6 +560,11 @@ void ConfigDialog::AdvancedSettingsChanged(wxCommandEvent& event) case ID_SAFETEXTURECACHE: g_Config.bSafeTextureCache = m_SafeTextureCache->IsChecked(); break; + // Screen size + case IDC_SCREEN_SIZE: + g_Config.bScreenSize = m_ScreenSize->GetValue(); + break; + // Extented frame buffer case ID_RADIO_COPYEFBTORAM: TextureMngr::ClearRenderTargets(); g_Config.bCopyEFBToRAM = true; @@ -479,6 +582,8 @@ void ConfigDialog::AdvancedSettingsChanged(wxCommandEvent& event) default: break; } + + UpdateGUI(); } void ConfigDialog::TexturePathChange(wxFileDirPickerEvent& event) @@ -487,3 +592,12 @@ void ConfigDialog::TexturePathChange(wxFileDirPickerEvent& event) // the combobox) this event wil not be fired. strcpy(g_Config.texDumpPath, event.GetPath().mb_str()); } + +void ConfigDialog::UpdateGUI() +{ + // Update screen size labels + m_TextScreenWidth->SetLabel(wxString::Format("Width: %i", g_Config.iScreenWidth)); + m_TextScreenHeight->SetLabel(wxString::Format("Height: %i", g_Config.iScreenHeight)); + m_TextScreenLeft->SetLabel(wxString::Format("Left: %i", g_Config.iScreenLeft)); + m_TextScreenTop->SetLabel(wxString::Format("Top: %i", g_Config.iScreenTop)); +} \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h index 0fc2d17536..97590c46a1 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h @@ -109,6 +109,10 @@ class ConfigDialog : public wxDialog wxCheckBox *m_ProjectionHax1; wxCheckBox *m_ProjectionHax2; wxCheckBox *m_SafeTextureCache; + // Screen size + wxStaticText *m_TextScreenWidth, *m_TextScreenHeight, *m_TextScreenLeft, *m_TextScreenTop; + wxSlider *m_SliderWidth, *m_SliderHeight, *m_SliderLeft, *m_SliderTop; + wxCheckBox *m_ScreenSize; enum { @@ -159,15 +163,21 @@ class ConfigDialog : public wxDialog ID_PROJECTIONHACK1, ID_PROJECTIONHACK2, ID_RADIO_COPYEFBTORAM, - ID_RADIO_COPYEFBTOGL + ID_RADIO_COPYEFBTOGL, + + // Screen size + IDS_WIDTH, IDS_LEFT, + IDS_HEIGHT, IDS_TOP, + IDC_SCREEN_SIZE }; void OnClose(wxCloseEvent& event); void CreateGUIControls(); + void UpdateGUI(); void AboutClick(wxCommandEvent& event); void GeneralSettingsChanged(wxCommandEvent& event); - void AdvancedSettingsChanged(wxCommandEvent& event); + void AdvancedSettingsChanged(wxCommandEvent& event); void AdvancedSettingsChanged(wxScrollEvent& event); void TexturePathChange(wxFileDirPickerEvent& event); }; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index d2d27b3511..0d2d454905 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -1153,7 +1153,9 @@ void UpdateViewport() 2 * rawViewport[0], 2 * rawViewport[1], (rawViewport[5] - rawViewport[2]) / 16777215.0f, rawViewport[5] / 16777215.0f);*/ + // ----------------------------------------------------------------------- // Keep aspect ratio at 4:3 + // ------------------ // rawViewport[0] = 320, rawViewport[1] = -240 int scissorXOff = bpmem.scissorOffset.x * 2 - 342; int scissorYOff = bpmem.scissorOffset.y * 2 - 342; @@ -1164,13 +1166,15 @@ void UpdateViewport() int xoffs = 0, yoffs = 0; int wid, hei, actualWid, actualHei; + // The rendering window width and height int winw = OpenGL_GetWidth(); int winh = OpenGL_GetHeight(); + // The rendering window aspect ratio float ratio = (float)winw / (float)winh / fourThree; if (g_Config.bKeepAR) { - // Check if height or width is the limiting factor - if (ratio > 1) // then we are to wide and have to limit the width + // Check if height or width is the limiting factor. If ratio > 1 the picture is to wide and have to limit the width. + if (ratio > 1) { wAdj = ratio; hAdj = 1; @@ -1183,7 +1187,8 @@ void UpdateViewport() overfl = (winw - actualWid) / actualRatiow; xoffs = overfl / 2; } - else // the window is to high, we have to limit the height + // The window is to high, we have to limit the height + else { ratio = 1 / ratio; @@ -1204,24 +1209,62 @@ void UpdateViewport() wid = ceil(fabs(2 * xfregs.rawViewport[0])); hei = ceil(fabs(2 * xfregs.rawViewport[1])); } + // ------------------------------------- + + // ----------------------------------------------------------------------- + // GLViewPort variables + // ------------------ + int GLWidth, GLHeight, GLx, GLy; + // ------------------------------------- + + + // ----------------------------------------------------------------------- + // Stretch picture while keeping the native resolution + // ------------------ if (g_Config.bStretchToFit) { - glViewport( - (int)(xfregs.rawViewport[3]-xfregs.rawViewport[0]-342-scissorXOff) + xoffs, - Renderer::GetTargetHeight() - ((int)(xfregs.rawViewport[4]-xfregs.rawViewport[1]-342-scissorYOff)) + yoffs, - wid, // width - hei // height - ); + GLx = (int)(xfregs.rawViewport[3]-xfregs.rawViewport[0]-342-scissorXOff) + xoffs; + GLy = Renderer::GetTargetHeight() - ((int)(xfregs.rawViewport[4]-xfregs.rawViewport[1]-342-scissorYOff)) + yoffs; + GLWidth = wid; // width + GLHeight = hei; // height } else { float MValueX = OpenGL_GetXmax(); float MValueY = OpenGL_GetYmax(); - glViewport((int)(xfregs.rawViewport[3]-xfregs.rawViewport[0]-342-scissorXOff) * MValueX, - Renderer::GetTargetHeight()-((int)(xfregs.rawViewport[4]-xfregs.rawViewport[1]-342-scissorYOff)) * MValueY, - abs((int)(2 * xfregs.rawViewport[0])) * MValueX, abs((int)(2 * xfregs.rawViewport[1])) * MValueY); + + GLx = (int)(xfregs.rawViewport[3]-xfregs.rawViewport[0]-342-scissorXOff) * MValueX; + GLy = Renderer::GetTargetHeight()-((int)(xfregs.rawViewport[4]-xfregs.rawViewport[1]-342-scissorYOff)) * MValueY; + GLWidth = abs((int)(2 * xfregs.rawViewport[0])) * MValueX; + GLHeight = abs((int)(2 * xfregs.rawViewport[1])) * MValueY; } + // ------------------------------------- + + // ----------------------------------------------------------------------- + // Adjust the screen size. If someone figures out how to correctly adjust the screen size as the GC or Wii does, this may not be needed. + // ------------------ + if (g_Config.bScreenSize) + { + // Calculate width and height as a fraction of the current + float Width = (float)GLWidth * ((float)g_Config.iScreenWidth / 100.0); + float Height = (float)GLHeight * ((float)g_Config.iScreenHeight / 100.0); + + // Adjust X and Y + GLx = GLx + g_Config.iScreenLeft; + GLy = GLy - g_Config.iScreenTop; + + GLWidth = (int)Width; + GLHeight = (int)Height; + + //Console::Print("W:%i H:%i W:%f H:%f Wid:%i Hei:%i x:%i y:%i\n", g_Config.iScreenWidth, g_Config.iScreenHeight, Width, Height, GLWidth, GLHeight, GLx, GLy); + } + // ------------------------------------- + + glViewport( + GLx, GLy, + GLWidth, GLHeight + ); glDepthRange((xfregs.rawViewport[5]- xfregs.rawViewport[2])/16777215.0f, xfregs.rawViewport[5]/16777215.0f); }