comparison libcore/core/texture.h @ 186:f37b8e95aaaa

core: add blend routines in texture
author David Demelier <markand@malikania.fr>
date Fri, 06 Nov 2020 11:30:29 +0100
parents c92957c3b82b
children 633a25df450e
comparison
equal deleted inserted replaced
185:7103d6574062 186:f37b8e95aaaa
39 unsigned int h; /*!< (-) Texture height. */ 39 unsigned int h; /*!< (-) Texture height. */
40 void *handle; /*!< (*) Native handle. */ 40 void *handle; /*!< (*) Native handle. */
41 }; 41 };
42 42
43 /** 43 /**
44 * \brief Blend type when rendering.
45 */
46 enum texture_blend {
47 TEXTURE_BLEND_NONE, /*!< No pixel modulation. */
48 TEXTURE_BLEND_BLEND, /*!< Blend transparency. */
49 TEXTURE_BLEND_ADD, /*!< Additive blending. */
50 TEXTURE_BLEND_MODULATE /*!< Color modulation. */
51 };
52
53 /**
44 * Create a new texture. 54 * Create a new texture.
45 * 55 *
46 * \pre tex != NULL 56 * \pre tex != NULL
47 * \param tex the texture to initialize 57 * \param tex the texture to initialize
48 * \param w the width 58 * \param w the width
63 */ 73 */
64 bool 74 bool
65 texture_ok(const struct texture *tex); 75 texture_ok(const struct texture *tex);
66 76
67 /** 77 /**
78 * Set blend mode.
79 *
80 * \pre texture_ok(tex)
81 * \param tex the texture
82 * \param blend the blend mode
83 * \return False on errors.
84 */
85 bool
86 texture_set_blend_mode(struct texture *tex, enum texture_blend blend);
87
88 /**
68 * Apply an alpha modulation (aka transparency). 89 * Apply an alpha modulation (aka transparency).
90 *
91 * You may need to use texture_set_blend_mode before this function to work.
69 * 92 *
70 * \pre texture_ok(tex) 93 * \pre texture_ok(tex)
71 * \param tex the texture 94 * \param tex the texture
72 * \param alpha the alpha (0-255) 95 * \param alpha the alpha (0-255)
96 * \return False on errors.
73 */ 97 */
74 bool 98 bool
75 texture_set_alpha_mod(struct texture *tex, unsigned int alpha); 99 texture_set_alpha_mod(struct texture *tex, unsigned int alpha);
76 100
77 /** 101 /**
78 * Apply a color modulation (for every pixel). 102 * Apply a color modulation (for every pixel).
79 * 103 *
80 * \pre texture_ok(tex) 104 * \pre texture_ok(tex)
81 * \param tex the texture to modify 105 * \param tex the texture to modify
82 * \param color the color 106 * \param color the color
107 * \return False on errors.
83 */ 108 */
84 bool 109 bool
85 texture_set_color_mod(struct texture *tex, unsigned long color); 110 texture_set_color_mod(struct texture *tex, unsigned long color);
86 111
87 /** 112 /**