diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp index f37dc3fa79..1a92be40ca 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp @@ -37,13 +37,12 @@ void Config::Load() // get resolution iniFile.Get("Hardware", "WindowedRes", &temp, "640x480"); strncpy(iWindowedRes, temp.c_str(), 16); - - iniFile.Get("Hardware", "FullscreenRes", &temp, "640x480"); + // apply this to the fullscreen resolution too strncpy(iFSResolution, temp.c_str(), 16); 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, true); iniFile.Get("Settings", "StretchToFit", &bNativeResolution, true); iniFile.Get("Settings", "KeepAR_4_3", &bKeepAR43, false); iniFile.Get("Settings", "KeepAR_16_9", &bKeepAR169, false); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp index ceca9c1de6..8b5dddb74a 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp @@ -160,19 +160,16 @@ void ConfigDialog::CreateGUIControls() this->SetSizer(sMain); this->Layout(); - // General - sbBasic = new wxStaticBoxSizer(wxVERTICAL, m_PageGeneral, wxT("Basic Settings")); - m_Fullscreen = new wxCheckBox(m_PageGeneral, ID_FULLSCREEN, wxT("Fullscreen"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - m_Fullscreen->SetValue(g_Config.bFullscreen); - m_VSync = new wxCheckBox(m_PageGeneral, ID_VSYNC, wxT("VSync (req. restart)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - m_VSync->SetValue(g_Config.bVSync); + // 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_NativeResolution = new wxCheckBox(m_PageGeneral, ID_NATIVERESOLUTION, wxT("Native resolution"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_NativeResolution = new wxCheckBox(m_PageGeneral, ID_NATIVERESOLUTION, wxT("native"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); // Aspect ratio / positioning controls - m_KeepAR43 = new wxCheckBox(m_PageGeneral, ID_KEEPAR_4_3, wxT("Keep 4:3 aspect ratio"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - m_KeepAR169 = new wxCheckBox(m_PageGeneral, ID_KEEPAR_16_9, wxT("Keep 16:9 aspect ratio"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + wxStaticText *KeepARText = new wxStaticText(m_PageGeneral, wxID_ANY, wxT("Keep aspect ratio:"), wxDefaultPosition, wxDefaultSize, 0); + m_KeepAR43 = new wxCheckBox(m_PageGeneral, ID_KEEPAR_4_3, wxT("4:3"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_KeepAR169 = new wxCheckBox(m_PageGeneral, ID_KEEPAR_16_9, wxT("16:9"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_Crop = new wxCheckBox(m_PageGeneral, ID_CROP, wxT("Crop"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_UseXFB = new wxCheckBox(m_PageGeneral, ID_USEXFB, wxT("Use Real XFB"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_AutoScale = new wxCheckBox(m_PageGeneral, ID_AUTOSCALE, wxT("Auto scale (try to remove borders)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); @@ -189,14 +186,17 @@ void ConfigDialog::CreateGUIControls() m_HideCursor->SetValue(g_Config.bHideCursor); #endif - wxStaticText *FSText = new wxStaticText(m_PageGeneral, ID_FSTEXT, wxT("Fullscreen video mode:"), wxDefaultPosition, wxDefaultSize, 0); - m_FullscreenCB = new wxComboBox(m_PageGeneral, ID_FULLSCREENCB, arrayStringFor_FullscreenCB[0], wxDefaultPosition, wxDefaultSize, arrayStringFor_FullscreenCB, wxCB_READONLY, wxDefaultValidator); - m_FullscreenCB->SetValue(wxString::FromAscii(g_Config.iFSResolution)); - - wxStaticText *WMText = new wxStaticText(m_PageGeneral, ID_WMTEXT, wxT("Windowed resolution:"), wxDefaultPosition, wxDefaultSize, 0); + wxStaticText *WMText = new wxStaticText(m_PageGeneral, ID_WMTEXT, wxT("Internal resolution:"), 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.iWindowedRes)); + // Advanced Display Settings + sbBasicAdvanced = new wxStaticBoxSizer(wxVERTICAL, m_PageGeneral, wxT("Advanced Display Settings")); + m_Fullscreen = new wxCheckBox(m_PageGeneral, ID_FULLSCREEN, wxT("Fullscreen"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_Fullscreen->SetValue(g_Config.bFullscreen); + m_VSync = new wxCheckBox(m_PageGeneral, ID_VSYNC, wxT("VSync (req. restart)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_VSync->SetValue(g_Config.bVSync); + wxStaticText *MSAAText = new wxStaticText(m_PageGeneral, ID_MSAAMODETEXT, wxT("Antialias (MSAA):"), wxDefaultPosition, wxDefaultSize, 0); m_MSAAModeCB = new wxChoice(m_PageGeneral, ID_MSAAMODECB, wxDefaultPosition, wxDefaultSize, arrayStringFor_MSAAModeCB, 0, wxDefaultValidator); m_MSAAModeCB->Append(wxT("(off)")); @@ -209,26 +209,26 @@ void ConfigDialog::CreateGUIControls() m_MSAAModeCB->Append(wxT("16xQ CSAA")); m_MSAAModeCB->SetSelection(g_Config.iMultisampleMode); - // Tool tips m_Fullscreen->SetToolTip(wxT( "This will create a Fullscreen window using the chosen Fullscreen resolution." "\nPress Alt+Enter to switch between Fullscreen and Windowed mode." - )); + "\n\nApplies instanty during gameplay: No")); m_NativeResolution->SetToolTip(wxT( "This will use the game's native resolution and stretch it to fill the" "\nwindow instead of changing the internal display resolution. It" - "\nmay result in a slightly blurrier image, but it may also give a higher" - "\nFPS if you have a slow graphics card.")); + "\nmay result in a blurrier image, but it may also give a higher" + "\nFPS if you have a slow graphics card." + "\n\nApplies instanty during gameplay: Yes")); m_Crop->SetToolTip(wxT( "Crop the picture instead of creating a letterbox. It will assume that your screen" "\nis of the 5:4 format if you have selected the 4:3 aspect ratio. It will assume" - "\nthat your screen is of the 16:10 format if you have selected the 16:9 aspect ratio.")); - m_FullscreenCB->SetToolTip(wxT( - "Select resolution for the (separate window) fullscreen mode.")); - // This almost sounds like an unnecessary option + "\nthat your screen is of the 16:10 format if you have selected the 16:9 aspect ratio." + "\n\nApplies instanty during gameplay: Yes")); m_WindowResolutionCB->SetToolTip(wxT( - "Select initial resolution for the separate rendering window.")); + "Select internal resolution for the separate rendering window. This resolution also applies" + " to the fullscreen mode" + "\n\nApplies instanty during gameplay: No")); // Enhancements sbEnhancements = new wxStaticBoxSizer(wxVERTICAL, m_PageGeneral, wxT("Enhancements")); @@ -243,32 +243,37 @@ void ConfigDialog::CreateGUIControls() m_ForceFiltering = new wxCheckBox(m_PageGeneral, ID_FORCEFILTERING, wxT("Force bi/trilinear filtering"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_ForceFiltering->SetValue(g_Config.bForceFiltering); - // Usage: The wxGBPosition() must have a column and row + // How to use the wxGridBagSizer: The wxGBPosition() must have a column and row sGeneral = new wxBoxSizer(wxVERTICAL); - sBasic = new wxGridBagSizer(0, 0); - sBasic->Add(m_Fullscreen, wxGBPosition(0, 0), wxGBSpan(1, 3), wxALL, 5); - sBasic->Add(m_VSync, wxGBPosition(1, 0), wxGBSpan(1, 3), wxALL, 5); - sBasic->Add(m_RenderToMainWindow, wxGBPosition(2, 0), wxGBSpan(1, 3), wxALL, 5); - sBasic->Add(m_AutoScale, wxGBPosition(3, 0), wxGBSpan(1, 3), wxALL, 5); - sBasic->Add(m_NativeResolution, wxGBPosition(4, 0), wxGBSpan(1, 3), wxALL, 5); - sBasic->Add(m_UseXFB, wxGBPosition(5, 0), wxGBSpan(1, 3), wxALL, 5); - sBasic->Add(m_KeepAR43, wxGBPosition(6, 0), wxGBSpan(1, 1), wxALL, 5); - sBasic->Add(m_KeepAR169, wxGBPosition(6, 1), wxGBSpan(1, 1), wxALL, 5); - sBasic->Add(m_Crop, wxGBPosition(6, 2), wxGBSpan(1, 1), wxALL, 5); + sBasic = new wxGridBagSizer(0, 0); - // Because of the ifdef here we need this variable for the row number - int Row = 7; + sBasic->Add(WMText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5); + sBasic->Add(m_NativeResolution, wxGBPosition(0, 1), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxTOP, 0); + sBasic->Add(m_WindowResolutionCB, wxGBPosition(0, 2), wxGBSpan(1, 2), wxALL, 5); + + sBasic->Add(KeepARText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5); + sBasic->Add(m_KeepAR43, wxGBPosition(1, 1), wxGBSpan(1, 1), wxALL, 5); + sBasic->Add(m_KeepAR169, wxGBPosition(1, 2), wxGBSpan(1, 1), wxALL, 5); + sBasic->Add(m_Crop, wxGBPosition(1, 3), wxGBSpan(1, 1), wxALL, 5); + + // This option is configured from the main Dolphin.exe settings for _WIN32 #ifndef _WIN32 - sBasic->Add(m_HideCursor, wxGBPosition(Row++, 0), wxGBSpan(1, 3), wxALL, 5); + sBasic->Add(m_HideCursor, wxGBPosition(5, 0), wxGBSpan(1, 3), wxALL, 5); #endif - sBasic->Add(FSText, wxGBPosition(Row, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5); - sBasic->Add(m_FullscreenCB, wxGBPosition(Row++, 1), wxGBSpan(1, 1), wxALL, 5); - sBasic->Add(WMText, wxGBPosition(Row, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL | wxALL, 5); - sBasic->Add(m_WindowResolutionCB, wxGBPosition(Row++, 1), wxGBSpan(1, 1), wxALL, 5); sbBasic->Add(sBasic); sGeneral->Add(sbBasic, 0, wxEXPAND|wxALL, 5); + sBasicAdvanced = new wxGridBagSizer(0, 0); + sBasicAdvanced->Add(m_Fullscreen, 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(m_AutoScale, wxGBPosition(4, 0), wxGBSpan(1, 3), wxALL, 5); + + sbBasicAdvanced->Add(sBasicAdvanced); + sGeneral->Add(sbBasicAdvanced, 0, wxEXPAND|wxALL, 5); + sEnhancements = new wxGridBagSizer(0, 0); sEnhancements->Add(AnisoText, wxGBPosition(0, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); sEnhancements->Add(m_MaxAnisotropyCB, wxGBPosition(0, 1), wxGBSpan(1, 2), wxALL, 5); @@ -502,11 +507,10 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event) g_Config.bHideCursor = m_HideCursor->IsChecked(); break; #endif - case ID_FULLSCREENCB: - strcpy(g_Config.iFSResolution, m_FullscreenCB->GetValue().mb_str() ); - break; case ID_WINDOWRESOLUTIONCB: strcpy(g_Config.iWindowedRes, m_WindowResolutionCB->GetValue().mb_str() ); + // Apply this resolution as fullscreen resolution too + strcpy(g_Config.iFSResolution, m_WindowResolutionCB->GetValue().mb_str() ); break; case ID_MAXANISOTROPY: g_Config.iMaxAnisotropy = m_MaxAnisotropyCB->GetSelection() + 1; @@ -636,9 +640,12 @@ void ConfigDialog::UpdateGUI() m_Fullscreen->Enable(!g_Config.renderToMainframe); if (g_Config.renderToMainframe) m_Fullscreen->SetValue(false); - m_FullscreenCB->Enable(!g_Config.renderToMainframe); - m_WindowResolutionCB->Enable(!g_Config.renderToMainframe); + + // Disable the internal resolution option if it's set to native + m_WindowResolutionCB->Enable(!g_Config.bNativeResolution); } + + void Config::UpdateProjectionHack() { switch(g_Config.iPhackvalue) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h index e77dd4ada6..7ec4fd30d3 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h @@ -65,8 +65,8 @@ class ConfigDialog : public wxDialog DECLARE_EVENT_TABLE(); wxBoxSizer* sGeneral; - wxStaticBoxSizer* sbBasic; - wxGridBagSizer* sBasic; + wxStaticBoxSizer* sbBasic, *sbBasicAdvanced; + wxGridBagSizer* sBasic, *sBasicAdvanced; wxStaticBoxSizer* sbEnhancements; wxGridBagSizer* sEnhancements; wxBoxSizer* sAdvanced; @@ -95,7 +95,6 @@ class ConfigDialog : public wxDialog #ifndef _WIN32 wxCheckBox *m_HideCursor; #endif - wxComboBox *m_FullscreenCB; wxArrayString arrayStringFor_WindowResolutionCB; wxComboBox *m_WindowResolutionCB; wxArrayString arrayStringFor_MaxAnisotropyCB; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index b8632a9deb..932daf6f89 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -50,6 +50,7 @@ #include "XFB.h" #include "OnScreenDisplay.h" #include "Timer.h" +#include "StringUtil.h" #include "main.h" // Local #ifdef _WIN32 @@ -868,6 +869,32 @@ void Renderer::Swap(const TRectangle& rc) v_max = (float)GetTargetHeight(); } + // --------------------------------------------------------------------- + // Save screenshot + // ŻŻŻŻŻŻŻŻŻŻŻŻŻ + if (s_bScreenshot) + { + s_criticalScreenshot.Enter(); + + /* + // Logging + char msg[255]; + sprintf(msg, "Target: %i | %i %i %i %i\n", + (int)v_min, + //back_rc.top, back_rc.left, back_rc.right, back_rc.bottom); + rc.right, rc.bottom - (int)(v_min), rc.right, rc.bottom); + OSD::AddMessage(msg, 5000); + */ + + // Save screenshot + SaveRenderTarget(s_sScreenshotName.c_str(), rc.right, rc.bottom, (int)(v_min)); + // Reset settings + s_sScreenshotName = ""; + s_bScreenshot = false; + s_criticalScreenshot.Leave(); + } + // --------------------------------------------------------------------- + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); if (/*s_bHaveFramebufferBlit*/ s_MSAASamples > 1) @@ -940,21 +967,6 @@ void Renderer::Swap(const TRectangle& rc) if (g_Config.bWireFrame) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - // Take screenshot, if requested - if (s_bScreenshot) { - s_criticalScreenshot.Enter(); - if (SaveRenderTarget(s_sScreenshotName.c_str(), OpenGL_GetBackbufferWidth(), OpenGL_GetBackbufferHeight())) { - char msg[255]; - sprintf(msg, "Saved %s\n", s_sScreenshotName.c_str()); - OSD::AddMessage(msg, 2000); - } else { - PanicAlert("Error capturing or saving screenshot."); - } - s_sScreenshotName = ""; - s_bScreenshot = false; - s_criticalScreenshot.Leave(); - } - // Frame dumps are handled a little differently in Windows #ifdef _WIN32 if (g_Config.bDumpFrames) { @@ -1262,18 +1274,60 @@ void Renderer::SetScreenshot(const char *filename) s_criticalScreenshot.Leave(); } -bool Renderer::SaveRenderTarget(const char *filename, int w, int h) +bool Renderer::SaveRenderTarget(const char *filename, int W, int H, int YOffset) { - u8 *data = (u8 *)malloc(3 * w * h); + // The height seemed to be one less than the setting sometimes (and sometimes not), + // perhaps a rounding error + if (H == 479) H = 480; + if (H == 599) H = 600; + if (H == 767) H = 768; + if (H == 1023) H = 1024; + + u8 *data = (u8 *)malloc(3 * W * H); glPixelStorei(GL_PACK_ALIGNMENT, 1); - glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, data); + glReadPixels(0, YOffset, W, H, GL_RGB, GL_UNSIGNED_BYTE, data); + // Show failure messages if (glGetError() != GL_NO_ERROR) - return false; - FlipImageData(data, w, h); + OSD::AddMessage("Error capturing or saving screenshot.", 2000); + // Turn image upside down + FlipImageData(data, W, H); #if defined(HAVE_WX) && HAVE_WX - wxImage a(w, h, data); + // Create wxImage + wxImage a(W, H, data); + + // --------------------------------------------------------------------- + // If it's not a 4:3 picture rescale it to 4:3. This only applied to native resolutions. + // ŻŻŻŻŻŻŻŻŻŻŻŻŻ + // Todo: There is currently no adjustment for non-16:9 source pictures that are intended for a 16:9 + // size because I think all Wii 16:9 source pictures are 16:9 to begin with. If not, add a 16:9 adjustment + // too. + // ŻŻŻŻŻŻŻŻŻŻŻŻŻ + /**/ + float Ratio = (float)W / (float)(H); + // Don't bother with 1.25 resolutions either, for example 1280 x 1024 + if (g_Config.bNativeResolution && Ratio != 4.0/3.0 && Ratio != 1.25 && Ratio != 16.0/9.0) + { + // Check if the height or width should be changed + if (Ratio < 4.0/3.0) + { + float fW = (float)W * 4.0/3.0; + W = (int)fW; + } + else + { + float fH = (float)W * 3.0/4.0; + H = (int)fH; + } + a.Rescale(W, H, wxIMAGE_QUALITY_HIGH); + } + // --------------------------------------------------------------------- + a.SaveFile(wxString::FromAscii(filename), wxBITMAP_TYPE_BMP); bool result = true; + + // Show success messages + OSD::AddMessage(StringFromFormat("Saved %i x %i %s\n", W, H, s_sScreenshotName.c_str()).c_str(), 2000); + #else bool result = SaveTGA(filename, w, h, data); free(data); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.h b/Source/Plugins/Plugin_VideoOGL/Src/Render.h index 10b84762a4..d049dd617c 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.h @@ -86,7 +86,7 @@ public: static void DrawDebugText(); static void SetScreenshot(const char *filename); static void FlipImageData(u8 *data, int w, int h); - static bool SaveRenderTarget(const char *filename, int w, int h); + static bool SaveRenderTarget(const char *filename, int, int, int); // Finish up the current frame, print some stats static void Swap(const TRectangle& rc); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index 4d2d219850..1be8064e64 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -15,6 +15,25 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ + +////////////////////////////////////////////////////////////////////////////////////////// +// OpenGL Plugin Documentation +/* ŻŻŻŻŻŻŻŻŻŻŻŻŻ + +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. + +Todo: Make the internal resolution option apply instantly, currently only the native or not option +applies instantly + +////////////////////////////////////////////////////////////////////////////////////////*/ + + + #include "Globals.h" #include