The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Macros | Typedefs | Functions | Variables
SDL_gpu.c File Reference
#include "SDL_gpu.h"
#include "SDL_platform.h"
#include "stb_image.h"
#include "stb_image_write.h"
Include dependency graph for SDL_gpu.c:

Go to the source code of this file.

Classes

struct  GPU_WindowMapping
 

Macros

#define GET_ALPHA(sdl_color)   ((sdl_color).a)
 
#define CHECK_RENDERER   (current_renderer != NULL)
 
#define CHECK_CONTEXT   (current_renderer->current_context_target != NULL)
 
#define CHECK_FUNCTION_POINTER(fn)   (current_renderer->fn != NULL)
 
#define RETURN_ERROR(code, details)   do{ GPU_PushErrorCode(__func__, code, "%s", details); return; } while(0)
 
#define GPU_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
 

Typedefs

typedef struct GPU_WindowMapping GPU_WindowMapping
 

Functions

void GPU_InitRendererRegister (void)
 
SDL_version GPU_GetLinkedVersion (void)
 
void GPU_SetCurrentRenderer (GPU_RendererID id)
 
GPU_RendererGPU_GetCurrentRenderer (void)
 
Uint32 GPU_GetCurrentShaderProgram (void)
 
void GPU_LogInfo (const char *format,...)
 
void GPU_LogWarning (const char *format,...)
 
void GPU_LogError (const char *format,...)
 
static Uint8 init_SDL (void)
 
void GPU_SetInitWindow (Uint32 windowID)
 
Uint32 GPU_GetInitWindow (void)
 
void GPU_SetPreInitFlags (GPU_InitFlagEnum GPU_flags)
 
GPU_InitFlagEnum GPU_GetPreInitFlags (void)
 
static void init_error_stack ()
 
static void init_window_mappings ()
 
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)
 
Uint8 GPU_IsFeatureEnabled (GPU_FeatureEnum feature)
 
GPU_TargetGPU_CreateTargetFromWindow (Uint32 windowID)
 
GPU_TargetGPU_CreateAliasTarget (GPU_Target *target)
 
void GPU_MakeCurrent (GPU_Target *target, Uint32 windowID)
 
Uint8 GPU_ToggleFullscreen (Uint8 use_desktop_resolution)
 
Uint8 GPU_SetWindowResolution (Uint16 w, Uint16 h)
 
void GPU_SetVirtualResolution (GPU_Target *target, Uint16 w, Uint16 h)
 
void GPU_UnsetVirtualResolution (GPU_Target *target)
 
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 (GPU_RendererEnum id, int major_version, int minor_version)
 
void GPU_SetViewport (GPU_Target *target, GPU_Rect viewport)
 
GPU_Camera GPU_GetDefaultCamera (void)
 
GPU_Camera GPU_GetCamera (GPU_Target *target)
 
GPU_Camera GPU_SetCamera (GPU_Target *target, GPU_Camera *cam)
 
GPU_ImageGPU_CreateImage (Uint16 w, Uint16 h, GPU_FormatEnum format)
 
GPU_ImageGPU_LoadImage (const char *filename)
 
GPU_ImageGPU_CreateAliasImage (GPU_Image *image)
 
Uint8 GPU_SaveImage (GPU_Image *image, const char *filename)
 
GPU_ImageGPU_CopyImage (GPU_Image *image)
 
void GPU_UpdateImage (GPU_Image *image, SDL_Surface *surface, const GPU_Rect *surface_rect)
 
void GPU_UpdateSubImage (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)
 
SDL_Surface * GPU_LoadSurface (const char *filename)
 
static const char * get_filename_ext (const char *filename)
 
Uint8 GPU_SaveSurface (SDL_Surface *surface, const char *filename)
 
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)
 
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 angle)
 
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 angle, 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 angle, float scaleX, float scaleY)
 
void GPU_BlitTransformMatrix (GPU_Image *image, GPU_Rect *src_rect, GPU_Target *target, float x, float y, float *matrix3x3)
 
void GPU_BlitBatch (GPU_Image *image, GPU_Target *target, unsigned int num_sprites, float *values, GPU_BlitFlagEnum flags)
 
void GPU_BlitBatchSeparate (GPU_Image *image, GPU_Target *target, unsigned int num_sprites, float *positions, float *src_rects, float *colors, GPU_BlitFlagEnum flags)
 
void GPU_TriangleBatch (GPU_Image *image, GPU_Target *target, unsigned short num_vertices, float *values, unsigned int num_indices, unsigned short *indices, GPU_BlitFlagEnum 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)
 
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_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)
 
Uint8 GPU_GetBlending (GPU_Image *image)
 
