Kanzi Graphics Engine
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
kzu_shader.h File Reference

Shader. More...

Data Structures

struct  KzuShaderLightContainer
 Light container in shader. More...
 

Functions

kzsError kzuShaderCreate (const struct KzuResourceManager *resourceManager, kzString name, struct KzuResourceLoader *loader, struct KzuShader **out_shader)
 Creates a shader that loads the data when needed using the given resource loader. More...
 
kzsError kzuShaderRegisterToFactory (const struct KzuFactory *factory)
 Registers shader type to factory. More...
 
kzsError kzuShaderCreateFromMemory (const struct KzuResourceManager *resourceManager, kzString name, kzString vertexShader, kzString fragmentShader, kzUint vertexAttributeCount, const kzString *vertexAttribute, struct KzuShader **out_shader)
 Creates a shader with the given vertex and fragment shader strings and given vertex attributes. More...
 
kzsError kzuShaderInitializeFromMemory (struct KzuShader *shader, kzString vertexShader, kzString fragmentShader, kzUint vertexAttributeCount, const kzString *vertexAttributes)
 Initializes a shader with the given vertex and fragment shader strings and given vertex attributes. More...
 
struct KzuGPUResourcekzuShaderToGPUResource (const struct KzuShader *shader)
 Converts shader to GPU resource. More...
 
struct KzuShaderkzuShaderFromGPUResource (const struct KzuGPUResource *gpuResource)
 Converts GPU resource to shader. More...
 
struct KzuResourcekzuShaderToResource (const struct KzuShader *shader)
 Converts shader to resource. More...
 
struct KzuShaderkzuShaderFromResource (const struct KzuResource *resource)
 Converts resource to shader. More...
 
struct KzuShaderkzuShaderCastFromResource (const struct KzuResource *resource)
 Casts shader from resource, KZ_NULL if invalid type. More...
 
kzsError kzuShaderAddPropertyType (struct KzuShader *shader, const struct KzuPropertyType *propertyType)
 Adds property type to shader. More...
 
kzsError kzuShaderRemovePropertyType (const struct KzuShader *shader, const struct KzuPropertyType *propertyType)
 Removes property type from shader. More...
 
kzsError kzuShaderAddLightType (struct KzuShader *shader, const struct KzuStructPropertyType *propertyType)
 Assigns lights for shader. More...
 
kzsError kzuShaderRemoveLightType (const struct KzuShader *shader, const struct KzuStructPropertyType *propertyType)
 Removes lights from shader. More...
 
struct KzuPropertyTypekzuShaderGetPropertyTypeByName (const struct KzuShader *shader, kzString propertyTypeName)
 Gets property type from shader by name. More...
 
struct KzcDynamicArrayIterator kzuShaderGetPropertyTypes (const struct KzuShader *shader)
 Returns all property types from shader. More...
 
struct KzcDynamicArrayIterator kzuShaderGetLightTypes (const struct KzuShader *shader)
 Returns all light types from shader. More...
 
kzBool kzuShaderIsRenderable (const struct KzuShader *shader)
 Returns true if the shader is deployed and valid. More...
 
struct KzcHashMapIterator kzuShaderGetVertexAttributes (const struct KzuShader *shader)
 Gets vertex attributes from shader. More...
 
kzsError kzuShaderBind (const struct KzuShader *shader)
 Binds the shader for rendering. More...
 
kzsError kzuShaderGetUniformLocation (const struct KzuShader *shader, kzUint index, kzInt *out_location)
 Gets uniform location from shader object based on index in the property collection. More...
 
kzsError kzuShaderGetLightUniformLocation (const struct KzuShader *shader, kzUint lightIndex, kzUint lightPropertyTypeIndex, kzInt *out_location)
 Gets uniform location for light property type from shader object based on index in the property collection. More...
 
kzBool kzuShaderGetUniformBufferLocation (const struct KzuShader *shader, kzUint index, kzInt *out_offset, kzByte **out_data, kzUint *out_uniformBufferHandle)
 Gets uniform location in buffer. More...
 
kzsError kzuShaderGetTextureUniformLocation (struct KzuShader *shader, kzString textureName, kzUint textureUnit, kzInt *out_textureLocation, kzInt *out_textureWidthUniformLocation, kzInt *out_textureHeightUniformLocation)
 Returns texture specific uniform locations form shader. More...
 

Variables

const KzuResourceType KZU_RESOURCE_TYPE_SHADER
 Resource type identifier for shader. More...
 

Detailed Description

Shader.

Copyright 2008-2019 by Rightware. All rights reserved.

