1
0
Эх сурвалжийг харах

libobs/graphics: Add gs_effect_set_color

Convenience function for setting a color (in hex format, e.g.
0xAARRGGBB)
jp9000 8 жил өмнө
parent
commit
78411de75e

+ 10 - 0
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.

+ 7 - 0
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*));

+ 2 - 0
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
  * --------------------------------------------------- */