SDL_gpu  0.11.0
A hardware-accelerated, cross-platform 2D graphics API
Data Structures | Macros | Functions
SDL_gpu.c File Reference
#include "SDL_gpu.h"
#include "SDL_gpu_RendererImpl.h"
#include "SDL_platform.h"
#include "stb_image.h"
#include "stb_image_write.h"
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  GPU_WindowMapping
 

Macros

#define GET_ALPHA(sdl_color)   ((sdl_color).unused)
 
#define CHECK_RENDERER   (_gpu_current_renderer != NULL)
 
#define MAKE_CURRENT_IF_NONE(target)   do{ if(_gpu_current_renderer->current_context_target == NULL && target != NULL && target->context != NULL) GPU_MakeCurrent(target, target->context->windowID); } while(0)
 
#define CHECK_CONTEXT   (_gpu_current_renderer->current_context_target != NULL)
 
#define RETURN_ERROR(code, details)   do{ GPU_PushErrorCode(__func__, code, "%s", details); return; } while(0)
 
#define GPU_DEFAULT_MAX_NUM_ERRORS   20
 
#define GPU_ERROR_FUNCTION_STRING_MAX   128
 
#define GPU_ERROR_DETAILS_STRING_MAX   512
 
#define GPU_INITIAL_WINDOW_MAPPINGS_SIZE   10
 

Functions

int gpu_strcasecmp (const char *s1, const char *s2)
 
void gpu_init_renderer_register (void)
 
void gpu_free_renderer_register (void)
 
GPU_Renderergpu_create_and_add_renderer (GPU_RendererID id)
 
int gpu_default_print (GPU_LogLevelEnum log_level, const char *format, va_list args)
 
SDL_version GPU_GetLinkedVersion (void)
 
void GPU_SetCurrentRenderer (GPU_RendererID id)
 
void GPU_ResetRendererState (void)
 
void GPU_SetCoordinateMode (GPU_bool use_math_coords)
 
GPU_bool GPU_GetCoordinateMode (void)
 
GPU_RendererGPU_GetCurrentRenderer (void)
 
Uint32 GPU_GetCurrentShaderProgram (void)
 
void GPU_SetLogCallback (int(*callback)(GPU_LogLevelEnum log_level, const char *format, va_list args))
 
void GPU_LogInfo (const char *format,...)
 
void GPU_LogWarning (const char *format,...)
 
void GPU_LogError (const char *format,...)
 
void GPU_SetInitWindow (Uint32 windowID)
 
Uint32 GPU_GetInitWindow (void)
 
void GPU_SetPreInitFlags (GPU_InitFlagEnum GPU_flags)
 
GPU_InitFlagEnum GPU_GetPreInitFlags (void)
 
void GPU_SetRequiredFeatures (GPU_FeatureEnum features)
 
GPU_FeatureEnum GPU_GetRequiredFeatures (void)
 
void GPU_AddWindowMapping (GPU_Target *target)
 
void GPU_RemoveWindowMapping (Uint32 windowID)
 
void GPU_RemoveWindowMappingByTarget (GPU_Target *target)
 
GPU_TargetGPU_GetWindowTarget (Uint32 windowID)
 
GPU_TargetGPU_Init (Uint16 w, Uint16 h, GPU_WindowFlagEnum SDL_flags)
 
GPU_TargetGPU_InitRenderer (GPU_RendererEnum renderer_enum, Uint16 w, Uint16 h, GPU_WindowFlagEnum SDL_flags)
 
GPU_TargetGPU_InitRendererByID (GPU_RendererID renderer_request, Uint16 w, Uint16 h, GPU_WindowFlagEnum SDL_flags)
 
GPU_bool GPU_IsFeatureEnabled (GPU_FeatureEnum feature)
 
GPU_TargetGPU_CreateTargetFromWindow (Uint32 windowID)
 
GPU_TargetGPU_CreateAliasTarget (GPU_Target *target)
 
void GPU_MakeCurrent (GPU_Target *target, Uint32 windowID)
 
GPU_bool GPU_SetFullscreen (GPU_bool enable_fullscreen, GPU_bool use_desktop_resolution)
 
GPU_bool GPU_GetFullscreen (void)
 
GPU_bool GPU_SetWindowResolution (Uint16 w, Uint16 h)
 
void GPU_GetVirtualResolution (GPU_Target *target, Uint16 *w, Uint16 *h)
 
void GPU_SetVirtualResolution (GPU_Target *target, Uint16 w, Uint16 h)
 
void GPU_UnsetVirtualResolution (GPU_Target *target)
 
void GPU_SetImageVirtualResolution (GPU_Image *image, Uint16 w, Uint16 h)
 
void GPU_UnsetImageVirtualResolution (GPU_Image *image)
 
void gpu_free_error_queue (void)
 
void GPU_SetErrorQueueMax (unsigned int max)
 
void GPU_CloseCurrentRenderer (void)
 
void GPU_Quit (void)
 
void GPU_SetDebugLevel (GPU_DebugLevelEnum level)
 
GPU_DebugLevelEnum GPU_GetDebugLevel (void)
 
void GPU_PushErrorCode (const char *function, GPU_ErrorEnum error, const char *details,...)
 
GPU_ErrorObject GPU_PopErrorCode (void)
 
const char * GPU_GetErrorString (GPU_ErrorEnum error)
 
void GPU_GetVirtualCoords (GPU_Target *target, float *x, float *y, float displayX, float displayY)
 
GPU_Rect GPU_MakeRect (float x, float y, float w, float h)
 
SDL_Color GPU_MakeColor (Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 
GPU_RendererID GPU_MakeRendererID (const char *name, GPU_RendererEnum renderer, int major_version, int minor_version)
 
void GPU_SetViewport (GPU_Target *target, GPU_Rect viewport)
 
void GPU_UnsetViewport (GPU_Target *target)
 
GPU_Camera GPU_GetDefaultCamera (void)
 
GPU_Camera GPU_GetCamera (GPU_Target *target)
 
GPU_Camera GPU_SetCamera (GPU_Target *target, GPU_Camera *cam)
 
void GPU_EnableCamera (GPU_Target *target, GPU_bool use_camera)
 
GPU_bool GPU_IsCameraEnabled (GPU_Target *target)
 
GPU_ImageGPU_CreateImage (Uint16 w, Uint16 h, GPU_FormatEnum format)
 
GPU_ImageGPU_CreateImageUsingTexture (Uint32 handle, GPU_bool take_ownership)
 
GPU_ImageGPU_LoadImage (const char *filename)
 
GPU_ImageGPU_LoadImage_RW (SDL_RWops *rwops, GPU_bool free_rwops)
 
GPU_ImageGPU_CreateAliasImage (GPU_Image *image)
 
GPU_bool GPU_SaveImage (GPU_Image *image, const char *filename, GPU_FileFormatEnum format)
 
GPU_bool GPU_SaveImage_RW (GPU_Image *image, SDL_RWops *rwops, GPU_bool free_rwops, GPU_FileFormatEnum format)
 
GPU_ImageGPU_CopyImage (GPU_Image *image)
 
void GPU_UpdateImage (GPU_Image *image, const GPU_Rect *image_rect, SDL_Surface *surface, const GPU_Rect *surface_rect)
 
void GPU_UpdateImageBytes (GPU_Image *image, const GPU_Rect *image_rect, const unsigned char *bytes, int bytes_per_row)
 
GPU_bool GPU_ReplaceImage (GPU_Image *image, SDL_Surface *surface, const GPU_Rect *surface_rect)
 
SDL_Surface * GPU_LoadSurface_RW (SDL_RWops *rwops, GPU_bool free_rwops)
 
SDL_Surface * GPU_LoadSurface (const char *filename)
 
GPU_bool GPU_SaveSurface (SDL_Surface *surface, const char *filename, GPU_FileFormatEnum format)
 
GPU_bool GPU_SaveSurface_RW (SDL_Surface *surface, SDL_RWops *rwops, GPU_bool free_rwops, GPU_FileFormatEnum format)
 
GPU_ImageGPU_CopyImageFromSurface (SDL_Surface *surface)
 
GPU_ImageGPU_CopyImageFromTarget (GPU_Target *target)
 
SDL_Surface * GPU_CopySurfaceFromTarget (GPU_Target *target)
 
SDL_Surface * GPU_CopySurfaceFromImage (GPU_Image *image)
 
void GPU_FreeImage (GPU_Image *image)
 
GPU_TargetGPU_GetContextTarget (void)
 
GPU_TargetGPU_LoadTarget (GPU_Image *image)
 
GPU_TargetGPU_GetTarget (GPU_Image *image)
 
void GPU_FreeTarget (GPU_Target *target)
 
void GPU_Blit (GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y)
 
void GPU_BlitRotate (GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float degrees)
 
void GPU_BlitScale (GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float scaleX, float scaleY)
 
void GPU_BlitTransform (GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float degrees, float scaleX, float scaleY)
 
void 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)
 
