this repo has no description
1#ifndef _SDL_GPU_H__
2#define _SDL_GPU_H__
3
4#include "SDL.h"
5#include <stdio.h>
6#include <stdarg.h>
7
8// Use SDL's DLL defines
9#include "begin_code.h"
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15// Compile-time versions
16#define SDL_GPU_VERSION_MAJOR 0
17#define SDL_GPU_VERSION_MINOR 11
18#define SDL_GPU_VERSION_PATCH 0
19
20/* Auto-detect if we're using the SDL2 API by the headers available. */
21#if SDL_VERSION_ATLEAST(2,0,0)
22 #define SDL_GPU_USE_SDL2
23#else
24 #define SDL_GPU_USE_SDL1
25#endif
26
27typedef struct GPU_Renderer GPU_Renderer;
28typedef struct GPU_Target GPU_Target;
29
30/*!
31 * \defgroup Initialization Initialization
32 * \defgroup Logging Debugging, Logging, and Error Handling
33 * \defgroup RendererSetup Renderer Setup
34 * \defgroup RendererControls Renderer Controls
35 * \defgroup ContextControls Context Controls
36 * \defgroup TargetControls Target Controls
37 * \defgroup SurfaceControls Surface Controls
38 * \defgroup ImageControls Image Controls
39 * \defgroup Conversions Surface, Image, and Target Conversions
40 * \defgroup Matrix Matrix Controls
41 * \defgroup Rendering Rendering
42 * \defgroup Shapes Shapes
43 * \defgroup ShaderInterface Shader Interface
44 */
45
46/*! \ingroup Rendering
47 * A struct representing a rectangular area with floating point precision.
48 * \see GPU_MakeRect()
49 */
50typedef struct GPU_Rect
51{
52 float x, y;
53 float w, h;
54} GPU_Rect;
55
56#define GPU_RENDERER_ORDER_MAX 10
57
58typedef Uint32 GPU_RendererEnum;
59static const GPU_RendererEnum GPU_RENDERER_UNKNOWN = 0; // invalid value
60static const GPU_RendererEnum GPU_RENDERER_OPENGL_1_BASE = 1;
61static const GPU_RendererEnum GPU_RENDERER_OPENGL_1 = 2;
62static const GPU_RendererEnum GPU_RENDERER_OPENGL_2 = 3;
63static const GPU_RendererEnum GPU_RENDERER_OPENGL_3 = 4;
64static const GPU_RendererEnum GPU_RENDERER_OPENGL_4 = 5;
65static const GPU_RendererEnum GPU_RENDERER_GLES_1 = 11;
66static const GPU_RendererEnum GPU_RENDERER_GLES_2 = 12;
67static const GPU_RendererEnum GPU_RENDERER_GLES_3 = 13;
68static const GPU_RendererEnum GPU_RENDERER_D3D9 = 21;
69static const GPU_RendererEnum GPU_RENDERER_D3D10 = 22;
70static const GPU_RendererEnum GPU_RENDERER_D3D11 = 23;
71#define GPU_RENDERER_CUSTOM_0 1000
72
73/*! \ingroup Initialization
74 * \ingroup RendererSetup
75 * \ingroup RendererControls
76 * Renderer ID object for identifying a specific renderer.
77 * \see GPU_MakeRendererID()
78 * \see GPU_InitRendererByID()
79 */
80typedef struct GPU_RendererID
81{
82 const char* name;
83 GPU_RendererEnum renderer;
84 int major_version;
85 int minor_version;
86} GPU_RendererID;
87
88
89/*! \ingroup ImageControls
90 * Blend component functions
91 * \see GPU_SetBlendFunction()
92 * Values chosen for direct OpenGL compatibility.
93 */
94typedef enum {
95 GPU_FUNC_ZERO = 0,
96 GPU_FUNC_ONE = 1,
97 GPU_FUNC_SRC_COLOR = 0x0300,
98 GPU_FUNC_DST_COLOR = 0x0306,
99 GPU_FUNC_ONE_MINUS_SRC = 0x0301,
100 GPU_FUNC_ONE_MINUS_DST = 0x0307,
101 GPU_FUNC_SRC_ALPHA = 0x0302,
102 GPU_FUNC_DST_ALPHA = 0x0304,
103 GPU_FUNC_ONE_MINUS_SRC_ALPHA = 0x0303,
104 GPU_FUNC_ONE_MINUS_DST_ALPHA = 0x0305
105} GPU_BlendFuncEnum;
106
107/*! \ingroup ImageControls
108 * Blend component equations
109 * \see GPU_SetBlendEquation()
110 * Values chosen for direct OpenGL compatibility.
111 */
112typedef enum {
113 GPU_EQ_ADD = 0x8006,
114 GPU_EQ_SUBTRACT = 0x800A,
115 GPU_EQ_REVERSE_SUBTRACT = 0x800B
116} GPU_BlendEqEnum;
117
118/*! \ingroup ImageControls
119 * Blend mode storage struct */
120typedef struct GPU_BlendMode
121{
122 GPU_BlendFuncEnum source_color;
123 GPU_BlendFuncEnum dest_color;
124 GPU_BlendFuncEnum source_alpha;
125 GPU_BlendFuncEnum dest_alpha;
126
127 GPU_BlendEqEnum color_equation;
128 GPU_BlendEqEnum alpha_equation;
129} GPU_BlendMode;
130
131/*! \ingroup ImageControls
132 * Blend mode presets
133 * \see GPU_SetBlendMode()
134 * \see GPU_GetBlendModeFromPreset()
135 */
136typedef enum {
137 GPU_BLEND_NORMAL = 0,
138 GPU_BLEND_PREMULTIPLIED_ALPHA = 1,
139 GPU_BLEND_MULTIPLY = 2,
140 GPU_BLEND_ADD = 3,
141 GPU_BLEND_SUBTRACT = 4,
142 GPU_BLEND_MOD_ALPHA = 5,
143 GPU_BLEND_SET_ALPHA = 6,
144 GPU_BLEND_SET = 7,
145 GPU_BLEND_NORMAL_KEEP_ALPHA = 8,
146 GPU_BLEND_NORMAL_ADD_ALPHA = 9
147} GPU_BlendPresetEnum;
148
149/*! \ingroup ImageControls
150 * Image filtering options. These affect the quality/interpolation of colors when images are scaled.
151 * \see GPU_SetImageFilter()
152 */
153typedef enum {
154 GPU_FILTER_NEAREST = 0,
155 GPU_FILTER_LINEAR = 1,
156 GPU_FILTER_LINEAR_MIPMAP = 2
157} GPU_FilterEnum;
158
159/*! \ingroup ImageControls
160 * Snap modes. Blitting with these modes will align the sprite with the target's pixel grid.
161 * \see GPU_SetSnapMode()
162 * \see GPU_GetSnapMode()
163 */
164typedef enum {
165 GPU_SNAP_NONE = 0,
166 GPU_SNAP_POSITION = 1,
167 GPU_SNAP_DIMENSIONS = 2,
168 GPU_SNAP_POSITION_AND_DIMENSIONS = 3
169} GPU_SnapEnum;
170
171
172/*! \ingroup ImageControls
173 * Image wrapping options. These affect how images handle src_rect coordinates beyond their dimensions when blitted.
174 * \see GPU_SetWrapMode()
175 */
176typedef enum {
177 GPU_WRAP_NONE = 0,
178 GPU_WRAP_REPEAT = 1,
179 GPU_WRAP_MIRRORED = 2
180} GPU_WrapEnum;
181
182/*! \ingroup ImageControls
183 * Image format enum
184 * \see GPU_CreateImage()
185 */
186typedef enum {
187 GPU_FORMAT_LUMINANCE = 1,
188 GPU_FORMAT_LUMINANCE_ALPHA = 2,
189 GPU_FORMAT_RGB = 3,
190 GPU_FORMAT_RGBA = 4,
191 GPU_FORMAT_ALPHA = 5,
192 GPU_FORMAT_RG = 6,
193 GPU_FORMAT_YCbCr422 = 7,
194 GPU_FORMAT_YCbCr420P = 8
195} GPU_FormatEnum;
196
197/*! \ingroup ImageControls
198 * File format enum
199 * \see GPU_SaveSurface()
200 * \see GPU_SaveImage()
201 */
202typedef enum {
203 GPU_FILE_AUTO = 0,
204 GPU_FILE_PNG,
205 GPU_FILE_BMP,
206 GPU_FILE_TGA
207} GPU_FileFormatEnum;
208
209
210
211/*! \ingroup ImageControls
212 * Image object for containing pixel/texture data.
213 * A GPU_Image can be created with GPU_CreateImage(), GPU_LoadImage(), GPU_CopyImage(), or GPU_CopyImageFromSurface().
214 * Free the memory with GPU_FreeImage() when you're done.
215 * \see GPU_CreateImage()
216 * \see GPU_LoadImage()
217 * \see GPU_CopyImage()
218 * \see GPU_CopyImageFromSurface()
219 * \see GPU_Target
220 */
221typedef struct GPU_Image
222{
223 struct GPU_Renderer* renderer;
224 GPU_Target* target;
225 Uint16 w, h;
226 Uint8 using_virtual_resolution;
227 GPU_FormatEnum format;
228 int num_layers;
229 int bytes_per_pixel;
230 Uint16 base_w, base_h; // Original image dimensions
231 Uint16 texture_w, texture_h; // Underlying texture dimensions
232 Uint8 has_mipmaps;
233
234 SDL_Color color;
235 Uint8 use_blending;
236 GPU_BlendMode blend_mode;
237 GPU_FilterEnum filter_mode;
238 GPU_SnapEnum snap_mode;
239 GPU_WrapEnum wrap_mode_x;
240 GPU_WrapEnum wrap_mode_y;
241
242 void* data;
243 int refcount;
244 Uint8 is_alias;
245} GPU_Image;
246
247
248/*! \ingroup TargetControls
249 * Camera object that determines viewing transform.
250 * \see GPU_SetCamera()
251 * \see GPU_GetDefaultCamera()
252 * \see GPU_GetCamera()
253 */
254typedef struct GPU_Camera
255{
256 float x, y, z;
257 float angle;
258 float zoom;
259} GPU_Camera;
260
261
262/*! \ingroup ShaderInterface
263 * Container for the built-in shader attribute and uniform locations (indices).
264 * \see GPU_LoadShaderBlock()
265 * \see GPU_SetShaderBlock()
266 */
267typedef struct GPU_ShaderBlock
268{
269 // Attributes
270 int position_loc;
271 int texcoord_loc;
272 int color_loc;
273 // Uniforms
274 int modelViewProjection_loc;
275} GPU_ShaderBlock;
276
277
278
279
280
281#define GPU_MODELVIEW 0
282#define GPU_PROJECTION 1
283
284#ifndef GPU_MATRIX_STACK_MAX
285#define GPU_MATRIX_STACK_MAX 5
286#endif
287
288/*! \ingroup Matrix
289 * Matrix stack data structure for global vertex transforms. */
290typedef struct GPU_MatrixStack
291{
292 unsigned int size;
293 float matrix[GPU_MATRIX_STACK_MAX][16];
294} GPU_MatrixStack;
295
296
297/*! \ingroup ContextControls
298 * Rendering context data. Only GPU_Targets which represent windows will store this. */
299typedef struct GPU_Context
300{
301 /*! SDL_GLContext */
302 void* context;
303 Uint8 failed;
304
305 /*! SDL window ID */
306 Uint32 windowID;
307
308 /*! Actual window dimensions */
309 int window_w;
310 int window_h;
311
312 /*! Drawable region dimensions */
313 int drawable_w;
314 int drawable_h;
315
316 /*! Window dimensions for restoring windowed mode after GPU_SetFullscreen(1,1). */
317 int stored_window_w;
318 int stored_window_h;
319
320 /*! Internal state */
321 Uint32 current_shader_program;
322 Uint32 default_textured_shader_program;
323 Uint32 default_untextured_shader_program;
324
325 Uint8 shapes_use_blending;
326 GPU_BlendMode shapes_blend_mode;
327 float line_thickness;
328 Uint8 use_texturing;
329
330 int matrix_mode;
331 GPU_MatrixStack projection_matrix;
332 GPU_MatrixStack modelview_matrix;
333
334 void* data;
335} GPU_Context;
336
337
338/*! \ingroup TargetControls
339 * Render target object for use as a blitting destination.
340 * A GPU_Target can be created from a GPU_Image with GPU_LoadTarget().
341 * A GPU_Target can also represent a separate window with GPU_CreateTargetFromWindow(). In that case, 'context' is allocated and filled in.
342 * Note: You must have passed the SDL_WINDOW_OPENGL flag to SDL_CreateWindow() for OpenGL renderers to work with new windows.
343 * Free the memory with GPU_FreeTarget() when you're done.
344 * \see GPU_LoadTarget()
345 * \see GPU_CreateTargetFromWindow()
346 * \see GPU_FreeTarget()
347 */
348struct GPU_Target
349{
350 struct GPU_Renderer* renderer;
351 GPU_Image* image;
352 void* data;
353 Uint16 w, h;
354 Uint8 using_virtual_resolution;
355 Uint16 base_w, base_h; // The true dimensions of the underlying image or window
356 Uint8 use_clip_rect;
357 GPU_Rect clip_rect;
358 Uint8 use_color;
359 SDL_Color color;
360
361 GPU_Rect viewport;
362
363 /*! Perspective and object viewing transforms. */
364 GPU_Camera camera;
365
366 /*! Renderer context data. NULL if the target does not represent a window or rendering context. */
367 GPU_Context* context;
368 int refcount;
369 Uint8 is_alias;
370};
371
372/*! \ingroup Initialization
373 * Important GPU features which may not be supported depending on a device's extension support. Can be bitwise OR'd together.
374 * \see GPU_IsFeatureEnabled()
375 * \see GPU_SetRequiredFeatures()
376 */
377typedef Uint32 GPU_FeatureEnum;
378static const GPU_FeatureEnum GPU_FEATURE_NON_POWER_OF_TWO = 0x1;
379static const GPU_FeatureEnum GPU_FEATURE_RENDER_TARGETS = 0x2;
380static const GPU_FeatureEnum GPU_FEATURE_BLEND_EQUATIONS = 0x4;
381static const GPU_FeatureEnum GPU_FEATURE_BLEND_FUNC_SEPARATE = 0x8;
382static const GPU_FeatureEnum GPU_FEATURE_BLEND_EQUATIONS_SEPARATE = 0x10;
383static const GPU_FeatureEnum GPU_FEATURE_GL_BGR = 0x20;
384static const GPU_FeatureEnum GPU_FEATURE_GL_BGRA = 0x40;
385static const GPU_FeatureEnum GPU_FEATURE_GL_ABGR = 0x80;
386static const GPU_FeatureEnum GPU_FEATURE_VERTEX_SHADER = 0x100;
387static const GPU_FeatureEnum GPU_FEATURE_FRAGMENT_SHADER = 0x200;
388static const GPU_FeatureEnum GPU_FEATURE_PIXEL_SHADER = 0x200;
389static const GPU_FeatureEnum GPU_FEATURE_GEOMETRY_SHADER = 0x400;
390static const GPU_FeatureEnum GPU_FEATURE_WRAP_REPEAT_MIRRORED = 0x800;
391
392/*! Combined feature flags */
393#define GPU_FEATURE_ALL_BASE GPU_FEATURE_RENDER_TARGETS
394#define GPU_FEATURE_ALL_BLEND_PRESETS (GPU_FEATURE_BLEND_EQUATIONS | GPU_FEATURE_BLEND_FUNC_SEPARATE)
395#define GPU_FEATURE_ALL_GL_FORMATS (GPU_FEATURE_GL_BGR | GPU_FEATURE_GL_BGRA | GPU_FEATURE_GL_ABGR)
396#define GPU_FEATURE_BASIC_SHADERS (GPU_FEATURE_FRAGMENT_SHADER | GPU_FEATURE_VERTEX_SHADER)
397#define GPU_FEATURE_ALL_SHADERS (GPU_FEATURE_FRAGMENT_SHADER | GPU_FEATURE_VERTEX_SHADER | GPU_FEATURE_GEOMETRY_SHADER)
398
399
400typedef Uint32 GPU_WindowFlagEnum;
401
402/*! \ingroup Initialization
403 * Initialization flags for changing default init parameters. Can be bitwise OR'ed together.
404 * Default (0) is to use late swap vsync and double buffering.
405 * \see GPU_SetPreInitFlags()
406 * \see GPU_GetPreInitFlags()
407 */
408typedef Uint32 GPU_InitFlagEnum;
409static const GPU_InitFlagEnum GPU_INIT_ENABLE_VSYNC = 0x1;
410static const GPU_InitFlagEnum GPU_INIT_DISABLE_VSYNC = 0x2;
411static const GPU_InitFlagEnum GPU_INIT_DISABLE_DOUBLE_BUFFER = 0x4;
412static const GPU_InitFlagEnum GPU_INIT_DISABLE_AUTO_VIRTUAL_RESOLUTION = 0x8;
413static const GPU_InitFlagEnum GPU_INIT_REQUEST_COMPATIBILITY_PROFILE = 0x10;
414
415#define GPU_DEFAULT_INIT_FLAGS 0
416
417
418static const Uint32 GPU_NONE = 0x0;
419
420/*! \ingroup Rendering
421 * Bit flags for geometry batching.
422 * \see GPU_TriangleBatch()
423 */
424typedef Uint32 GPU_BatchFlagEnum;
425static const GPU_BatchFlagEnum GPU_BATCH_XY = 0x1;
426static const GPU_BatchFlagEnum GPU_BATCH_XYZ = 0x2;
427static const GPU_BatchFlagEnum GPU_BATCH_ST = 0x4;
428static const GPU_BatchFlagEnum GPU_BATCH_RGB = 0x8;
429static const GPU_BatchFlagEnum GPU_BATCH_RGBA = 0x10;
430
431#define GPU_BATCH_XY_ST (GPU_BATCH_XY | GPU_BATCH_ST)
432#define GPU_BATCH_XYZ_ST (GPU_BATCH_XYZ | GPU_BATCH_ST)
433#define GPU_BATCH_XY_RGB (GPU_BATCH_XY | GPU_BATCH_RGB)
434#define GPU_BATCH_XYZ_RGB (GPU_BATCH_XYZ | GPU_BATCH_RGB)
435#define GPU_BATCH_XY_RGBA (GPU_BATCH_XY | GPU_BATCH_RGBA)
436#define GPU_BATCH_XYZ_RGBA (GPU_BATCH_XYZ | GPU_BATCH_RGBA)
437#define GPU_BATCH_XY_ST_RGBA (GPU_BATCH_XY | GPU_BATCH_ST | GPU_BATCH_RGBA)
438#define GPU_BATCH_XYZ_ST_RGBA (GPU_BATCH_XYZ | GPU_BATCH_ST | GPU_BATCH_RGBA)
439
440/*! \ingroup ShaderInterface
441 * Type enumeration for GPU_AttributeFormat specifications.
442 */
443typedef Uint32 GPU_TypeEnum;
444// Use OpenGL's values for simpler translation
445static const GPU_TypeEnum GPU_TYPE_BYTE = 0x1400;
446static const GPU_TypeEnum GPU_TYPE_UNSIGNED_BYTE = 0x1401;
447static const GPU_TypeEnum GPU_TYPE_SHORT = 0x1402;
448static const GPU_TypeEnum GPU_TYPE_UNSIGNED_SHORT = 0x1403;
449static const GPU_TypeEnum GPU_TYPE_INT = 0x1404;
450static const GPU_TypeEnum GPU_TYPE_UNSIGNED_INT = 0x1405;
451static const GPU_TypeEnum GPU_TYPE_FLOAT = 0x1406;
452static const GPU_TypeEnum GPU_TYPE_DOUBLE = 0x140A;
453
454
455
456
457
458
459/*! \ingroup ShaderInterface
460 * Shader type enum.
461 * \see GPU_LoadShader()
462 * \see GPU_CompileShader()
463 * \see GPU_CompileShader_RW()
464 */
465typedef enum {
466 GPU_VERTEX_SHADER = 0,
467 GPU_FRAGMENT_SHADER = 1,
468 GPU_PIXEL_SHADER = 1,
469 GPU_GEOMETRY_SHADER = 2
470} GPU_ShaderEnum;
471
472
473
474/*! \ingroup ShaderInterface
475 * Type enumeration for the shader language used by the renderer.
476 */
477typedef enum {
478 GPU_LANGUAGE_NONE = 0,
479 GPU_LANGUAGE_ARB_ASSEMBLY = 1,
480 GPU_LANGUAGE_GLSL = 2,
481 GPU_LANGUAGE_GLSLES = 3,
482 GPU_LANGUAGE_HLSL = 4,
483 GPU_LANGUAGE_CG = 5
484} GPU_ShaderLanguageEnum;
485
486/*! \ingroup ShaderInterface */
487typedef struct GPU_AttributeFormat
488{
489 Uint8 is_per_sprite; // Per-sprite values are expanded to 4 vertices
490 int num_elems_per_value;
491 GPU_TypeEnum type; // GPU_TYPE_FLOAT, GPU_TYPE_INT, GPU_TYPE_UNSIGNED_INT, etc.
492 Uint8 normalize;
493 int stride_bytes; // Number of bytes between two vertex specifications
494 int offset_bytes; // Number of bytes to skip at the beginning of 'values'
495} GPU_AttributeFormat;
496
497/*! \ingroup ShaderInterface */
498typedef struct GPU_Attribute
499{
500 int location;
501 void* values; // Expect 4 values for each sprite
502 GPU_AttributeFormat format;
503} GPU_Attribute;
504
505/*! \ingroup ShaderInterface */
506typedef struct GPU_AttributeSource
507{
508 Uint8 enabled;
509 int num_values;
510 void* next_value;
511 // Automatic storage format
512 int per_vertex_storage_stride_bytes;
513 int per_vertex_storage_offset_bytes;
514 int per_vertex_storage_size; // Over 0 means that the per-vertex storage has been automatically allocated
515 void* per_vertex_storage; // Could point to the attribute's values or to allocated storage
516 GPU_Attribute attribute;
517} GPU_AttributeSource;
518
519
520/*! \ingroup ShaderInterface */
521typedef struct GPU_MultitextureBlock
522{
523 int num_textures;
524 char** image_names; /* array of char* */
525 char** texcoord_names; /* array of char* */
526} GPU_MultitextureBlock;
527
528
529/*! \ingroup Logging
530 * Type enumeration for error codes.
531 * \see GPU_PushErrorCode()
532 * \see GPU_PopErrorCode()
533 */
534typedef enum {
535 GPU_ERROR_NONE = 0,
536 GPU_ERROR_BACKEND_ERROR = 1,
537 GPU_ERROR_DATA_ERROR = 2,
538 GPU_ERROR_USER_ERROR = 3,
539 GPU_ERROR_UNSUPPORTED_FUNCTION = 4,
540 GPU_ERROR_NULL_ARGUMENT = 5,
541 GPU_ERROR_FILE_NOT_FOUND = 6
542} GPU_ErrorEnum;
543
544/*! \ingroup Logging */
545typedef struct GPU_ErrorObject
546{
547 char* function;
548 GPU_ErrorEnum error;
549 char* details;
550} GPU_ErrorObject;
551
552
553/*! \ingroup Logging
554 * Type enumeration for debug levels.
555 * \see GPU_SetDebugLevel()
556 * \see GPU_GetDebugLevel()
557 */
558typedef enum {
559 GPU_DEBUG_LEVEL_0 = 0,
560 GPU_DEBUG_LEVEL_1 = 1,
561 GPU_DEBUG_LEVEL_2 = 2,
562 GPU_DEBUG_LEVEL_3 = 3,
563 GPU_DEBUG_LEVEL_MAX = 3
564} GPU_DebugLevelEnum;
565
566
567/*! \ingroup Logging
568 * Type enumeration for logging levels.
569 * \see GPU_SetLogCallback()
570 */
571typedef enum {
572 GPU_LOG_INFO = 0,
573 GPU_LOG_WARNING,
574 GPU_LOG_ERROR
575} GPU_LogLevelEnum;
576
577
578/* Private implementation of renderer members */
579struct GPU_RendererImpl;
580
581/*! Renderer object which specializes the API to a particular backend. */
582struct GPU_Renderer
583{
584 /*! Struct identifier of the renderer. */
585 GPU_RendererID id;
586 GPU_RendererID requested_id;
587 GPU_WindowFlagEnum SDL_init_flags;
588 GPU_InitFlagEnum GPU_init_flags;
589
590 GPU_ShaderLanguageEnum shader_language;
591 int min_shader_version;
592 int max_shader_version;
593 GPU_FeatureEnum enabled_features;
594
595 /*! Current display target */
596 GPU_Target* current_context_target;
597
598 /*! 0 for inverted, 1 for mathematical */
599 Uint8 coordinate_mode;
600
601 struct GPU_MultitextureBlock* multitexture_block;
602 int multitexture_texCoord_buffers[32];
603
604 struct GPU_RendererImpl* impl;
605};
606
607
608
609
610
611
612/*! \ingroup Initialization
613 * @{ */
614
615// Visual C does not support static inline
616#ifdef _MSC_VER
617static SDL_version SDLCALL GPU_GetCompiledVersion(void)
618#else
619static inline SDL_version SDLCALL GPU_GetCompiledVersion(void)
620#endif
621{
622 SDL_version v = {SDL_GPU_VERSION_MAJOR, SDL_GPU_VERSION_MINOR, SDL_GPU_VERSION_PATCH};
623 return v;
624}
625
626DECLSPEC SDL_version SDLCALL GPU_GetLinkedVersion(void);
627
628/*! The window corresponding to 'windowID' will be used to create the rendering context instead of creating a new window. */
629DECLSPEC void SDLCALL GPU_SetInitWindow(Uint32 windowID);
630
631/*! Returns the window ID that has been set via GPU_SetInitWindow(). */
632DECLSPEC Uint32 SDLCALL GPU_GetInitWindow(void);
633
634/*! Set special flags to use for initialization. Set these before calling GPU_Init().
635 * \param GPU_flags An OR'ed combination of GPU_InitFlagEnum flags. Default flags (0) enable late swap vsync and double buffering. */
636DECLSPEC void SDLCALL GPU_SetPreInitFlags(GPU_InitFlagEnum GPU_flags);
637
638/*! Returns the current special flags to use for initialization. */
639DECLSPEC GPU_InitFlagEnum SDLCALL GPU_GetPreInitFlags(void);
640
641/*! Set required features to use for initialization. Set these before calling GPU_Init().
642 * \param features An OR'ed combination of GPU_FeatureEnum flags. Required features will force GPU_Init() to create a renderer that supports all of the given flags or else fail. */
643DECLSPEC void SDLCALL GPU_SetRequiredFeatures(GPU_FeatureEnum features);
644
645/*! Returns the current required features to use for initialization. */
646DECLSPEC GPU_FeatureEnum SDLCALL GPU_GetRequiredFeatures(void);
647
648/*! Gets the default initialization renderer IDs for the current platform copied into the 'order' array and the number of renderer IDs into 'order_size'. Pass NULL for 'order' to just get the size of the renderer order array. Will return at most GPU_RENDERER_ORDER_MAX renderers. */
649DECLSPEC void SDLCALL GPU_GetDefaultRendererOrder(int* order_size, GPU_RendererID* order);
650
651/*! Gets the current renderer ID order for initialization copied into the 'order' array and the number of renderer IDs into 'order_size'. Pass NULL for 'order' to just get the size of the renderer order array. */
652DECLSPEC void SDLCALL GPU_GetRendererOrder(int* order_size, GPU_RendererID* order);
653
654/*! Sets the renderer ID order to use for initialization. If 'order' is NULL, it will restore the default order. */
655DECLSPEC void SDLCALL GPU_SetRendererOrder(int order_size, GPU_RendererID* order);
656
657/*! Initializes SDL and SDL_gpu. Creates a window and goes through the renderer order to create a renderer context.
658 * \see GPU_SetRendererOrder()
659 */
660DECLSPEC GPU_Target* SDLCALL GPU_Init(Uint16 w, Uint16 h, GPU_WindowFlagEnum SDL_flags);
661
662/*! Initializes SDL and SDL_gpu. Creates a window and the requested renderer context. */
663DECLSPEC GPU_Target* SDLCALL GPU_InitRenderer(GPU_RendererEnum renderer_enum, Uint16 w, Uint16 h, GPU_WindowFlagEnum SDL_flags);
664
665/*! Initializes SDL and SDL_gpu. Creates a window and the requested renderer context.
666 * By requesting a renderer via ID, you can specify the major and minor versions of an individual renderer backend.
667 * \see GPU_MakeRendererID
668 */
669DECLSPEC GPU_Target* SDLCALL GPU_InitRendererByID(GPU_RendererID renderer_request, Uint16 w, Uint16 h, GPU_WindowFlagEnum SDL_flags);
670
671/*! Checks for important GPU features which may not be supported depending on a device's extension support. Feature flags (GPU_FEATURE_*) can be bitwise OR'd together.
672 * \return 1 if all of the passed features are enabled/supported
673 * \return 0 if any of the passed features are disabled/unsupported
674 */
675DECLSPEC Uint8 SDLCALL GPU_IsFeatureEnabled(GPU_FeatureEnum feature);
676
677/*! Clean up the renderer state. */
678DECLSPEC void SDLCALL GPU_CloseCurrentRenderer(void);
679
680/*! Clean up the renderer state and shut down SDL_gpu. */
681DECLSPEC void SDLCALL GPU_Quit(void);
682
683// End of Initialization
684/*! @} */
685
686
687
688// Debugging, logging, and error handling
689
690#define GPU_Log GPU_LogInfo
691/*! \ingroup Logging
692 * @{ */
693
694/*! Sets the global debug level.
695 * GPU_DEBUG_LEVEL_0: Normal
696 * GPU_DEBUG_LEVEL_1: Prints messages when errors are pushed via GPU_PushErrorCode()
697 * GPU_DEBUG_LEVEL_2: Elevates warning logs to error priority
698 * GPU_DEBUG_LEVEL_3: Elevates info logs to error priority
699 */
700DECLSPEC void SDLCALL GPU_SetDebugLevel(GPU_DebugLevelEnum level);
701
702/*! Returns the current global debug level. */
703DECLSPEC GPU_DebugLevelEnum SDLCALL GPU_GetDebugLevel(void);
704
705/*! Prints an informational log message. */
706DECLSPEC void SDLCALL GPU_LogInfo(const char* format, ...);
707
708/*! Prints a warning log message. */
709DECLSPEC void SDLCALL GPU_LogWarning(const char* format, ...);
710
711/*! Prints an error log message. */
712DECLSPEC void SDLCALL GPU_LogError(const char* format, ...);
713
714/*! Sets a custom callback for handling logging. Use stdio's vsnprintf() to process the va_list into a string. Passing NULL as the callback will reset to the default internal logging. */
715DECLSPEC void SDLCALL GPU_SetLogCallback(int (*callback)(GPU_LogLevelEnum log_level, const char* format, va_list args));
716
717/*! Pushes a new error code into the error queue. If the queue is full, the queue is not modified.
718 * \param function The name of the function that pushed the error
719 * \param error The error code to push on the error queue
720 * \param details Additional information string, can be NULL.
721 */
722DECLSPEC void SDLCALL GPU_PushErrorCode(const char* function, GPU_ErrorEnum error, const char* details, ...);
723
724/*! Pops an error object from the error queue and returns it. If the error queue is empty, it returns an error object with NULL function, GPU_ERROR_NONE error, and NULL details. */
725DECLSPEC GPU_ErrorObject SDLCALL GPU_PopErrorCode(void);
726
727/*! Gets the string representation of an error code. */
728DECLSPEC const char* SDLCALL GPU_GetErrorString(GPU_ErrorEnum error);
729
730/*! Changes the maximum number of error objects that SDL_gpu will store. This deletes all currently stored errors. */
731DECLSPEC void SDLCALL GPU_SetErrorQueueMax(unsigned int max);
732
733// End of Logging
734/*! @} */
735
736
737
738
739
740
741
742/*! \ingroup RendererSetup
743 * @{ */
744
745/*! Returns an initialized GPU_RendererID. */
746DECLSPEC GPU_RendererID SDLCALL GPU_MakeRendererID(const char* name, GPU_RendererEnum renderer, int major_version, int minor_version);
747
748/*! Gets the first registered renderer identifier for the given enum value. */
749DECLSPEC GPU_RendererID SDLCALL GPU_GetRendererID(GPU_RendererEnum renderer);
750
751/*! Gets the number of registered (available) renderers. */
752DECLSPEC int SDLCALL GPU_GetNumRegisteredRenderers(void);
753
754/*! Gets an array of identifiers for the registered (available) renderers. */
755DECLSPEC void SDLCALL GPU_GetRegisteredRendererList(GPU_RendererID* renderers_array);
756
757/*! Prepares a renderer for use by SDL_gpu. */
758DECLSPEC void SDLCALL GPU_RegisterRenderer(GPU_RendererID id, GPU_Renderer* (SDLCALL *create_renderer)(GPU_RendererID request), void (SDLCALL *free_renderer)(GPU_Renderer* renderer));
759
760// End of RendererSetup
761/*! @} */
762
763
764
765/*! \ingroup RendererControls
766 * @{ */
767
768/*! Gets the next enum ID that can be used for a custom renderer. */
769DECLSPEC GPU_RendererEnum SDLCALL GPU_ReserveNextRendererEnum(void);
770
771/*! Gets the number of active (created) renderers. */
772DECLSPEC int SDLCALL GPU_GetNumActiveRenderers(void);
773
774/*! Gets an array of identifiers for the active renderers. */
775DECLSPEC void SDLCALL GPU_GetActiveRendererList(GPU_RendererID* renderers_array);
776
777/*! \return The current renderer */
778DECLSPEC GPU_Renderer* SDLCALL GPU_GetCurrentRenderer(void);
779
780/*! Switches the current renderer to the renderer matching the given identifier. */
781DECLSPEC void SDLCALL GPU_SetCurrentRenderer(GPU_RendererID id);
782
783/*! \return The renderer matching the given identifier. */
784DECLSPEC GPU_Renderer* SDLCALL GPU_GetRenderer(GPU_RendererID id);
785
786DECLSPEC void SDLCALL GPU_FreeRenderer(GPU_Renderer* renderer);
787
788/*! Reapplies the renderer state to the backend API (e.g. OpenGL, Direct3D). Use this if you want SDL_gpu to be able to render after you've used direct backend calls. */
789DECLSPEC void SDLCALL GPU_ResetRendererState(void);
790
791/*! Sets the coordinate mode for this renderer. Target and image coordinates will be either "inverted" (0,0 is the upper left corner, y increases downward) or "mathematical" (0,0 is the bottom-left corner, y increases upward).
792 * The default is inverted (0), as this is traditional for 2D graphics.
793 * \param inverted 0 is for inverted coordinates, 1 is for mathematical coordinates */
794DECLSPEC void SDLCALL GPU_SetCoordinateMode(Uint8 use_math_coords);
795
796DECLSPEC Uint8 SDLCALL GPU_GetCoordinateMode(void);
797
798// End of RendererControls
799/*! @} */
800
801
802
803
804// Context / window controls
805
806/*! \ingroup ContextControls
807 * @{ */
808
809/*! \return The renderer's current context target. */
810DECLSPEC GPU_Target* SDLCALL GPU_GetContextTarget(void);
811
812/*! \return The target that is associated with the given windowID. */
813DECLSPEC GPU_Target* SDLCALL GPU_GetWindowTarget(Uint32 windowID);
814
815/*! Creates a separate context for the given window using the current renderer and returns a GPU_Target that represents it. */
816DECLSPEC GPU_Target* SDLCALL GPU_CreateTargetFromWindow(Uint32 windowID);
817
818/*! Makes the given window the current rendering destination for the given context target.
819 * This also makes the target the current context for image loading and window operations.
820 * If the target does not represent a window, this does nothing.
821 */
822DECLSPEC void SDLCALL GPU_MakeCurrent(GPU_Target* target, Uint32 windowID);
823
824/*! Change the actual size of the current context target's window. This resets the virtual resolution and viewport of the context target.
825 * Aside from direct resolution changes, this should also be called in response to SDL_WINDOWEVENT_RESIZED window events for resizable windows. */
826DECLSPEC Uint8 SDLCALL GPU_SetWindowResolution(Uint16 w, Uint16 h);
827
828/*! Enable/disable fullscreen mode for the current context target's window.
829 * On some platforms, this may destroy the renderer context and require that textures be reloaded. Unfortunately, SDL does not provide a notification mechanism for this.
830 * \param enable_fullscreen If true, make the application go fullscreen. If false, make the application go to windowed mode.
831 * \param use_desktop_resolution If true, lets the window change its resolution when it enters fullscreen mode (via SDL_WINDOW_FULLSCREEN_DESKTOP).
832 * \return 0 if the new mode is windowed, 1 if the new mode is fullscreen. */
833DECLSPEC Uint8 SDLCALL GPU_SetFullscreen(Uint8 enable_fullscreen, Uint8 use_desktop_resolution);
834
835/*! Returns true if the current context target's window is in fullscreen mode. */
836DECLSPEC Uint8 SDLCALL GPU_GetFullscreen(void);
837
838/*! Enables/disables alpha blending for shape rendering on the current window. */
839DECLSPEC void SDLCALL GPU_SetShapeBlending(Uint8 enable);
840
841/*! Translates a blend preset into a blend mode. */
842DECLSPEC GPU_BlendMode SDLCALL GPU_GetBlendModeFromPreset(GPU_BlendPresetEnum preset);
843
844/*! Sets the blending component functions for shape rendering. */
845DECLSPEC void SDLCALL GPU_SetShapeBlendFunction(GPU_BlendFuncEnum source_color, GPU_BlendFuncEnum dest_color, GPU_BlendFuncEnum source_alpha, GPU_BlendFuncEnum dest_alpha);
846
847/*! Sets the blending component equations for shape rendering. */
848DECLSPEC void SDLCALL GPU_SetShapeBlendEquation(GPU_BlendEqEnum color_equation, GPU_BlendEqEnum alpha_equation);
849
850/*! Sets the blending mode for shape rendering on the current window, if supported by the renderer. */
851DECLSPEC void SDLCALL GPU_SetShapeBlendMode(GPU_BlendPresetEnum mode);
852
853/*! Sets the thickness of lines for the current context.
854 * \param thickness New line thickness in pixels measured across the line. Default is 1.0f.
855 * \return The old thickness value
856 */
857DECLSPEC float SDLCALL GPU_SetLineThickness(float thickness);
858
859/*! Returns the current line thickness value. */
860DECLSPEC float SDLCALL GPU_GetLineThickness(void);
861
862// End of ContextControls
863/*! @} */
864
865
866
867
868/*! \ingroup TargetControls
869 * @{ */
870
871/*! Creates a target that aliases the given target. Aliases can be used to store target settings (e.g. viewports) for easy switching.
872 * GPU_FreeTarget() frees the alias's memory, but does not affect the original. */
873DECLSPEC GPU_Target* SDLCALL GPU_CreateAliasTarget(GPU_Target* target);
874
875/*! Creates a new render target from the given image. It can then be accessed from image->target. */
876DECLSPEC GPU_Target* SDLCALL GPU_LoadTarget(GPU_Image* image);
877
878/*! Deletes a render target in the proper way for this renderer. */
879DECLSPEC void SDLCALL GPU_FreeTarget(GPU_Target* target);
880
881/*! Change the logical size of the given target. Rendering to this target will be scaled as if the dimensions were actually the ones given. */
882DECLSPEC void SDLCALL GPU_SetVirtualResolution(GPU_Target* target, Uint16 w, Uint16 h);
883
884/*! Query the logical size of the given target. */
885DECLSPEC void SDLCALL GPU_GetVirtualResolution(GPU_Target* target, Uint16* w, Uint16* h);
886
887/*! Converts screen space coordinates (such as from mouse input) to logical drawing coordinates. */
888DECLSPEC void SDLCALL GPU_GetVirtualCoords(GPU_Target* target, float* x, float* y, float displayX, float displayY);
889
890/*! Reset the logical size of the given target to its original value. */
891DECLSPEC void SDLCALL GPU_UnsetVirtualResolution(GPU_Target* target);
892
893/*! \return A GPU_Rect with the given values. */
894DECLSPEC GPU_Rect SDLCALL GPU_MakeRect(float x, float y, float w, float h);
895
896/*! \return An SDL_Color with the given values. */
897DECLSPEC SDL_Color SDLCALL GPU_MakeColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
898
899/*! Sets the given target's viewport. */
900DECLSPEC void SDLCALL GPU_SetViewport(GPU_Target* target, GPU_Rect viewport);
901
902/*! Resets the given target's viewport to the entire target area. */
903DECLSPEC void SDLCALL GPU_UnsetViewport(GPU_Target* target);
904
905/*! \return A GPU_Camera with position (0, 0, -10), angle of 0, and zoom of 1. */
906DECLSPEC GPU_Camera SDLCALL GPU_GetDefaultCamera(void);
907
908/*! \return The camera of the given render target. If target is NULL, returns the default camera. */
909DECLSPEC GPU_Camera SDLCALL GPU_GetCamera(GPU_Target* target);
910
911/*! Sets the current render target's current camera.
912 * \param target A pointer to the target that will copy this camera.
913 * \param cam A pointer to the camera data to use or NULL to use the default camera.
914 * \return The old camera. */
915DECLSPEC GPU_Camera SDLCALL GPU_SetCamera(GPU_Target* target, GPU_Camera* cam);
916
917/*! \return The RGBA color of a pixel. */
918DECLSPEC SDL_Color SDLCALL GPU_GetPixel(GPU_Target* target, Sint16 x, Sint16 y);
919
920/*! Sets the clipping rect for the given render target. */
921DECLSPEC GPU_Rect SDLCALL GPU_SetClipRect(GPU_Target* target, GPU_Rect rect);
922
923/*! Sets the clipping rect for the given render target. */
924DECLSPEC GPU_Rect SDLCALL GPU_SetClip(GPU_Target* target, Sint16 x, Sint16 y, Uint16 w, Uint16 h);
925
926/*! Turns off clipping for the given target. */
927DECLSPEC void SDLCALL GPU_UnsetClip(GPU_Target* target);
928
929/*! Sets the modulation color for subsequent drawing of images and shapes on the given target.
930 * This has a cumulative effect with the image coloring functions.
931 * e.g. GPU_SetRGB(image, 255, 128, 0); GPU_SetTargetRGB(target, 128, 128, 128);
932 * Would make the image draw with color of roughly (128, 64, 0).
933 */
934DECLSPEC void SDLCALL GPU_SetTargetColor(GPU_Target* target, SDL_Color color);
935
936/*! Sets the modulation color for subsequent drawing of images and shapes on the given target.
937 * This has a cumulative effect with the image coloring functions.
938 * e.g. GPU_SetRGB(image, 255, 128, 0); GPU_SetTargetRGB(target, 128, 128, 128);
939 * Would make the image draw with color of roughly (128, 64, 0).
940 */
941DECLSPEC void SDLCALL GPU_SetTargetRGB(GPU_Target* target, Uint8 r, Uint8 g, Uint8 b);
942
943/*! Sets the modulation color for subsequent drawing of images and shapes on the given target.
944 * This has a cumulative effect with the image coloring functions.
945 * e.g. GPU_SetRGB(image, 255, 128, 0); GPU_SetTargetRGB(target, 128, 128, 128);
946 * Would make the image draw with color of roughly (128, 64, 0).
947 */
948DECLSPEC void SDLCALL GPU_SetTargetRGBA(GPU_Target* target, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
949
950/*! Unsets the modulation color for subsequent drawing of images and shapes on the given target.
951 * This has the same effect as coloring with pure opaque white (255, 255, 255, 255).
952 */
953DECLSPEC void SDLCALL GPU_UnsetTargetColor(GPU_Target* target);
954
955// End of TargetControls
956/*! @} */
957
958
959
960/*! \ingroup SurfaceControls
961 * @{ */
962
963/*! Load surface from an image file that is supported by this renderer. Don't forget to SDL_FreeSurface() it. */
964DECLSPEC SDL_Surface* SDLCALL GPU_LoadSurface(const char* filename);
965
966/*! Load surface from an image file in memory. Don't forget to SDL_FreeSurface() it. */
967DECLSPEC SDL_Surface* SDLCALL GPU_LoadSurface_RW(SDL_RWops* rwops, Uint8 free_rwops);
968
969/*! Save surface to a file.
970 * With a format of GPU_FILE_AUTO, the file type is deduced from the extension. Supported formats are: png, bmp, tga.
971 * Returns 0 on failure. */
972DECLSPEC Uint8 SDLCALL GPU_SaveSurface(SDL_Surface* surface, const char* filename, GPU_FileFormatEnum format);
973
974// End of SurfaceControls
975/*! @} */
976
977
978
979
980/*! \ingroup ImageControls
981 * @{ */
982
983/*! Create a new, blank image with the given format. Don't forget to GPU_FreeImage() it.
984 * \param w Image width in pixels
985 * \param h Image height in pixels
986 * \param format Format of color channels.
987 */
988DECLSPEC GPU_Image* SDLCALL GPU_CreateImage(Uint16 w, Uint16 h, GPU_FormatEnum format);
989
990/*! Create a new image that uses the given native texture handle as the image texture. */
991DECLSPEC GPU_Image* SDLCALL GPU_CreateImageUsingTexture(Uint32 handle, Uint8 take_ownership);
992
993/*! Load image from an image file that is supported by this renderer. Don't forget to GPU_FreeImage() it. */
994DECLSPEC GPU_Image* SDLCALL GPU_LoadImage(const char* filename);
995
996/*! Creates an image that aliases the given image. Aliases can be used to store image settings (e.g. modulation color) for easy switching.
997 * GPU_FreeImage() frees the alias's memory, but does not affect the original. */
998DECLSPEC GPU_Image* SDLCALL GPU_CreateAliasImage(GPU_Image* image);
999
1000/*! Copy an image to a new image. Don't forget to GPU_FreeImage() both. */
1001DECLSPEC GPU_Image* SDLCALL GPU_CopyImage(GPU_Image* image);
1002
1003/*! Deletes an image in the proper way for this renderer. Also deletes the corresponding GPU_Target if applicable. Be careful not to use that target afterward! */
1004DECLSPEC void SDLCALL GPU_FreeImage(GPU_Image* image);
1005
1006/*! Change the logical size of the given image. Rendering this image will scaled it as if the dimensions were actually the ones given. */
1007DECLSPEC void SDLCALL GPU_SetImageVirtualResolution(GPU_Image* image, Uint16 w, Uint16 h);
1008
1009/*! Reset the logical size of the given image to its original value. */
1010DECLSPEC void SDLCALL GPU_UnsetImageVirtualResolution(GPU_Image* image);
1011
1012/*! Update an image from surface data. Ignores virtual resolution on the image so the number of pixels needed from the surface is known. */
1013DECLSPEC void SDLCALL GPU_UpdateImage(GPU_Image* image, const GPU_Rect* image_rect, SDL_Surface* surface, const GPU_Rect* surface_rect);
1014
1015/*! Update an image from an array of pixel data. Ignores virtual resolution on the image so the number of pixels needed from the surface is known. */
1016DECLSPEC void SDLCALL GPU_UpdateImageBytes(GPU_Image* image, const GPU_Rect* image_rect, const unsigned char* bytes, int bytes_per_row);
1017
1018/*! Update an image from surface data, replacing its underlying texture to allow for size changes. Ignores virtual resolution on the image so the number of pixels needed from the surface is known. */
1019DECLSPEC Uint8 SDLCALL GPU_ReplaceImage(GPU_Image* image, SDL_Surface* surface, const GPU_Rect* surface_rect);
1020
1021/*! Save image to a file.
1022 * With a format of GPU_FILE_AUTO, the file type is deduced from the extension. Supported formats are: png, bmp, tga.
1023 * Returns 0 on failure. */
1024DECLSPEC Uint8 SDLCALL GPU_SaveImage(GPU_Image* image, const char* filename, GPU_FileFormatEnum format);
1025
1026/*! Loads mipmaps for the given image, if supported by the renderer. */
1027DECLSPEC void SDLCALL GPU_GenerateMipmaps(GPU_Image* image);
1028
1029/*! Sets the modulation color for subsequent drawing of the given image. */
1030DECLSPEC void SDLCALL GPU_SetColor(GPU_Image* image, SDL_Color color);
1031
1032/*! Gets the modulation color for subsequent drawing of the given image. */
1033DECLSPEC SDL_Color SDLCALL GPU_GetColor(GPU_Image* image);
1034
1035/*! Sets the modulation color for subsequent drawing of the given image. */
1036DECLSPEC void SDLCALL GPU_SetRGB(GPU_Image* image, Uint8 r, Uint8 g, Uint8 b);
1037
1038/*! Sets the modulation color for subsequent drawing of the given image. */
1039DECLSPEC void SDLCALL GPU_SetRGBA(GPU_Image* image, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
1040
1041/*! Unsets the modulation color for subsequent drawing of the given image.
1042 * This is equivalent to coloring with pure opaque white (255, 255, 255, 255). */
1043DECLSPEC void SDLCALL GPU_UnsetColor(GPU_Image* image);
1044
1045/*! Gets the current alpha blending setting. */
1046DECLSPEC Uint8 SDLCALL GPU_GetBlending(GPU_Image* image);
1047
1048/*! Enables/disables alpha blending for the given image. */
1049DECLSPEC void SDLCALL GPU_SetBlending(GPU_Image* image, Uint8 enable);
1050
1051/*! Sets the blending component functions. */
1052DECLSPEC void SDLCALL GPU_SetBlendFunction(GPU_Image* image, GPU_BlendFuncEnum source_color, GPU_BlendFuncEnum dest_color, GPU_BlendFuncEnum source_alpha, GPU_BlendFuncEnum dest_alpha);
1053
1054/*! Sets the blending component equations. */
1055DECLSPEC void SDLCALL GPU_SetBlendEquation(GPU_Image* image, GPU_BlendEqEnum color_equation, GPU_BlendEqEnum alpha_equation);
1056
1057/*! Sets the blending mode, if supported by the renderer. */
1058DECLSPEC void SDLCALL GPU_SetBlendMode(GPU_Image* image, GPU_BlendPresetEnum mode);
1059
1060/*! Sets the image filtering mode, if supported by the renderer. */
1061DECLSPEC void SDLCALL GPU_SetImageFilter(GPU_Image* image, GPU_FilterEnum filter);
1062
1063/*! Gets the current pixel snap setting. The default value is GPU_SNAP_POSITION_AND_DIMENSIONS. */
1064DECLSPEC GPU_SnapEnum SDLCALL GPU_GetSnapMode(GPU_Image* image);
1065
1066/*! Sets the pixel grid snapping mode for the given image. */
1067DECLSPEC void SDLCALL GPU_SetSnapMode(GPU_Image* image, GPU_SnapEnum mode);
1068
1069/*! Sets the image wrapping mode, if supported by the renderer. */
1070DECLSPEC void SDLCALL GPU_SetWrapMode(GPU_Image* image, GPU_WrapEnum wrap_mode_x, GPU_WrapEnum wrap_mode_y);
1071
1072// End of ImageControls
1073/*! @} */
1074
1075
1076// Surface / Image / Target conversions
1077/*! \ingroup Conversions
1078 * @{ */
1079
1080/*! Copy SDL_Surface data into a new GPU_Image. Don't forget to SDL_FreeSurface() the surface and GPU_FreeImage() the image.*/
1081DECLSPEC GPU_Image* SDLCALL GPU_CopyImageFromSurface(SDL_Surface* surface);
1082
1083/*! Copy GPU_Target data into a new GPU_Image. Don't forget to GPU_FreeImage() the image.*/
1084DECLSPEC GPU_Image* SDLCALL GPU_CopyImageFromTarget(GPU_Target* target);
1085
1086/*! Copy GPU_Target data into a new SDL_Surface. Don't forget to SDL_FreeSurface() the surface.*/
1087DECLSPEC SDL_Surface* SDLCALL GPU_CopySurfaceFromTarget(GPU_Target* target);
1088
1089/*! Copy GPU_Image data into a new SDL_Surface. Don't forget to SDL_FreeSurface() the surface and GPU_FreeImage() the image.*/
1090DECLSPEC SDL_Surface* SDLCALL GPU_CopySurfaceFromImage(GPU_Image* image);
1091
1092// End of Conversions
1093/*! @} */
1094
1095
1096
1097
1098
1099/*! \ingroup Matrix
1100 * @{ */
1101
1102
1103// Basic matrix operations (4x4)
1104
1105/*! Copy matrix A to the given 'result' matrix. */
1106DECLSPEC void SDLCALL GPU_MatrixCopy(float* result, const float* A);
1107
1108/*! Fills 'result' matrix with the identity matrix. */
1109DECLSPEC void SDLCALL GPU_MatrixIdentity(float* result);
1110
1111/*! Multiplies matrices A and B and stores the result in the given 'result' matrix (result = A*B). Do not use A or B as 'result'.
1112 * \see GPU_MultiplyAndAssign
1113*/
1114DECLSPEC void SDLCALL GPU_Multiply4x4(float* result, float* A, float* B);
1115
1116/*! Multiplies matrices 'result' and A and stores the result in the given 'result' matrix (result = result * A). */
1117DECLSPEC void SDLCALL GPU_MultiplyAndAssign(float* result, float* A);
1118
1119
1120// Matrix stack accessors
1121
1122/*! Returns an internal string that represents the contents of matrix A. */
1123DECLSPEC const char* SDLCALL GPU_GetMatrixString(float* A);
1124
1125/*! Returns the current matrix from the top of the matrix stack. Returns NULL if stack is empty. */
1126DECLSPEC float* SDLCALL GPU_GetCurrentMatrix(void);
1127
1128/*! Returns the current modelview matrix from the top of the matrix stack. Returns NULL if stack is empty. */
1129DECLSPEC float* SDLCALL GPU_GetModelView(void);
1130
1131/*! Returns the current projection matrix from the top of the matrix stack. Returns NULL if stack is empty. */
1132DECLSPEC float* SDLCALL GPU_GetProjection(void);
1133
1134/*! Copies the current modelview-projection matrix into the given 'result' matrix (result = P*M). */
1135DECLSPEC void SDLCALL GPU_GetModelViewProjection(float* result);
1136
1137
1138// Matrix stack manipulators
1139
1140/*! Changes matrix mode to either GPU_PROJECTION or GPU_MODELVIEW. Further matrix stack operations manipulate that particular stack. */
1141DECLSPEC void SDLCALL GPU_MatrixMode(int matrix_mode);
1142
1143/*! Pushes the current matrix as a new matrix stack item. */
1144DECLSPEC void SDLCALL GPU_PushMatrix(void);
1145
1146/*! Removes the current matrix from the stack. */
1147DECLSPEC void SDLCALL GPU_PopMatrix(void);
1148
1149/*! Fills current matrix with the identity matrix. */
1150DECLSPEC void SDLCALL GPU_LoadIdentity(void);
1151
1152/*! Multiplies an orthographic projection matrix into the current matrix. */
1153DECLSPEC void SDLCALL GPU_Ortho(float left, float right, float bottom, float top, float near, float far);
1154
1155/*! Multiplies a perspective projection matrix into the current matrix. */
1156DECLSPEC void SDLCALL GPU_Frustum(float right, float left, float bottom, float top, float near, float far);
1157
1158/*! Adds a translation into the current matrix. */
1159DECLSPEC void SDLCALL GPU_Translate(float x, float y, float z);
1160
1161/*! Multiplies a scaling matrix into the current matrix. */
1162DECLSPEC void SDLCALL GPU_Scale(float sx, float sy, float sz);
1163
1164/*! Multiplies a rotation matrix into the current matrix. */
1165DECLSPEC void SDLCALL GPU_Rotate(float degrees, float x, float y, float z);
1166
1167/*! Multiplies a given matrix into the current matrix. */
1168DECLSPEC void SDLCALL GPU_MultMatrix(float* matrix4x4);
1169
1170// End of Matrix
1171/*! @} */
1172
1173
1174
1175
1176
1177
1178/*! \ingroup Rendering
1179 * @{ */
1180
1181/*! Clears the contents of the given render target. Fills the target with color {0, 0, 0, 0}. */
1182DECLSPEC void SDLCALL GPU_Clear(GPU_Target* target);
1183
1184/*! Fills the given render target with a color. */
1185DECLSPEC void SDLCALL GPU_ClearColor(GPU_Target* target, SDL_Color color);
1186
1187/*! Fills the given render target with a color (alpha is 255, fully opaque). */
1188DECLSPEC void SDLCALL GPU_ClearRGB(GPU_Target* target, Uint8 r, Uint8 g, Uint8 b);
1189
1190/*! Fills the given render target with a color. */
1191DECLSPEC void SDLCALL GPU_ClearRGBA(GPU_Target* target, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
1192
1193/*! Draws the given image to the given render target.
1194 * \param src_rect The region of the source image to use.
1195 * \param x Destination x-position
1196 * \param y Destination y-position */
1197DECLSPEC void SDLCALL GPU_Blit(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y);
1198
1199/*! Rotates and draws the given image to the given render target.
1200 * \param src_rect The region of the source image to use.
1201 * \param x Destination x-position
1202 * \param y Destination y-position
1203 * \param degrees Rotation angle (in degrees) */
1204DECLSPEC void SDLCALL GPU_BlitRotate(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float degrees);
1205
1206/*! Scales and draws the given image to the given render target.
1207 * \param src_rect The region of the source image to use.
1208 * \param x Destination x-position
1209 * \param y Destination y-position
1210 * \param scaleX Horizontal stretch factor
1211 * \param scaleY Vertical stretch factor */
1212DECLSPEC void SDLCALL GPU_BlitScale(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float scaleX, float scaleY);
1213
1214/*! Scales, rotates, and draws the given image to the given render target.
1215 * \param src_rect The region of the source image to use.
1216 * \param x Destination x-position
1217 * \param y Destination y-position
1218 * \param degrees Rotation angle (in degrees)
1219 * \param scaleX Horizontal stretch factor
1220 * \param scaleY Vertical stretch factor */
1221DECLSPEC void SDLCALL GPU_BlitTransform(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float degrees, float scaleX, float scaleY);
1222
1223/*! Scales, rotates around a pivot point, and draws the given image to the given render target. The drawing point (x, y) coincides with the pivot point on the src image (pivot_x, pivot_y).
1224 * \param src_rect The region of the source image to use.
1225 * \param x Destination x-position
1226 * \param y Destination y-position
1227 * \param pivot_x Pivot x-position (in image coordinates)
1228 * \param pivot_y Pivot y-position (in image coordinates)
1229 * \param degrees Rotation angle (in degrees)
1230 * \param scaleX Horizontal stretch factor
1231 * \param scaleY Vertical stretch factor */
1232DECLSPEC void SDLCALL GPU_BlitTransformX(GPU_Image* image, GPU_Rect* src_rect, GPU_Target* target, float x, float y, float pivot_x, float pivot_y, float degrees, float scaleX, float scaleY);
1233
1234/*! Renders triangles from the given set of vertices. This lets you render arbitrary 2D geometry. It is a direct path to the GPU, so the format is different than typical SDL_gpu calls.
1235 * \param values A tightly-packed array of vertex position (e.g. x,y), texture coordinates (e.g. s,t), and color (e.g. r,g,b,a) values. Texture coordinates and color values are expected to be already normalized to 0.0 - 1.0. Pass NULL to render with only custom shader attributes.
1236 * \param indices If not NULL, this is used to specify which vertices to use and in what order (i.e. it indexes the vertices in the 'values' array).
1237 * \param flags Bit flags to control the interpretation of the 'values' array parameters.
1238 */
1239DECLSPEC void SDLCALL GPU_TriangleBatch(GPU_Image* image, GPU_Target* target, unsigned short num_vertices, float* values, unsigned int num_indices, unsigned short* indices, GPU_BatchFlagEnum flags);
1240
1241DECLSPEC void SDLCALL GPU_BlitBatch(GPU_Image* image, GPU_Target* target, Uint32 num_sprites,
1242 float* values, GPU_BatchFlagEnum flags);
1243
1244DECLSPEC void SDLCALL GPU_BlitBatchSeparate(GPU_Image* image, GPU_Target* target, Uint32 num_sprites,
1245 float* positions, float* src_rects, float* colors, GPU_BatchFlagEnum flags);
1246
1247/*! Send all buffered blitting data to the current context target. */
1248DECLSPEC void SDLCALL GPU_FlushBlitBuffer(void);
1249
1250/*! Updates the given target's associated window. */
1251DECLSPEC void SDLCALL GPU_Flip(GPU_Target* target);
1252
1253// End of Rendering
1254/*! @} */
1255
1256
1257
1258
1259
1260/*! \ingroup Shapes
1261 * @{ */
1262
1263/*! Renders a colored point.
1264 * \param target The destination render target
1265 * \param x x-coord of the point
1266 * \param y y-coord of the point
1267 * \param color The color of the shape to render
1268 */
1269DECLSPEC void SDLCALL GPU_Pixel(GPU_Target* target, float x, float y, SDL_Color color);
1270
1271/*! Renders a colored line.
1272 * \param target The destination render target
1273 * \param x1 x-coord of starting point
1274 * \param y1 y-coord of starting point
1275 * \param x2 x-coord of ending point
1276 * \param y2 y-coord of ending point
1277 * \param color The color of the shape to render
1278 */
1279DECLSPEC void SDLCALL GPU_Line(GPU_Target* target, float x1, float y1, float x2, float y2, SDL_Color color);
1280
1281/*! Renders a colored arc curve (circle segment).
1282 * \param target The destination render target
1283 * \param x x-coord of center point
1284 * \param y y-coord of center point
1285 * \param radius The radius of the circle / distance from the center point that rendering will occur
1286 * \param start_angle The angle to start from, in degrees. Measured clockwise from the positive x-axis.
1287 * \param end_angle The angle to end at, in degrees. Measured clockwise from the positive x-axis.
1288 * \param color The color of the shape to render
1289 */
1290DECLSPEC void SDLCALL GPU_Arc(GPU_Target* target, float x, float y, float radius, float start_angle, float end_angle, SDL_Color color);
1291
1292/*! Renders a colored filled arc (circle segment / pie piece).
1293 * \param target The destination render target
1294 * \param x x-coord of center point
1295 * \param y y-coord of center point
1296 * \param radius The radius of the circle / distance from the center point that rendering will occur
1297 * \param start_angle The angle to start from, in degrees. Measured clockwise from the positive x-axis.
1298 * \param end_angle The angle to end at, in degrees. Measured clockwise from the positive x-axis.
1299 * \param color The color of the shape to render
1300 */
1301DECLSPEC void SDLCALL GPU_ArcFilled(GPU_Target* target, float x, float y, float radius, float start_angle, float end_angle, SDL_Color color);
1302
1303/*! Renders a colored circle outline.
1304 * \param target The destination render target
1305 * \param x x-coord of center point
1306 * \param y y-coord of center point
1307 * \param radius The radius of the circle / distance from the center point that rendering will occur
1308 * \param color The color of the shape to render
1309 */
1310DECLSPEC void SDLCALL GPU_Circle(GPU_Target* target, float x, float y, float radius, SDL_Color color);
1311
1312/*! Renders a colored filled circle.
1313 * \param target The destination render target
1314 * \param x x-coord of center point
1315 * \param y y-coord of center point
1316 * \param radius The radius of the circle / distance from the center point that rendering will occur
1317 * \param color The color of the shape to render
1318 */
1319DECLSPEC void SDLCALL GPU_CircleFilled(GPU_Target* target, float x, float y, float radius, SDL_Color color);
1320
1321/*! Renders a colored ellipse outline.
1322 * \param target The destination render target
1323 * \param x x-coord of center point
1324 * \param y y-coord of center point
1325 * \param rx x-radius of ellipse
1326 * \param ry y-radius of ellipse
1327 * \param degrees The angle to rotate the ellipse
1328 * \param color The color of the shape to render
1329 */
1330DECLSPEC void SDLCALL GPU_Ellipse(GPU_Target* target, float x, float y, float rx, float ry, float degrees, SDL_Color color);
1331
1332/*! Renders a colored filled ellipse.
1333 * \param target The destination render target
1334 * \param x x-coord of center point
1335 * \param y y-coord of center point
1336 * \param rx x-radius of ellipse
1337 * \param ry y-radius of ellipse
1338 * \param degrees The angle to rotate the ellipse
1339 * \param color The color of the shape to render
1340 */
1341DECLSPEC void SDLCALL GPU_EllipseFilled(GPU_Target* target, float x, float y, float rx, float ry, float degrees, SDL_Color color);
1342
1343/*! Renders a colored annular sector outline (ring segment).
1344 * \param target The destination render target
1345 * \param x x-coord of center point
1346 * \param y y-coord of center point
1347 * \param inner_radius The inner radius of the ring
1348 * \param outer_radius The outer radius of the ring
1349 * \param start_angle The angle to start from, in degrees. Measured clockwise from the positive x-axis.
1350 * \param end_angle The angle to end at, in degrees. Measured clockwise from the positive x-axis.
1351 * \param color The color of the shape to render
1352 */
1353DECLSPEC void SDLCALL GPU_Sector(GPU_Target* target, float x, float y, float inner_radius, float outer_radius, float start_angle, float end_angle, SDL_Color color);
1354
1355/*! Renders a colored filled annular sector (ring segment).
1356 * \param target The destination render target
1357 * \param x x-coord of center point
1358 * \param y y-coord of center point
1359 * \param inner_radius The inner radius of the ring
1360 * \param outer_radius The outer radius of the ring
1361 * \param start_angle The angle to start from, in degrees. Measured clockwise from the positive x-axis.
1362 * \param end_angle The angle to end at, in degrees. Measured clockwise from the positive x-axis.
1363 * \param color The color of the shape to render
1364 */
1365DECLSPEC void SDLCALL GPU_SectorFilled(GPU_Target* target, float x, float y, float inner_radius, float outer_radius, float start_angle, float end_angle, SDL_Color color);
1366
1367/*! Renders a colored triangle outline.
1368 * \param target The destination render target
1369 * \param x1 x-coord of first point
1370 * \param y1 y-coord of first point
1371 * \param x2 x-coord of second point
1372 * \param y2 y-coord of second point
1373 * \param x3 x-coord of third point
1374 * \param y3 y-coord of third point
1375 * \param color The color of the shape to render
1376 */
1377DECLSPEC void SDLCALL GPU_Tri(GPU_Target* target, float x1, float y1, float x2, float y2, float x3, float y3, SDL_Color color);
1378
1379/*! Renders a colored filled triangle.
1380 * \param target The destination render target
1381 * \param x1 x-coord of first point
1382 * \param y1 y-coord of first point
1383 * \param x2 x-coord of second point
1384 * \param y2 y-coord of second point
1385 * \param x3 x-coord of third point
1386 * \param y3 y-coord of third point
1387 * \param color The color of the shape to render
1388 */
1389DECLSPEC void SDLCALL GPU_TriFilled(GPU_Target* target, float x1, float y1, float x2, float y2, float x3, float y3, SDL_Color color);
1390
1391/*! Renders a colored rectangle outline.
1392 * \param target The destination render target
1393 * \param x1 x-coord of top-left corner
1394 * \param y1 y-coord of top-left corner
1395 * \param x2 x-coord of bottom-right corner
1396 * \param y2 y-coord of bottom-right corner
1397 * \param color The color of the shape to render
1398 */
1399DECLSPEC void SDLCALL GPU_Rectangle(GPU_Target* target, float x1, float y1, float x2, float y2, SDL_Color color);
1400
1401/*! Renders a colored filled rectangle.
1402 * \param target The destination render target
1403 * \param x1 x-coord of top-left corner
1404 * \param y1 y-coord of top-left corner
1405 * \param x2 x-coord of bottom-right corner
1406 * \param y2 y-coord of bottom-right corner
1407 * \param color The color of the shape to render
1408 */
1409DECLSPEC void SDLCALL GPU_RectangleFilled(GPU_Target* target, float x1, float y1, float x2, float y2, SDL_Color color);
1410
1411/*! Renders a colored rounded (filleted) rectangle outline.
1412 * \param target The destination render target
1413 * \param x1 x-coord of top-left corner
1414 * \param y1 y-coord of top-left corner
1415 * \param x2 x-coord of bottom-right corner
1416 * \param y2 y-coord of bottom-right corner
1417 * \param radius The radius of the corners
1418 * \param color The color of the shape to render
1419 */
1420DECLSPEC void SDLCALL GPU_RectangleRound(GPU_Target* target, float x1, float y1, float x2, float y2, float radius, SDL_Color color);
1421
1422/*! Renders a colored filled rounded (filleted) rectangle.
1423 * \param target The destination render target
1424 * \param x1 x-coord of top-left corner
1425 * \param y1 y-coord of top-left corner
1426 * \param x2 x-coord of bottom-right corner
1427 * \param y2 y-coord of bottom-right corner
1428 * \param radius The radius of the corners
1429 * \param color The color of the shape to render
1430 */
1431DECLSPEC void SDLCALL GPU_RectangleRoundFilled(GPU_Target* target, float x1, float y1, float x2, float y2, float radius, SDL_Color color);
1432
1433/*! Renders a colored polygon outline. The vertices are expected to define a convex polygon.
1434 * \param target The destination render target
1435 * \param num_vertices Number of vertices (x and y pairs)
1436 * \param vertices An array of vertex positions stored as interlaced x and y coords, e.g. {x1, y1, x2, y2, ...}
1437 * \param color The color of the shape to render
1438 */
1439DECLSPEC void SDLCALL GPU_Polygon(GPU_Target* target, unsigned int num_vertices, float* vertices, SDL_Color color);
1440
1441/*! Renders a colored filled polygon. The vertices are expected to define a convex polygon.
1442 * \param target The destination render target
1443 * \param num_vertices Number of vertices (x and y pairs)
1444 * \param vertices An array of vertex positions stored as interlaced x and y coords, e.g. {x1, y1, x2, y2, ...}
1445 * \param color The color of the shape to render
1446 */
1447DECLSPEC void SDLCALL GPU_PolygonFilled(GPU_Target* target, unsigned int num_vertices, float* vertices, SDL_Color color);
1448
1449// End of Shapes
1450/*! @} */
1451
1452
1453
1454
1455
1456/*! \ingroup ShaderInterface
1457 * @{ */
1458
1459/*! Creates a new, empty shader program. You will need to compile shaders, attach them to the program, then link the program.
1460 * \see GPU_AttachShader
1461 * \see GPU_LinkShaderProgram
1462 */
1463DECLSPEC Uint32 SDLCALL GPU_CreateShaderProgram(void);
1464
1465/*! Deletes a shader program. */
1466DECLSPEC void SDLCALL GPU_FreeShaderProgram(Uint32 program_object);
1467
1468/*! Loads shader source from an SDL_RWops, compiles it, and returns the new shader object. */
1469DECLSPEC Uint32 SDLCALL GPU_CompileShader_RW(GPU_ShaderEnum shader_type, SDL_RWops* shader_source, Uint8 free_rwops);
1470
1471/*! Compiles shader source and returns the new shader object. */
1472DECLSPEC Uint32 SDLCALL GPU_CompileShader(GPU_ShaderEnum shader_type, const char* shader_source);
1473
1474/*! Loads shader source from a file, compiles it, and returns the new shader object. */
1475DECLSPEC Uint32 SDLCALL GPU_LoadShader(GPU_ShaderEnum shader_type, const char* filename);
1476
1477/*! Creates and links a shader program with the given shader objects. */
1478DECLSPEC Uint32 SDLCALL GPU_LinkShaders(Uint32 shader_object1, Uint32 shader_object2);
1479
1480/*! Deletes a shader object. */
1481DECLSPEC void SDLCALL GPU_FreeShader(Uint32 shader_object);
1482
1483/*! Attaches a shader object to a shader program for future linking. */
1484DECLSPEC void SDLCALL GPU_AttachShader(Uint32 program_object, Uint32 shader_object);
1485
1486/*! Detaches a shader object from a shader program. */
1487DECLSPEC void SDLCALL GPU_DetachShader(Uint32 program_object, Uint32 shader_object);
1488
1489/*! Links a shader program with any attached shader objects. */
1490DECLSPEC Uint8 SDLCALL GPU_LinkShaderProgram(Uint32 program_object);
1491
1492/*! \return The current shader program */
1493DECLSPEC Uint32 SDLCALL GPU_GetCurrentShaderProgram(void);
1494
1495/*! Returns 1 if the given shader program is a default shader for the current context, 0 otherwise. */
1496DECLSPEC Uint8 SDLCALL GPU_IsDefaultShaderProgram(Uint32 program_object);
1497
1498/*! Activates the given shader program. Passing NULL for 'block' will disable the built-in shader variables for custom shaders until a GPU_ShaderBlock is set again. */
1499DECLSPEC void SDLCALL GPU_ActivateShaderProgram(Uint32 program_object, GPU_ShaderBlock* block);
1500
1501/*! Deactivates the current shader program (activates program 0). */
1502DECLSPEC void SDLCALL GPU_DeactivateShaderProgram(void);
1503
1504/*! Returns the last shader log message. */
1505DECLSPEC const char* SDLCALL GPU_GetShaderMessage(void);
1506
1507/*! Returns an integer representing the location of the specified attribute shader variable. */
1508DECLSPEC int SDLCALL GPU_GetAttributeLocation(Uint32 program_object, const char* attrib_name);
1509
1510/*! Returns a filled GPU_AttributeFormat object. */
1511DECLSPEC GPU_AttributeFormat SDLCALL GPU_MakeAttributeFormat(int num_elems_per_vertex, GPU_TypeEnum type, Uint8 normalize, int stride_bytes, int offset_bytes);
1512
1513/*! Returns a filled GPU_Attribute object. */
1514DECLSPEC GPU_Attribute SDLCALL GPU_MakeAttribute(int location, void* values, GPU_AttributeFormat format);
1515
1516/*! Returns an integer representing the location of the specified uniform shader variable. */
1517DECLSPEC int SDLCALL GPU_GetUniformLocation(Uint32 program_object, const char* uniform_name);
1518
1519/*! Loads the given shader program's built-in attribute and uniform locations. */
1520DECLSPEC GPU_ShaderBlock SDLCALL GPU_LoadShaderBlock(Uint32 program_object, const char* position_name, const char* texcoord_name, const char* color_name, const char* modelViewMatrix_name);
1521
1522/*! Sets the current shader block to use the given attribute and uniform locations. */
1523DECLSPEC void SDLCALL GPU_SetShaderBlock(GPU_ShaderBlock block);
1524
1525/*! Sets the given image unit to the given image so that a custom shader can sample multiple textures.
1526 \param image The source image/texture. Pass NULL to disable the image unit.
1527 \param location The uniform location of a texture sampler
1528 \param image_unit The index of the texture unit to set. 0 is the first unit, which is used by SDL_gpu's blitting functions. 1 would be the second unit. */
1529DECLSPEC void SDLCALL GPU_SetShaderImage(GPU_Image* image, int location, int image_unit);
1530
1531DECLSPEC GPU_MultitextureBlock SDLCALL GPU_LoadMultitextureBlock(int count, char** image_names, char** texcoord_names);
1532
1533DECLSPEC void SDLCALL GPU_SetMultitextureBlock(GPU_MultitextureBlock* value);
1534
1535DECLSPEC void SDLCALL GPU_FreeMultitextureBlock(GPU_MultitextureBlock* value);
1536
1537DECLSPEC void SDLCALL GPU_MultitextureBlit(GPU_Image** images, GPU_Rect* rects, GPU_Target* target, float x, float y);
1538
1539/*! Fills "values" with the value of the uniform shader variable at the given location. */
1540DECLSPEC void SDLCALL GPU_GetUniformiv(Uint32 program_object, int location, int* values);
1541
1542/*! Sets the value of the integer uniform shader variable at the given location.
1543 This is equivalent to calling GPU_SetUniformiv(location, 1, 1, &value). */
1544DECLSPEC void SDLCALL GPU_SetUniformi(int location, int value);
1545
1546/*! Sets the value of the integer uniform shader variable at the given location. */
1547DECLSPEC void SDLCALL GPU_SetUniformiv(int location, int num_elements_per_value, int num_values, int* values);
1548
1549/*! Fills "values" with the value of the uniform shader variable at the given location. */
1550DECLSPEC void SDLCALL GPU_GetUniformuiv(Uint32 program_object, int location, unsigned int* values);
1551
1552/*! Sets the value of the unsigned integer uniform shader variable at the given location.
1553 This is equivalent to calling GPU_SetUniformuiv(location, 1, 1, &value). */
1554DECLSPEC void SDLCALL GPU_SetUniformui(int location, unsigned int value);
1555
1556/*! Sets the value of the unsigned integer uniform shader variable at the given location. */
1557DECLSPEC void SDLCALL GPU_SetUniformuiv(int location, int num_elements_per_value, int num_values, unsigned int* values);
1558
1559/*! Fills "values" with the value of the uniform shader variable at the given location. */
1560DECLSPEC void SDLCALL GPU_GetUniformfv(Uint32 program_object, int location, float* values);
1561
1562/*! Sets the value of the floating point uniform shader variable at the given location.
1563 This is equivalent to calling GPU_SetUniformfv(location, 1, 1, &value). */
1564DECLSPEC void SDLCALL GPU_SetUniformf(int location, float value);
1565
1566/*! Sets the value of the floating point uniform shader variable at the given location. */
1567DECLSPEC void SDLCALL GPU_SetUniformfv(int location, int num_elements_per_value, int num_values, float* values);
1568
1569/*! Fills "values" with the value of the uniform shader variable at the given location. The results are identical to calling GPU_GetUniformfv(). Matrices are gotten in column-major order. */
1570DECLSPEC void SDLCALL GPU_GetUniformMatrixfv(Uint32 program_object, int location, float* values);
1571
1572/*! Sets the value of the matrix uniform shader variable at the given location. The size of the matrices sent is specified by num_rows and num_columns. Rows and columns must be between 2 and 4. */
1573DECLSPEC void SDLCALL GPU_SetUniformMatrixfv(int location, int num_matrices, int num_rows, int num_columns, Uint8 transpose, float* values);
1574
1575/*! Sets a constant-value shader attribute that will be used for each rendered vertex. */
1576DECLSPEC void SDLCALL GPU_SetAttributef(int location, float value);
1577
1578/*! Sets a constant-value shader attribute that will be used for each rendered vertex. */
1579DECLSPEC void SDLCALL GPU_SetAttributei(int location, int value);
1580
1581/*! Sets a constant-value shader attribute that will be used for each rendered vertex. */
1582DECLSPEC void SDLCALL GPU_SetAttributeui(int location, unsigned int value);
1583
1584/*! Sets a constant-value shader attribute that will be used for each rendered vertex. */
1585DECLSPEC void SDLCALL GPU_SetAttributefv(int location, int num_elements, float* value);
1586
1587/*! Sets a constant-value shader attribute that will be used for each rendered vertex. */
1588DECLSPEC void SDLCALL GPU_SetAttributeiv(int location, int num_elements, int* value);
1589
1590/*! Sets a constant-value shader attribute that will be used for each rendered vertex. */
1591DECLSPEC void SDLCALL GPU_SetAttributeuiv(int location, int num_elements, unsigned int* value);
1592
1593/*! Enables a shader attribute and sets its source data. */
1594DECLSPEC void SDLCALL GPU_SetAttributeSource(int num_values, GPU_Attribute source);
1595
1596// End of ShaderInterface
1597/*! @} */
1598
1599
1600#ifdef __cplusplus
1601}
1602#endif
1603
1604#include "close_code.h"
1605
1606
1607#endif
1608