Result = CreateShader(ShaderID, VertexProgram$, FragmentProgram$)
Creates a new shader using the specified vertex and fragment programs.


ShaderID A number between 0 and 65536 to identify the new shader. To select one of the predefined shader, use one of the following values as 'ShaderID' (VertexProgram$ and FragmentProgram$ values will be ignored):
VertexProgram$ The GLSL program to use for vertices.
FragmentProgram$ The GLSL program to use for fragments.

Return value

Nonzero if the shader was successfully created, zero otherwise.


Shaders usually need to receive parameters to work and two functions allow to pass these parameters: MaterialShaderAutoParameter() (automatic parameter) and MaterialShaderParameter() (shader parameter).
PureBasic also allows to set these parameters directly in the shader programs by adding at the end of the 'uniform' declaration line: "//" followed by either:
- the auto parameter number preceded by a "+" (cf. 'ParameterType' constants of the MaterialShaderAutoParameter() function).
- one or more values (separated by a space) corresponding to the shader parameter (MaterialShaderParameter()).

uniform vec4 camera_pos;//+76 <- automatic parameter #PB_Shader_CameraPosition
uniform vec4 fog_params;//+31 <- automatic parameter #PB_Shader_FogParams
uniform vec3 speed;//0.5 1 0 <- shader parameter 'speed'
uniform sampler2D diffuseMap;//1 <- shader parameter texture number

See Also

CreateShaderMaterial(), MaterialShaderAutoParameter(), MaterialShaderParameter()

Supported OS


<- CreateMaterial() - Material Index - CreateShaderMaterial() ->