void GPU_BlitRect (GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, GPU_Rect *dest_rect)
 
void GPU_BlitRectX (GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, GPU_Rect *dest_rect, float degrees, float pivot_x, float pivot_y, GPU_FlipEnum flip_direction)
 
void GPU_TriangleBatch (GPU_Image *image, GPU_Target *target, unsigned short num_vertices, float *values, unsigned int num_indices, unsigned short *indices, GPU_BatchFlagEnum flags)
 
void GPU_TriangleBatchX (GPU_Image *image, GPU_Target *target, unsigned short num_vertices, void *values, unsigned int num_indices, unsigned short *indices, GPU_BatchFlagEnum flags)
 
void GPU_GenerateMipmaps (GPU_Image *image)
 
GPU_Rect GPU_SetClipRect (GPU_Target *target, GPU_Rect rect)
 
GPU_Rect GPU_SetClip (GPU_Target *target, Sint16 x, Sint16 y, Uint16 w, Uint16 h)
 
void GPU_UnsetClip (GPU_Target *target)
 
GPU_bool GPU_IntersectRect (GPU_Rect A, GPU_Rect B, GPU_Rect *result)
 
GPU_bool GPU_IntersectClipRect (GPU_Target *target, GPU_Rect B, GPU_Rect *result)
 
void GPU_SetColor (GPU_Image *image, SDL_Color color)
 
void GPU_SetRGB (GPU_Image *image, Uint8 r, Uint8 g, Uint8 b)
 