void GPU_SetBlending (GPU_Image *image, Uint8 enable)
 
void GPU_SetShapeBlending (Uint8 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)
 
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_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)
 
Uint32 GPU_LoadShader (GPU_ShaderEnum shader_type, const char *filename)
 
Uint32 GPU_CompileShader (GPU_ShaderEnum shader_type, const char *shader_source)
 
Uint32 GPU_LinkShaderProgram (Uint32 program_object)
 
Uint32 GPU_LinkShaders (Uint32 shader_object1, Uint32 shader_object2)
 
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)
 
Uint8 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, Uint8 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)
 
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, Uint8 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)
 

Variables

static GPU_Renderercurrent_renderer = NULL
 
static GPU_DebugLevelEnum debug_level = GPU_DEBUG_LEVEL_0
 
static GPU_ErrorObject error_code_stack [GPU_MAX_NUM_ERRORS]
 
static int num_error_codes = 0
 
static int inited_error_code_stack = 0
 
static GPU_WindowMappingwindow_mappings = NULL
 
static int window_mappings_size = 0
 
static int num_window_mappings = 0
 
static Uint32 init_windowID = 0
 
static GPU_InitFlagEnum preinit_flags = GPU_DEFAULT_INIT_FLAGS
 

Macro Definition Documentation

#define CHECK_CONTEXT   (current_renderer->current_context_target != NULL)
#define CHECK_FUNCTION_POINTER (   fn)    (current_renderer->fn != NULL)
#define CHECK_RENDERER   (current_renderer != NULL)
#define GET_ALPHA (   sdl_color)    ((sdl_color).a)

Definition at line 15 of file SDL_gpu.c.

Referenced by GPU_ClearColor().

#define GPU_ERROR_DETAILS_STRING_MAX   512

Definition at line 33 of file SDL_gpu.c.

Referenced by GPU_PushErrorCode(), and init_error_stack().

#define GPU_ERROR_FUNCTION_STRING_MAX   128

Definition at line 32 of file SDL_gpu.c.

Referenced by GPU_PushErrorCode(), and init_error_stack().

#define GPU_INITIAL_WINDOW_MAPPINGS_SIZE   10

Definition at line 45 of file SDL_gpu.c.

Referenced by init_window_mappings().

#define GPU_MAX_NUM_ERRORS   20

Definition at line 31 of file SDL_gpu.c.

Referenced by GPU_PushErrorCode(), GPU_Quit(), and init_error_stack().

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

Typedef Documentation

A mapping of windowID to a GPU_Target to facilitate GPU_GetWindowTarget().

Function Documentation

static const char* get_filename_ext ( const char *  filename)
static

Definition at line 802 of file SDL_gpu.c.

Referenced by GPU_SaveSurface().

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 2291 of file SDL_gpu.c.

References GPU_Renderer::ActivateShaderProgram, and GPU_Renderer::current_context_target.

void GPU_AddWindowMapping ( GPU_Target target)
void GPU_AttachShader ( Uint32  program_object,
Uint32  shader_object 
)

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

Definition at line 2267 of file SDL_gpu.c.

References GPU_Renderer::AttachShader, and GPU_Renderer::current_context_target.

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.
xDestination x-position
yDestination y-position

Definition at line 911 of file SDL_gpu.c.

References GPU_Renderer::Blit, Blit(), CHECK_CONTEXT, CHECK_FUNCTION_POINTER, CHECK_RENDERER, GPU_ERROR_NULL_ARGUMENT, GPU_ERROR_UNSUPPORTED_FUNCTION, GPU_ERROR_USER_ERROR, and RETURN_ERROR.

void GPU_BlitBatch ( GPU_Image image,
GPU_Target target,
unsigned int  num_sprites,
float *  values,
GPU_BlitFlagEnum  flags 
)

Performs 'num_sprites' blits of the given image to the given target. Note: GPU_BlitBatch() cannot interpret a mix of normal values and "passthrough" values due to format ambiguity.

Parameters
valuesA tightly-packed array of position (x,y), src_rect (x,y,w,h) values in image coordinates, and color (r,g,b,a) values with a range from 0-255. Pass NULL to render with only custom shader attributes.
flagsBit flags to control the interpretation of the array parameters. The only passthrough option accepted is GPU_PASSTHROUGH_ALL.

Definition at line 1017 of file SDL_gpu.c.