Function Documentation

kzsError kzuShaderCreate ( const struct KzuResourceManager resourceManager,
kzString  name,
struct KzuResourceLoader loader,
struct KzuShader **  out_shader 
)

Creates a shader that loads the data when needed using the given resource loader.

kzsError kzuShaderRegisterToFactory ( const struct KzuFactory factory)

Registers shader type to factory.

kzsError kzuShaderCreateFromMemory ( const struct KzuResourceManager resourceManager,
kzString  name,
kzString  vertexShader,
kzString  fragmentShader,
kzUint  vertexAttributeCount,
const kzString vertexAttribute,
struct KzuShader **  out_shader 
)

Creates a shader with the given vertex and fragment shader strings and given vertex attributes.

kzsError kzuShaderInitializeFromMemory ( struct KzuShader shader,
kzString  vertexShader,
kzString  fragmentShader,
kzUint  vertexAttributeCount,
const kzString vertexAttributes 
)

Initializes a shader with the given vertex and fragment shader strings and given vertex attributes.

Calling this function is safe only from a resource loader passed as an argument to kzuShaderCreate().

See Also
kzuShaderCreate for creating the shader.
struct KzuGPUResource* kzuShaderToGPUResource ( const struct KzuShader shader)

Converts shader to GPU resource.

struct KzuShader* kzuShaderFromGPUResource ( const struct KzuGPUResource gpuResource)

Converts GPU resource to shader.

struct KzuResource* kzuShaderToResource ( const struct KzuShader shader)

Converts shader to resource.

struct KzuShader* kzuShaderFromResource ( const struct KzuResource resource)

Converts resource to shader.

struct KzuShader* kzuShaderCastFromResource ( const struct KzuResource resource)

Casts shader from resource, KZ_NULL if invalid type.

kzsError kzuShaderAddPropertyType ( struct KzuShader shader,
const struct KzuPropertyType propertyType 
)

Adds property type to shader.

kzsError kzuShaderRemovePropertyType ( const struct KzuShader shader,
const struct KzuPropertyType propertyType 
)

Removes property type from shader.

kzsError kzuShaderAddLightType ( struct KzuShader shader,
const struct KzuStructPropertyType propertyType 
)

Assigns lights for shader.

kzsError kzuShaderRemoveLightType ( const struct KzuShader shader,
const struct KzuStructPropertyType propertyType 
)

Removes lights from shader.

struct KzuPropertyType* kzuShaderGetPropertyTypeByName ( const struct KzuShader shader,
kzString  propertyTypeName 
)

Gets property type from shader by name.

Returns KZ_NULL if not found.

struct KzcDynamicArrayIterator kzuShaderGetPropertyTypes ( const struct KzuShader shader)

Returns all property types from shader.

<PropertyType>.

struct KzcDynamicArrayIterator kzuShaderGetLightTypes ( const struct KzuShader shader)

Returns all light types from shader.

<KzuShaderLightContainer>.

kzBool kzuShaderIsRenderable ( const struct KzuShader shader)

Returns true if the shader is deployed and valid.

struct KzcHashMapIterator kzuShaderGetVertexAttributes ( const struct KzuShader shader)

Gets vertex attributes from shader.

<kzString(attributeName), kzUint(attributeIndex)>.

kzsError kzuShaderBind ( const struct KzuShader shader)

Binds the shader for rendering.

kzsError kzuShaderGetUniformLocation ( const struct KzuShader shader,
kzUint  index,
kzInt out_location 
)

Gets uniform location from shader object based on index in the property collection.

Uses caching if possible.

kzsError kzuShaderGetLightUniformLocation ( const struct KzuShader shader,
kzUint  lightIndex,
kzUint  lightPropertyTypeIndex,
kzInt out_location 
)

Gets uniform location for light property type from shader object based on index in the property collection.

Uses caching if possible.

kzBool kzuShaderGetUniformBufferLocation ( const struct KzuShader shader,
kzUint  index,
kzInt out_offset,
kzByte **  out_data,
kzUint out_uniformBufferHandle 
)

Gets uniform location in buffer.

kzsError kzuShaderGetTextureUniformLocation ( struct KzuShader shader,
kzString  textureName,
kzUint  textureUnit,
kzInt out_textureLocation,
kzInt out_textureWidthUniformLocation,
kzInt out_textureHeightUniformLocation 
)

Returns texture specific uniform locations form shader.

Variable Documentation

const KzuResourceType KZU_RESOURCE_TYPE_SHADER

Resource type identifier for shader.