Logo   Home Table of Contents    News  Dev Blogs  Gallery  Timeline  Legend  Tags  Sponsors 
Join us on... 
Banner

Current: Month Day, Year

9.1.6 Code of opengl/shaders.py

opengl/shaders provides all methods to deal with openGL shaders. The file only contains 2 classes:

Class ShaderFiles

This class is derived from QOpenGLShaderProgram and is the class to store 3 connected shaders

Variables

These variables are all preset by __init__.
namedescription
uniforms Dictionary of shader uniform values, all preset by -1 (so no position in shader).
env reference to environment object.
name The name of the shader.
frag_id ID of the fragment shader (preset: None).
vert_id ID of the vertex shader (preset: None).
geom_id ID of the geometry shader (preset: None).
path The path of the shader (without suffix .frag, .vert and .geom.

Methods:

nameparametersreturnsdescription
loadFragShader Nonesuccess boolean Adds fragment shader path.frag and the shader ID to frag_id. Returns True on success.
loadVertShader Nonesuccess boolean Adds fragment shader path.vert and the shader ID to vert_id. Returns True on success.
loadGeomShader Nonesuccess boolean Adds geometry shader path.geom and the shader ID to geom_id. Returns True on success.
loadAllShaderTypes Nonesuccess boolean Adds at least fragment and vertex shader, but also geometry shader path.geom is existent. Returns True on success.

Class ShaderRepository

Handles all shaders.

Variables

These variables are all preset by __init__.
namedescription
glob reference to global object.
env reference to environment object.
_shaders List of all shaders.
_shadernames shader dictionary referencing _shaders by name.
prefix special index for Apple (v12_) or empty.

Methods:

nameparametersreturnsdescription
getShader nameshader object returns shader object by name.
loadshader filenameshader loads or reuses a shader given by pathname and returns shader number.
loadShaders filenamesNone loads a list of shaders and sets attributes and uniform values.
attribVertShader numNone set attributes of vertex shader (aPosition, aNormal, aTexCoords) to location 0 to 2 and links and binds shader.
bindShader shader numberNone bind the shader.
getUniforms shader numberNone set shader uniforms array of ShaderFiles class to the shader uniform location evaluated.
setShaderUniform shader reference
name
var
None set shader uniforms value of a certain name to a specific value.
setShaderArrayStruct shader
name
index
member
var
None Get the location of "name[index],member". If not -1 set value to var (float must be handled different).