QOpenGLShader¶
- PyQt5.QtGui.QOpenGLShader
Inherits from QObject.
Description¶
The QOpenGLShader class allows OpenGL shaders to be compiled.
This class supports shaders written in the OpenGL Shading Language (GLSL) and in the OpenGL/ES Shading Language (GLSL/ES).
QOpenGLShader and QOpenGLShaderProgram shelter the programmer from the details of compiling and linking vertex and fragment shaders.
See also
Classes¶
Enums¶
- ShaderTypeBit
This enum specifies the type of QOpenGLShader that is being created.
Member
Value
Description
Compute 0x0020
Compute shaders written in the OpenGL shading language (GLSL) (requires OpenGL >= 4.3 or OpenGL ES >= 3.1).
Fragment 0x0002
Fragment shader written in the OpenGL Shading Language (GLSL).
Geometry 0x0004
Geometry shaders written in the OpenGL Shading Language (GLSL) (requires OpenGL >= 3.2 or OpenGL ES >= 3.2).
TessellationControl 0x0008
Tessellation control shaders written in the OpenGL shading language (GLSL) (requires OpenGL >= 4.0 or OpenGL ES >= 3.2).
TessellationEvaluation 0x0010
Tessellation evaluation shaders written in the OpenGL shading language (GLSL) (requires OpenGL >= 4.0 or OpenGL ES >= 3.2).
Vertex 0x0001
Vertex shader written in the OpenGL Shading Language (GLSL).
Methods¶
- __init__(Union[ShaderType, ShaderTypeBit], parent: QObject = None)
Constructs a new QOpenGLShader object of the specified type and attaches it to parent. If shader programs are not supported, hasOpenGLShaderPrograms() will return false.
This constructor is normally followed by a call to compileSourceCode() or compileSourceFile().
The shader will be associated with the current QOpenGLContext.
See also
- compileSourceCode(Union[QByteArray, bytes, bytearray]) → bool
This is an overloaded function.
Sets the source code for this shader and compiles it. Returns
trueif the source was successfully compiled, false otherwise.See also
- compileSourceCode(str) → bool
This is an overloaded function.
Sets the source code for this shader and compiles it. Returns
trueif the source was successfully compiled, false otherwise.See also
- compileSourceFile(str) → bool
Sets the source code for this shader to the contents of fileName and compiles it. Returns
trueif the file could be opened and the source compiled, false otherwise.See also
-
@staticmethod
hasOpenGLShaders(Union[ShaderType, ShaderTypeBit], context: QOpenGLContext = None) → bool Returns
trueif shader programs of type type are supported on this system; false otherwise.The context is used to resolve the GLSL extensions. If context is null, then currentContext() is used.
- isCompiled() → bool
Returns
trueif this shader has been compiled; false otherwise.See also
- log() → str
Returns the errors and warnings that occurred during the last compile.
See also
- shaderId() → int
Returns the OpenGL identifier associated with this shader.
See also
- shaderType() → ShaderType
Returns the type of this shader.
- sourceCode() → QByteArray
Returns the source code for this shader.
See also