···2424 #define SDL_GPU_USE_SDL1
2525#endif
26262727+// Use bool type if available
2828+#if defined(_MSC_VER)
2929+ // As of 2016, MSVC still doesn't have bool.
3030+ #include <WinDef.h>
3131+ #define GPU_bool BOOL
3232+#elif defined(__cplusplus)
3333+ #define GPU_bool bool
3434+#elif __STDC_VERSION__ >= 199901L
3535+ #define GPU_bool _Bool
3636+#else
3737+ // Fall back to compatibility with MSVC BOOL
3838+ #define GPU_bool int
3939+#endif
4040+4141+static const GPU_bool GPU_FALSE = 0;
4242+static const GPU_bool GPU_TRUE = 1;
4343+2744typedef struct GPU_Renderer GPU_Renderer;
2845typedef struct GPU_Target GPU_Target;
2946···223240 struct GPU_Renderer* renderer;
224241 GPU_Target* target;
225242 Uint16 w, h;
226226- Uint8 using_virtual_resolution;
243243+ GPU_bool using_virtual_resolution;
227244 GPU_FormatEnum format;
228245 int num_layers;
229246 int bytes_per_pixel;
230247 Uint16 base_w, base_h; // Original image dimensions
231248 Uint16 texture_w, texture_h; // Underlying texture dimensions
232232- Uint8 has_mipmaps;
249249+ GPU_bool has_mipmaps;
233250234251 float anchor_x; // Normalized coords for the point at which the image is blitted. Default is (0.5, 0.5), that is, the image is drawn centered.
235252 float anchor_y; // These are interpreted according to GPU_SetCoordinateMode() and range from (0.0 - 1.0) normally.
236253237254 SDL_Color color;
238238- Uint8 use_blending;
255255+ GPU_bool use_blending;
239256 GPU_BlendMode blend_mode;
240257 GPU_FilterEnum filter_mode;
241258 GPU_SnapEnum snap_mode;
···244261245262 void* data;
246263 int refcount;
247247- Uint8 is_alias;
264264+ GPU_bool is_alias;
248265} GPU_Image;
249266250267···303320{
304321 /*! SDL_GLContext */
305322 void* context;
306306- Uint8 failed;
323323+ GPU_bool failed;
307324308325 /*! SDL window ID */
309326 Uint32 windowID;
···325342 Uint32 default_textured_shader_program;
326343 Uint32 default_untextured_shader_program;
327344328328- Uint8 shapes_use_blending;
345345+ GPU_bool shapes_use_blending;
329346 GPU_BlendMode shapes_blend_mode;
330347 float line_thickness;
331331- Uint8 use_texturing;
348348+ GPU_bool use_texturing;
332349333350 int matrix_mode;
334351 GPU_MatrixStack projection_matrix;
···354371 GPU_Image* image;
355372 void* data;
356373 Uint16 w, h;
357357- Uint8 using_virtual_resolution;
374374+ GPU_bool using_virtual_resolution;
358375 Uint16 base_w, base_h; // The true dimensions of the underlying image or window
359359- Uint8 use_clip_rect;
376376+ GPU_bool use_clip_rect;
360377 GPU_Rect clip_rect;
361361- Uint8 use_color;
378378+ GPU_bool use_color;
362379 SDL_Color color;
363380364381 GPU_Rect viewport;
365382366383 /*! Perspective and object viewing transforms. */
367384 GPU_Camera camera;
368368- Uint8 use_camera;
385385+ GPU_bool use_camera;
369386370387 /*! Renderer context data. NULL if the target does not represent a window or rendering context. */
371388 GPU_Context* context;
372389 int refcount;
373373- Uint8 is_alias;
390390+ GPU_bool is_alias;
374391};
375392376393/*! \ingroup Initialization
···501518/*! \ingroup ShaderInterface */
502519typedef struct GPU_AttributeFormat
503520{
504504- Uint8 is_per_sprite; // Per-sprite values are expanded to 4 vertices
521521+ GPU_bool is_per_sprite; // Per-sprite values are expanded to 4 vertices
505522 int num_elems_per_value;
506523 GPU_TypeEnum type; // GPU_TYPE_FLOAT, GPU_TYPE_INT, GPU_TYPE_UNSIGNED_INT, etc.
507507- Uint8 normalize;
524524+ GPU_bool normalize;
508525 int stride_bytes; // Number of bytes between two vertex specifications
509526 int offset_bytes; // Number of bytes to skip at the beginning of 'values'
510527} GPU_AttributeFormat;
···520537/*! \ingroup ShaderInterface */
521538typedef struct GPU_AttributeSource
522539{
523523- Uint8 enabled;
540540+ GPU_bool enabled;
524541 int num_values;
525542 void* next_value;
526543 // Automatic storage format
···602619 GPU_Target* current_context_target;
603620604621 /*! 0 for inverted, 1 for mathematical */
605605- Uint8 coordinate_mode;
622622+ GPU_bool coordinate_mode;
606623607624 /*! Default is (0.5, 0.5) - images draw centered. */
608625 float default_image_anchor_x;
···679696 * \return 1 if all of the passed features are enabled/supported
680697 * \return 0 if any of the passed features are disabled/unsupported
681698 */
682682-DECLSPEC Uint8 SDLCALL GPU_IsFeatureEnabled(GPU_FeatureEnum feature);
699699+DECLSPEC GPU_bool SDLCALL GPU_IsFeatureEnabled(GPU_FeatureEnum feature);
683700684701/*! Clean up the renderer state. */
685702DECLSPEC void SDLCALL GPU_CloseCurrentRenderer(void);
···798815/*! 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).
799816 * The default is inverted (0), as this is traditional for 2D graphics.
800817 * \param inverted 0 is for inverted coordinates, 1 is for mathematical coordinates */
801801-DECLSPEC void SDLCALL GPU_SetCoordinateMode(Uint8 use_math_coords);
818818+DECLSPEC void SDLCALL GPU_SetCoordinateMode(GPU_bool use_math_coords);
802819803803-DECLSPEC Uint8 SDLCALL GPU_GetCoordinateMode(void);
820820+DECLSPEC GPU_bool SDLCALL GPU_GetCoordinateMode(void);
804821805822/*! Sets the default image blitting anchor for newly created images.
806823 * \see GPU_SetAnchor
···840857841858/*! Change the actual size of the current context target's window. This resets the virtual resolution and viewport of the context target.
842859 * Aside from direct resolution changes, this should also be called in response to SDL_WINDOWEVENT_RESIZED window events for resizable windows. */
843843-DECLSPEC Uint8 SDLCALL GPU_SetWindowResolution(Uint16 w, Uint16 h);
860860+DECLSPEC GPU_bool SDLCALL GPU_SetWindowResolution(Uint16 w, Uint16 h);
844861845862/*! Enable/disable fullscreen mode for the current context target's window.
846863 * 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.
847864 * \param enable_fullscreen If true, make the application go fullscreen. If false, make the application go to windowed mode.
848865 * \param use_desktop_resolution If true, lets the window change its resolution when it enters fullscreen mode (via SDL_WINDOW_FULLSCREEN_DESKTOP).
849866 * \return 0 if the new mode is windowed, 1 if the new mode is fullscreen. */
850850-DECLSPEC Uint8 SDLCALL GPU_SetFullscreen(Uint8 enable_fullscreen, Uint8 use_desktop_resolution);
867867+DECLSPEC GPU_bool SDLCALL GPU_SetFullscreen(GPU_bool enable_fullscreen, GPU_bool use_desktop_resolution);
851868852869/*! Returns true if the current context target's window is in fullscreen mode. */
853853-DECLSPEC Uint8 SDLCALL GPU_GetFullscreen(void);
870870+DECLSPEC GPU_bool SDLCALL GPU_GetFullscreen(void);
854871855872/*! Enables/disables alpha blending for shape rendering on the current window. */
856856-DECLSPEC void SDLCALL GPU_SetShapeBlending(Uint8 enable);
873873+DECLSPEC void SDLCALL GPU_SetShapeBlending(GPU_bool enable);
857874858875/*! Translates a blend preset into a blend mode. */
859876DECLSPEC GPU_BlendMode SDLCALL GPU_GetBlendModeFromPreset(GPU_BlendPresetEnum preset);
···932949DECLSPEC GPU_Camera SDLCALL GPU_SetCamera(GPU_Target* target, GPU_Camera* cam);
933950934951/*! Enables or disables using the built-in camera matrix transforms. */
935935-DECLSPEC void SDLCALL GPU_EnableCamera(GPU_Target* target, Uint8 use_camera);
952952+DECLSPEC void SDLCALL GPU_EnableCamera(GPU_Target* target, GPU_bool use_camera);
936953937954/*! Returns 1 if the camera transforms are enabled, 0 otherwise. */
938938-DECLSPEC Uint8 SDLCALL GPU_IsCameraEnabled(GPU_Target* target);
955955+DECLSPEC GPU_bool SDLCALL GPU_IsCameraEnabled(GPU_Target* target);
939956940957/*! \return The RGBA color of a pixel. */
941958DECLSPEC SDL_Color SDLCALL GPU_GetPixel(GPU_Target* target, Sint16 x, Sint16 y);
···9871004DECLSPEC SDL_Surface* SDLCALL GPU_LoadSurface(const char* filename);
98810059891006/*! Load surface from an image file in memory. Don't forget to SDL_FreeSurface() it. */
990990-DECLSPEC SDL_Surface* SDLCALL GPU_LoadSurface_RW(SDL_RWops* rwops, Uint8 free_rwops);
10071007+DECLSPEC SDL_Surface* SDLCALL GPU_LoadSurface_RW(SDL_RWops* rwops, GPU_bool free_rwops);
99110089921009/*! Save surface to a file.
9931010 * With a format of GPU_FILE_AUTO, the file type is deduced from the extension. Supported formats are: png, bmp, tga.
9941011 * Returns 0 on failure. */
995995-DECLSPEC Uint8 SDLCALL GPU_SaveSurface(SDL_Surface* surface, const char* filename, GPU_FileFormatEnum format);
10121012+DECLSPEC GPU_bool SDLCALL GPU_SaveSurface(SDL_Surface* surface, const char* filename, GPU_FileFormatEnum format);
99610139971014// End of SurfaceControls
9981015/*! @} */
···10111028DECLSPEC GPU_Image* SDLCALL GPU_CreateImage(Uint16 w, Uint16 h, GPU_FormatEnum format);
1012102910131030/*! Create a new image that uses the given native texture handle as the image texture. */
10141014-DECLSPEC GPU_Image* SDLCALL GPU_CreateImageUsingTexture(Uint32 handle, Uint8 take_ownership);
10311031+DECLSPEC GPU_Image* SDLCALL GPU_CreateImageUsingTexture(Uint32 handle, GPU_bool take_ownership);
1015103210161033/*! Load image from an image file that is supported by this renderer. Don't forget to GPU_FreeImage() it. */
10171034DECLSPEC GPU_Image* SDLCALL GPU_LoadImage(const char* filename);
1018103510191036/*! Load image from an image file in memory. Don't forget to GPU_FreeImage() it. */
10201020-DECLSPEC GPU_Image* SDLCALL GPU_LoadImage_RW(SDL_RWops* rwops, Uint8 free_rwops);
10371037+DECLSPEC GPU_Image* SDLCALL GPU_LoadImage_RW(SDL_RWops* rwops, GPU_bool free_rwops);
1021103810221039/*! Creates an image that aliases the given image. Aliases can be used to store image settings (e.g. modulation color) for easy switching.
10231040 * GPU_FreeImage() frees the alias's memory, but does not affect the original. */
···10421059DECLSPEC void SDLCALL GPU_UpdateImageBytes(GPU_Image* image, const GPU_Rect* image_rect, const unsigned char* bytes, int bytes_per_row);
1043106010441061/*! 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. */
10451045-DECLSPEC Uint8 SDLCALL GPU_ReplaceImage(GPU_Image* image, SDL_Surface* surface, const GPU_Rect* surface_rect);
10621062+DECLSPEC GPU_bool SDLCALL GPU_ReplaceImage(GPU_Image* image, SDL_Surface* surface, const GPU_Rect* surface_rect);
1046106310471064/*! Save image to a file.
10481065 * With a format of GPU_FILE_AUTO, the file type is deduced from the extension. Supported formats are: png, bmp, tga.
10491066 * Returns 0 on failure. */
10501050-DECLSPEC Uint8 SDLCALL GPU_SaveImage(GPU_Image* image, const char* filename, GPU_FileFormatEnum format);
10671067+DECLSPEC GPU_bool SDLCALL GPU_SaveImage(GPU_Image* image, const char* filename, GPU_FileFormatEnum format);
1051106810521069/*! Loads mipmaps for the given image, if supported by the renderer. */
10531070DECLSPEC void SDLCALL GPU_GenerateMipmaps(GPU_Image* image);
···10661083DECLSPEC void SDLCALL GPU_UnsetColor(GPU_Image* image);
1067108410681085/*! Gets the current alpha blending setting. */
10691069-DECLSPEC Uint8 SDLCALL GPU_GetBlending(GPU_Image* image);
10861086+DECLSPEC GPU_bool SDLCALL GPU_GetBlending(GPU_Image* image);
1070108710711088/*! Enables/disables alpha blending for the given image. */
10721072-DECLSPEC void SDLCALL GPU_SetBlending(GPU_Image* image, Uint8 enable);
10891089+DECLSPEC void SDLCALL GPU_SetBlending(GPU_Image* image, GPU_bool enable);
1073109010741091/*! Sets the blending component functions. */
10751092DECLSPEC void SDLCALL GPU_SetBlendFunction(GPU_Image* image, GPU_BlendFuncEnum source_color, GPU_BlendFuncEnum dest_color, GPU_BlendFuncEnum source_alpha, GPU_BlendFuncEnum dest_alpha);
···15781595DECLSPEC void SDLCALL GPU_FreeShaderProgram(Uint32 program_object);
1579159615801597/*! Loads shader source from an SDL_RWops, compiles it, and returns the new shader object. */
15811581-DECLSPEC Uint32 SDLCALL GPU_CompileShader_RW(GPU_ShaderEnum shader_type, SDL_RWops* shader_source, Uint8 free_rwops);
15981598+DECLSPEC Uint32 SDLCALL GPU_CompileShader_RW(GPU_ShaderEnum shader_type, SDL_RWops* shader_source, GPU_bool free_rwops);
1582159915831600/*! Compiles shader source and returns the new shader object. */
15841601DECLSPEC Uint32 SDLCALL GPU_CompileShader(GPU_ShaderEnum shader_type, const char* shader_source);
···16021619DECLSPEC void SDLCALL GPU_DetachShader(Uint32 program_object, Uint32 shader_object);
1603162016041621/*! Links a shader program with any attached shader objects. */
16051605-DECLSPEC Uint8 SDLCALL GPU_LinkShaderProgram(Uint32 program_object);
16221622+DECLSPEC GPU_bool SDLCALL GPU_LinkShaderProgram(Uint32 program_object);
1606162316071624/*! \return The current shader program */
16081625DECLSPEC Uint32 SDLCALL GPU_GetCurrentShaderProgram(void);
1609162616101627/*! Returns 1 if the given shader program is a default shader for the current context, 0 otherwise. */
16111611-DECLSPEC Uint8 SDLCALL GPU_IsDefaultShaderProgram(Uint32 program_object);
16281628+DECLSPEC GPU_bool SDLCALL GPU_IsDefaultShaderProgram(Uint32 program_object);
1612162916131630/*! 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. */
16141631DECLSPEC void SDLCALL GPU_ActivateShaderProgram(Uint32 program_object, GPU_ShaderBlock* block);
···16231640DECLSPEC int SDLCALL GPU_GetAttributeLocation(Uint32 program_object, const char* attrib_name);
1624164116251642/*! Returns a filled GPU_AttributeFormat object. */
16261626-DECLSPEC GPU_AttributeFormat SDLCALL GPU_MakeAttributeFormat(int num_elems_per_vertex, GPU_TypeEnum type, Uint8 normalize, int stride_bytes, int offset_bytes);
16431643+DECLSPEC GPU_AttributeFormat SDLCALL GPU_MakeAttributeFormat(int num_elems_per_vertex, GPU_TypeEnum type, GPU_bool normalize, int stride_bytes, int offset_bytes);
1627164416281645/*! Returns a filled GPU_Attribute object. */
16291646DECLSPEC GPU_Attribute SDLCALL GPU_MakeAttribute(int location, void* values, GPU_AttributeFormat format);
···16771694DECLSPEC void SDLCALL GPU_GetUniformMatrixfv(Uint32 program_object, int location, float* values);
1678169516791696/*! 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. */
16801680-DECLSPEC void SDLCALL GPU_SetUniformMatrixfv(int location, int num_matrices, int num_rows, int num_columns, Uint8 transpose, float* values);
16971697+DECLSPEC void SDLCALL GPU_SetUniformMatrixfv(int location, int num_matrices, int num_rows, int num_columns, GPU_bool transpose, float* values);
1681169816821699/*! Sets a constant-value shader attribute that will be used for each rendered vertex. */
16831700DECLSPEC void SDLCALL GPU_SetAttributef(int location, float value);