References GPU_Renderer::BlitBatch, BlitBatch(), CHECK_CONTEXT, CHECK_FUNCTION_POINTER, CHECK_RENDERER, g, GPU_ERROR_NULL_ARGUMENT, GPU_ERROR_UNSUPPORTED_FUNCTION, GPU_ERROR_USER_ERROR, GPU_PASSTHROUGH_ALL, GPU_PASSTHROUGH_COLORS, GPU_PASSTHROUGH_TEXCOORDS, GPU_PASSTHROUGH_VERTICES, GPU_PushErrorCode(), GPU_USE_DEFAULT_COLORS, GPU_USE_DEFAULT_POSITIONS, GPU_USE_DEFAULT_SRC_RECTS, GPU_Image::h, RETURN_ERROR, GPU_Image::texture_h, GPU_Image::texture_w, and GPU_Image::w.

void GPU_BlitBatchSeparate ( GPU_Image image,
GPU_Target target,
unsigned int  num_sprites,
float *  positions,
float *  src_rects,
float *  colors,
GPU_BlitFlagEnum  flags 
)

Performs 'num_sprites' blits of the given image to the given target.

Parameters
positionsA tightly-packed array of (x,y) values
src_rectsA tightly-packed array of (x,y,w,h) values in image coordinates
colorsA tightly-packed array of (r,g,b,a) values with a range from 0-255
flagsBit flags to control the interpretation of the array parameters

Definition at line 1349 of file SDL_gpu.c.

References GPU_Renderer::BlitBatch, BlitBatch(), CHECK_CONTEXT, CHECK_FUNCTION_POINTER, CHECK_RENDERER, g, GPU_ERROR_NULL_ARGUMENT, GPU_ERROR_UNSUPPORTED_FUNCTION, GPU_ERROR_USER_ERROR, GPU_PASSTHROUGH_ALL, GPU_PASSTHROUGH_COLORS, GPU_PASSTHROUGH_TEXCOORDS, GPU_PASSTHROUGH_VERTICES, GPU_Image::h, RETURN_ERROR, GPU_Image::texture_h, GPU_Image::texture_w, and GPU_Image::w.

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.
xDestination x-position
yDestination y-position
degreesRotation angle (in degrees)

Definition at line 929 of file SDL_gpu.c.

References GPU_Renderer::BlitRotate, BlitRotate(), CHECK_CONTEXT, CHECK_FUNCTION_POINTER, CHECK_RENDERER, GPU_ERROR_NULL_ARGUMENT, GPU_ERROR_UNSUPPORTED_FUNCTION, GPU_ERROR_USER_ERROR, and RETURN_ERROR.

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.
xDestination x-position
yDestination y-position
scaleXHorizontal stretch factor
scaleYVertical stretch factor

Definition at line 946 of file SDL_gpu.c.

References GPU_Renderer::BlitScale, BlitScale(), CHECK_CONTEXT, CHECK_FUNCTION_POINTER, CHECK_RENDERER, GPU_ERROR_NULL_ARGUMENT, GPU_ERROR_UNSUPPORTED_FUNCTION, GPU_ERROR_USER_ERROR, and RETURN_ERROR.

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.
xDestination x-position
yDestination y-position
degreesRotation angle (in degrees)
scaleXHorizontal stretch factor
scaleYVertical stretch factor

Definition at line 963 of file SDL_gpu.c.

References GPU_Renderer::BlitTransform, BlitTransform(), CHECK_CONTEXT, CHECK_FUNCTION_POINTER, CHECK_RENDERER, GPU_ERROR_NULL_ARGUMENT, GPU_ERROR_UNSUPPORTED_FUNCTION, GPU_ERROR_USER_ERROR, and RETURN_ERROR.

void GPU_BlitTransformMatrix ( GPU_Image image,
GPU_Rect src_rect,
GPU_Target target,
float  x,
float  y,
float *  matrix3x3 
)

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

Parameters
src_rectThe region of the source image to use.
xDestination x-position
yDestination y-position
matrix3x33x3 matrix in column-major order (index = row + column*numColumns)

Definition at line 997 of file SDL_gpu.c.

References GPU_Renderer::BlitTransformMatrix, BlitTransformMatrix(), CHECK_CONTEXT, CHECK_FUNCTION_POINTER, CHECK_RENDERER, GPU_ERROR_NULL_ARGUMENT, GPU_ERROR_UNSUPPORTED_FUNCTION, GPU_ERROR_USER_ERROR, and RETURN_ERROR.

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.
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 980 of file SDL_gpu.c.

References GPU_Renderer::BlitTransformX, BlitTransformX(), CHECK_CONTEXT, CHECK_FUNCTION_POINTER, CHECK_RENDERER, GPU_ERROR_NULL_ARGUMENT, GPU_ERROR_UNSUPPORTED_FUNCTION, GPU_ERROR_USER_ERROR, and RETURN_ERROR.

void GPU_Clear ( GPU_Target target)

