diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp index 6bdb3220dc..6e9ef472a8 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp @@ -72,6 +72,8 @@ void Config::Load() iniFile.Get("Enhancements", "ForceMaxAniso", &bForceMaxAniso, 0); iniFile.Get("Enhancements", "StretchToFit", &bStretchToFit, false); iniFile.Get("Enhancements", "KeepAR", &bKeepAR, false); + + iniFile.Get("Hacks", "InvertDepth", &bInvertDepth, 0); } void Config::Save() @@ -100,5 +102,7 @@ void Config::Save() iniFile.Set("Enhancements", "StretchToFit", bStretchToFit); iniFile.Set("Enhancements", "KeepAR", bKeepAR); + iniFile.Set("Hacks", "InvertDepth", bInvertDepth); + iniFile.Save("gfx_opengl.ini"); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Config.h b/Source/Plugins/Plugin_VideoOGL/Src/Config.h index 5221d0583b..b20b47a4f9 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Config.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Config.h @@ -50,6 +50,9 @@ struct Config bool bDumpTextures; char texDumpPath[280]; + // Hacks + bool bInvertDepth; + 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 4badb030d8..0e970b4ffd 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp @@ -44,6 +44,7 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog) EVT_CHECKBOX(ID_TEXFMTCENTER,ConfigDialog::TexFmtOverlayChange) EVT_CHECKBOX(ID_USEXFB,ConfigDialog::UseXFBChange) EVT_CHECKBOX(ID_DUMPTEXTURES,ConfigDialog::DumpTexturesChange) + EVT_CHECKBOX(ID_INVERTDEPTH,ConfigDialog::InvertDepth) EVT_DIRPICKER_CHANGED(ID_TEXTUREPATH,ConfigDialog::TexturePathChange) END_EVENT_TABLE() @@ -70,6 +71,9 @@ void ConfigDialog::CreateGUIControls() m_PageAdvanced = new wxPanel(m_Notebook, ID_PAGEADVANCED, wxDefaultPosition, wxDefaultSize); m_Notebook->AddPage(m_PageAdvanced, wxT("Advanced")); + + m_PageHacks = new wxPanel(m_Notebook, ID_PAGEHACKS, wxDefaultPosition, wxDefaultSize); + m_Notebook->AddPage(m_PageHacks, wxT("Hacks")); //buttons m_About = new wxButton(this, ID_GRAPHIC_ABOUT, wxT("About"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); @@ -164,6 +168,11 @@ void ConfigDialog::CreateGUIControls() //m_ShaderErrors->SetValue(g_Config.bShowShaderErrors); m_ShaderErrors->Enable(false); + // Page 4 (hacks) + m_InvertDepth = new wxCheckBox(m_PageHacks, ID_INVERTDEPTH, wxT("Invert Depth"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_InvertDepth->Enable(true); + m_InvertDepth->SetValue(g_Config.bInvertDepth); + //Put options in sizers within the notebook wxGridBagSizer* sPage1; sPage1 = new wxGridBagSizer(0, 0); @@ -206,6 +215,14 @@ void ConfigDialog::CreateGUIControls() m_PageAdvanced->SetSizer(sPage3); sPage3->Layout(); + wxGridBagSizer* sPage4; + sPage4 = new wxGridBagSizer(0, 0); + sPage4->SetFlexibleDirection(wxBOTH); + sPage4->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); + sPage4->Add(m_InvertDepth, wxGBPosition(0, 0), wxGBSpan(1, 2), wxALL, 5); + m_PageHacks->SetSizer(sPage4); + sPage4->Layout(); + SetIcon(wxNullIcon); Fit(); } @@ -348,3 +365,7 @@ void ConfigDialog::DllAbout(wxCommandEvent& event) info.SetDescription(_T("Vertex/Pixel Shader 2.0 or higher, framebuffer objects, multiple render targets")); wxAboutBox(info); } +void ConfigDialog::InvertDepth(wxCommandEvent& event) +{ + g_Config.bInvertDepth = m_InvertDepth->IsChecked(); +} diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h index cdef7f6827..27d95124f3 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h @@ -46,7 +46,8 @@ class ConfigDialog : public wxDialog virtual ~ConfigDialog(); void OKClick(wxCommandEvent& event); - void FullScreenCheck(wxCommandEvent& event); // video + // Video + void FullScreenCheck(wxCommandEvent& event); void RenderMainCheck(wxCommandEvent& event); void AddFSReso(char *reso); void FSCB(wxCommandEvent& event); @@ -55,12 +56,14 @@ class ConfigDialog : public wxDialog void AddAAMode(int mode); void AACB(wxCommandEvent& event); - void ForceFilteringCheck(wxCommandEvent& event); // enhancements + // Enhancements + void ForceFilteringCheck(wxCommandEvent& event); void ForceAnisotropyCheck(wxCommandEvent& event); void StretchToFitCheck(wxCommandEvent& event); void KeepARCheck(wxCommandEvent& event); - void WireframeCheck(wxCommandEvent& event); // advanced + // Advanced + void WireframeCheck(wxCommandEvent& event); void ShowFPSCheck(wxCommandEvent& event); void OverlayCheck(wxCommandEvent& event); void ShowShaderErrorsCheck(wxCommandEvent& event); @@ -70,6 +73,9 @@ class ConfigDialog : public wxDialog void TexturePathChange(wxFileDirPickerEvent& event); void DllAbout(wxCommandEvent& event); + // Hacks + void InvertDepth(wxCommandEvent& event); + private: wxButton* m_About; @@ -93,9 +99,11 @@ class ConfigDialog : public wxDialog wxComboBox *m_FullscreenCB; wxCheckBox *m_RenderToMainWindow; wxCheckBox *m_Fullscreen; + wxCheckBox *m_InvertDepth; wxPanel *m_PageAdvanced; wxPanel *m_PageEnhancements; wxPanel *m_PageVideo; + wxPanel *m_PageHacks; wxNotebook *m_Notebook; private: @@ -130,6 +138,8 @@ class ConfigDialog : public wxDialog ID_NOTEBOOK, ID_PAGEVIDEO, ID_PAGEENHANCEMENTS, + ID_INVERTDEPTH, + ID_PAGEHACKS, ID_GRAPHIC_ABOUT, ////GUI Enum Control ID End ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp index 7bea2d5383..7d4b0e884e 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderManager.cpp @@ -425,7 +425,7 @@ void VertexShaderMngr::SetConstants() } // Metroid Prime 1 & 2 likes this - glDepthRange(-(0.0f - (rawViewport[5]-rawViewport[2])/16777215.0f), rawViewport[5]/16777215.0f); + glDepthRange((g_Config.bInvertDepth ? -1 : 1) * -(0.0f - (rawViewport[5]-rawViewport[2])/16777215.0f), rawViewport[5]/16777215.0f); // FZero stage likes this (a sonic hack) // glDepthRange(-(0.0f - (rawViewport[5]-rawViewport[2])/-16777215.0f), rawViewport[5]/16777215.0f);