From 78411de75e137ba25bfe3b43ffe01c4dffb6ac06 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Fri, 1 Dec 2017 11:55:55 -0800 Subject: [PATCH] libobs/graphics: Add gs_effect_set_color Convenience function for setting a color (in hex format, e.g. 0xAARRGGBB) --- docs/sphinx/reference-libobs-graphics-effects.rst | 10 ++++++++++ libobs/graphics/effect.c | 7 +++++++ libobs/graphics/graphics.h | 2 ++ 3 files changed, 19 insertions(+) diff --git a/docs/sphinx/reference-libobs-graphics-effects.rst b/docs/sphinx/reference-libobs-graphics-effects.rst index 89217d8ba..1392b418a 100644 --- a/docs/sphinx/reference-libobs-graphics-effects.rst +++ b/docs/sphinx/reference-libobs-graphics-effects.rst @@ -288,6 +288,16 @@ HLSL format. --------------------- +.. function:: void gs_effect_set_color(gs_eparam_t *param, uint32_t argb) + + Convenience function for setting a color value via an integer value. + + :param param: Effect parameter + :param argb: Integer color value (i.e. hex value would be + 0xAARRGGBB) + +--------------------- + .. function:: void gs_effect_set_texture(gs_eparam_t *param, gs_texture_t *val) Sets a texture parameter. diff --git a/libobs/graphics/effect.c b/libobs/graphics/effect.c index 737391dd3..4b2a71660 100644 --- a/libobs/graphics/effect.c +++ b/libobs/graphics/effect.c @@ -368,6 +368,13 @@ void gs_effect_set_vec4(gs_eparam_t *param, const struct vec4 *val) effect_setval_inline(param, val, sizeof(struct vec4)); } +void gs_effect_set_color(gs_eparam_t *param, uint32_t argb) +{ + struct vec4 v_color; + vec4_from_bgra(&v_color, argb); + effect_setval_inline(param, &v_color, sizeof(struct vec4)); +} + void gs_effect_set_texture(gs_eparam_t *param, gs_texture_t *val) { effect_setval_inline(param, &val, sizeof(gs_texture_t*)); diff --git a/libobs/graphics/graphics.h b/libobs/graphics/graphics.h index d619c3a69..8ad0afce1 100644 --- a/libobs/graphics/graphics.h +++ b/libobs/graphics/graphics.h @@ -398,6 +398,8 @@ EXPORT void gs_effect_set_default(gs_eparam_t *param); EXPORT void gs_effect_set_next_sampler(gs_eparam_t *param, gs_samplerstate_t *sampler); +EXPORT void gs_effect_set_color(gs_eparam_t *param, uint32_t argb); + /* --------------------------------------------------- * texture render helper functions * --------------------------------------------------- */