Clears the contents of the given render target. Fills the target with color {0, 0, 0, 0}.

Definition at line 2148 of file SDL_gpu.c.

References GPU_Renderer::Clear, and GPU_Renderer::current_context_target.

void GPU_ClearColor ( GPU_Target target,
SDL_Color *  color 
)

Fills the given render target with a color. If 'color' is NULL, {0, 0, 0, 0} is used.

Definition at line 2156 of file SDL_gpu.c.

References GPU_Renderer::ClearRGBA, GPU_Renderer::current_context_target, and GET_ALPHA.

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 2167 of file SDL_gpu.c.

References GPU_Renderer::ClearRGBA, and GPU_Renderer::current_context_target.

void GPU_CloseCurrentRenderer ( void  )

Clean up the renderer state.

Definition at line 452 of file SDL_gpu.c.

References GPU_RemoveRenderer(), GPU_Renderer::id, and GPU_Renderer::Quit.

Referenced by GPU_InitRendererByID().

Uint32 GPU_CompileShader ( GPU_ShaderEnum  shader_type,
const char *  shader_source 
)

Compiles shader source and returns the new shader object.

Definition at line 2227 of file SDL_gpu.c.

References GPU_Renderer::CompileShader, and GPU_Renderer::current_context_target.

Uint32 GPU_CompileShader_RW ( GPU_ShaderEnum  shader_type,
SDL_RWops *  shader_source 
)

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

Definition at line 2198 of file SDL_gpu.c.

References GPU_Renderer::CompileShader_RW, and GPU_Renderer::current_context_target.

Referenced by GPU_LoadShader().

GPU_Image* GPU_CopyImage ( GPU_Image image)

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

Definition at line 684 of file SDL_gpu.c.

References GPU_Renderer::CopyImage, and GPU_Renderer::current_context_target.

GPU_Image* GPU_CopyImageFromSurface ( SDL_Surface *  surface)

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

Definition at line 841 of file SDL_gpu.c.

References GPU_Renderer::CopyImageFromSurface, and GPU_Renderer::current_context_target.

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 849 of file SDL_gpu.c.

References GPU_Renderer::CopyImageFromTarget, and GPU_Renderer::current_context_target.

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 865 of file SDL_gpu.c.

References GPU_Renderer::CopySurfaceFromImage, and GPU_Renderer::current_context_target.

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 857 of file SDL_gpu.c.

References GPU_Renderer::CopySurfaceFromTarget, and GPU_Renderer::current_context_target.

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 668 of file SDL_gpu.c.

References GPU_Renderer::CreateAliasImage, and GPU_Renderer::current_context_target.

GPU_Target* GPU_CreateAliasTarget ( GPU_Target target)

Creates a target that aliases the given target. Aliases can be used to store target settings (e.g. viewports) for easy switching. GPU_FreeTarget() frees the alias's memory, but does not affect the original.

Definition at line 403 of file SDL_gpu.c.

References GPU_Renderer::CreateAliasTarget, and GPU_Renderer::current_context_target.

GPU_Image* GPU_CreateImage ( Uint16  w,
Uint16  h,
GPU_FormatEnum  format 
)

Create a new, blank image with the given format. Don't forget to GPU_FreeImage() it.

Parameters
wImage width in pixels
hImage height in pixels
formatFormat of color channels.

Definition at line 652 of file SDL_gpu.c.

References GPU_Renderer::CreateImage, and GPU_Renderer::current_context_target.

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 395 of file SDL_gpu.c.

References GPU_Renderer::CreateTargetFromWindow, and GPU_Renderer::current_context_target.

void GPU_DeactivateShaderProgram ( void  )

Deactivates the current shader program (activates program 0).

Definition at line 2299 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::DeactivateShaderProgram.

void GPU_DetachShader ( Uint32  program_object,
Uint32  shader_object 
)

Detaches a shader object from a shader program.

Definition at line 2275 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::DetachShader.

void GPU_Flip ( GPU_Target target)

Updates the given target's associated window.

Definition at line 2183 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::Flip.

Referenced by CVideo::flip().

void GPU_FlushBlitBuffer ( void  )

Send all buffered blitting data to the current context target.

Definition at line 2175 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::FlushBlitBuffer.

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 873 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::FreeImage.

Referenced by CopyImage().

void GPU_FreeShader ( Uint32  shader_object)

Deletes a shader object.

Definition at line 2251 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::FreeShader.

void GPU_FreeShaderProgram ( Uint32  program_object)

Deletes a shader program.

Definition at line 2259 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::FreeShaderProgram.

void GPU_FreeTarget ( GPU_Target target)

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

Definition at line 901 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::FreeTarget.

