pyGLV.GL.Shader¶
Shader classes
The Shader Compoment class is the dedicated to a specific type of data container in the pyECSS Component class that of assembling, using and destroying OpenGL API shader programs
Based on the Composite and Iterator design patterns:
https://github.com/faif/python-patterns/blob/master/patterns/structural/composite.py
https://github.com/faif/python-patterns/blob/master/patterns/behavioral/iterator.py
- class pyGLV.GL.Shader.Shader(name=None, type=None, id=None, vertex_source=None, fragment_source=None)[source]¶
A concrete OpenGL-GLSL Shader container Component class
- update()[source]¶
method to be subclassed for debuging purposes only, in case we need some behavioral or logic computation within te Component. This violates the ECS architecture and should be avoided.
- class pyGLV.GL.Shader.ShaderGLDecorator(comp, name=None, type=None, id=None)[source]¶
A decorator of the Shader Compoment to decorate it with custom standard pass-through shader attributes
- Parameters
ComponentDecorator ([type]) – [description]
- class pyGLV.GL.Shader.InitGLShaderSystem(name=None, type=None, id=None, priority=0)[source]¶
Initialise outside of the rendering loop RenderMesh, Shader, VertexArray, ShaderGLDecorator classes
- init()[source]¶
method to be subclassed for behavioral or logic computation when visits Components of an EntityNode.
- apply2RenderMesh(renderMesh: pyECSS.Component.RenderMesh)[source]¶
method to be subclassed for behavioral or logic computation when visits Components.
- apply2VertexArray(vertexArray: pyGLV.GL.VertexArray.VertexArray)[source]¶
method to be subclassed for behavioral or logic computation when visits Components.
- apply2Shader(shader: pyGLV.GL.Shader.Shader)[source]¶
method to be subclassed for behavioral or logic computation when visits Components.
- apply2ShaderGLDecorator(shaderGLDecorator: pyGLV.GL.Shader.ShaderGLDecorator)[source]¶
method to be subclassed for behavioral or logic computation when visits Components.
- class pyGLV.GL.Shader.RenderGLShaderSystem(name=None, type=None, id=None, priority=0)[source]¶
A RenderSystem specifically for GL vertex and fragment Shaders and associated VertexArray components attached to a specific Entity
- init()[source]¶
method to be subclassed for behavioral or logic computation when visits Components of an EntityNode.
- apply2VertexArray(vertexArray: pyGLV.GL.VertexArray.VertexArray)[source]¶
Main GPU rendering is initiated when a vertexArray node is encountered and if a Shader/Shaderdecorator and RenderMesh components are present
method to be subclassed for behavioral or logic computation when visits RenderMesh Components of the parent EntityNode. Separate SystemDecorator is needed for each case, e.g. for rendering with GL vertex and fragment Shaders: RenderShaderSystem
Actuall RenderShaderSystem rendering is initiated in this update call, according to following pseudocode:
- render(vertexArray: Optional[pyGLV.GL.VertexArray.VertexArray] = None, compRenderMesh: Optional[pyECSS.Component.RenderMesh] = None, compShader=None)[source]¶
- Shader-based main draw():
retrive ShaderDecorator glid
useShaderProgram(ShaderDecorator.glid)
call ShaderDecorator::update to pass on uniform shader parameters to GPU
renderMeshVertexArray.execute(gl.GL_TRIANGLES)
userShaderProgram(0) #clean GL state