From b07e14f98da00eb639883e5a0c73e34dd6cd24c3 Mon Sep 17 00:00:00 2001 From: The Dax Date: Sat, 12 Oct 2013 00:14:58 -0400 Subject: [PATCH] Win32: Add dynamic submenu for Postprocessing Shaders. --- GPU/GLES/Framebuffer.cpp | 3 ++- Windows/WndMainWindow.cpp | 39 ++++++++++++++++++++++++++++++++++++++- Windows/resource.h | 1 + 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index f28cb2d8fe..1b3bd4f553 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -835,7 +835,8 @@ void FramebufferManager::CopyDisplayToOutput() { // Use the extra FBO, with applied FXAA, as a texture. // fbo_bind_color_as_texture(extraFBOs_[0], 0); - colorTexture = fbo_get_color_texture(extraFBOs_[0]); + if (extraFBOs_.size()) + colorTexture = fbo_get_color_texture(extraFBOs_[0]); } glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight); diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index c1610e68ba..3504712798 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -66,6 +66,7 @@ #include "ControlMapping.h" #include "UI/OnScreenDisplay.h" #include "Core/HLE/sceUtility.h" +#include "GPU/Common/PostShader.h" #ifdef THEMES #include "XPTheme.h" @@ -108,7 +109,8 @@ namespace MainWindow static size_t rawInputBufferSize; static std::map initialMenuKeys; static std::vector countryCodes; - + static std::vector availableShaders; + static std::vector testVec; #define MAX_LOADSTRING 100 const TCHAR *szTitle = TEXT("PPSSPP"); const TCHAR *szWindowClass = TEXT("PPSSPPWnd"); @@ -345,12 +347,14 @@ namespace MainWindow SUBMENU_FILE_SAVESTATE_SLOT = 6, // Game Settings submenus + SUBMENU_CUSTOM_SHADERS = 8, SUBMENU_RENDERING_RESOLUTION = 9, SUBMENU_WINDOW_SIZE = 10, SUBMENU_RENDERING_MODE = 11, SUBMENU_FRAME_SKIPPING = 12, SUBMENU_TEXTURE_FILTERING = 13, SUBMENU_TEXTURE_SCALING = 14, + }; std::string GetMenuItemText(int menuID) { @@ -444,6 +448,23 @@ namespace MainWindow } } + void CreateShadersSubmenu() { + const std::wstring key = L"HEY"; + HMENU optionsMenu = GetSubMenu(menu, MENU_OPTIONS); + RemoveMenu(optionsMenu, SUBMENU_CUSTOM_SHADERS, MF_BYPOSITION); + HMENU shaderMenu = CreatePopupMenu(); + + int item = ID_SHADERS_BASE + 1; + InsertMenu(optionsMenu, SUBMENU_CUSTOM_SHADERS, MF_POPUP | MF_STRING | MF_BYPOSITION, (UINT_PTR)shaderMenu, key.c_str()); + + std::vector info = GetAllPostShaderInfo(); + availableShaders.clear(); + for (auto i = info.begin(); i != info.end(); ++i) { + availableShaders.push_back(i->section); + AppendMenu(shaderMenu, MF_STRING | MF_BYPOSITION | MF_UNCHECKED, item++, ConvertUTF8ToWString(i->name).c_str()); + } + } + void _TranslateMenuItem(const int menuIDOrPosition, const char *key, bool byCommand = false, const std::wstring& accelerator = L"", const HMENU hMenu = menu) { I18NCategory *des = GetI18NCategory("DesktopUI"); @@ -558,6 +579,8 @@ namespace MainWindow // Help menu: it's translated in CreateHelpMenu. CreateHelpMenu(); + CreateShadersSubmenu(); + // TODO: Urgh! Why do we need this here? // The menu is supposed to enable/disable this stuff directly afterward. SetIngameMenuItemStates(globalUIState); @@ -1433,6 +1456,20 @@ namespace MainWindow break; } + + // Handle the dynamic shader switching here. + // The Menu ID is contained in wParam, so subtract + // ID_SHADERS_BASE and an additional 1 off it. + index = (wParam - ID_SHADERS_BASE - 1); + if (index >= 0) { + g_Config.sPostShaderName = availableShaders[index]; + + if (gpu) + gpu->Resized(); + + break; + } + MessageBox(hwndMain, L"Unimplemented", L"Sorry",0); } break; diff --git a/Windows/resource.h b/Windows/resource.h index 5c66173569..f50a955e7d 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -162,6 +162,7 @@ // Don't define anything else in the 3000 range. // It's reserved for languages. #define ID_LANGUAGE_BASE 3000 +#define ID_SHADERS_BASE 5000 #define ID_FILE_EXIT 40000 #define ID_DEBUG_SAVEMAPFILE 40001