diff options
author | 3gg <3gg@shellblade.net> | 2025-08-30 16:53:58 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2025-08-30 16:53:58 -0700 |
commit | 6aaedb813fa11ba0679c3051bc2eb28646b9506c (patch) | |
tree | 34acbfc9840e02cb4753e6306ea7ce978bf8b58e /src/contrib/SDL-3.2.20/include/SDL3/SDL_blendmode.h | |
parent | 8f228ade99dd3d4c8da9b78ade1815c9adf85c8f (diff) |
Update to SDL3
Diffstat (limited to 'src/contrib/SDL-3.2.20/include/SDL3/SDL_blendmode.h')
-rw-r--r-- | src/contrib/SDL-3.2.20/include/SDL3/SDL_blendmode.h | 202 |
1 files changed, 202 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/include/SDL3/SDL_blendmode.h b/src/contrib/SDL-3.2.20/include/SDL3/SDL_blendmode.h new file mode 100644 index 0000000..8f00cbc --- /dev/null +++ b/src/contrib/SDL-3.2.20/include/SDL3/SDL_blendmode.h | |||
@@ -0,0 +1,202 @@ | |||
1 | /* | ||
2 | Simple DirectMedia Layer | ||
3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
4 | |||
5 | This software is provided 'as-is', without any express or implied | ||
6 | warranty. In no event will the authors be held liable for any damages | ||
7 | arising from the use of this software. | ||
8 | |||
9 | Permission is granted to anyone to use this software for any purpose, | ||
10 | including commercial applications, and to alter it and redistribute it | ||
11 | freely, subject to the following restrictions: | ||
12 | |||
13 | 1. The origin of this software must not be misrepresented; you must not | ||
14 | claim that you wrote the original software. If you use this software | ||
15 | in a product, an acknowledgment in the product documentation would be | ||
16 | appreciated but is not required. | ||
17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
18 | misrepresented as being the original software. | ||
19 | 3. This notice may not be removed or altered from any source distribution. | ||
20 | */ | ||
21 | |||
22 | /** | ||
23 | * # CategoryBlendmode | ||
24 | * | ||
25 | * Blend modes decide how two colors will mix together. There are both | ||
26 | * standard modes for basic needs and a means to create custom modes, | ||
27 | * dictating what sort of math to do on what color components. | ||
28 | */ | ||
29 | |||
30 | #ifndef SDL_blendmode_h_ | ||
31 | #define SDL_blendmode_h_ | ||
32 | |||
33 | #include <SDL3/SDL_stdinc.h> | ||
34 | |||
35 | #include <SDL3/SDL_begin_code.h> | ||
36 | /* Set up for C function definitions, even when using C++ */ | ||
37 | #ifdef __cplusplus | ||
38 | extern "C" { | ||
39 | #endif | ||
40 | |||
41 | /** | ||
42 | * A set of blend modes used in drawing operations. | ||
43 | * | ||
44 | * These predefined blend modes are supported everywhere. | ||
45 | * | ||
46 | * Additional values may be obtained from SDL_ComposeCustomBlendMode. | ||
47 | * | ||
48 | * \since This datatype is available since SDL 3.2.0. | ||
49 | * | ||
50 | * \sa SDL_ComposeCustomBlendMode | ||
51 | */ | ||
52 | typedef Uint32 SDL_BlendMode; | ||
53 | |||
54 | #define SDL_BLENDMODE_NONE 0x00000000u /**< no blending: dstRGBA = srcRGBA */ | ||
55 | #define SDL_BLENDMODE_BLEND 0x00000001u /**< alpha blending: dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)), dstA = srcA + (dstA * (1-srcA)) */ | ||
56 | #define SDL_BLENDMODE_BLEND_PREMULTIPLIED 0x00000010u /**< pre-multiplied alpha blending: dstRGBA = srcRGBA + (dstRGBA * (1-srcA)) */ | ||
57 | #define SDL_BLENDMODE_ADD 0x00000002u /**< additive blending: dstRGB = (srcRGB * srcA) + dstRGB, dstA = dstA */ | ||
58 | #define SDL_BLENDMODE_ADD_PREMULTIPLIED 0x00000020u /**< pre-multiplied additive blending: dstRGB = srcRGB + dstRGB, dstA = dstA */ | ||
59 | #define SDL_BLENDMODE_MOD 0x00000004u /**< color modulate: dstRGB = srcRGB * dstRGB, dstA = dstA */ | ||
60 | #define SDL_BLENDMODE_MUL 0x00000008u /**< color multiply: dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)), dstA = dstA */ | ||
61 | #define SDL_BLENDMODE_INVALID 0x7FFFFFFFu | ||
62 | |||
63 | /** | ||
64 | * The blend operation used when combining source and destination pixel | ||
65 | * components. | ||
66 | * | ||
67 | * \since This enum is available since SDL 3.2.0. | ||
68 | */ | ||
69 | typedef enum SDL_BlendOperation | ||
70 | { | ||
71 | SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */ | ||
72 | SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< src - dst : supported by D3D, OpenGL, OpenGLES, and Vulkan */ | ||
73 | SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< dst - src : supported by D3D, OpenGL, OpenGLES, and Vulkan */ | ||
74 | SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan */ | ||
75 | SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D, OpenGL, OpenGLES, and Vulkan */ | ||
76 | } SDL_BlendOperation; | ||
77 | |||
78 | /** | ||
79 | * The normalized factor used to multiply pixel components. | ||
80 | * | ||
81 | * The blend factors are multiplied with the pixels from a drawing operation | ||
82 | * (src) and the pixels from the render target (dst) before the blend | ||
83 | * operation. The comma-separated factors listed above are always applied in | ||
84 | * the component order red, green, blue, and alpha. | ||
85 | * | ||
86 | * \since This enum is available since SDL 3.2.0. | ||
87 | */ | ||
88 | typedef enum SDL_BlendFactor | ||
89 | { | ||
90 | SDL_BLENDFACTOR_ZERO = 0x1, /**< 0, 0, 0, 0 */ | ||
91 | SDL_BLENDFACTOR_ONE = 0x2, /**< 1, 1, 1, 1 */ | ||
92 | SDL_BLENDFACTOR_SRC_COLOR = 0x3, /**< srcR, srcG, srcB, srcA */ | ||
93 | SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4, /**< 1-srcR, 1-srcG, 1-srcB, 1-srcA */ | ||
94 | SDL_BLENDFACTOR_SRC_ALPHA = 0x5, /**< srcA, srcA, srcA, srcA */ | ||
95 | SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6, /**< 1-srcA, 1-srcA, 1-srcA, 1-srcA */ | ||
96 | SDL_BLENDFACTOR_DST_COLOR = 0x7, /**< dstR, dstG, dstB, dstA */ | ||
97 | SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */ | ||
98 | SDL_BLENDFACTOR_DST_ALPHA = 0x9, /**< dstA, dstA, dstA, dstA */ | ||
99 | SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */ | ||
100 | } SDL_BlendFactor; | ||
101 | |||
102 | /** | ||
103 | * Compose a custom blend mode for renderers. | ||
104 | * | ||
105 | * The functions SDL_SetRenderDrawBlendMode and SDL_SetTextureBlendMode accept | ||
106 | * the SDL_BlendMode returned by this function if the renderer supports it. | ||
107 | * | ||
108 | * A blend mode controls how the pixels from a drawing operation (source) get | ||
109 | * combined with the pixels from the render target (destination). First, the | ||
110 | * components of the source and destination pixels get multiplied with their | ||
111 | * blend factors. Then, the blend operation takes the two products and | ||
112 | * calculates the result that will get stored in the render target. | ||
113 | * | ||
114 | * Expressed in pseudocode, it would look like this: | ||
115 | * | ||
116 | * ```c | ||
117 | * dstRGB = colorOperation(srcRGB * srcColorFactor, dstRGB * dstColorFactor); | ||
118 | * dstA = alphaOperation(srcA * srcAlphaFactor, dstA * dstAlphaFactor); | ||
119 | * ``` | ||
120 | * | ||
121 | * Where the functions `colorOperation(src, dst)` and `alphaOperation(src, | ||
122 | * dst)` can return one of the following: | ||
123 | * | ||
124 | * - `src + dst` | ||
125 | * - `src - dst` | ||
126 | * - `dst - src` | ||
127 | * - `min(src, dst)` | ||
128 | * - `max(src, dst)` | ||
129 | * | ||
130 | * The red, green, and blue components are always multiplied with the first, | ||
131 | * second, and third components of the SDL_BlendFactor, respectively. The | ||
132 | * fourth component is not used. | ||
133 | * | ||
134 | * The alpha component is always multiplied with the fourth component of the | ||
135 | * SDL_BlendFactor. The other components are not used in the alpha | ||
136 | * calculation. | ||
137 | * | ||
138 | * Support for these blend modes varies for each renderer. To check if a | ||
139 | * specific SDL_BlendMode is supported, create a renderer and pass it to | ||
140 | * either SDL_SetRenderDrawBlendMode or SDL_SetTextureBlendMode. They will | ||
141 | * return with an error if the blend mode is not supported. | ||
142 | * | ||
143 | * This list describes the support of custom blend modes for each renderer. | ||
144 | * All renderers support the four blend modes listed in the SDL_BlendMode | ||
145 | * enumeration. | ||
146 | * | ||
147 | * - **direct3d**: Supports all operations with all factors. However, some | ||
148 | * factors produce unexpected results with `SDL_BLENDOPERATION_MINIMUM` and | ||
149 | * `SDL_BLENDOPERATION_MAXIMUM`. | ||
150 | * - **direct3d11**: Same as Direct3D 9. | ||
151 | * - **opengl**: Supports the `SDL_BLENDOPERATION_ADD` operation with all | ||
152 | * factors. OpenGL versions 1.1, 1.2, and 1.3 do not work correctly here. | ||
153 | * - **opengles2**: Supports the `SDL_BLENDOPERATION_ADD`, | ||
154 | * `SDL_BLENDOPERATION_SUBTRACT`, `SDL_BLENDOPERATION_REV_SUBTRACT` | ||
155 | * operations with all factors. | ||
156 | * - **psp**: No custom blend mode support. | ||
157 | * - **software**: No custom blend mode support. | ||
158 | * | ||
159 | * Some renderers do not provide an alpha component for the default render | ||
160 | * target. The `SDL_BLENDFACTOR_DST_ALPHA` and | ||
161 | * `SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA` factors do not have an effect in this | ||
162 | * case. | ||
163 | * | ||
164 | * \param srcColorFactor the SDL_BlendFactor applied to the red, green, and | ||
165 | * blue components of the source pixels. | ||
166 | * \param dstColorFactor the SDL_BlendFactor applied to the red, green, and | ||
167 | * blue components of the destination pixels. | ||
168 | * \param colorOperation the SDL_BlendOperation used to combine the red, | ||
169 | * green, and blue components of the source and | ||
170 | * destination pixels. | ||
171 | * \param srcAlphaFactor the SDL_BlendFactor applied to the alpha component of | ||
172 | * the source pixels. | ||
173 | * \param dstAlphaFactor the SDL_BlendFactor applied to the alpha component of | ||
174 | * the destination pixels. | ||
175 | * \param alphaOperation the SDL_BlendOperation used to combine the alpha | ||
176 | * component of the source and destination pixels. | ||
177 | * \returns an SDL_BlendMode that represents the chosen factors and | ||
178 | * operations. | ||
179 | * | ||
180 | * \threadsafety It is safe to call this function from any thread. | ||
181 | * | ||
182 | * \since This function is available since SDL 3.2.0. | ||
183 | * | ||
184 | * \sa SDL_SetRenderDrawBlendMode | ||
185 | * \sa SDL_GetRenderDrawBlendMode | ||
186 | * \sa SDL_SetTextureBlendMode | ||
187 | * \sa SDL_GetTextureBlendMode | ||
188 | */ | ||
189 | extern SDL_DECLSPEC SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor, | ||
190 | SDL_BlendFactor dstColorFactor, | ||
191 | SDL_BlendOperation colorOperation, | ||
192 | SDL_BlendFactor srcAlphaFactor, | ||
193 | SDL_BlendFactor dstAlphaFactor, | ||
194 | SDL_BlendOperation alphaOperation); | ||
195 | |||
196 | /* Ends C function definitions when using C++ */ | ||
197 | #ifdef __cplusplus | ||
198 | } | ||
199 | #endif | ||
200 | #include <SDL3/SDL_close_code.h> | ||
201 | |||
202 | #endif /* SDL_blendmode_h_ */ | ||