void GPU_SetRGBA (GPU_Image *image, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 
void GPU_UnsetColor (GPU_Image *image)
 
void GPU_SetTargetColor (GPU_Target *target, SDL_Color color)
 
void GPU_SetTargetRGB (GPU_Target *target, Uint8 r, Uint8 g, Uint8 b)
 
void GPU_SetTargetRGBA (GPU_Target *target, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 
void GPU_UnsetTargetColor (GPU_Target *target)
 
GPU_bool GPU_GetBlending (GPU_Image *image)
 
void GPU_SetBlending (GPU_Image *image, GPU_bool enable)
 
void GPU_SetShapeBlending (GPU_bool enable)
 
GPU_BlendMode GPU_GetBlendModeFromPreset (GPU_BlendPresetEnum preset)
 
void GPU_SetBlendFunction (GPU_Image *image, GPU_BlendFuncEnum source_color, GPU_BlendFuncEnum dest_color, GPU_BlendFuncEnum source_alpha, GPU_BlendFuncEnum dest_alpha)
 
void GPU_SetBlendEquation (GPU_Image *image, GPU_BlendEqEnum color_equation, GPU_BlendEqEnum alpha_equation)
 
void GPU_SetBlendMode (GPU_Image *image, GPU_BlendPresetEnum preset)
 
void GPU_SetShapeBlendFunction (GPU_BlendFuncEnum source_color, GPU_BlendFuncEnum dest_color, GPU_BlendFuncEnum source_alpha, GPU_BlendFuncEnum dest_alpha)
 
void GPU_SetShapeBlendEquation (GPU_BlendEqEnum color_equation, GPU_BlendEqEnum alpha_equation)
 
void GPU_SetShapeBlendMode (GPU_BlendPresetEnum preset)
 
void GPU_SetImageFilter (GPU_Image *image, GPU_FilterEnum filter)
 
void GPU_SetDefaultAnchor (float anchor_x, float anchor_y)
 
void GPU_GetDefaultAnchor (float *anchor_x, float *anchor_y)
 
void GPU_SetAnchor (GPU_Image *image, float anchor_x, float anchor_y)
 
void GPU_GetAnchor (GPU_Image *image, float *anchor_x, float *anchor_y)
 
GPU_SnapEnum GPU_GetSnapMode (GPU_Image *image)
 
void GPU_SetSnapMode (GPU_Image *image, GPU_SnapEnum mode)
 
void GPU_SetWrapMode (GPU_Image *image, GPU_WrapEnum wrap_mode_x, GPU_WrapEnum wrap_mode_y)
 
SDL_Color GPU_GetPixel (GPU_Target *target, Sint16 x, Sint16 y)
 
void GPU_Clear (GPU_Target *target)
 
void GPU_ClearColor (GPU_Target *target, SDL_Color color)
 
void GPU_ClearRGB (GPU_Target *target, Uint8 r, Uint8 g, Uint8 b)
 
void GPU_ClearRGBA (GPU_Target *target, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 
void GPU_FlushBlitBuffer (void)
 
void GPU_Flip (GPU_Target *target)
 
Uint32 GPU_CompileShader_RW (GPU_ShaderEnum shader_type, SDL_RWops *shader_source, GPU_bool free_rwops)
 
Uint32 GPU_LoadShader (GPU_ShaderEnum shader_type, const char *filename)
 
Uint32 GPU_CompileShader (GPU_ShaderEnum shader_type, const char *shader_source)
 
GPU_bool GPU_LinkShaderProgram (Uint32 program_object)
 
Uint32 GPU_CreateShaderProgram (void)
 
Uint32 GPU_LinkShaders (Uint32 shader_object1, Uint32 shader_object2)
 
Uint32 GPU_LinkManyShaders (Uint32 *shader_objects, int count)
 
void GPU_FreeShader (Uint32 shader_object)
 
void GPU_FreeShaderProgram (Uint32 program_object)
 
void GPU_AttachShader (Uint32 program_object, Uint32 shader_object)
 
void GPU_DetachShader (Uint32 program_object, Uint32 shader_object)
 
GPU_bool GPU_IsDefaultShaderProgram (Uint32 program_object)
 
void GPU_ActivateShaderProgram (Uint32 program_object, GPU_ShaderBlock *block)
 
void GPU_DeactivateShaderProgram (void)
 
const char * GPU_GetShaderMessage (void)
 
int GPU_GetAttributeLocation (Uint32 program_object, const char *attrib_name)
 
GPU_AttributeFormat GPU_MakeAttributeFormat (int num_elems_per_vertex, GPU_TypeEnum type, GPU_bool normalize, int stride_bytes, int offset_bytes)
 
GPU_Attribute GPU_MakeAttribute (int location, void *values, GPU_AttributeFormat format)
 
int GPU_GetUniformLocation (Uint32 program_object, const char *uniform_name)
 
GPU_ShaderBlock GPU_LoadShaderBlock (Uint32 program_object, const char *position_name, const char *texcoord_name, const char *color_name, const char *modelViewMatrix_name)
 
void GPU_SetShaderBlock (GPU_ShaderBlock block)
 
GPU_ShaderBlock GPU_GetShaderBlock (void)
 
void GPU_SetShaderImage (GPU_Image *image, int location, int image_unit)
 
void GPU_GetUniformiv (Uint32 program_object, int location, int *values)
 
void GPU_SetUniformi (int location, int value)
 
void GPU_SetUniformiv (int location, int num_elements_per_value, int num_values, int *values)
 
void GPU_GetUniformuiv (Uint32 program_object, int location, unsigned int *values)
 
void GPU_SetUniformui (int location, unsigned int value)
 
void GPU_SetUniformuiv (int location, int num_elements_per_value, int num_values, unsigned int *values)
 
void GPU_GetUniformfv (Uint32 program_object, int location, float *values)
 
void GPU_SetUniformf (int location, float value)
 
void GPU_SetUniformfv (int location, int num_elements_per_value, int num_values, float *values)
 
void GPU_GetUniformMatrixfv (Uint32 program_object, int location, float *values)
 
void GPU_SetUniformMatrixfv (int location, int num_matrices, int num_rows, int num_columns, GPU_bool transpose, float *values)
 
void GPU_SetAttributef (int location, float value)
 
void GPU_SetAttributei (int location, int value)
 
void GPU_SetAttributeui (int location, unsigned int value)
 
void GPU_SetAttributefv (int location, int num_elements, float *value)
 
void GPU_SetAttributeiv (int location, int num_elements, int *value)
 
void GPU_SetAttributeuiv (int location, int num_elements, unsigned int *value)
 
void GPU_SetAttributeSource (int num_values, GPU_Attribute source)
 

Macro Definition Documentation

◆ CHECK_CONTEXT

#define CHECK_CONTEXT   (_gpu_current_renderer->current_context_target != NULL)

Definition at line 30 of file SDL_gpu.c.

◆ CHECK_RENDERER

#define CHECK_RENDERER   (_gpu_current_renderer != NULL)

Definition at line 28 of file SDL_gpu.c.

◆ GET_ALPHA

#define GET_ALPHA (   sdl_color)    ((sdl_color).unused)

Definition at line 25 of file SDL_gpu.c.

◆ GPU_DEFAULT_MAX_NUM_ERRORS

#define GPU_DEFAULT_MAX_NUM_ERRORS   20

Definition at line 52 of file SDL_gpu.c.

◆ GPU_ERROR_DETAILS_STRING_MAX

#define GPU_ERROR_DETAILS_STRING_MAX   512

Definition at line 54 of file SDL_gpu.c.

◆ GPU_ERROR_FUNCTION_STRING_MAX

#define GPU_ERROR_FUNCTION_STRING_MAX   128

Definition at line 53 of file SDL_gpu.c.

◆ GPU_INITIAL_WINDOW_MAPPINGS_SIZE

#define GPU_INITIAL_WINDOW_MAPPINGS_SIZE   10

Definition at line 60 of file SDL_gpu.c.

◆ MAKE_CURRENT_IF_NONE

#define MAKE_CURRENT_IF_NONE (   target)    do{ if(_gpu_current_renderer->current_context_target == NULL && target != NULL && target->context != NULL) GPU_MakeCurrent(target, target->context->windowID); } while(0)

Definition at line 29 of file SDL_gpu.c.

◆ RETURN_ERROR

#define RETURN_ERROR (   code,
  details 
)    do{ GPU_PushErrorCode(__func__, code, "%s", details); return; } while(0)

Definition at line 31 of file SDL_gpu.c.

Function Documentation

◆ GPU_ActivateShaderProgram()

void GPU_ActivateShaderProgram ( Uint32  program_object,
GPU_ShaderBlock block 
)

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.

Definition at line 2199 of file SDL_gpu.c.

◆ GPU_AddWindowMapping()

void GPU_AddWindowMapping ( GPU_Target target)

Definition at line 271 of file SDL_gpu.c.

◆ GPU_AttachShader()

void GPU_AttachShader ( Uint32  program_object,
Uint32  shader_object 
)

Attaches a shader object to a shader program for future linking.

Definition at line 2172 of file SDL_gpu.c.

◆ GPU_Blit()

void GPU_Blit ( GPU_Image image,
GPU_Rect src_rect,
GPU_Target target,
float  x,
float  y 
)

Draws the given image to the given render target.

Parameters
src_rectThe region of the source image to use. Pass NULL for the entire image.
xDestination x-position
yDestination y-position

Definition at line 1333 of file SDL_gpu.c.

◆ GPU_BlitRect()

void GPU_BlitRect ( GPU_Image image,
GPU_Rect src_rect,
GPU_Target target,
GPU_Rect dest_rect 
)

Draws the given image to the given render target, scaling it to fit the destination region.

Parameters
src_rectThe region of the source image to use. Pass NULL for the entire image.
dest_rectThe region of the destination target image to draw upon. Pass NULL for the entire target.

Definition at line 1414 of file SDL_gpu.c.

◆ GPU_BlitRectX()

void GPU_BlitRectX ( GPU_Image image,
GPU_Rect src_rect,
GPU_Target target,
GPU_Rect dest_rect,
float  degrees,
float  pivot_x,
float  pivot_y,
GPU_FlipEnum  flip_direction 
)

Draws the given image to the given render target, scaling it to fit the destination region.

Parameters
src_rectThe region of the source image to use. Pass NULL for the entire image.
dest_rectThe region of the destination target image to draw upon. Pass NULL for the entire target.
degreesRotation angle (in degrees)
pivot_xPivot x-position (in image coordinates)
pivot_yPivot y-position (in image coordinates)
flip_directionA GPU_FlipEnum value (or bitwise OR'd combination) that specifies which direction the image should be flipped.

Definition at line 1436 of file SDL_gpu.c.

◆ GPU_BlitRotate()

void GPU_BlitRotate ( GPU_Image image,
GPU_Rect src_rect,
GPU_Target target,
float  x,
float  y,
float  degrees 
)

Rotates and draws the given image to the given render target.

Parameters
src_rectThe region of the source image to use. Pass NULL for the entire image.
xDestination x-position
yDestination y-position
degreesRotation angle (in degrees)

Definition at line 1350 of file SDL_gpu.c.

◆ GPU_BlitScale()

void GPU_BlitScale ( GPU_Image image,
GPU_Rect src_rect,
GPU_Target target,
float  x,
float  y,
float  scaleX,
float  scaleY 
)

Scales and draws the given image to the given render target.

Parameters
src_rectThe region of the source image to use. Pass NULL for the entire image.
xDestination x-position
yDestination y-position
scaleXHorizontal stretch factor
scaleYVertical stretch factor

Definition at line 1366 of file SDL_gpu.c.

◆ GPU_BlitTransform()

void GPU_BlitTransform ( GPU_Image image,
GPU_Rect src_rect,
GPU_Target target,
float  x,
float  y,
float  degrees,
float  scaleX,
float  scaleY 
)

Scales, rotates, and draws the given image to the given render target.

Parameters
src_rectThe region of the source image to use. Pass NULL for the entire image.
xDestination x-position
yDestination y-position
degreesRotation angle (in degrees)
scaleXHorizontal stretch factor
scaleYVertical stretch factor

Definition at line 1382 of file SDL_gpu.c.

◆ GPU_BlitTransformX()

void 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 
)

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).

Parameters
src_rectThe region of the source image to use. Pass NULL for the entire image.
xDestination x-position
yDestination y-position
pivot_xPivot x-position (in image coordinates)
pivot_yPivot y-position (in image coordinates)
degreesRotation angle (in degrees)
scaleXHorizontal stretch factor
scaleYVertical stretch factor

Definition at line 1398 of file SDL_gpu.c.

◆ GPU_ClearColor()

void GPU_ClearColor ( GPU_Target target,
SDL_Color  color 
)

Fills the given render target with a color.

Definition at line 2003 of file SDL_gpu.c.

◆ GPU_ClearRGB()

void GPU_ClearRGB ( GPU_Target target,
Uint8  r,
Uint8  g,
Uint8  b 
)

Fills the given render target with a color (alpha is 255, fully opaque).

Definition at line 2014 of file SDL_gpu.c.

◆ GPU_ClearRGBA()

void GPU_ClearRGBA ( GPU_Target target,
Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a 
)

Fills the given render target with a color.

Definition at line 2025 of file SDL_gpu.c.

◆ GPU_CloseCurrentRenderer()

void GPU_CloseCurrentRenderer ( void  )

Clean up the renderer state.

Definition at line 633 of file SDL_gpu.c.

◆ GPU_CompileShader()

Uint32 GPU_CompileShader ( GPU_ShaderEnum  shader_type,
const char *  shader_source 
)

Compiles shader source and returns the new shader object.

Definition at line 2101 of file SDL_gpu.c.

◆ GPU_CompileShader_RW()

Uint32 GPU_CompileShader_RW ( GPU_ShaderEnum  shader_type,
SDL_RWops *  shader_source,
GPU_bool  free_rwops 
)

Loads shader source from an SDL_RWops, compiles it, and returns the new shader object.

Definition at line 2069 of file SDL_gpu.c.

◆ GPU_CopyImage()

GPU_Image* GPU_CopyImage ( GPU_Image image)

Copy an image to a new image. Don't forget to GPU_FreeImage() both.

Definition at line 975 of file SDL_gpu.c.

◆ GPU_CopyImageFromTarget()

GPU_Image* GPU_CopyImageFromTarget ( GPU_Target target)

Copy GPU_Target data into a new GPU_Image. Don't forget to GPU_FreeImage() the image.

Definition at line 1254 of file SDL_gpu.c.

◆ GPU_CopySurfaceFromImage()

SDL_Surface* GPU_CopySurfaceFromImage ( GPU_Image image)

Copy GPU_Image data into a new SDL_Surface. Don't forget to SDL_FreeSurface() the surface and GPU_FreeImage() the image.

Definition at line 1276 of file SDL_gpu.c.

◆ GPU_CopySurfaceFromTarget()

SDL_Surface* GPU_CopySurfaceFromTarget ( GPU_Target target)

Copy GPU_Target data into a new SDL_Surface. Don't forget to SDL_FreeSurface() the surface.

Definition at line 1265 of file SDL_gpu.c.

◆ gpu_create_and_add_renderer()

GPU_Renderer* gpu_create_and_add_renderer ( GPU_RendererID  id)

Definition at line 433 of file SDL_gpu_renderer.c.

◆ GPU_CreateAliasImage()

GPU_Image* GPU_CreateAliasImage ( GPU_Image image)

Creates an image that aliases the given image. Aliases can be used to store image settings (e.g. modulation color) for easy switching. GPU_FreeImage() frees the alias's memory, but does not affect the original.

Definition at line 947 of file SDL_gpu.c.

◆ GPU_CreateImageUsingTexture()

GPU_Image* GPU_CreateImageUsingTexture ( Uint32  handle,
GPU_bool  take_ownership 
)

Create a new image that uses the given native texture handle as the image texture.

Definition at line 914 of file SDL_gpu.c.

◆ GPU_CreateTargetFromWindow()

GPU_Target* GPU_CreateTargetFromWindow ( Uint32  windowID)

Creates a separate context for the given window using the current renderer and returns a GPU_Target that represents it.

Definition at line 478 of file SDL_gpu.c.

◆ GPU_DeactivateShaderProgram()

void GPU_DeactivateShaderProgram ( void  )

Deactivates the current shader program (activates program 0).

Definition at line 2207 of file SDL_gpu.c.

◆ gpu_default_print()

int gpu_default_print ( GPU_LogLevelEnum  log_level,
const char *  format,
va_list  args 
)

Definition at line 127 of file SDL_gpu.c.

◆ GPU_DetachShader()

void GPU_DetachShader ( Uint32  program_object,
Uint32  shader_object 
)

Detaches a shader object from a shader program.

Definition at line 2180 of file SDL_gpu.c.

◆ GPU_EnableCamera()

void GPU_EnableCamera ( GPU_Target target,
GPU_bool  use_camera 
)

Enables or disables using the built-in camera matrix transforms.

Definition at line 891 of file SDL_gpu.c.

◆ GPU_Flip()

void GPU_Flip ( GPU_Target target)

Updates the given target's associated window. For non-context targets (e.g. image targets), this will flush the blit buffer.

Definition at line 2044 of file SDL_gpu.c.

◆ GPU_FlushBlitBuffer()

void GPU_FlushBlitBuffer ( void  )

Send all buffered blitting data to the current context target.

Definition at line 2036 of file SDL_gpu.c.

◆ gpu_free_error_queue()

void gpu_free_error_queue ( void  )

Definition at line 602 of file SDL_gpu.c.

◆ gpu_free_renderer_register()

void gpu_free_renderer_register ( void  )

Definition at line 266 of file SDL_gpu_renderer.c.

◆ GPU_FreeImage()

void GPU_FreeImage ( GPU_Image image)

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!

Definition at line 1284 of file SDL_gpu.c.

◆ GPU_FreeShader()

void GPU_FreeShader ( Uint32  shader_object)

Deletes a shader object.

Definition at line 2156 of file SDL_gpu.c.

◆ GPU_FreeShaderProgram()

void GPU_FreeShaderProgram ( Uint32  program_object)

Deletes a shader program.

Definition at line 2164 of file SDL_gpu.c.

◆ GPU_FreeTarget()

void GPU_FreeTarget ( GPU_Target target)

Deletes a render target in the proper way for this renderer.

Definition at line 1323 of file SDL_gpu.c.

◆ GPU_GenerateMipmaps()

void GPU_GenerateMipmaps ( GPU_Image image)

Loads mipmaps for the given image, if supported by the renderer.

Definition at line 1517 of file SDL_gpu.c.

◆ GPU_GetAnchor()

void GPU_GetAnchor ( GPU_Image image,
float *  anchor_x,
float *  anchor_y 
)

Returns the image anchor via the passed parameters. The anchor is in normalized coordinates (0.0-1.0).

Definition at line 1936 of file SDL_gpu.c.

◆ GPU_GetAttributeLocation()

int GPU_GetAttributeLocation ( Uint32  program_object,
const char *  attrib_name 
)

Returns an integer representing the location of the specified attribute shader variable.

Definition at line 2223 of file SDL_gpu.c.

◆ GPU_GetBlending()

GPU_bool GPU_GetBlending ( GPU_Image image)

Gets the current alpha blending setting.

Definition at line 1717 of file SDL_gpu.c.

◆ GPU_GetBlendModeFromPreset()

GPU_BlendMode GPU_GetBlendModeFromPreset ( GPU_BlendPresetEnum  preset)

Translates a blend preset into a blend mode.

Definition at line 1743 of file SDL_gpu.c.

◆ GPU_GetCamera()

GPU_Camera GPU_GetCamera ( GPU_Target target)
Returns
The camera of the given render target. If target is NULL, returns the default camera.

Definition at line 873 of file SDL_gpu.c.

◆ GPU_GetCoordinateMode()

GPU_bool GPU_GetCoordinateMode ( void  )

Definition at line 105 of file SDL_gpu.c.

◆ GPU_GetCurrentRenderer()

GPU_Renderer* GPU_GetCurrentRenderer ( void  )
Returns
The current renderer

Definition at line 113 of file SDL_gpu.c.

◆ GPU_GetCurrentShaderProgram()

Uint32 GPU_GetCurrentShaderProgram ( void  )
Returns
The current shader program

Definition at line 118 of file SDL_gpu.c.

◆ GPU_GetDebugLevel()

GPU_DebugLevelEnum GPU_GetDebugLevel ( void  )

Returns the current global debug level.

Definition at line 687 of file SDL_gpu.c.

◆ GPU_GetDefaultAnchor()

void GPU_GetDefaultAnchor ( float *  anchor_x,
float *  anchor_y 
)

Returns the default image blitting anchor through the given variables.

See also
GPU_GetAnchor

Definition at line 1915 of file SDL_gpu.c.

◆ GPU_GetDefaultCamera()

GPU_Camera GPU_GetDefaultCamera ( void  )
Returns
A GPU_Camera with position (0, 0, -10), angle of 0, and zoom of 1.

Definition at line 867 of file SDL_gpu.c.

◆ GPU_GetErrorString()

const char* GPU_GetErrorString ( GPU_ErrorEnum  error)

Gets the string representation of an error code.

Definition at line 765 of file SDL_gpu.c.

◆ GPU_GetFullscreen()

GPU_bool GPU_GetFullscreen ( void  )

Returns true if the current context target's window is in fullscreen mode.

Definition at line 513 of file SDL_gpu.c.

◆ GPU_GetInitWindow()

Uint32 GPU_GetInitWindow ( void  )

Returns the window ID that has been set via GPU_SetInitWindow().

Definition at line 215 of file SDL_gpu.c.

◆ GPU_GetLinkedVersion()

SDL_version GPU_GetLinkedVersion ( void  )

Definition at line 76 of file SDL_gpu.c.

◆ GPU_GetPixel()

SDL_Color GPU_GetPixel ( GPU_Target target,
Sint16  x,
Sint16  y 
)
Returns
The RGBA color of a pixel.

Definition at line 1975 of file SDL_gpu.c.

◆ GPU_GetPreInitFlags()

GPU_InitFlagEnum GPU_GetPreInitFlags ( void  )

Returns the current special flags to use for initialization.

Definition at line 225 of file SDL_gpu.c.

◆ GPU_GetRequiredFeatures()

GPU_FeatureEnum GPU_GetRequiredFeatures ( void  )

Returns the current required features to use for initialization.

Definition at line 235 of file SDL_gpu.c.

◆ GPU_GetShaderBlock()

GPU_ShaderBlock GPU_GetShaderBlock ( void  )

Gets the shader block for the current shader.

Definition at line 2283 of file SDL_gpu.c.

◆ GPU_GetShaderMessage()

const char* GPU_GetShaderMessage ( void  )

Returns the last shader log message.

Definition at line 2215 of file SDL_gpu.c.

◆ GPU_GetSnapMode()

GPU_SnapEnum GPU_GetSnapMode ( GPU_Image image)

Gets the current pixel snap setting. The default value is GPU_SNAP_POSITION_AND_DIMENSIONS.

Definition at line 1948 of file SDL_gpu.c.

◆ GPU_GetTarget()

GPU_Target* GPU_GetTarget ( GPU_Image image)

Creates a new render target from the given image. It can then be accessed from image->target. This does not increment the internal refcount of the target, so it will be invalidated when the image is freed.

Definition at line 1313 of file SDL_gpu.c.

◆ GPU_GetUniformfv()

void GPU_GetUniformfv ( Uint32  program_object,
int  location,
float *  values 
)

Fills "values" with the value of the uniform shader variable at the given location.

Definition at line 2356 of file SDL_gpu.c.

◆ GPU_GetUniformiv()

void GPU_GetUniformiv ( Uint32  program_object,
int  location,
int *  values 
)

Fills "values" with the value of the uniform shader variable at the given location.

Definition at line 2306 of file SDL_gpu.c.

◆ GPU_GetUniformLocation()

int GPU_GetUniformLocation ( Uint32  program_object,
const char *  uniform_name 
)

Returns an integer representing the location of the specified uniform shader variable.

Definition at line 2252 of file SDL_gpu.c.

◆ GPU_GetUniformMatrixfv()

void GPU_GetUniformMatrixfv ( Uint32  program_object,
int  location,
float *  values 
)

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.

Definition at line 2381 of file SDL_gpu.c.

◆ GPU_GetUniformuiv()

void GPU_GetUniformuiv ( Uint32  program_object,
int  location,
unsigned int *  values 
)

Fills "values" with the value of the uniform shader variable at the given location.

Definition at line 2331 of file SDL_gpu.c.

◆ GPU_GetVirtualCoords()

void GPU_GetVirtualCoords ( GPU_Target target,
float *  x,
float *  y,
float  displayX,
float  displayY 
)

Converts screen space coordinates (such as from mouse input) to logical drawing coordinates. This interacts with GPU_SetCoordinateMode() when the y-axis is flipped (screen space is assumed to be inverted: (0,0) in the upper-left corner).

Definition at line 788 of file SDL_gpu.c.

◆ GPU_GetVirtualResolution()

void GPU_GetVirtualResolution ( GPU_Target target,
Uint16 *  w,
Uint16 *  h 
)

Query the logical size of the given target.

Definition at line 538 of file SDL_gpu.c.

◆ GPU_GetWindowTarget()

GPU_Target* GPU_GetWindowTarget ( Uint32  windowID)
Returns
The target that is associated with the given windowID.

Definition at line 385 of file SDL_gpu.c.

◆ GPU_Init()

GPU_Target* GPU_Init ( Uint16  w,
Uint16  h,
GPU_WindowFlagEnum  SDL_flags 
)

Initializes SDL's video subsystem (if necessary) and all of SDL_gpu's internal structures. Chooses a renderer and creates a window with the given dimensions and window creation flags. A pointer to the resulting window's render target is returned.

Parameters
wDesired window width in pixels
hDesired window height in pixels
SDL_flagsThe bit flags to pass to SDL when creating the window. Use GPU_DEFAULT_INIT_FLAGS if you don't care.
Returns
On success, returns the new context target (i.e. render target backed by a window). On failure, returns NULL.

Initializes these systems: The 'error queue': Stores error codes and description strings. The 'renderer registry': An array of information about the supported renderers on the current platform, such as the renderer name and id and its life cycle functions. The SDL library and its video subsystem: Calls SDL_Init() if SDL has not already been initialized. Use SDL_InitSubsystem() to initialize more parts of SDL. The current renderer: Walks through each renderer in the renderer registry and tries to initialize them until one succeeds.

See also
GPU_RendererID
GPU_InitRenderer()
GPU_InitRendererByID()
GPU_SetRendererOrder()
GPU_PushErrorCode()

Definition at line 405 of file SDL_gpu.c.

◆ gpu_init_renderer_register()

void gpu_init_renderer_register ( void  )

Definition at line 240 of file SDL_gpu_renderer.c.

◆ GPU_InitRenderer()

GPU_Target* GPU_InitRenderer ( GPU_RendererEnum  renderer_enum,
Uint16  w,
Uint16  h,
GPU_WindowFlagEnum  SDL_flags 
)

Initializes SDL and SDL_gpu. Creates a window and the requested renderer context.

Definition at line 433 of file SDL_gpu.c.

◆ GPU_InitRendererByID()

GPU_Target* GPU_InitRendererByID ( GPU_RendererID  renderer_request,
Uint16  w,
Uint16  h,
GPU_WindowFlagEnum  SDL_flags 
)

Initializes SDL and SDL_gpu. Creates a window and the requested renderer context. By requesting a renderer via ID, you can specify the major and minor versions of an individual renderer backend.

See also
GPU_MakeRendererID

Definition at line 439 of file SDL_gpu.c.

◆ GPU_IntersectClipRect()

GPU_bool GPU_IntersectClipRect ( GPU_Target target,
GPU_Rect  B,
GPU_Rect result 
)

Returns GPU_TRUE if the given target's clip rect and the given B rect overlap, in which case it also fills the given result rect with the intersection. result can be NULL if you don't need the intersection. If the target doesn't have a clip rect enabled, this uses the whole target area.

Definition at line 1608 of file SDL_gpu.c.

◆ GPU_IntersectRect()

GPU_bool GPU_IntersectRect ( GPU_Rect  A,
GPU_Rect  B,
GPU_Rect result 
)

Returns GPU_TRUE if the given rects A and B overlap, in which case it also fills the given result rect with the intersection. result can be NULL if you don't need the intersection.

Definition at line 1559 of file SDL_gpu.c.

◆ GPU_IsCameraEnabled()

GPU_bool GPU_IsCameraEnabled ( GPU_Target target)

Returns 1 if the camera transforms are enabled, 0 otherwise.

Definition at line 899 of file SDL_gpu.c.

◆ GPU_IsDefaultShaderProgram()

GPU_bool GPU_IsDefaultShaderProgram ( Uint32  program_object)

Returns 1 if the given shader program is a default shader for the current context, 0 otherwise.

Definition at line 2188 of file SDL_gpu.c.

◆ GPU_IsFeatureEnabled()

GPU_bool GPU_IsFeatureEnabled ( GPU_FeatureEnum  feature)

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.

Returns
1 if all of the passed features are enabled/supported
0 if any of the passed features are disabled/unsupported

Definition at line 470 of file SDL_gpu.c.

◆ GPU_LinkManyShaders()

Uint32 GPU_LinkManyShaders ( Uint32 *  shader_objects,
int  count 
)

Creates and links a shader program with the given shader objects.

Definition at line 2133 of file SDL_gpu.c.

◆ GPU_LinkShaderProgram()

GPU_bool GPU_LinkShaderProgram ( Uint32  program_object)

Links a shader program with any attached shader objects.

Definition at line 2109 of file SDL_gpu.c.

◆ GPU_LinkShaders()

Uint32 GPU_LinkShaders ( Uint32  shader_object1,
Uint32  shader_object2 
)

Creates and links a shader program with the given shader objects.

Definition at line 2125 of file SDL_gpu.c.

◆ GPU_LoadImage()

GPU_Image* GPU_LoadImage ( const char *  filename)

Load image from an image file that is supported by this renderer. Don't forget to GPU_FreeImage() it.

Definition at line 922 of file SDL_gpu.c.

◆ GPU_LoadImage_RW()

GPU_Image* GPU_LoadImage_RW ( SDL_RWops *  rwops,
GPU_bool  free_rwops 
)

Load image from an image file in memory. Don't forget to GPU_FreeImage() it.

Definition at line 927 of file SDL_gpu.c.

◆ GPU_LoadShader()

Uint32 GPU_LoadShader ( GPU_ShaderEnum  shader_type,
const char *  filename 
)

Loads shader source from a file, compiles it, and returns the new shader object.

Definition at line 2081 of file SDL_gpu.c.

◆ GPU_LoadShaderBlock()

GPU_ShaderBlock GPU_LoadShaderBlock ( Uint32  program_object,
const char *  position_name,
const char *  texcoord_name,
const char *  color_name,
const char *  modelViewMatrix_name 
)

Loads the given shader program's built-in attribute and uniform locations.

Definition at line 2260 of file SDL_gpu.c.

◆ GPU_LoadSurface_RW()

SDL_Surface* GPU_LoadSurface_RW ( SDL_RWops *  rwops,
GPU_bool  free_rwops 
)

Load surface from an image file in memory. Don't forget to SDL_FreeSurface() it.

Definition at line 1089 of file SDL_gpu.c.

◆ GPU_LoadTarget()

GPU_Target* GPU_LoadTarget ( GPU_Image image)

Creates a new render target from the given image. It can then be accessed from image->target. This increments the internal refcount of the target, so it should be matched with a GPU_FreeTarget().

Definition at line 1302 of file SDL_gpu.c.

◆ GPU_LogError()

void GPU_LogError ( const char *  format,
  ... 
)

Prints an error log message.

Definition at line 175 of file SDL_gpu.c.

◆ GPU_LogInfo()

void GPU_LogInfo ( const char *  format,
  ... 
)

Prints an informational log message.

Definition at line 159 of file SDL_gpu.c.

◆ GPU_LogWarning()

void GPU_LogWarning ( const char *  format,
  ... 
)

Prints a warning log message.

Definition at line 167 of file SDL_gpu.c.

◆ GPU_MakeAttribute()

GPU_Attribute GPU_MakeAttribute ( int  location,
void *  values,
GPU_AttributeFormat  format 
)

Returns a filled GPU_Attribute object.

Definition at line 2243 of file SDL_gpu.c.

◆ GPU_MakeAttributeFormat()

GPU_AttributeFormat GPU_MakeAttributeFormat ( int  num_elems_per_vertex,
GPU_TypeEnum  type,
GPU_bool  normalize,
int  stride_bytes,
int  offset_bytes 
)

Returns a filled GPU_AttributeFormat object.

Definition at line 2231 of file SDL_gpu.c.

◆ GPU_MakeColor()

SDL_Color GPU_MakeColor ( Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a 
)
Returns
An SDL_Color with the given values.

Definition at line 833 of file SDL_gpu.c.

◆ GPU_MakeCurrent()

void GPU_MakeCurrent ( GPU_Target target,
Uint32  windowID 
)

Makes the given window the current rendering destination for the given context target. This also makes the target the current context for image loading and window operations. If the target does not represent a window, this does nothing.

Definition at line 497 of file SDL_gpu.c.

◆ GPU_MakeRect()

GPU_Rect GPU_MakeRect ( float  x,
float  y,
float  w,
float  h 
)
Returns
A GPU_Rect with the given values.

Definition at line 822 of file SDL_gpu.c.

◆ GPU_PopErrorCode()

GPU_ErrorObject GPU_PopErrorCode ( void  )

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.

Definition at line 736 of file SDL_gpu.c.

◆ GPU_PushErrorCode()

void GPU_PushErrorCode ( const char *  function,
GPU_ErrorEnum  error,
const char *  details,
  ... 
)

Pushes a new error code into the error queue. If the queue is full, the queue is not modified.

Parameters
functionThe name of the function that pushed the error
errorThe error code to push on the error queue
detailsAdditional information string, can be NULL.

Definition at line 692 of file SDL_gpu.c.

◆ GPU_Quit()

void GPU_Quit ( void  )

Clean up the renderer state and shut down SDL_gpu.

Definition at line 642 of file SDL_gpu.c.

◆ GPU_RemoveWindowMapping()

void GPU_RemoveWindowMapping ( Uint32  windowID)

Definition at line 319 of file SDL_gpu.c.

◆ GPU_RemoveWindowMappingByTarget()

void GPU_RemoveWindowMappingByTarget ( GPU_Target target)

Definition at line 350 of file SDL_gpu.c.

◆ GPU_ReplaceImage()

GPU_bool GPU_ReplaceImage ( GPU_Image image,
SDL_Surface *  surface,
const GPU_Rect surface_rect 
)

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.

Definition at line 999 of file SDL_gpu.c.

◆ GPU_ResetRendererState()

void GPU_ResetRendererState ( void  )

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.

Definition at line 89 of file SDL_gpu.c.

◆ GPU_SaveImage()

GPU_bool GPU_SaveImage ( GPU_Image image,
const char *  filename,
GPU_FileFormatEnum  format 
)

Save image to a file. With a format of GPU_FILE_AUTO, the file type is deduced from the extension. Supported formats are: png, bmp, tga. Returns 0 on failure.

Definition at line 955 of file SDL_gpu.c.

◆ GPU_SaveImage_RW()

GPU_bool GPU_SaveImage_RW ( GPU_Image image,
SDL_RWops *  rwops,
GPU_bool  free_rwops,
GPU_FileFormatEnum  format 
)

Save image to a RWops stream. Does not support format of GPU_FILE_AUTO, because the file type cannot be deduced. Supported formats are: png, bmp, tga. Returns 0 on failure.

Definition at line 963 of file SDL_gpu.c.

◆ GPU_SaveSurface()

GPU_bool GPU_SaveSurface ( SDL_Surface *  surface,
const char *  filename,
GPU_FileFormatEnum  format 
)

Save surface to a file. With a format of GPU_FILE_AUTO, the file type is deduced from the extension. Supported formats are: png, bmp, tga. Returns 0 on failure.

Definition at line 1149 of file SDL_gpu.c.

◆ GPU_SaveSurface_RW()

GPU_bool GPU_SaveSurface_RW ( SDL_Surface *  surface,
SDL_RWops *  rwops,
GPU_bool  free_rwops,
GPU_FileFormatEnum  format 
)

Save surface to a RWops stream. Does not support format of GPU_FILE_AUTO, because the file type cannot be deduced. Supported formats are: png, bmp, tga. Returns 0 on failure.

Definition at line 1204 of file SDL_gpu.c.

◆ GPU_SetAnchor()

void GPU_SetAnchor ( GPU_Image image,
float  anchor_x,
float  anchor_y 
)

Sets the image anchor, which is the point about which the image is blitted. The default is to blit the image on-center (0.5, 0.5). The anchor is in normalized coordinates (0.0-1.0).

Definition at line 1927 of file SDL_gpu.c.

◆ GPU_SetAttributef()

void GPU_SetAttributef ( int  location,
float  value 
)

Sets a constant-value shader attribute that will be used for each rendered vertex.

Definition at line 2398 of file SDL_gpu.c.

◆ GPU_SetAttributefv()

void GPU_SetAttributefv ( int  location,
int  num_elements,
float *  value 
)

Sets a constant-value shader attribute that will be used for each rendered vertex.

Definition at line 2422 of file SDL_gpu.c.

◆ GPU_SetAttributei()

void GPU_SetAttributei ( int  location,
int  value 
)

Sets a constant-value shader attribute that will be used for each rendered vertex.

Definition at line 2406 of file SDL_gpu.c.

◆ GPU_SetAttributeiv()

void GPU_SetAttributeiv ( int  location,
int  num_elements,
int *  value 
)

Sets a constant-value shader attribute that will be used for each rendered vertex.

Definition at line 2430 of file SDL_gpu.c.

◆ GPU_SetAttributeSource()

void GPU_SetAttributeSource ( int  num_values,
GPU_Attribute  source 
)

Enables a shader attribute and sets its source data.

Definition at line 2446 of file SDL_gpu.c.

◆ GPU_SetAttributeui()

void GPU_SetAttributeui ( int  location,
unsigned int  value 
)

Sets a constant-value shader attribute that will be used for each rendered vertex.

Definition at line 2414 of file SDL_gpu.c.

◆ GPU_SetAttributeuiv()

void GPU_SetAttributeuiv ( int  location,
int  num_elements,
unsigned int *  value 
)

Sets a constant-value shader attribute that will be used for each rendered vertex.

Definition at line 2438 of file SDL_gpu.c.

◆ GPU_SetBlendEquation()

void GPU_SetBlendEquation ( GPU_Image image,
GPU_BlendEqEnum  color_equation,
GPU_BlendEqEnum  alpha_equation 
)

Sets the blending component equations.

Definition at line 1838 of file SDL_gpu.c.

◆ GPU_SetBlendFunction()

void GPU_SetBlendFunction ( GPU_Image image,
GPU_BlendFuncEnum  source_color,
GPU_BlendFuncEnum  dest_color,
GPU_BlendFuncEnum  source_alpha,
GPU_BlendFuncEnum  dest_alpha 
)

Sets the blending component functions.

Definition at line 1827 of file SDL_gpu.c.

◆ GPU_SetBlending()

void GPU_SetBlending ( GPU_Image image,
GPU_bool  enable 
)

Enables/disables alpha blending for the given image.

Definition at line 1726 of file SDL_gpu.c.

◆ GPU_SetBlendMode()

void GPU_SetBlendMode ( GPU_Image image,
GPU_BlendPresetEnum  mode 
)

Sets the blending mode, if supported by the renderer.

Definition at line 1847 of file SDL_gpu.c.

◆ GPU_SetCamera()

GPU_Camera GPU_SetCamera ( GPU_Target target,
GPU_Camera cam 
)

Sets the current render target's current camera.

Parameters
targetA pointer to the target that will copy this camera.
camA pointer to the camera data to use or NULL to use the default camera.
Returns
The old camera.

Definition at line 880 of file SDL_gpu.c.

◆ GPU_SetClip()

GPU_Rect GPU_SetClip ( GPU_Target target,
Sint16  x,
Sint16  y,
Uint16  w,
Uint16  h 
)

Sets the clipping rect for the given render target.

Definition at line 1539 of file SDL_gpu.c.

◆ GPU_SetClipRect()

GPU_Rect GPU_SetClipRect ( GPU_Target target,
GPU_Rect  rect 
)

Sets the clipping rect for the given render target.

Definition at line 1528 of file SDL_gpu.c.

◆ GPU_SetColor()

void GPU_SetColor ( GPU_Image image,
SDL_Color  color 
)

Sets the modulation color for subsequent drawing of the given image.

Definition at line 1623 of file SDL_gpu.c.

◆ GPU_SetCoordinateMode()

void GPU_SetCoordinateMode ( GPU_bool  use_math_coords)

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). The default is inverted (0), as this is traditional for 2D graphics.

