···17171818/* Auto-detect if we're using the SDL2 API by the headers available. */
1919#if SDL_VERSION_ATLEAST(2,0,0)
2020- #define SDL_GPU_USE_SDL2
2020+ #define SDL_GPU_USE_SDL2
2121#endif
22222323typedef struct GPU_Renderer GPU_Renderer;
2424typedef struct GPU_Target GPU_Target;
25252626-/*! A struct representing a rectangular area with floating point precision.
2626+/*!
2727+ * \defgroup Initialization Initialization
2828+ * \defgroup Logging Debugging, Logging, and Error Handling
2929+ * \defgroup RendererSetup Renderer Setup
3030+ * \defgroup RendererControls Renderer Controls
3131+ * \defgroup ContextControls Context Controls
3232+ * \defgroup TargetControls Target Controls
3333+ * \defgroup SurfaceControls Surface Controls
3434+ * \defgroup ImageControls Image Controls
3535+ * \defgroup Conversions Surface, Image, and Target Conversions
3636+ * \defgroup Rendering Rendering
3737+ * \defgroup Shapes Shapes
3838+ * \defgroup ShaderInterface Shader Interface
3939+ */
4040+4141+/*! \ingroup Rendering
4242+ * A struct representing a rectangular area with floating point precision.
2743 * \see GPU_MakeRect()
2844 */
2945typedef struct GPU_Rect
···4864static const GPU_RendererEnum GPU_RENDERER_D3D10 = 0x20000;
4965static const GPU_RendererEnum GPU_RENDERER_D3D11 = 0x40000;
50665151-/*! Renderer ID object for identifying a specific renderer.
6767+/*! \ingroup Initialization
6868+ * \ingroup RendererSetup
6969+ * \ingroup RendererControls
7070+ * Renderer ID object for identifying a specific renderer.
5271 * \see GPU_MakeRendererID()
5372 * \see GPU_InitRendererByID()
5473 */
···6281} GPU_RendererID;
638264836565-/*! Blend component functions
8484+/*! \ingroup ImageControls
8585+ * Blend component functions
6686 * \see GPU_SetBlendFunction()
6787 * Values chosen for direct OpenGL compatibility.
6888 */
···7999 GPU_FUNC_ONE_MINUS_DST_ALPHA = 0x0305
80100} GPU_BlendFuncEnum;
811018282-/*! Blend component equations
102102+/*! \ingroup ImageControls
103103+ * Blend component equations
83104 * \see GPU_SetBlendEquation()
84105 * Values chosen for direct OpenGL compatibility.
85106 */
···89110 GPU_EQ_REVERSE_SUBTRACT = 0x800B
90111} GPU_BlendEqEnum;
911129292-/*! Blend mode storage struct */
113113+/*! \ingroup ImageControls
114114+ * Blend mode storage struct */
93115typedef struct GPU_BlendMode
94116{
95117 GPU_BlendFuncEnum source_color;
···101123 GPU_BlendEqEnum alpha_equation;
102124} GPU_BlendMode;
103125104104-/*! Blend mode presets
126126+/*! \ingroup ImageControls
127127+ * Blend mode presets
105128 * \see GPU_SetBlendMode()
106129 * \see GPU_GetBlendModeFromPreset()
107130 */
···118141 GPU_BLEND_NORMAL_ADD_ALPHA = 9
119142} GPU_BlendPresetEnum;
120143121121-/*! Image filtering options. These affect the quality/interpolation of colors when images are scaled.
144144+/*! \ingroup ImageControls
145145+ * Image filtering options. These affect the quality/interpolation of colors when images are scaled.
122146 * \see GPU_SetImageFilter()
123147 */
124148typedef enum {
···127151 GPU_FILTER_LINEAR_MIPMAP = 2
128152} GPU_FilterEnum;
129153130130-/*! Snap modes. Blitting with these modes will align the sprite with the target's pixel grid.
154154+/*! \ingroup ImageControls
155155+ * Snap modes. Blitting with these modes will align the sprite with the target's pixel grid.
131156 * \see GPU_SetSnapMode()
132157 * \see GPU_GetSnapMode()
133158 */
···139164} GPU_SnapEnum;
140165141166142142-/*! Image wrapping options. These affect how images handle src_rect coordinates beyond their dimensions when blitted.
167167+/*! \ingroup ImageControls
168168+ * Image wrapping options. These affect how images handle src_rect coordinates beyond their dimensions when blitted.
143169 * \see GPU_SetWrapMode()
144170 */
145171typedef enum {
···148174 GPU_WRAP_MIRRORED = 2
149175} GPU_WrapEnum;
150176151151-/*! Image format enum
177177+/*! \ingroup ImageControls
178178+ * Image format enum
152179 * \see GPU_CreateImage()
153180 */
154181typedef enum {
···164191165192166193167167-/*! Image object for containing pixel/texture data.
194194+/*! \ingroup ImageControls
195195+ * Image object for containing pixel/texture data.
168196 * A GPU_Image can be created with GPU_CreateImage(), GPU_LoadImage(), GPU_CopyImage(), or GPU_CopyImageFromSurface().
169197 * Free the memory with GPU_FreeImage() when you're done.
170198 * \see GPU_CreateImage()
···198226} GPU_Image;
199227200228201201-/*! Camera object that determines viewing transform.
229229+/*! \ingroup TargetControls
230230+ * Camera object that determines viewing transform.
202231 * \see GPU_SetCamera()
203232 * \see GPU_GetDefaultCamera()
204233 * \see GPU_GetCamera()
···211240} GPU_Camera;
212241213242214214-/*! Container for the built-in shader attribute and uniform locations (indices).
243243+/*! \ingroup ShaderInterface
244244+ * Container for the built-in shader attribute and uniform locations (indices).
215245 * \see GPU_LoadShaderBlock()
216246 * \see GPU_SetShaderBlock()
217247 */
···232262#define GPU_MATRIX_STACK_MAX 5
233263#endif
234264235235-/*! Matrix stack data structure for replacing the old OpenGL matrix stack. */
265265+/*! \ingroup Rendering
266266+ * Matrix stack data structure for replacing the old OpenGL matrix stack. */
236267typedef struct GPU_MatrixStack
237268{
238269 unsigned int size;
···240271} GPU_MatrixStack;
241272242273243243-/*! Rendering context data. Only GPU_Targets which represent windows will store this. */
274274+/*! \ingroup ContextControls
275275+ * Rendering context data. Only GPU_Targets which represent windows will store this. */
244276typedef struct GPU_Context
245277{
246278 /*! SDL_GLContext */
247247- void* context;
279279+ void* context;
248280 Uint8 failed;
249281250282 /*! SDL window ID */
···276308} GPU_Context;
277309278310279279-/*! Render target object for use as a blitting destination.
311311+/*! \ingroup TargetControls
312312+ * Render target object for use as a blitting destination.
280313 * A GPU_Target can be created from a GPU_Image with GPU_LoadTarget().
281314 * A GPU_Target can also represent a separate window with GPU_CreateTargetFromWindow(). In that case, 'context' is allocated and filled in.
282315 * Note: You must have passed the SDL_WINDOW_OPENGL flag to SDL_CreateWindow() for OpenGL renderers to work with new windows.
···308341 Uint8 is_alias;
309342};
310343311311-/*! Important GPU features which may not be supported depending on a device's extension support. Can be OR'd together.
344344+/*! \ingroup Initialization
345345+ * Important GPU features which may not be supported depending on a device's extension support. Can be OR'd together.
312346 * \see GPU_IsFeatureEnabled()
313347 * \see GPU_SetPreInitFlags()
314348 * \see GPU_GetPreInitFlags()
···341375342376typedef Uint32 GPU_WindowFlagEnum;
343377344344-/*! Initialization flags for changing default init parameters. Can be bitwise OR'ed together with GPU_FeatureEnums.
378378+/*! \ingroup Initialization
379379+ * Initialization flags for changing default init parameters. Can be bitwise OR'ed together with GPU_FeatureEnums.
345380 * Default (0) is to use late swap vsync and double buffering.
346381 * \see GPU_SetPreInitFlags()
347382 * \see GPU_GetPreInitFlags()
···356391357392static const Uint32 GPU_NONE = 0x0;
358393359359-/*! Bit flags for the blit batch functions.
394394+/*! \ingroup Rendering
395395+ * Bit flags for the blit batch functions.
360396 * \see GPU_BlitBatch()
361397 * \see GPU_BlitBatchSeparate()
362398 */
···370406371407#define GPU_PASSTHROUGH_ALL (GPU_PASSTHROUGH_VERTICES | GPU_PASSTHROUGH_TEXCOORDS | GPU_PASSTHROUGH_COLORS)
372408373373-/*! Type enumeration for GPU_AttributeFormat specifications. */
409409+/*! \ingroup ShaderInterface
410410+ * Type enumeration for GPU_AttributeFormat specifications.
411411+ */
374412typedef Uint32 GPU_TypeEnum;
375413// Use OpenGL's values for simpler translation
376414static const GPU_TypeEnum GPU_TYPE_BYTE = 0x1400;
···387425388426389427390390-/*! Shader type enum.
428428+/*! \ingroup ShaderInterface
429429+ * Shader type enum.
391430 * \see GPU_LoadShader()
392431 * \see GPU_CompileShader()
393432 * \see GPU_CompileShader_RW()
···401440402441403442404404-/*! Type enumeration for the shader language used by the renderer. */
443443+/*! \ingroup ShaderInterface
444444+ * Type enumeration for the shader language used by the renderer.
445445+ */
405446typedef enum {
406447 GPU_LANGUAGE_NONE = 0,
407448 GPU_LANGUAGE_ARB_ASSEMBLY = 1,
···411452 GPU_LANGUAGE_CG = 5
412453} GPU_ShaderLanguageEnum;
413454455455+/*! \ingroup ShaderInterface */
414456typedef struct GPU_AttributeFormat
415457{
416458 Uint8 is_per_sprite; // Per-sprite values are expanded to 4 vertices
···421463 int offset_bytes; // Number of bytes to skip at the beginning of 'values'
422464} GPU_AttributeFormat;
423465466466+/*! \ingroup ShaderInterface */
424467typedef struct GPU_Attribute
425468{
426469 int location;
···428471 GPU_AttributeFormat format;
429472} GPU_Attribute;
430473474474+/*! \ingroup ShaderInterface */
431475typedef struct GPU_AttributeSource
432476{
433477 Uint8 enabled;
···442486} GPU_AttributeSource;
443487444488445445-/*! Type enumeration for error codes.
489489+/*! \ingroup Logging
490490+ * Type enumeration for error codes.
446491 * \see GPU_PushErrorCode()
447492 * \see GPU_PopErrorCode()
448493 */
···456501 GPU_ERROR_FILE_NOT_FOUND = 6
457502} GPU_ErrorEnum;
458503459459-504504+/*! \ingroup Logging */
460505typedef struct GPU_ErrorObject
461506{
462507 char* function;
···465510} GPU_ErrorObject;
466511467512468468-/*! Type enumeration for debug levels.
513513+/*! \ingroup Logging
514514+ * Type enumeration for debug levels.
469515 * \see GPU_SetDebugLevel()
470516 * \see GPU_GetDebugLevel()
471517 */
···505551506552507553508508-// Setup calls
554554+/*! \ingroup Initialization
555555+ * @{ */
509556510557// Visual C does not support static inline
511558#ifdef _MSC_VER
···568615/*! Clean up the renderer state and shut down SDL_gpu. */
569616void GPU_Quit(void);
570617618618+// End of Initialization
619619+/*! @} */
571620572621573622574623// Debugging, logging, and error handling
624624+625625+/*! \ingroup Logging
626626+ * @{ */
575627576628/*! Sets the global debug level.
577629 * GPU_DEBUG_LEVEL_0: Normal
···608660/*! Gets the string representation of an error code. */
609661const char* GPU_GetErrorString(GPU_ErrorEnum error);
610662663663+// End of Logging
664664+/*! @} */
611665612666613667···615669616670617671618618-// Renderer setup controls
672672+/*! \ingroup RendererSetup
673673+ * @{ */
619674620675/*! Translates a GPU_RendererEnum into a string. */
621676const char* GPU_GetRendererEnumString(GPU_RendererEnum id);
···638693/*! Deletes the renderer matching the given identifier. */
639694void GPU_RemoveRenderer(GPU_RendererID id);
640695696696+// End of RendererSetup
697697+/*! @} */
641698642699643643-// Renderer controls
700700+701701+/*! \ingroup RendererControls
702702+ * @{ */
644703645704/*! Gets the number of active (created) renderers. */
646705int GPU_GetNumActiveRenderers(void);
···663722/*! 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. */
664723void GPU_ResetRendererState(void);
665724725725+// End of RendererControls
726726+/*! @} */
666727667728668729669730670731// Context / window controls
671732733733+/*! \ingroup ContextControls
734734+ * @{ */
735735+672736/*! \return The renderer's current context target. */
673737GPU_Target* GPU_GetContextTarget(void);
674738···722786/*! Returns the current line thickness value. */
723787float GPU_GetLineThickness(void);
724788789789+// End of ContextControls
790790+/*! @} */
725791726792727793728794729729-// Target controls
795795+/*! \ingroup TargetControls
796796+ * @{ */
730797731798/*! Creates a target that aliases the given target. Aliases can be used to store target settings (e.g. viewports) for easy switching.
732799 * GPU_FreeTarget() frees the alias's memory, but does not affect the original. */
···801868 */
802869void GPU_SetTargetRGBA(GPU_Target* target, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
803870871871+// End of TargetControls
872872+/*! @} */
804873805874806875807807-// Surface controls
876876+/*! \ingroup SurfaceControls
877877+ * @{ */
808878809879/*! Load surface from an image file that is supported by this renderer. Don't forget to SDL_FreeSurface() it. */
810880SDL_Surface* GPU_LoadSurface(const char* filename);
···812882/*! Save surface to a file. The file type is deduced from the extension. Supported formats are: png, bmp, tga. Returns 0 on failure. */
813883Uint8 GPU_SaveSurface(SDL_Surface* surface, const char* filename);
814884885885+// End of SurfaceControls
886886+/*! @} */
815887816888817889818890819819-// Image controls
891891+/*! \ingroup ImageControls
892892+ * @{ */
820893821894/*! Create a new, blank image with the given format. Don't forget to GPU_FreeImage() it.
822895 * \param w Image width in pixels
···889962/*! Sets the image wrapping mode, if supported by the renderer. */
890963void GPU_SetWrapMode(GPU_Image* image, GPU_WrapEnum wrap_mode_x, GPU_WrapEnum wrap_mode_y);
891964965965+// End of ImageControls
966966+/*! @} */
892967893968894969// Surface / Image / Target conversions
970970+/*! \ingroup Conversions
971971+ * @{ */
895972896973/*! Copy SDL_Surface data into a new GPU_Image. Don't forget to SDL_FreeSurface() the surface and GPU_FreeImage() the image.*/
897974GPU_Image* GPU_CopyImageFromSurface(SDL_Surface* surface);
···905982/*! Copy GPU_Image data into a new SDL_Surface. Don't forget to SDL_FreeSurface() the surface and GPU_FreeImage() the image.*/
906983SDL_Surface* GPU_CopySurfaceFromImage(GPU_Image* image);
907984985985+// End of Conversions
986986+/*! @} */
908987909988910910-// Rendering
989989+/*! \ingroup Rendering
990990+ * @{ */
911991912992/*! Clears the contents of the given render target. Fills the target with color {0, 0, 0, 0}. */
913993void GPU_Clear(GPU_Target* target);
···9941074/*! Updates the given target's associated window. */
9951075void GPU_Flip(GPU_Target* target);
996107610771077+// End of Rendering
10781078+/*! @} */
997107999810809991081100010821001108310021002-// Shapes
10841084+/*! \ingroup Shapes
10851085+ * @{ */
1003108610041087/*! Renders a colored point.
10051088 * \param target The destination render target
···11651248 */
11661249void GPU_PolygonFilled(GPU_Target* target, unsigned int num_vertices, float* vertices, SDL_Color color);
1167125012511251+// End of Shapes
12521252+/*! @} */
116812531169125411701255117112561172125711731173-// Shaders
12581258+/*! \ingroup ShaderInterface
12591259+ * @{ */
1174126011751261/*! Loads shader source from an SDL_RWops, compiles it, and returns the new shader object. */
11761262Uint32 GPU_CompileShader_RW(GPU_ShaderEnum shader_type, SDL_RWops* shader_source);
···12951381/*! Enables a shader attribute and sets its source data. */
12961382void GPU_SetAttributeSource(int num_values, GPU_Attribute source);
1297138312981298-13841384+// End of ShaderInterface
13851385+/*! @} */
129913861300138713011388#ifdef __cplusplus