From 2962be9d524662cc0853a85811fcd994f3ab0761 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Sat, 27 Nov 2021 01:59:40 +0100 Subject: [PATCH] obs/gs/effect: gs_get_device_type() requires graphics context --- source/obs/gs/gs-effect.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/source/obs/gs/gs-effect.cpp b/source/obs/gs/gs-effect.cpp index a47e8ccc..64fcd6ea 100644 --- a/source/obs/gs/gs-effect.cpp +++ b/source/obs/gs/gs-effect.cpp @@ -46,14 +46,17 @@ static std::string load_file_as_code(std::filesystem::path shader_file) } // Push Graphics API to shader. - switch (gs_get_device_type()) { - case GS_DEVICE_DIRECT3D_11: - shader_stream << "#define GS_DEVICE_DIRECT3D_11" << std::endl; - shader_stream << "#define GS_DEVICE_DIRECT3D" << std::endl; - break; - case GS_DEVICE_OPENGL: - shader_stream << "#define GS_DEVICE_OPENGL" << std::endl; - break; + { + auto gctx = streamfx::obs::gs::context(); + switch (gs_get_device_type()) { + case GS_DEVICE_DIRECT3D_11: + shader_stream << "#define GS_DEVICE_DIRECT3D_11" << std::endl; + shader_stream << "#define GS_DEVICE_DIRECT3D" << std::endl; + break; + case GS_DEVICE_OPENGL: + shader_stream << "#define GS_DEVICE_OPENGL" << std::endl; + break; + } } // Pre-process the shader.