Parameters
inverted0 is for inverted coordinates, 1 is for mathematical coordinates

Definition at line 97 of file SDL_gpu.c.

◆ GPU_SetCurrentRenderer()

void GPU_SetCurrentRenderer ( GPU_RendererID  id)

Switches the current renderer to the renderer matching the given identifier.

Definition at line 81 of file SDL_gpu.c.

◆ GPU_SetDefaultAnchor()

void GPU_SetDefaultAnchor ( float  anchor_x,
float  anchor_y 
)

Sets the default image blitting anchor for newly created images.

See also
GPU_SetAnchor

Definition at line 1906 of file SDL_gpu.c.

◆ GPU_SetErrorQueueMax()

void GPU_SetErrorQueueMax ( unsigned int  max)

Changes the maximum number of error objects that SDL_gpu will store. This deletes all currently stored errors.

Definition at line 624 of file SDL_gpu.c.

◆ GPU_SetFullscreen()

GPU_bool GPU_SetFullscreen ( GPU_bool  enable_fullscreen,
GPU_bool  use_desktop_resolution 
)

Enable/disable fullscreen mode for the current context target's window. 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.

Parameters
enable_fullscreenIf true, make the application go fullscreen. If false, make the application go to windowed mode.
use_desktop_resolutionIf true, lets the window change its resolution when it enters fullscreen mode (via SDL_WINDOW_FULLSCREEN_DESKTOP).
Returns
0 if the new mode is windowed, 1 if the new mode is fullscreen.

