This modules provides classes to manager OpenGL Shader.
Bases: object
This class defines a shader source code.
Instances have an internal source code buffer to accumulate the source code before to compile it. We can get the content of this buffer using the str(). And we can test if the shader is compiled using a Boolean evaluation of the instance.
The shader type can be passed to the constructor or retrieved from a source file, where a comment line with the following pattern must be present:
// #shader_type SHADER_TYPE
where SHADER_TYPE could be either vertex, fragment and geometry. It is case insensitive.
Source files are preprocessed so as to replace line of the form:
#include(file.glsl)
the path is relative to the parent source file.
Set the shader type. It raise an exception if the shader is already set.
Bases: object
This class provides a shader manager where each shader or program are identified by a name and the shader sources are loaded from files.
The shaders or programs can be accessed using an attribute or a dictionary interface. For example to get the shader fixed_fragment we can use either:
shader_manager.fixed_fragment
shader_manager.['fixed_fragment']
We can test if an identifier exists using:
'fixed_fragment' in shader_manager
Link a program with the given list of shader names. This program is identified by shader_name. The argument program_interface can be used to set the program interface.
Bases: object
This class defines a shader program.
We can access the uniforms and vertex attributes defined in the shader program using the two class attributes: uniforms and attributes, respectively. Both act as class that has an attribute for each uniform and vertex attribute.
For example we can set a colour uniform using:
shader_program.uniforms.colour = (1., 1., 1.)
and get back its values using:
shader_program.uniforms.colour
We can also use a dictionary interface:
# to set the values
shader_program.uniforms['colour'] = (1., 1., 1.)
# to get the values
shader_program.uniforms['colour']
Moreover we can test if an uniform is defined using:
'colour' in shader_program.uniforms
Similarly, we can access a vertex attribute using:
shader_program.attributes.positions
For example to attach a VBO:
shader_program.attributes.positions.bind_to_buffer(positions_vbo)
Bind an attribute location. The program should not be linked.
Bases: PyOpenGLng.Tools.AttributeDictionaryInterface.AttributeDictionaryInterface
This class is a wrapper to access the vertex attributes within a shader program.
Bases: object
This class defines a programming interface for a program.
Bases: object
This class defines a programming interface for an attribute as a pair (name, location)
Bases: object
This class defines a programming interface for an uniform block as a pair (name, binding_point)
Bases: PyOpenGLng.Tools.AttributeDictionaryInterface.AttributeDictionaryInterface
This class is a wrapper to access the uniform blocks within a shader program.
Bases: PyOpenGLng.Tools.AttributeDictionaryInterface.AttributeDictionaryInterfaceDescriptor
This class is a wrapper to access the uniforms within a shader program.
Bases: PyOpenGLng.HighLevelApi.Shader.GlVariable
This class defines a uniform within a shader program.
The argument shader_program is the GlShaderProgram instance, name is the name of the uniform in the source code, location is the location of the uniform, gl_type the OpenGL data type and size is the number of elements of the uniform.
Bases: PyOpenGLng.Tools.AttributeDictionaryInterface.AttributeDictionaryInterface
This class defines an uniform block.
Bases: PyOpenGLng.HighLevelApi.Shader.GlUniformNd
This class defines a matrix uniform.
The argument shader_program is the GlShaderProgram instance, name is the name of the uniform in the source code, location is the location of the uniform, gl_type the OpenGL data type and size is the number of elements of the uniform.
Bases: PyOpenGLng.HighLevelApi.Shader.GlUniform
This class is a base class for vector and matrix uniforms.
The argument shader_program is the GlShaderProgram instance, name is the name of the uniform in the source code, location is the location of the uniform, gl_type the OpenGL data type and size is the number of elements of the uniform.
Bases: PyOpenGLng.HighLevelApi.Shader.GlUniform
This class defines a sampler uniform.
The argument shader_program is the GlShaderProgram instance, name is the name of the uniform in the source code, location is the location of the uniform, gl_type the OpenGL data type and size is the number of elements of the uniform.
Bases: PyOpenGLng.HighLevelApi.Shader.GlUniform
This class defines a variable uniform.
The argument shader_program is the GlShaderProgram instance, name is the name of the uniform in the source code, location is the location of the uniform, gl_type the OpenGL data type and size is the number of elements of the uniform.
Bases: PyOpenGLng.HighLevelApi.Shader.GlUniformNd
This class defines a vector uniform.
The argument shader_program is the GlShaderProgram instance, name is the name of the uniform in the source code, location is the location of the uniform, gl_type the OpenGL data type and size is the number of elements of the uniform.
Bases: object
This class is a base class for Attributes and Uniforms.
The argument shader_program is the GlShaderProgram instance, name is the name of the uniform in the source code, location is the location of the uniform, gl_type the OpenGL data type and size is the number of elements of the uniform.
This attribute is used to set the variable label: attribute or uniform.
Bases: PyOpenGLng.HighLevelApi.Shader.GlVariable
This class defines a vertex attributes.
The argument shader_program is the GlShaderProgram instance, name is the name of the uniform in the source code, location is the location of the uniform, gl_type the OpenGL data type and size is the number of elements of the uniform.