OpenGL.GL.shaders

Convenience module providing common shader entry points
The point of this module is to allow client code to use OpenGL Core names to reference shader-related operations even if the local hardware only supports ARB extension-based shader rendering.
There are also two utility methods compileProgram and compileShader which make it easy to create demos which are shader-using.

Functions

_alt( base , name )
compileProgram( * shaders , ** named )
Create a new program, attach shaders and validate
shaders
arbitrary number of shaders to attach to the generated program.separable (keyword only) -- set the separable flag to allow for partial installation of shader into the pipeline (see glUseProgramStages)retrievable (keyword only) -- set the retrievable flag to allow retrieval of the program binary representation, (see glProgramBinary, glGetProgramBinary)
This convenience function is *not* standard OpenGL, but it does wind up being fairly useful for demos and the like. You may wish to copy it to your code base to guard against PyOpenGL changes.
Usage:
shader = compileProgram( compileShader( source, GL_VERTEX_SHADER ), compileShader( source2, GL_FRAGMENT_SHADER ), ) glUseProgram( shader )
Note: If (and only if) validation of the linked program *passes* then the passed-in shader objects will be deleted from the GL.
returns ShaderProgram() (GLuint) program reference raises RuntimeError when a link/validation failure occurs
compileShader( source , shaderType )
Compile shader source of given type
source
GLSL source-code for the shader
shaderType
GLenum GL_VERTEX_SHADER, GL_FRAGMENT_SHADER, etc,
returns GLuint compiled shader reference raises RuntimeError when a compilation failure occurs
glVertexAttribPointer (alternate implementations)
glVertexAttribPointer( index , size , type , normalized , stride , pointer )
Set an attribute pointer for a given shader (index)
index
the index of the generic vertex to bind, see glGetAttribLocation for retrieval of the value, note that index is a global variable, not per-shader
size
number of basic elements per record, 1,2,3, or 4
type
enum constant for data-type
normalized
whether to perform int to float normalization on integer-type values
stride
stride in machine units (bytes) between consecutive records, normally used to create "interleaved" arrays
pointer
data-pointer which provides the data-values, normally a vertex-buffer-object or offset into the same.
This implementation stores a copy of the data-pointer in the contextdata structure in order to prevent null- reference errors in the renderer.
glVertexAttribPointerARB( index , size , type , normalized , stride , pointer )
Set an attribute pointer for a given shader (index)
index
the index of the generic vertex to bind, see glGetAttribLocation for retrieval of the value, note that index is a global variable, not per-shader
size
number of basic elements per record, 1,2,3, or 4
type
enum constant for data-type
normalized
whether to perform int to float normalization on integer-type values
stride
stride in machine units (bytes) between consecutive records, normally used to create "interleaved" arrays
pointer
data-pointer which provides the data-values, normally a vertex-buffer-object or offset into the same.
This implementation stores a copy of the data-pointer in the contextdata structure in order to prevent null- reference errors in the renderer.

Classes

class ShaderProgram( int ):
Integer sub-class with context-manager operation

AltStyle によって変換されたページ (->オリジナル) /