Definition at line 505 of file SDL_gpu.c.

◆ GPU_SetImageFilter()

void GPU_SetImageFilter ( GPU_Image image,
GPU_FilterEnum  filter 
)

Sets the image filtering mode, if supported by the renderer.

Definition at line 1895 of file SDL_gpu.c.

◆ GPU_SetImageVirtualResolution()

void GPU_SetImageVirtualResolution ( GPU_Image image,
Uint16  w,
Uint16  h 
)

Change the logical size of the given image. Rendering this image will scaled it as if the dimensions were actually the ones given.

Definition at line 576 of file SDL_gpu.c.

◆ GPU_SetInitWindow()

void GPU_SetInitWindow ( Uint32  windowID)

The window corresponding to 'windowID' will be used to create the rendering context instead of creating a new window.

Definition at line 210 of file SDL_gpu.c.

◆ GPU_SetLogCallback()

void GPU_SetLogCallback ( int(*)(GPU_LogLevelEnum log_level, const char *format, va_list args)  callback)

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.

Definition at line 151 of file SDL_gpu.c.

◆ GPU_SetPreInitFlags()

void GPU_SetPreInitFlags ( GPU_InitFlagEnum  GPU_flags)

Set special flags to use for initialization. Set these before calling GPU_Init().

Parameters
GPU_flagsAn OR'ed combination of GPU_InitFlagEnum flags. Default flags (0) enable late swap vsync and double buffering.

