SDL_gpu  0.11.0
A hardware-accelerated, cross-platform 2D graphics API
Data Structures | Typedefs | Enumerations
Shader Interface

Data Structures

struct  GPU_ShaderBlock
 
struct  GPU_AttributeFormat
 
struct  GPU_Attribute
 
struct  GPU_AttributeSource
 

Typedefs

typedef Uint32 GPU_TypeEnum
 

Enumerations

enum  GPU_ShaderEnum { GPU_VERTEX_SHADER = 0, GPU_FRAGMENT_SHADER = 1, GPU_PIXEL_SHADER = 1, GPU_GEOMETRY_SHADER = 2 }
 
enum  GPU_ShaderLanguageEnum {
  GPU_LANGUAGE_NONE = 0, GPU_LANGUAGE_ARB_ASSEMBLY = 1, GPU_LANGUAGE_GLSL = 2, GPU_LANGUAGE_GLSLES = 3,
  GPU_LANGUAGE_HLSL = 4, GPU_LANGUAGE_CG = 5
}
 
DECLSPEC Uint32 SDLCALL GPU_CreateShaderProgram (void)
 
DECLSPEC void SDLCALL GPU_FreeShaderProgram (Uint32 program_object)
 
DECLSPEC Uint32 SDLCALL GPU_CompileShader_RW (GPU_ShaderEnum shader_type, SDL_RWops *shader_source, GPU_bool free_rwops)
 
DECLSPEC Uint32 SDLCALL GPU_CompileShader (GPU_ShaderEnum shader_type, const char *shader_source)
 
DECLSPEC Uint32 SDLCALL GPU_LoadShader (GPU_ShaderEnum shader_type, const char *filename)
 
DECLSPEC Uint32 SDLCALL GPU_LinkShaders (Uint32 shader_object1, Uint32 shader_object2)
 
DECLSPEC Uint32 SDLCALL GPU_LinkManyShaders (Uint32 *shader_objects, int count)
 
DECLSPEC void SDLCALL GPU_FreeShader (Uint32 shader_object)
 
DECLSPEC void SDLCALL GPU_AttachShader (Uint32 program_object, Uint32 shader_object)
 
DECLSPEC void SDLCALL GPU_DetachShader (Uint32 program_object, Uint32 shader_object)
 
DECLSPEC GPU_bool SDLCALL GPU_LinkShaderProgram (Uint32 program_object)
 
DECLSPEC Uint32 SDLCALL GPU_GetCurrentShaderProgram (void)
 
DECLSPEC GPU_bool SDLCALL GPU_IsDefaultShaderProgram (Uint32 program_object)
 
DECLSPEC void SDLCALL GPU_ActivateShaderProgram (Uint32 program_object, GPU_ShaderBlock *block)
 
DECLSPEC void SDLCALL GPU_DeactivateShaderProgram (void)
 
DECLSPEC const char *SDLCALL GPU_GetShaderMessage (void)
 
DECLSPEC int SDLCALL GPU_GetAttributeLocation (Uint32 program_object, const char *attrib_name)
 
DECLSPEC GPU_AttributeFormat SDLCALL GPU_MakeAttributeFormat (int num_elems_per_vertex, GPU_TypeEnum type, GPU_bool normalize, int stride_bytes, int offset_bytes)
 
DECLSPEC GPU_Attribute SDLCALL GPU_MakeAttribute (int location, void *values, GPU_AttributeFormat format)
 
DECLSPEC int SDLCALL GPU_GetUniformLocation (Uint32 program_object, const char *uniform_name)
 
DECLSPEC GPU_ShaderBlock SDLCALL GPU_LoadShaderBlock (Uint32 program_object, const char *position_name, const char *texcoord_name, const char *color_name, const char *modelViewMatrix_name)
 
DECLSPEC void SDLCALL GPU_SetShaderBlock (GPU_ShaderBlock block)
 
DECLSPEC GPU_ShaderBlock SDLCALL GPU_GetShaderBlock (void)
 
DECLSPEC void SDLCALL GPU_SetShaderImage (GPU_Image *image, int location, int image_unit)
 
DECLSPEC void SDLCALL GPU_GetUniformiv (Uint32 program_object, int location, int *values)
 
DECLSPEC void SDLCALL GPU_SetUniformi (int location, int value)
 
DECLSPEC void SDLCALL GPU_SetUniformiv (int location, int num_elements_per_value, int num_values, int *values)
 
DECLSPEC void SDLCALL GPU_GetUniformuiv (Uint32 program_object, int location, unsigned int *values)
 
DECLSPEC void SDLCALL GPU_SetUniformui (int location, unsigned int value)
 
DECLSPEC void SDLCALL GPU_SetUniformuiv (int location, int num_elements_per_value, int num_values, unsigned int *values)
 
DECLSPEC void SDLCALL GPU_GetUniformfv (Uint32 program_object, int location, float *values)
 
DECLSPEC void SDLCALL GPU_SetUniformf (int location, float value)
 
DECLSPEC void SDLCALL GPU_SetUniformfv (int location, int num_elements_per_value, int num_values, float *values)
 
DECLSPEC void SDLCALL GPU_GetUniformMatrixfv (Uint32 program_object, int location, float *values)
 
DECLSPEC void SDLCALL GPU_SetUniformMatrixfv (int location, int num_matrices, int num_rows, int num_columns, GPU_bool transpose, float *values)
 
DECLSPEC void SDLCALL GPU_SetAttributef (int location, float value)
 
