From 7045cd84781f00efb8c435d8b76bb8c49d6ceec5 Mon Sep 17 00:00:00 2001 From: OV2 Date: Fri, 1 Feb 2019 22:41:29 +0100 Subject: [PATCH] win32: pass around active shader to parameter dialog --- win32/COpenGL.h | 4 ++++ win32/win32_display.cpp | 5 +++++ win32/win32_display.h | 2 ++ win32/wsnes9x.cpp | 19 +++++++++++-------- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/win32/COpenGL.h b/win32/COpenGL.h index 1e43dc2d..e65787ec 100644 --- a/win32/COpenGL.h +++ b/win32/COpenGL.h @@ -82,6 +82,10 @@ public: bool SetFullscreen(bool fullscreen); void SetSnes9xColorFormat(void); void EnumModes(std::vector *modeVector); + GLSLShader *GetActiveShader() + { + return glslShader; + } }; diff --git a/win32/win32_display.cpp b/win32/win32_display.cpp index 9a54dca4..e754c326 100644 --- a/win32/win32_display.cpp +++ b/win32/win32_display.cpp @@ -617,6 +617,11 @@ int WinGetAutomaticInputRate(void) return (int)newInputRate; } +GLSLShader *WinGetActiveGLSLShader() +{ + return OpenGL.GetActiveShader(); +} + /* Depth conversion functions begin */ void Convert16To24 (SSurface *src, SSurface *dst, RECT *srect) diff --git a/win32/win32_display.h b/win32/win32_display.h index 45606b5d..0439b557 100644 --- a/win32/win32_display.h +++ b/win32/win32_display.h @@ -10,6 +10,7 @@ #include "wsnes9x.h" #include "port.h" #include "render.h" +#include "../shaders/glsl.h" #include #define IsHiRes(x) ((x.Height > SNES_HEIGHT_EXTENDED || x.Width == 512)) @@ -40,5 +41,6 @@ char *ReadShaderFileContents(const TCHAR *filename); void ReduceToPath(TCHAR *filename); double WinGetRefreshRate(); int WinGetAutomaticInputRate(); +GLSLShader *WinGetActiveGLSLShader(); #endif diff --git a/win32/wsnes9x.cpp b/win32/wsnes9x.cpp index ea5b1832..4034417b 100644 --- a/win32/wsnes9x.cpp +++ b/win32/wsnes9x.cpp @@ -7740,14 +7740,17 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) break; } ShowWindow(hDlg, SW_HIDE); - GLSLShader shader; - shader.load_shader(_tToChar(GUI.OGLshaderFileName)); - CShaderParamDlg dlg(shader); - if(dlg.show()) { - SetDlgItemText(hDlg, IDC_SHADER_GLSL_FILE, GUI.OGLshaderFileName); - WinDisplayApplyChanges(); - WinRefreshDisplay(); - } + WinDisplayApplyChanges(); + WinRefreshDisplay(); + GLSLShader *shader = WinGetActiveGLSLShader(); + if (shader) { + CShaderParamDlg dlg(*shader); + if (dlg.show()) { + SetDlgItemText(hDlg, IDC_SHADER_GLSL_FILE, GUI.OGLshaderFileName); + WinDisplayApplyChanges(); + WinRefreshDisplay(); + } + } ShowWindow(hDlg, SW_SHOW); break; }