Definition at line 220 of file SDL_gpu.c.

◆ GPU_SetRequiredFeatures()

void GPU_SetRequiredFeatures ( GPU_FeatureEnum  features)

Set required features to use for initialization. Set these before calling GPU_Init().

Parameters
featuresAn 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.

Definition at line 230 of file SDL_gpu.c.

◆ GPU_SetRGB()

void GPU_SetRGB ( GPU_Image image,
Uint8  r,
Uint8  g,
Uint8  b 
)

Sets the modulation color for subsequent drawing of the given image.

Definition at line 1631 of file SDL_gpu.c.

◆ GPU_SetRGBA()

void GPU_SetRGBA ( GPU_Image image,
Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a 
)

Sets the modulation color for subsequent drawing of the given image.

Definition at line 1645 of file SDL_gpu.c.

◆ GPU_SetShaderBlock()

void GPU_SetShaderBlock ( GPU_ShaderBlock  block)

Sets the current shader block to use the given attribute and uniform locations.

Definition at line 2275 of file SDL_gpu.c.

◆ GPU_SetShaderImage()

void GPU_SetShaderImage ( GPU_Image image,
int  location,
int  image_unit 
)

Sets the given image unit to the given image so that a custom shader can sample multiple textures.

Parameters
imageThe source image/texture. Pass NULL to disable the image unit.
locationThe uniform location of a texture sampler
image_unitThe 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.

