From 6fe33df708fff44672accced2c171414417e9c27 Mon Sep 17 00:00:00 2001 From: jpark37 Date: Wed, 20 Jan 2021 08:18:09 -0800 Subject: [PATCH] libobs-winrt: Support linear SRGB Switch away from GDI-compatible texture for SRGB support. Never needed GDI compatibility anyway. --- libobs-winrt/winrt-capture.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/libobs-winrt/winrt-capture.cpp b/libobs-winrt/winrt-capture.cpp index 3cc14e7b1..9dfc33c00 100644 --- a/libobs-winrt/winrt-capture.cpp +++ b/libobs-winrt/winrt-capture.cpp @@ -186,8 +186,10 @@ struct winrt_capture { } if (!texture) { - texture = gs_texture_create_gdi(texture_width, - texture_height); + texture = gs_texture_create(texture_width, + texture_height, + GS_BGRA, 1, NULL, + 0); } if (client_area) { @@ -491,7 +493,15 @@ static void draw_texture(struct winrt_capture *capture, gs_effect_t *effect) gs_eparam_t *image = gs_effect_get_param_by_name(effect, "image"); size_t passes; - gs_effect_set_texture(image, texture); + const bool linear_srgb = gs_get_linear_srgb(); + + const bool previous = gs_framebuffer_srgb_enabled(); + gs_enable_framebuffer_srgb(linear_srgb); + + if (linear_srgb) + gs_effect_set_texture_srgb(image, texture); + else + gs_effect_set_texture(image, texture); passes = gs_technique_begin(tech); for (size_t i = 0; i < passes; i++) { @@ -502,6 +512,8 @@ static void draw_texture(struct winrt_capture *capture, gs_effect_t *effect) } } gs_technique_end(tech); + + gs_enable_framebuffer_srgb(previous); } extern "C" EXPORT BOOL winrt_capture_active(const struct winrt_capture *capture)