DECLSPEC void SDLCALL GPU_SetAttributei (int location, int value)
 
DECLSPEC void SDLCALL GPU_SetAttributeui (int location, unsigned int value)
 
DECLSPEC void SDLCALL GPU_SetAttributefv (int location, int num_elements, float *value)
 
DECLSPEC void SDLCALL GPU_SetAttributeiv (int location, int num_elements, int *value)
 
DECLSPEC void SDLCALL GPU_SetAttributeuiv (int location, int num_elements, unsigned int *value)
 
DECLSPEC void SDLCALL GPU_SetAttributeSource (int num_values, GPU_Attribute source)
 

Detailed Description

Typedef Documentation

◆ GPU_TypeEnum

typedef Uint32 GPU_TypeEnum

Type enumeration for GPU_AttributeFormat specifications.

Definition at line 523 of file SDL_gpu.h.

Enumeration Type Documentation

◆ GPU_ShaderEnum

Shader type enum.

See also
GPU_LoadShader()
GPU_CompileShader()
GPU_CompileShader_RW()
Enumerator
GPU_VERTEX_SHADER 
GPU_FRAGMENT_SHADER 
GPU_PIXEL_SHADER 
GPU_GEOMETRY_SHADER 

Definition at line 545 of file SDL_gpu.h.

◆ GPU_ShaderLanguageEnum

Type enumeration for the shader language used by the renderer.

Enumerator
GPU_LANGUAGE_NONE 
GPU_LANGUAGE_ARB_ASSEMBLY 
GPU_LANGUAGE_GLSL 
GPU_LANGUAGE_GLSLES 
GPU_LANGUAGE_HLSL 
GPU_LANGUAGE_CG 

Definition at line 557 of file SDL_gpu.h.

Function Documentation

◆ GPU_ActivateShaderProgram()

DECLSPEC void SDLCALL 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_AttachShader()

DECLSPEC void SDLCALL 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_CompileShader()

DECLSPEC Uint32 SDLCALL 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()

DECLSPEC Uint32 SDLCALL 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_CreateShaderProgram()

DECLSPEC Uint32 SDLCALL GPU_CreateShaderProgram ( void  )

Creates a new, empty shader program. You will need to compile shaders, attach them to the program, then link the program.

See also
GPU_AttachShader
GPU_LinkShaderProgram

Definition at line 2117 of file SDL_gpu.c.

◆ GPU_DeactivateShaderProgram()

DECLSPEC void SDLCALL GPU_DeactivateShaderProgram ( void  )

Deactivates the current shader program (activates program 0).

Definition at line 2207 of file SDL_gpu.c.

◆ GPU_DetachShader()

DECLSPEC void SDLCALL 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_FreeShader()

DECLSPEC void SDLCALL GPU_FreeShader ( Uint32  shader_object)

Deletes a shader object.

Definition at line 2156 of file SDL_gpu.c.

◆ GPU_FreeShaderProgram()

DECLSPEC void SDLCALL GPU_FreeShaderProgram ( Uint32  program_object)

Deletes a shader program.

Definition at line 2164 of file SDL_gpu.c.

◆ GPU_GetAttributeLocation()

DECLSPEC int SDLCALL 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_GetCurrentShaderProgram()

DECLSPEC Uint32 SDLCALL GPU_GetCurrentShaderProgram ( void  )
Returns
The current shader program

Definition at line 118 of file SDL_gpu.c.

◆ GPU_GetShaderBlock()

DECLSPEC GPU_ShaderBlock SDLCALL GPU_GetShaderBlock ( void  )

Gets the shader block for the current shader.

Definition at line 2283 of file SDL_gpu.c.

◆ GPU_GetShaderMessage()

DECLSPEC const char* SDLCALL GPU_GetShaderMessage ( void  )

Returns the last shader log message.

Definition at line 2215 of file SDL_gpu.c.

◆ GPU_GetUniformfv()

DECLSPEC void SDLCALL 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()

DECLSPEC void SDLCALL 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()

DECLSPEC int SDLCALL 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()

DECLSPEC void SDLCALL 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()

DECLSPEC void SDLCALL 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_IsDefaultShaderProgram()

DECLSPEC GPU_bool SDLCALL 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_LinkManyShaders()

DECLSPEC Uint32 SDLCALL 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()

DECLSPEC GPU_bool SDLCALL 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()

DECLSPEC Uint32 SDLCALL 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_LoadShader()

DECLSPEC Uint32 SDLCALL 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()

DECLSPEC GPU_ShaderBlock SDLCALL 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_MakeAttribute()

DECLSPEC GPU_Attribute SDLCALL 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()

DECLSPEC GPU_AttributeFormat SDLCALL 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_SetAttributef()

DECLSPEC void SDLCALL 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()

DECLSPEC void SDLCALL 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()

DECLSPEC void SDLCALL 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()

DECLSPEC void SDLCALL 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()

DECLSPEC void SDLCALL 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()

DECLSPEC void SDLCALL 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()

DECLSPEC void SDLCALL 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_SetShaderBlock()

DECLSPEC void SDLCALL 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()

DECLSPEC void SDLCALL 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_SetUniformf()

DECLSPEC void SDLCALL 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()

DECLSPEC void SDLCALL 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()

DECLSPEC void SDLCALL 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()

DECLSPEC void SDLCALL 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()

DECLSPEC void SDLCALL 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()

DECLSPEC void SDLCALL 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()

DECLSPEC void SDLCALL 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.