Definition at line 2298 of file SDL_gpu.c.

◆ GPU_SetShapeBlendEquation()

void GPU_SetShapeBlendEquation ( GPU_BlendEqEnum  color_equation,
GPU_BlendEqEnum  alpha_equation 
)

Sets the blending component equations for shape rendering.

Definition at line 1872 of file SDL_gpu.c.

◆ GPU_SetShapeBlendFunction()

void GPU_SetShapeBlendFunction ( GPU_BlendFuncEnum  source_color,
GPU_BlendFuncEnum  dest_color,
GPU_BlendFuncEnum  source_alpha,
GPU_BlendFuncEnum  dest_alpha 
)

Sets the blending component functions for shape rendering.

Definition at line 1858 of file SDL_gpu.c.

◆ GPU_SetShapeBlending()

void GPU_SetShapeBlending ( GPU_bool  enable)

Enables/disables alpha blending for shape rendering on the current window.

Definition at line 1734 of file SDL_gpu.c.

◆ GPU_SetShapeBlendMode()

void GPU_SetShapeBlendMode ( GPU_BlendPresetEnum  mode)

Sets the blending mode for shape rendering on the current window, if supported by the renderer.

Definition at line 1884 of file SDL_gpu.c.

◆ GPU_SetSnapMode()

void GPU_SetSnapMode ( GPU_Image image,
GPU_SnapEnum  mode 
)

