All Classes Functions Variables Typedefs Enumerations Groups
Classes | Typedefs | Enumerations
Shader Interface

Classes

struct  GPU_ShaderBlock
 
struct  GPU_AttributeFormat
 
struct  GPU_Attribute
 
struct  GPU_AttributeSource
 

Typedefs

typedef struct GPU_ShaderBlock GPU_ShaderBlock
 
typedef Uint32 GPU_TypeEnum
 
typedef struct GPU_AttributeFormat GPU_AttributeFormat
 
typedef struct GPU_Attribute GPU_Attribute
 
typedef struct GPU_AttributeSource GPU_AttributeSource
 

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

typedef struct GPU_Attribute GPU_Attribute

Container for the built-in shader attribute and uniform locations (indices).

See Also
GPU_LoadShaderBlock()
GPU_SetShaderBlock()
typedef Uint32 GPU_TypeEnum

Type enumeration for GPU_AttributeFormat specifications.

Enumeration Type Documentation

Type enumeration for the shader language used by the renderer.

Function Documentation

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.

DECLSPEC void SDLCALL GPU_AttachShader ( Uint32  program_object,
Uint32  shader_object 
)

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

DECLSPEC Uint32 SDLCALL GPU_CompileShader ( GPU_ShaderEnum  shader_type,
const char *  shader_source 
)

Compiles shader source and returns the new shader object.

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.

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

Deactivates the current shader program (activates program 0).

DECLSPEC void SDLCALL GPU_DetachShader ( Uint32  program_object,
Uint32  shader_object 
)

Detaches a shader object from a shader program.

DECLSPEC void SDLCALL GPU_FreeShader ( Uint32  shader_object)

Deletes a shader object.

DECLSPEC void SDLCALL GPU_FreeShaderProgram ( Uint32  program_object)

Deletes a shader program.

DECLSPEC int SDLCALL GPU_GetAttributeLocation ( Uint32  program_object,
const char *  attrib_name 
)

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

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

Gets the shader block for the current shader.

DECLSPEC const char* SDLCALL GPU_GetShaderMessage ( void  )

Returns the last shader log message.

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.

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.

DECLSPEC int SDLCALL GPU_GetUniformLocation ( Uint32  program_object,
const char *  uniform_name 
)

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

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.

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.

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.

DECLSPEC Uint32 SDLCALL GPU_LinkManyShaders ( Uint32 *  shader_objects,
int  count 
)

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

DECLSPEC GPU_bool SDLCALL GPU_LinkShaderProgram ( Uint32  program_object)

Links a shader program with any attached shader objects.

DECLSPEC Uint32 SDLCALL GPU_LinkShaders ( Uint32  shader_object1,
Uint32  shader_object2 
)

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

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.

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.

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

Returns a filled GPU_Attribute object.

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.

DECLSPEC void SDLCALL GPU_SetAttributef ( int  location,
float  value 
)

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

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.

DECLSPEC void SDLCALL GPU_SetAttributei ( int  location,
int  value 
)

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

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.

DECLSPEC void SDLCALL GPU_SetAttributeSource ( int  num_values,
GPU_Attribute  source 
)

Enables a shader attribute and sets its source data.

DECLSPEC void SDLCALL GPU_SetAttributeui ( int  location,
unsigned int  value 
)

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

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.

DECLSPEC void SDLCALL GPU_SetShaderBlock ( GPU_ShaderBlock  block)

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

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

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.

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

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.

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.

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

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.