void GPU_GenerateMipmaps ( GPU_Image image)

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

Definition at line 1800 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::GenerateMipmaps.

Referenced by CopyImage().

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 2315 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::GetAttributeLocation.

Uint8 GPU_GetBlending ( GPU_Image image)

Gets the current alpha blending setting.

Definition at line 1922 of file SDL_gpu.c.

References GPU_Image::use_blending.

GPU_BlendMode GPU_GetBlendModeFromPreset ( GPU_BlendPresetEnum  preset)
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 637 of file SDL_gpu.c.

References GPU_Target::camera, and GPU_GetDefaultCamera().

GPU_Target* GPU_GetContextTarget ( void  )
GPU_Renderer* GPU_GetCurrentRenderer ( void  )
Returns
The current renderer

Definition at line 64 of file SDL_gpu.c.

References current_renderer.

Uint32 GPU_GetCurrentShaderProgram ( void  )
Returns
The current shader program

Definition at line 69 of file SDL_gpu.c.

References GPU_Target::context, GPU_Renderer::current_context_target, and GPU_Context::current_shader_program.

GPU_DebugLevelEnum GPU_GetDebugLevel ( void  )

Returns the current global debug level.

Definition at line 498 of file SDL_gpu.c.

References debug_level.

Referenced by GPU_LogInfo(), GPU_LogWarning(), GPU_PushErrorCode(), and GPU_Quit().

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

Definition at line 631 of file SDL_gpu.c.

Referenced by CreateTargetFromWindow(), GPU_GetCamera(), GPU_SetCamera(), LoadTarget(), and SetCamera().

const char* GPU_GetErrorString ( GPU_ErrorEnum  error)

Gets the string representation of an error code.

Definition at line 556 of file SDL_gpu.c.

References GPU_ERROR_BACKEND_ERROR, GPU_ERROR_DATA_ERROR, GPU_ERROR_FILE_NOT_FOUND, GPU_ERROR_NONE, GPU_ERROR_NULL_ARGUMENT, GPU_ERROR_UNSUPPORTED_FUNCTION, and GPU_ERROR_USER_ERROR.

Referenced by GPU_PushErrorCode().

Uint32 GPU_GetInitWindow ( void  )

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

Definition at line 150 of file SDL_gpu.c.

References init_windowID.

Referenced by Init().

SDL_version GPU_GetLinkedVersion ( void  )

Definition at line 51 of file SDL_gpu.c.

References GPU_GetCompiledVersion().

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

Definition at line 2131 of file SDL_gpu.c.

References c, GPU_Renderer::current_context_target, and GPU_Renderer::GetPixel.

GPU_InitFlagEnum GPU_GetPreInitFlags ( void  )

Returns the current special flags to use for initialization.

Definition at line 162 of file SDL_gpu.c.

References preinit_flags.

Referenced by Init().

const char* GPU_GetShaderMessage ( void  )

Returns the last shader log message.

Definition at line 2307 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::GetShaderMessage.

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 2104 of file SDL_gpu.c.

References GPU_Image::snap_mode.

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 2427 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::GetUniformfv.

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 2377 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::GetUniformiv.

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 2338 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::GetUniformLocation.

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 2452 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::GetUniformfv.

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 2402 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::GetUniformuiv.

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.

Definition at line 579 of file SDL_gpu.c.

References GPU_Target::context, GPU_Image::h, GPU_Target::h, GPU_Target::image, GPU_Image::w, GPU_Target::w, GPU_Context::window_h, and GPU_Context::window_w.

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

Definition at line 305 of file SDL_gpu.c.

References i, init_window_mappings(), num_window_mappings, and GPU_WindowMapping::target.

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

Initializes SDL and SDL_gpu. Creates a window and goes through the renderer order to create a renderer context.

See also
GPU_SetRendererOrder()

Definition at line 325 of file SDL_gpu.c.

References GPU_GetRendererOrder(), GPU_InitRendererByID(), GPU_InitRendererRegister(), GPU_RENDERER_ORDER_MAX, i, init_error_stack(), init_SDL(), renderer_order, renderer_order_size, and resources::screen.

Referenced by CVideo::initSDL().

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 352 of file SDL_gpu.c.

References GPU_InitRendererByID(), and GPU_MakeRendererID().

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 357 of file SDL_gpu.c.

References GPU_AddRenderer(), GPU_CloseCurrentRenderer(), GPU_InitRendererRegister(), GPU_SetCurrentRenderer(), GPU_SetInitWindow(), GPU_Renderer::id, GPU_Renderer::Init, init_error_stack(), init_SDL(), num_window_mappings, and resources::screen.

Referenced by GPU_Init(), and GPU_InitRenderer().