Sets the pixel grid snapping mode for the given image.

Definition at line 1956 of file SDL_gpu.c.

◆ GPU_SetTargetColor()

void GPU_SetTargetColor ( GPU_Target target,
SDL_Color  color 
)

Sets the modulation color for subsequent drawing of images and shapes on the given target. This has a cumulative effect with the image coloring functions. e.g. GPU_SetRGB(image, 255, 128, 0); GPU_SetTargetRGB(target, 128, 128, 128); Would make the image draw with color of roughly (128, 64, 0).

Definition at line 1668 of file SDL_gpu.c.

◆ GPU_SetTargetRGB()

void GPU_SetTargetRGB ( GPU_Target target,
Uint8  r,
Uint8  g,
Uint8  b 
)

Sets the modulation color for subsequent drawing of images and shapes on the given target. This has a cumulative effect with the image coloring functions. e.g. GPU_SetRGB(image, 255, 128, 0); GPU_SetTargetRGB(target, 128, 128, 128); Would make the image draw with color of roughly (128, 64, 0).

Definition at line 1677 of file SDL_gpu.c.

◆ GPU_SetTargetRGBA()

void GPU_SetTargetRGBA ( GPU_Target target,
Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a 
)

Sets the modulation color for subsequent drawing of images and shapes on the given target. This has a cumulative effect with the image coloring functions. e.g. GPU_SetRGB(image, 255, 128, 0); GPU_SetTargetRGB(target, 128, 128, 128); Would make the image draw with color of roughly (128, 64, 0).

Definition at line 1692 of file SDL_gpu.c.

◆ GPU_SetUniformf()

void GPU_SetUniformf ( int  location,
float  value 
)

Sets the value of the floating point uniform shader variable at the given location. This is equivalent to calling GPU_SetUniformfv(location, 1, 1, &value).

Definition at line 2364 of file SDL_gpu.c.

◆ GPU_SetUniformfv()

void GPU_SetUniformfv ( int  location,
int  num_elements_per_value,
int  num_values,
float *  values 
)

Sets the value of the floating point uniform shader variable at the given location.

Definition at line 2372 of file SDL_gpu.c.

◆ GPU_SetUniformi()

void GPU_SetUniformi ( int  location,
int  value 
)

Sets the value of the integer uniform shader variable at the given location. This is equivalent to calling GPU_SetUniformiv(location, 1, 1, &value).

Definition at line 2314 of file SDL_gpu.c.

◆ GPU_SetUniformiv()

void GPU_SetUniformiv ( int  location,
int  num_elements_per_value,
int  num_values,
int *  values 
)

Sets the value of the integer uniform shader variable at the given location.

Definition at line 2322 of file SDL_gpu.c.

◆ GPU_SetUniformMatrixfv()

void GPU_SetUniformMatrixfv ( int  location,
int  num_matrices,
int  num_rows,
int  num_columns,
GPU_bool  transpose,
float *  values 
)

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.

Definition at line 2389 of file SDL_gpu.c.

◆ GPU_SetUniformui()

void GPU_SetUniformui ( int  location,
unsigned int  value 
)

Sets the value of the unsigned integer uniform shader variable at the given location. This is equivalent to calling GPU_SetUniformuiv(location, 1, 1, &value).

Definition at line 2339 of file SDL_gpu.c.

◆ GPU_SetUniformuiv()

void GPU_SetUniformuiv ( int  location,
int  num_elements_per_value,
int  num_values,
unsigned int *  values 
)

Sets the value of the unsigned integer uniform shader variable at the given location.

Definition at line 2347 of file SDL_gpu.c.

◆ GPU_SetViewport()

void GPU_SetViewport ( GPU_Target target,
GPU_Rect  viewport 
)

Sets the given target's viewport.

Definition at line 855 of file SDL_gpu.c.

◆ GPU_SetVirtualResolution()

void GPU_SetVirtualResolution ( GPU_Target target,
Uint16  w,
Uint16  h 
)

Change the logical size of the given target. Rendering to this target will be scaled as if the dimensions were actually the ones given.

Definition at line 552 of file SDL_gpu.c.

◆ GPU_SetWindowResolution()

GPU_bool GPU_SetWindowResolution ( Uint16  w,
Uint16  h 
)

Change the actual size of the current context target's window. This resets the virtual resolution and viewport of the context target. Aside from direct resolution changes, this should also be called in response to SDL_WINDOWEVENT_RESIZED window events for resizable windows.

Definition at line 529 of file SDL_gpu.c.

◆ GPU_SetWrapMode()

void GPU_SetWrapMode ( GPU_Image image,
GPU_WrapEnum  wrap_mode_x,
GPU_WrapEnum  wrap_mode_y 
)

Sets the image wrapping mode, if supported by the renderer.

Definition at line 1964 of file SDL_gpu.c.

◆ gpu_strcasecmp()

int gpu_strcasecmp ( const char *  s1,
const char *  s2 
)

Definition at line 2512 of file SDL_gpu.c.

◆ GPU_TriangleBatch()

void GPU_TriangleBatch ( GPU_Image image,
GPU_Target target,
unsigned short  num_vertices,
float *  values,
unsigned int  num_indices,
unsigned short *  indices,
GPU_BatchFlagEnum  flags 
)

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.

Parameters
valuesA 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.
indicesIf 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).
flagsBit flags to control the interpretation of the 'values' array parameters.

Definition at line 1491 of file SDL_gpu.c.

◆ GPU_TriangleBatchX()

void GPU_TriangleBatchX ( GPU_Image image,
GPU_Target target,
unsigned short  num_vertices,
void *  values,
unsigned int  num_indices,
unsigned short *  indices,
GPU_BatchFlagEnum  flags 
)

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.

Parameters
valuesA 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 (or 0 - 255 for 8-bit color components). Pass NULL to render with only custom shader attributes.
indicesIf 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).
flagsBit flags to control the interpretation of the 'values' array parameters.

Definition at line 1496 of file SDL_gpu.c.

◆ GPU_UnsetClip()

void GPU_UnsetClip ( GPU_Target target)

Turns off clipping for the given target.

Definition at line 1550 of file SDL_gpu.c.

◆ GPU_UnsetColor()

void GPU_UnsetColor ( GPU_Image image)

Unsets the modulation color for subsequent drawing of the given image. This is equivalent to coloring with pure opaque white (255, 255, 255, 255).

Definition at line 1659 of file SDL_gpu.c.

◆ GPU_UnsetImageVirtualResolution()

void GPU_UnsetImageVirtualResolution ( GPU_Image image)

Reset the logical size of the given image to its original value.

Definition at line 589 of file SDL_gpu.c.

◆ GPU_UnsetTargetColor()

void GPU_UnsetTargetColor ( GPU_Target target)

Unsets the modulation color for subsequent drawing of images and shapes on the given target. This has the same effect as coloring with pure opaque white (255, 255, 255, 255).

Definition at line 1707 of file SDL_gpu.c.

◆ GPU_UnsetViewport()

void GPU_UnsetViewport ( GPU_Target target)

Resets the given target's viewport to the entire target area.

Definition at line 861 of file SDL_gpu.c.

◆ GPU_UnsetVirtualResolution()

void GPU_UnsetVirtualResolution ( GPU_Target target)

Reset the logical size of the given target to its original value.

Definition at line 565 of file SDL_gpu.c.

◆ GPU_UpdateImage()

void GPU_UpdateImage ( GPU_Image image,
const GPU_Rect image_rect,
SDL_Surface *  surface,
const GPU_Rect surface_rect 
)

Update an image from surface data. Ignores virtual resolution on the image so the number of pixels needed from the surface is known.

Definition at line 983 of file SDL_gpu.c.

◆ GPU_UpdateImageBytes()

void GPU_UpdateImageBytes ( GPU_Image image,
const GPU_Rect image_rect,
const unsigned char *  bytes,
int  bytes_per_row 
)

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.

Definition at line 991 of file SDL_gpu.c.