QGLShader

The QGLShader class allows OpenGL shaders to be compiled. More

Inheritance diagram of PySide2.QtOpenGL.QGLShader

New in version 4.6.

Synopsis

Functions

Static functions

Detailed Description

This class supports shaders written in the OpenGL Shading Language (GLSL) and in the OpenGL/ES Shading Language (GLSL/ES).

QGLShader and QGLShaderProgram shelter the programmer from the details of compiling and linking vertex and fragment shaders.

Note

This class has been deprecated in favor of QOpenGLShader .

See also

QGLShaderProgram

class PySide2.QtOpenGL.QGLShader(type[, parent=None])

PySide2.QtOpenGL.QGLShader(type, context[, parent=None])

param type:

ShaderType

param parent:

PySide2.QtCore.QObject

param context:

PySide2.QtOpenGL.QGLContext

Constructs a new QGLShader 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 QGLContext .

Constructs a new QGLShader object of the specified type and attaches it to parent . If shader programs are not supported, then hasOpenGLShaderPrograms() will return false.

This constructor is normally followed by a call to compileSourceCode() or compileSourceFile() .

The shader will be associated with context .

PySide2.QtOpenGL.QGLShader.ShaderTypeBit

This enum specifies the type of QGLShader that is being created.

Constant

Description

QGLShader.Vertex

Vertex shader written in the OpenGL Shading Language (GLSL).

QGLShader.Fragment

Fragment shader written in the OpenGL Shading Language (GLSL).

QGLShader.Geometry

Geometry shaders written in the OpenGL Shading Language (GLSL), based on the GL_EXT_geometry_shader4 extension.

PySide2.QtOpenGL.QGLShader.compileSourceCode(source)
Parameters:

sourcePySide2.QtCore.QByteArray

Return type:

bool

PySide2.QtOpenGL.QGLShader.compileSourceCode(source)
Parameters:

source – str

Return type:

bool

PySide2.QtOpenGL.QGLShader.compileSourceCode(source)
Parameters:

source – str

Return type:

bool

Sets the source code for this shader and compiles it. Returns true if the source was successfully compiled, false otherwise.

PySide2.QtOpenGL.QGLShader.compileSourceFile(fileName)
Parameters:

fileName – str

Return type:

bool

Sets the source code for this shader to the contents of fileName and compiles it. Returns true if the file could be opened and the source compiled, false otherwise.

static PySide2.QtOpenGL.QGLShader.hasOpenGLShaders(type[, context=None])
Parameters:
Return type:

bool

Returns true if shader programs of type type are supported on this system; false otherwise.

The context is used to resolve the GLSL extensions. If context is None , then currentContext() is used.

PySide2.QtOpenGL.QGLShader.isCompiled()
Return type:

bool

Returns true if this shader has been compiled; false otherwise.

PySide2.QtOpenGL.QGLShader.log()
Return type:

str

Returns the errors and warnings that occurred during the last compile.

PySide2.QtOpenGL.QGLShader.shaderId()
Return type:

GLuint

Returns the OpenGL identifier associated with this shader.

See also

programId()

PySide2.QtOpenGL.QGLShader.shaderType()
Return type:

ShaderType

Returns the type of this shader.

PySide2.QtOpenGL.QGLShader.sourceCode()
Return type:

PySide2.QtCore.QByteArray

Returns the source code for this shader.