void GPU_InitRendererRegister ( void  )
Uint8 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 2283 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::IsDefaultShaderProgram.

Uint8 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 387 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::IsFeatureEnabled.

Uint32 GPU_LinkShaderProgram ( Uint32  program_object)

Links a shader program with any attached shader objects.

Definition at line 2235 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::LinkShaderProgram.

Uint32 GPU_LinkShaders ( Uint32  shader_object1,
Uint32  shader_object2 
)

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

Definition at line 2243 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::LinkShaders.

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 660 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::LoadImage.

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 2206 of file SDL_gpu.c.

References GPU_CompileShader_RW(), GPU_ERROR_FILE_NOT_FOUND, GPU_ERROR_NULL_ARGUMENT, and GPU_PushErrorCode().

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

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

Definition at line 716 of file SDL_gpu.c.

References GPU_ERROR_DATA_ERROR, GPU_ERROR_NULL_ARGUMENT, GPU_PushErrorCode(), stbi_failure_reason(), stbi_image_free(), stbi_load(), and stbi_load_from_memory().

Referenced by LoadImage().

GPU_Target* GPU_LoadTarget ( GPU_Image image)

Creates a new render target from the given image. It can then be accessed from image->target.

Definition at line 891 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::LoadTarget.

Referenced by CopyImage().

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

Prints an error log message.

Definition at line 103 of file SDL_gpu.c.

Referenced by GPU_PushErrorCode(), and GPU_Quit().

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

Prints an informational log message.

Definition at line 79 of file SDL_gpu.c.

References GPU_DEBUG_LEVEL_3, and GPU_GetDebugLevel().

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

Prints a warning log message.

Definition at line 91 of file SDL_gpu.c.

References GPU_DEBUG_LEVEL_2, and GPU_GetDebugLevel().

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

Returns a filled GPU_Attribute object.

Definition at line 2329 of file SDL_gpu.c.

References GPU_Attribute::format, GPU_Attribute::location, and GPU_Attribute::values.

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

Returns a filled GPU_AttributeFormat object.

Definition at line 2323 of file SDL_gpu.c.

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

Definition at line 613 of file SDL_gpu.c.

References c, and g.

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 411 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::MakeCurrent.

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

Definition at line 607 of file SDL_gpu.c.

Referenced by CreateTargetFromWindow(), LoadTarget(), and SetWindowResolution().

GPU_RendererID GPU_MakeRendererID ( GPU_RendererEnum  id,
int  major_version,
int  minor_version 
)

Returns an initialized GPU_RendererID.

Definition at line 619 of file SDL_gpu.c.

Referenced by GPU_GetDefaultRendererOrder(), and GPU_InitRenderer().

GPU_ErrorObject GPU_PopErrorCode ( void  )

Pops an error object from the error stack and returns it. If the error stack is empty, it returns an error object with NULL function, GPU_ERROR_NONE error, and NULL details.

Definition at line 545 of file SDL_gpu.c.

References e, GPU_ERROR_NONE, and num_error_codes.

void GPU_PushErrorCode ( const char *  function,
GPU_ErrorEnum  error,
const char *  details,
  ... 
)
void GPU_Quit ( void  )
void GPU_RemoveWindowMapping ( Uint32  windowID)
void GPU_RemoveWindowMappingByTarget ( GPU_Target target)

Definition at line 268 of file SDL_gpu.c.

References GPU_Target::context, i, init_window_mappings(), num_window_mappings, and GPU_Context::windowID.

Referenced by FreeTarget().

Uint8 GPU_SaveImage ( GPU_Image image,
const char *  filename 
)

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

Definition at line 676 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SaveImage.

Uint8 GPU_SaveSurface ( SDL_Surface *  surface,
const char *  filename 
)

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

Definition at line 810 of file SDL_gpu.c.

References get_filename_ext(), GPU_ERROR_DATA_ERROR, GPU_PushErrorCode(), stbi_write_bmp(), stbi_write_png(), and stbi_write_tga().

void GPU_SetAttributef ( int  location,
float  value 
)

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

Definition at line 2469 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetAttributef.

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 2493 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetAttributefv.

void GPU_SetAttributei ( int  location,
int  value 
)

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

Definition at line 2477 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetAttributei.

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 2501 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetAttributeiv.

void GPU_SetAttributeSource ( int  num_values,
GPU_Attribute  source 
)

Enables a shader attribute and sets its source data.

Definition at line 2517 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetAttributeSource.

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 2485 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetAttributeui.

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 2509 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetAttributeuiv.

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

Sets the blending component equations.

Definition at line 2037 of file SDL_gpu.c.

References GPU_BlendMode::alpha_equation, GPU_Image::blend_mode, and GPU_BlendMode::color_equation.

Referenced by GPU_SetBlendMode().

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 2026 of file SDL_gpu.c.

References GPU_Image::blend_mode, GPU_BlendMode::dest_alpha, GPU_BlendMode::dest_color, GPU_BlendMode::source_alpha, and GPU_BlendMode::source_color.

Referenced by GPU_SetBlendMode().

void GPU_SetBlending ( GPU_Image image,
Uint8  enable 
)

Enables/disables alpha blending for the given image.

Definition at line 1931 of file SDL_gpu.c.

References GPU_Image::use_blending.

Referenced by CopyImage().

void GPU_SetBlendMode ( GPU_Image image,
GPU_BlendPresetEnum  mode 
)
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 644 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, GPU_GetDefaultCamera(), and GPU_Renderer::SetCamera.

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 1822 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetClip.

Referenced by dialogs::unit_preview_pane::draw_contents(), gui::menu::imgsel_style::draw_row(), and display::drawing_buffer_commit().

GPU_Rect GPU_SetClipRect ( GPU_Target target,
GPU_Rect  rect 
)

Sets the clipping rect for the given render target.

Definition at line 1811 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, GPU_Rect::h, GPU_Renderer::SetClip, GPU_Rect::w, GPU_Rect::x, and GPU_Rect::y.

void GPU_SetColor ( GPU_Image image,
SDL_Color *  color 
)

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

Definition at line 1844 of file SDL_gpu.c.

References c, and GPU_Image::color.

Referenced by CopyImage().

void GPU_SetCurrentRenderer ( GPU_RendererID  id)

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

Definition at line 56 of file SDL_gpu.c.

References GPU_GetRendererByID(), and GPU_Renderer::SetAsCurrent.

Referenced by GPU_InitRendererByID().

void GPU_SetDebugLevel ( GPU_DebugLevelEnum  level)

Sets the global debug level. GPU_DEBUG_LEVEL_0: Normal GPU_DEBUG_LEVEL_1: Prints messages when errors are pushed via GPU_PushErrorCode() GPU_DEBUG_LEVEL_2: Elevates warning logs to error priority GPU_DEBUG_LEVEL_3: Elevates info logs to error priority

Definition at line 491 of file SDL_gpu.c.

References debug_level, and GPU_DEBUG_LEVEL_MAX.

void GPU_SetImageFilter ( GPU_Image image,
GPU_FilterEnum  filter 
)

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

Definition at line 2094 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetImageFilter.

Referenced by CopyImage().

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 145 of file SDL_gpu.c.

References init_windowID.

Referenced by GPU_InitRendererByID(), and Init().

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 and GPU_FeatureEnum flags. GPU_FeatureEnum flags will force GPU_Init() to create a renderer that supports all of the given flags or else fail. Default flags (0) enable late swap vsync and double buffering.

Definition at line 157 of file SDL_gpu.c.

References preinit_flags.

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 1858 of file SDL_gpu.c.

References c, GPU_Image::color, and g.

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 1868 of file SDL_gpu.c.

References c, GPU_Image::color, and g.

void GPU_SetShaderBlock ( GPU_ShaderBlock  block)

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

Definition at line 2361 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetShaderBlock.

Referenced by CreateTargetFromWindow().

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 2369 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetShaderImage.

void GPU_SetShapeBlendEquation ( GPU_BlendEqEnum  color_equation,
GPU_BlendEqEnum  alpha_equation 
)

Sets the blending component equations for shape rendering.

Definition at line 2071 of file SDL_gpu.c.

References GPU_BlendMode::alpha_equation, GPU_BlendMode::color_equation, GPU_Target::context, GPU_Renderer::current_context_target, and GPU_Context::shapes_blend_mode.

Referenced by GPU_SetShapeBlendMode().

void GPU_SetShapeBlendFunction ( GPU_BlendFuncEnum  source_color,
GPU_BlendFuncEnum  dest_color,
GPU_BlendFuncEnum  source_alpha,
GPU_BlendFuncEnum  dest_alpha 
)
void GPU_SetShapeBlending ( Uint8  enable)

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

Definition at line 1939 of file SDL_gpu.c.

References GPU_Target::context, GPU_Renderer::current_context_target, and GPU_Context::shapes_use_blending.

void GPU_SetShapeBlendMode ( GPU_BlendPresetEnum  mode)
void GPU_SetSnapMode ( GPU_Image image,
GPU_SnapEnum  mode 
)

Sets the pixel grid snapping mode for the given image.

Definition at line 2112 of file SDL_gpu.c.

References GPU_Image::snap_mode.

Referenced by CopyImage().

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 1878 of file SDL_gpu.c.

References GPU_Target::color, and GPU_Target::use_color.

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 1892 of file SDL_gpu.c.

References c, GPU_Target::color, g, and GPU_Target::use_color.

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 1907 of file SDL_gpu.c.

References c, GPU_Target::color, g, and GPU_Target::use_color.

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 2435 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetUniformf.

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 2443 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetUniformfv.

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 2385 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetUniformi.

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 2393 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetUniformiv.

void GPU_SetUniformMatrixfv ( int  location,
int  num_matrices,
int  num_rows,
int  num_columns,
Uint8  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 2460 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetUniformMatrixfv.

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 2410 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetUniformui.

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 2418 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetUniformuiv.

void GPU_SetViewport ( GPU_Target target,
GPU_Rect  viewport 
)

Sets the given target's viewport.

Definition at line 625 of file SDL_gpu.c.

References GPU_Target::viewport.

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 436 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetVirtualResolution.

Uint8 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 427 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetWindowResolution.

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 2120 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::SetWrapMode.

Referenced by CopyImage().

Uint8 GPU_ToggleFullscreen ( Uint8  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
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 419 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::ToggleFullscreen.

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

Renders triangles from the given set of vertices. This lets you render arbitrary 2D geometry.

Parameters
valuesA tightly-packed array of vertex position (x,y), image coordinates (s,t), and color (r,g,b,a) values with a range from 0-255. 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 array parameters. Since 'values' contains per-vertex data, GPU_PASSTHROUGH_VERTICES is ignored. Texture coordinates are scaled down using the image dimensions and color components are normalized to [0.0, 1.0].

Definition at line 1634 of file SDL_gpu.c.

References CHECK_CONTEXT, CHECK_FUNCTION_POINTER, CHECK_RENDERER, GPU_ERROR_NULL_ARGUMENT, GPU_ERROR_UNSUPPORTED_FUNCTION, GPU_ERROR_USER_ERROR, GPU_PASSTHROUGH_ALL, GPU_PASSTHROUGH_COLORS, GPU_PASSTHROUGH_TEXCOORDS, GPU_USE_DEFAULT_COLORS, GPU_USE_DEFAULT_POSITIONS, GPU_USE_DEFAULT_SRC_RECTS, RETURN_ERROR, GPU_Image::texture_h, GPU_Image::texture_w, GPU_Renderer::TriangleBatch, and TriangleBatch().

void GPU_UnsetClip ( GPU_Target target)
void GPU_UnsetVirtualResolution ( GPU_Target target)

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

Definition at line 444 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::UnsetVirtualResolution.

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

Update an image from surface data.

Definition at line 692 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::UpdateImage.

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.

Definition at line 708 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::UpdateImageBytes.

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

Update an image from surface data.

Definition at line 700 of file SDL_gpu.c.

References GPU_Renderer::current_context_target, and GPU_Renderer::UpdateSubImage.

static void init_error_stack ( )
static
static Uint8 init_SDL ( void  )
static
static void init_window_mappings ( )
static

Variable Documentation

GPU_Renderer* current_renderer = NULL
static

Definition at line 27 of file SDL_gpu.c.

Referenced by GPU_GetCurrentRenderer().

GPU_DebugLevelEnum debug_level = GPU_DEBUG_LEVEL_0
static

Definition at line 29 of file SDL_gpu.c.

Referenced by GPU_GetDebugLevel(), and GPU_SetDebugLevel().

GPU_ErrorObject error_code_stack[GPU_MAX_NUM_ERRORS]
static

Definition at line 34 of file SDL_gpu.c.

Uint32 init_windowID = 0
static

Definition at line 143 of file SDL_gpu.c.

Referenced by GPU_GetInitWindow(), and GPU_SetInitWindow().

int inited_error_code_stack = 0
static

Definition at line 36 of file SDL_gpu.c.

Referenced by GPU_Quit(), and init_error_stack().

int num_error_codes = 0
static

Definition at line 35 of file SDL_gpu.c.

Referenced by GPU_PopErrorCode(), GPU_PushErrorCode(), and GPU_Quit().

int num_window_mappings = 0
static
GPU_InitFlagEnum preinit_flags = GPU_DEFAULT_INIT_FLAGS
static

Definition at line 155 of file SDL_gpu.c.

Referenced by GPU_GetPreInitFlags(), and GPU_SetPreInitFlags().

GPU_WindowMapping* window_mappings = NULL
static

Definition at line 46 of file SDL_gpu.c.

int window_mappings_size = 0
static

Definition at line 47 of file SDL_gpu.c.

Referenced by GPU_AddWindowMapping(), and init_window_mappings().