PySide6.QtOpenGL.QOpenGLShaderProgram¶
- class QOpenGLShaderProgram¶
- The - QOpenGLShaderProgramclass allows OpenGL shader programs to be linked and used. More…- Synopsis¶- Methods¶- def - __init__()
- def - addShader()
- def - bind()
- def - create()
- def - isLinked()
- def - log()
- def - programId()
- def - release()
- def - removeShader()
- def - shaders()
 - Virtual methods¶- def - link()
 - Static functions¶- Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- Warning - This section contains snippets that were automatically translated from C++ to Python and may contain errors. - Introduction¶- This class supports shader programs written in the OpenGL Shading Language (GLSL) and in the OpenGL/ES Shading Language (GLSL/ES). - QOpenGLShaderand- QOpenGLShaderProgramshelter the programmer from the details of compiling and linking vertex and fragment shaders.- The following example creates a vertex shader program using the supplied source - code. Once compiled and linked, the shader program is activated in the current QOpenGLContext by calling- bind():- shader = QOpenGLShader(QOpenGLShader.Vertex) shader.compileSourceCode(code) program = QOpenGLShaderProgram(context) program.addShader(shader) program.link() program.bind() - Writing Portable Shaders¶- Shader programs can be difficult to reuse across OpenGL implementations because of varying levels of support for standard vertex attributes and uniform variables. In particular, GLSL/ES lacks all of the standard variables that are present on desktop OpenGL systems: - gl_Vertex,- gl_Normal,- gl_Color, and so on. Desktop OpenGL lacks the variable qualifiers- highp,- mediump, and- lowp.- The - QOpenGLShaderProgramclass makes the process of writing portable shaders easier by prefixing all shader programs with the following lines on desktop OpenGL:- #define highp #define mediump #define lowp - This makes it possible to run most GLSL/ES shader programs on desktop systems. The programmer should restrict themselves to just features that are present in GLSL/ES, and avoid standard variable names that only work on the desktop. - Simple Shader Example¶- program.addShaderFromSourceCode(QOpenGLShader.Vertex, "attribute highp vec4 vertex;\n" "uniform highp mat4 matrix;\n" "void main(void)\n" "{\n" " gl_Position = matrix * vertex;\n" "}") program.addShaderFromSourceCode(QOpenGLShader.Fragment, "uniform mediump vec4 color;\n" "void main(void)\n" "{\n" " gl_FragColor = color;\n" "}") program.link() program.bind() vertexLocation = program.attributeLocation("vertex") matrixLocation = program.uniformLocation("matrix") colorLocation = program.uniformLocation("color") - With the above shader program active, we can draw a green triangle as follows: - triangleVertices = { 60.0f, 10.0f, 0.0f, 110.0f, 110.0f, 0.0f, 10.0f, 110.0f, 0.0f color = QColor(0, 255, 0, 255) pmvMatrix = QMatrix4x4() pmvMatrix.ortho(rect()) program.enableAttributeArray(vertexLocation) program.setAttributeArray(vertexLocation, triangleVertices, 3) program.setUniformValue(matrixLocation, pmvMatrix) program.setUniformValue(colorLocation, color) glDrawArrays(GL_TRIANGLES, 0, 3) program.disableAttributeArray(vertexLocation) - Binary Shaders and Programs¶- Binary shaders may be specified using - glShaderBinary()on the return value from- shaderId(). The- QOpenGLShaderinstance containing the binary can then be added to the shader program with- addShader()and linked in the usual fashion with- link().- Binary programs may be specified using - glProgramBinaryOES()on the return value from- programId(). Then the application should call- link(), which will notice that the program has already been specified and linked, allowing other operations to be performed on the shader program. The shader program’s id can be explicitly created using the- create()function.- Caching Program Binaries¶- As of Qt 5.9, support for caching program binaries on disk is built in. To enable this, switch to using - addCacheableShaderFromSourceCode()and- addCacheableShaderFromSourceFile(). With an OpenGL ES 3.x context or support for- GL_ARB_get_program_binary, this will transparently cache program binaries under QStandardPaths::GenericCacheLocation or QStandardPaths::CacheLocation. When support is not available, calling the cacheable function variants is equivalent to the normal ones.- Note - Some drivers do not have any binary formats available, even though they advertise the extension or offer OpenGL ES 3.0. In this case program binary support will be disabled. - See also - Constructs a new shader program and attaches it to - parent. The program will be invalid until- addShader()is called.- The shader program will be associated with the current QOpenGLContext. - See also - addCacheableShaderFromSourceCode(type, source)¶
- Parameters:
- type – Combination of - ShaderTypeBit
- source – - QByteArray
 
- Return type:
- bool 
 
 - This is an overloaded function. - Registers the shader of the specified - typeand- sourceto this program. Unlike- addShaderFromSourceCode(), this function does not perform compilation. Compilation is deferred to- link(), and may not happen at all, because- link()may potentially use a program binary from Qt’s shader disk cache. This will typically lead to a significant increase in performance.- Returns true if the shader has been registered or, in the non-cached case, compiled successfully; false if there was an error. The compilation error messages can be retrieved via - log().- When the disk cache is disabled, via Qt::AA_DisableShaderDiskCache for example, or the OpenGL context has no support for context binaries, calling this function is equivalent to - addShaderFromSourceCode().- addCacheableShaderFromSourceCode(type, source)
- Parameters:
- type – Combination of - ShaderTypeBit
- source – str 
 
- Return type:
- bool 
 
 - This is an overloaded function. - Registers the shader of the specified - typeand- sourceto this program. Unlike- addShaderFromSourceCode(), this function does not perform compilation. Compilation is deferred to- link(), and may not happen at all, because- link()may potentially use a program binary from Qt’s shader disk cache. This will typically lead to a significant increase in performance.- When the disk cache is disabled, via Qt::AA_DisableShaderDiskCache for example, or the OpenGL context has no support for context binaries, calling this function is equivalent to - addShaderFromSourceCode().- addCacheableShaderFromSourceCode(type, source)
- Parameters:
- type – Combination of - ShaderTypeBit
- source – str 
 
- Return type:
- bool 
 
 - Registers the shader of the specified - typeand- sourceto this program. Unlike- addShaderFromSourceCode(), this function does not perform compilation. Compilation is deferred to- link(), and may not happen at all, because- link()may potentially use a program binary from Qt’s shader disk cache. This will typically lead to a significant increase in performance.- Returns true if the shader has been registered or, in the non-cached case, compiled successfully; false if there was an error. The compilation error messages can be retrieved via - log().- When the disk cache is disabled, via Qt::AA_DisableShaderDiskCache for example, or the OpenGL context has no support for context binaries, calling this function is equivalent to - addShaderFromSourceCode().- addCacheableShaderFromSourceFile(type, fileName)¶
- Parameters:
- type – Combination of - ShaderTypeBit
- fileName – str 
 
- Return type:
- bool 
 
 - Registers the shader of the specified - typeand- fileNameto this program. Unlike- addShaderFromSourceFile(), this function does not perform compilation. Compilation is deferred to- link(), and may not happen at all, because- link()may potentially use a program binary from Qt’s shader disk cache. This will typically lead to a significant increase in performance.- Returns true if the file has been read successfully, false if the file could not be opened or the normal, non-cached compilation of the shader has failed. The compilation error messages can be retrieved via - log().- When the disk cache is disabled, via Qt::AA_DisableShaderDiskCache for example, or the OpenGL context has no support for context binaries, calling this function is equivalent to - addShaderFromSourceFile().- addShader(shader)¶
- Parameters:
- shader – - QOpenGLShader
- Return type:
- bool 
 
 - Adds a compiled - shaderto this shader program. Returns- trueif the shader could be added, or false otherwise.- Ownership of the - shaderobject remains with the caller. It will not be deleted when this- QOpenGLShaderPrograminstance is deleted. This allows the caller to add the same shader to multiple shader programs.- addShaderFromSourceCode(type, source)¶
- Parameters:
- type – Combination of - ShaderTypeBit
- source – - QByteArray
 
- Return type:
- bool 
 
 - This is an overloaded function. - Compiles - sourceas a shader of the specified- typeand adds it to this shader program. Returns- trueif compilation was successful, false otherwise. The compilation errors and warnings will be made available via- log().- This function is intended to be a short-cut for quickly adding vertex and fragment shaders to a shader program without creating an instance of - QOpenGLShaderfirst.- addShaderFromSourceCode(type, source)
- Parameters:
- type – Combination of - ShaderTypeBit
- source – str 
 
- Return type:
- bool 
 
 - This is an overloaded function. - Compiles - sourceas a shader of the specified- typeand adds it to this shader program. Returns- trueif compilation was successful, false otherwise. The compilation errors and warnings will be made available via- log().- This function is intended to be a short-cut for quickly adding vertex and fragment shaders to a shader program without creating an instance of - QOpenGLShaderfirst.- addShaderFromSourceCode(type, source)
- Parameters:
- type – Combination of - ShaderTypeBit
- source – str 
 
- Return type:
- bool 
 
 - Compiles - sourceas a shader of the specified- typeand adds it to this shader program. Returns- trueif compilation was successful, false otherwise. The compilation errors and warnings will be made available via- log().- This function is intended to be a short-cut for quickly adding vertex and fragment shaders to a shader program without creating an instance of - QOpenGLShaderfirst.- addShaderFromSourceFile(type, fileName)¶
- Parameters:
- type – Combination of - ShaderTypeBit
- fileName – str 
 
- Return type:
- bool 
 
 - Compiles the contents of - fileNameas a shader of the specified- typeand adds it to this shader program. Returns- trueif compilation was successful, false otherwise. The compilation errors and warnings will be made available via- log().- This function is intended to be a short-cut for quickly adding vertex and fragment shaders to a shader program without creating an instance of - QOpenGLShaderfirst.- See also - attributeLocation(name)¶
- Parameters:
- name – - QByteArray
- Return type:
- int 
 
 - This is an overloaded function. - Returns the location of the attribute - namewithin this shader program’s parameter list. Returns -1 if- nameis not a valid attribute for this shader program.- See also - attributeLocation(name)
- Parameters:
- name – str 
- Return type:
- int 
 
 - This is an overloaded function. - Returns the location of the attribute - namewithin this shader program’s parameter list. Returns -1 if- nameis not a valid attribute for this shader program.- See also - attributeLocation(name)
- Parameters:
- name – str 
- Return type:
- int 
 
 - Returns the location of the attribute - namewithin this shader program’s parameter list. Returns -1 if- nameis not a valid attribute for this shader program.- See also - bind()¶
- Return type:
- bool 
 
 - Binds this shader program to the active QOpenGLContext and makes it the current shader program. Any previously bound shader program is released. This is equivalent to calling - glUseProgram()on- programId(). Returns- trueif the program was successfully bound; false otherwise. If the shader program has not yet been linked, or it needs to be re-linked, this function will call- link().- bindAttributeLocation(name, location)¶
- Parameters:
- name – - QByteArray
- location – int 
 
 
 - This is an overloaded function. - Binds the attribute - nameto the specified- location. This function can be called before or after the program has been linked. Any attributes that have not been explicitly bound when the program is linked will be assigned locations automatically.- When this function is called after the program has been linked, the program will need to be relinked for the change to take effect. - See also - bindAttributeLocation(name, location)
- Parameters:
- name – str 
- location – int 
 
 
 - This is an overloaded function. - Binds the attribute - nameto the specified- location. This function can be called before or after the program has been linked. Any attributes that have not been explicitly bound when the program is linked will be assigned locations automatically.- When this function is called after the program has been linked, the program will need to be relinked for the change to take effect. - See also - bindAttributeLocation(name, location)
- Parameters:
- name – str 
- location – int 
 
 
 - Binds the attribute - nameto the specified- location. This function can be called before or after the program has been linked. Any attributes that have not been explicitly bound when the program is linked will be assigned locations automatically.- When this function is called after the program has been linked, the program will need to be relinked for the change to take effect. - See also - create()¶
- Return type:
- bool 
 
 - Requests the shader program’s id to be created immediately. Returns - trueif successful;- falseotherwise.- This function is primarily useful when combining - QOpenGLShaderProgramwith other OpenGL functions that operate directly on the shader program id, like- GL_OES_get_program_binary.- When the shader program is used normally, the shader program’s id will be created on demand. - See also - defaultInnerTessellationLevels()¶
- Return type:
- .list of float 
 
 - Returns the default inner tessellation levels to be used by the tessellation primitive generator in the event that the tessellation control shader does not output them. For more details on OpenGL and Tessellation shaders see OpenGL Tessellation Shaders. - Returns a QList of floats describing the inner tessellation levels. The vector will always have two elements but not all of them make sense for every mode of tessellation. - Note - This returns the global OpenGL state value. It is not specific to this - QOpenGLShaderPrograminstance.- Note - This function is only supported with OpenGL >= 4.0 and will not return valid results with OpenGL ES 3.2. - defaultOuterTessellationLevels()¶
- Return type:
- .list of float 
 
 - Returns the default outer tessellation levels to be used by the tessellation primitive generator in the event that the tessellation control shader does not output them. For more details on OpenGL and Tessellation shaders see OpenGL Tessellation Shaders. - Returns a QList of floats describing the outer tessellation levels. The vector will always have four elements but not all of them make sense for every mode of tessellation. - Note - This returns the global OpenGL state value. It is not specific to this - QOpenGLShaderPrograminstance.- Note - This function is only supported with OpenGL >= 4.0 and will not return valid results with OpenGL ES 3.2. - disableAttributeArray(name)¶
- Parameters:
- name – str 
 
 - This is an overloaded function. - Disables the vertex array called - namein this shader program that was enabled by a previous call to- enableAttributeArray().- disableAttributeArray(location)
- Parameters:
- location – int 
 
 - Disables the vertex array at - locationin this shader program that was enabled by a previous call to- enableAttributeArray().- enableAttributeArray(name)¶
- Parameters:
- name – str 
 
 - This is an overloaded function. - Enables the vertex array called - namein this shader program so that the value set by- setAttributeArray()on- namewill be used by the shader program.- enableAttributeArray(location)
- Parameters:
- location – int 
 
 - Enables the vertex array at - locationin this shader program so that the value set by- setAttributeArray()on- locationwill be used by the shader program.- static hasOpenGLShaderPrograms([context=None])¶
- Parameters:
- context – - QOpenGLContext
- Return type:
- bool 
 
 - Returns - trueif shader programs written in the OpenGL Shading Language (GLSL) are supported on this system; false otherwise.- The - contextis used to resolve the GLSL extensions. If- contextis- None, then QOpenGLContext::currentContext() is used.- isLinked()¶
- Return type:
- bool 
 
 - Returns - trueif this shader program has been linked; false otherwise.- See also - link()¶
- Return type:
- bool 
 
 - Links together the shaders that were added to this program with - addShader(). Returns- trueif the link was successful or false otherwise. If the link failed, the error messages can be retrieved with- log().- Subclasses can override this function to initialize attributes and uniform variables for use in specific shader programs. - If the shader program was already linked, calling this function again will force it to be re-linked. - When shaders were added to this program via - addCacheableShaderFromSourceCode()or- addCacheableShaderFromSourceFile(), program binaries are supported, and a cached binary is available on disk, actual compilation and linking are skipped. Instead, link() will initialize the program with the binary blob via glProgramBinary(). If there is no cached version of the program or it was generated with a different driver version, the shaders will be compiled from source and the program will get linked normally. This allows seamless upgrading of the graphics drivers, without having to worry about potentially incompatible binary formats.- See also - log()¶
- Return type:
- str 
 
 - Returns the errors and warnings that occurred during the last - link()or- addShader()with explicitly specified source code.- See also - maxGeometryOutputVertices()¶
- Return type:
- int 
 
 - Returns the hardware limit for how many vertices a geometry shader can output. - patchVertexCount()¶
- Return type:
- int 
 
 - Returns the number of vertices per-patch to be used when rendering. - Note - This returns the global OpenGL state value. It is not specific to this - QOpenGLShaderPrograminstance.- See also - programId()¶
- Return type:
- int 
 
 - Returns the OpenGL identifier associated with this shader program. - See also - release()¶
 - Releases the active shader program from the current QOpenGLContext. This is equivalent to calling - glUseProgram(0).- See also - removeAllShaders()¶
 - Removes all of the shaders that were added to this program previously. The - QOpenGLShaderobjects for the shaders will not be deleted if they were constructed externally.- QOpenGLShaderobjects that are constructed internally by- QOpenGLShaderProgramwill be deleted.- See also - removeShader(shader)¶
- Parameters:
- shader – - QOpenGLShader
 
 - Removes - shaderfrom this shader program. The object is not deleted.- The shader program must be valid in the current QOpenGLContext. - See also - setAttributeArray(name, values, tupleSize[, stride=0])¶
- Parameters:
- name – str 
- values – float 
- tupleSize – int 
- stride – int 
 
 
 - setAttributeArray(location, values, tupleSize[, stride=0])
- Parameters:
- location – int 
- values – float 
- tupleSize – int 
- stride – int 
 
 
 - setAttributeArray(name, type, values, tupleSize[, stride=0])
- Parameters:
- name – str 
- type – int 
- values – - void
- tupleSize – int 
- stride – int 
 
 
 - setAttributeArray(location, type, values, tupleSize[, stride=0])
- Parameters:
- location – int 
- type – int 
- values – - void
- tupleSize – int 
- stride – int 
 
 
 - setAttributeBuffer(name, type, offset, tupleSize[, stride=0])¶
- Parameters:
- name – str 
- type – int 
- offset – int 
- tupleSize – int 
- stride – int 
 
 
 - setAttributeBuffer(location, type, offset, tupleSize[, stride=0])
- Parameters:
- location – int 
- type – int 
- offset – int 
- tupleSize – int 
- stride – int 
 
 
 - This is an overloaded function. - Sets the attribute called - namein the current context to- value.- See also - setAttributeValue(name, value)
- Parameters:
- name – str 
- value – - QVector2D
 
 
 - This is an overloaded function. - Sets the attribute called - namein the current context to- value.- See also - setAttributeValue(name, value)
- Parameters:
- name – str 
- value – - QVector3D
 
 
 - This is an overloaded function. - Sets the attribute called - namein the current context to- value.- See also - setAttributeValue(name, value)
- Parameters:
- name – str 
- value – - QVector4D
 
 
 - This is an overloaded function. - Sets the attribute called - namein the current context to- value.- See also - setAttributeValue(name, value)
- Parameters:
- name – str 
- value – float 
 
 
 - setAttributeValue(location, value)
- Parameters:
- location – int 
- value – - QColor
 
 
 - Sets the attribute at - locationin the current context to- value.- See also - setAttributeValue(location, value)
- Parameters:
- location – int 
- value – - QVector2D
 
 
 - Sets the attribute at - locationin the current context to- value.- See also - setAttributeValue(location, value)
- Parameters:
- location – int 
- value – - QVector3D
 
 
 - Sets the attribute at - locationin the current context to- value.- See also - setAttributeValue(location, value)
- Parameters:
- location – int 
- value – - QVector4D
 
 
 - Sets the attribute at - locationin the current context to- value.- See also - setAttributeValue(location, value)
- Parameters:
- location – int 
- value – float 
 
 
 - setAttributeValue(name, x, y)
- Parameters:
- name – str 
- x – float 
- y – float 
 
 
 - setAttributeValue(location, x, y)
- Parameters:
- location – int 
- x – float 
- y – float 
 
 
 - setAttributeValue(name, values, columns, rows)
- Parameters:
- name – str 
- values – float 
- columns – int 
- rows – int 
 
 
 - setAttributeValue(name, x, y, z)
- Parameters:
- name – str 
- x – float 
- y – float 
- z – float 
 
 
 - setAttributeValue(location, values, columns, rows)
- Parameters:
- location – int 
- values – float 
- columns – int 
- rows – int 
 
 
 - setAttributeValue(location, x, y, z)
- Parameters:
- location – int 
- x – float 
- y – float 
- z – float 
 
 
 - setAttributeValue(name, x, y, z, w)
- Parameters:
- name – str 
- x – float 
- y – float 
- z – float 
- w – float 
 
 
 - setAttributeValue(location, x, y, z, w)
- Parameters:
- location – int 
- x – float 
- y – float 
- z – float 
- w – float 
 
 
 - setDefaultInnerTessellationLevels(levels)¶
- Parameters:
- levels – .list of float 
 
 - Sets the default outer tessellation levels to be used by the tessellation primitive generator in the event that the tessellation control shader does not output them to - levels. For more details on OpenGL and Tessellation shaders see OpenGL Tessellation Shaders.- The - levelsargument should be a QList consisting of 2 floats. Not all of the values make sense for all tessellation modes. If you specify a vector with fewer than 2 elements, the remaining elements will be given a default value of 1.- Note - This modifies global OpenGL state and is not specific to this - QOpenGLShaderPrograminstance. You should call this in your render function when needed, as- QOpenGLShaderProgramwill not apply this for you. This is purely a convenience function.- Note - This function is only available with OpenGL >= 4.0 and is not supported with OpenGL ES 3.2. - setDefaultOuterTessellationLevels(levels)¶
- Parameters:
- levels – .list of float 
 
 - Sets the default outer tessellation levels to be used by the tessellation primitive generator in the event that the tessellation control shader does not output them to - levels. For more details on OpenGL and Tessellation shaders see OpenGL Tessellation Shaders.- The - levelsargument should be a QList consisting of 4 floats. Not all of the values make sense for all tessellation modes. If you specify a vector with fewer than 4 elements, the remaining elements will be given a default value of 1.- Note - This modifies global OpenGL state and is not specific to this - QOpenGLShaderPrograminstance. You should call this in your render function when needed, as- QOpenGLShaderProgramwill not apply this for you. This is purely a convenience function.- Note - This function is only available with OpenGL >= 4.0 and is not supported with OpenGL ES 3.2. - setPatchVertexCount(count)¶
- Parameters:
- count – int 
 
 - Use this function to specify to OpenGL the number of vertices in a patch to - count. A patch is a custom OpenGL primitive whose interpretation is entirely defined by the tessellation shader stages. Therefore, calling this function only makes sense when using a- QOpenGLShaderProgramcontaining tessellation stage shaders. When using OpenGL tessellation, the only primitive that can be rendered with- glDraw*()functions is- GL_PATCHES.- This is equivalent to calling glPatchParameteri(GL_PATCH_VERTICES, count). - Note - This modifies global OpenGL state and is not specific to this - QOpenGLShaderPrograminstance. You should call this in your render function when needed, as- QOpenGLShaderProgramwill not apply this for you. This is purely a convenience function.- See also - This is an overloaded function. - Sets the uniform variable called - namein the current context to the red, green, blue, and alpha components of- color.- See also - setUniformValue(name, value)
- Parameters:
- name – str 
- value – - QMatrix2x2
 
 
 - This is an overloaded function. - Sets the uniform variable called - namein the current context to a 2x2 matrix- value.- See also - setUniformValue(name, value)
- Parameters:
- name – str 
- value – - QMatrix2x3
 
 
 - This is an overloaded function. - Sets the uniform variable called - namein the current context to a 2x3 matrix- value.- Note - This function is not aware of non square matrix support, that is, GLSL types like mat2x3, that is present in modern OpenGL versions. Instead, it treats the uniform as an array of vec3. - See also - setUniformValue(name, value)
- Parameters:
- name – str 
- value – - QMatrix2x4
 
 
 - This is an overloaded function. - Sets the uniform variable called - namein the current context to a 2x4 matrix- value.- Note - This function is not aware of non square matrix support, that is, GLSL types like mat2x4, that is present in modern OpenGL versions. Instead, it treats the uniform as an array of vec4. - See also - setUniformValue(name, value)
- Parameters:
- name – str 
- value – - QMatrix3x2
 
 
 - This is an overloaded function. - Sets the uniform variable called - namein the current context to a 3x2 matrix- value.- Note - This function is not aware of non square matrix support, that is, GLSL types like mat3x2, that is present in modern OpenGL versions. Instead, it treats the uniform as an array of vec2. - See also - setUniformValue(name, value)
- Parameters:
- name – str 
- value – - QMatrix3x3
 
 
 - This is an overloaded function. - Sets the uniform variable called - namein the current context to a 3x3 matrix- value.- See also - setUniformValue(name, value)
- Parameters:
- name – str 
- value – - QMatrix3x4
 
 
 - This is an overloaded function. - Sets the uniform variable called - namein the current context to a 3x4 matrix- value.- Note - This function is not aware of non square matrix support, that is, GLSL types like mat3x4, that is present in modern OpenGL versions. Instead, it treats the uniform as an array of vec4. - See also - setUniformValue(name, value)
- Parameters:
- name – str 
- value – - QMatrix4x2
 
 
 - This is an overloaded function. - Sets the uniform variable called - namein the current context to a 4x2 matrix- value.- Note - This function is not aware of non square matrix support, that is, GLSL types like mat4x2, that is present in modern OpenGL versions. Instead, it treats the uniform as an array of vec2. - See also - setUniformValue(name, value)
- Parameters:
- name – str 
- value – - QMatrix4x3
 
 
 - This is an overloaded function. - Sets the uniform variable called - namein the current context to a 4x3 matrix- value.- Note - This function is not aware of non square matrix support, that is, GLSL types like mat4x3, that is present in modern OpenGL versions. Instead, it treats the uniform as an array of vec3. - See also - setUniformValue(name, value)
- Parameters:
- name – str 
- value – - QMatrix4x4
 
 
 - This is an overloaded function. - Sets the uniform variable called - namein the current context to a 4x4 matrix- value.- See also - setUniformValue(name, point)
- Parameters:
- name – str 
- point – - QPoint
 
 
 - This is an overloaded function. - Sets the uniform variable associated with - namein the current context to the x and y coordinates of- point.- See also - setUniformValue(name, point)
- Parameters:
- name – str 
- point – - QPointF
 
 
 - This is an overloaded function. - Sets the uniform variable associated with - namein the current context to the x and y coordinates of- point.- See also - setUniformValue(name, size)
- Parameters:
- name – str 
- size – - QSize
 
 
 - This is an overloaded function. - Sets the uniform variable associated with - namein the current context to the width and height of the given- size.- See also - setUniformValue(name, size)
- Parameters:
- name – str 
- size – - QSizeF
 
 
 - This is an overloaded function. - Sets the uniform variable associated with - namein the current context to the width and height of the given- size.- See also - setUniformValue(name, value)
- Parameters:
- name – str 
- value – - QTransform
 
 
 - This is an overloaded function. - Sets the uniform variable called - namein the current context to a 3x3 transformation matrix- valuethat is specified as a QTransform value.- To set a QTransform value as a 4x4 matrix in a shader, use - setUniformValue(name, QMatrix4x4(value)).- setUniformValue(name, value)
- Parameters:
- name – str 
- value – - QVector2D
 
 
 - This is an overloaded function. - Sets the uniform variable called - namein the current context to- value.- See also - setUniformValue(name, value)
- Parameters:
- name – str 
- value – - QVector3D
 
 
 - This is an overloaded function. - Sets the uniform variable called - namein the current context to- value.- See also - setUniformValue(name, value)
- Parameters:
- name – str 
- value – - QVector4D
 
 
 - This is an overloaded function. - Sets the uniform variable called - namein the current context to- value.- See also - setUniformValue(name, value)
- Parameters:
- name – str 
- value – - float[][]
 
 
 - setUniformValue(name, value)
- Parameters:
- name – str 
- value – - float[][]
 
 
 - setUniformValue(name, value)
- Parameters:
- name – str 
- value – - float[][]
 
 
 - setUniformValue(location, color)
- Parameters:
- location – int 
- color – - QColor
 
 
 - Sets the uniform variable at - locationin the current context to the red, green, blue, and alpha components of- color.- See also - setUniformValue(location, value)
- Parameters:
- location – int 
- value – - QMatrix2x2
 
 
 - Sets the uniform variable at - locationin the current context to a 2x2 matrix- value.- See also - setUniformValue(location, value)
- Parameters:
- location – int 
- value – - QMatrix2x3
 
 
 - Sets the uniform variable at - locationin the current context to a 2x3 matrix- value.- Note - This function is not aware of non square matrix support, that is, GLSL types like mat2x3, that is present in modern OpenGL versions. Instead, it treats the uniform as an array of vec3. - See also - setUniformValue(location, value)
- Parameters:
- location – int 
- value – - QMatrix2x4
 
 
 - Sets the uniform variable at - locationin the current context to a 2x4 matrix- value.- Note - This function is not aware of non square matrix support, that is, GLSL types like mat2x4, that is present in modern OpenGL versions. Instead, it treats the uniform as an array of vec4. - See also - setUniformValue(location, value)
- Parameters:
- location – int 
- value – - QMatrix3x2
 
 
 - Sets the uniform variable at - locationin the current context to a 3x2 matrix- value.- Note - This function is not aware of non square matrix support, that is, GLSL types like mat3x2, that is present in modern OpenGL versions. Instead, it treats the uniform as an array of vec2. - See also - setUniformValue(location, value)
- Parameters:
- location – int 
- value – - QMatrix3x3
 
 
 - Sets the uniform variable at - locationin the current context to a 3x3 matrix- value.- See also - setUniformValue(location, value)
- Parameters:
- location – int 
- value – - QMatrix3x4
 
 
 - Sets the uniform variable at - locationin the current context to a 3x4 matrix- value.- Note - This function is not aware of non square matrix support, that is, GLSL types like mat3x4, that is present in modern OpenGL versions. Instead, it treats the uniform as an array of vec4. - See also - setUniformValue(location, value)
- Parameters:
- location – int 
- value – - QMatrix4x2
 
 
 - Sets the uniform variable at - locationin the current context to a 4x2 matrix- value.- Note - This function is not aware of non square matrix support, that is, GLSL types like mat4x2, that is present in modern OpenGL versions. Instead, it treats the uniform as an array of vec2. - See also - setUniformValue(location, value)
- Parameters:
- location – int 
- value – - QMatrix4x3
 
 
 - Sets the uniform variable at - locationin the current context to a 4x3 matrix- value.- Note - This function is not aware of non square matrix support, that is, GLSL types like mat4x3, that is present in modern OpenGL versions. Instead, it treats the uniform as an array of vec3. - See also - setUniformValue(location, value)
- Parameters:
- location – int 
- value – - QMatrix4x4
 
 
 - Sets the uniform variable at - locationin the current context to a 4x4 matrix- value.- See also - setUniformValue(location, point)
- Parameters:
- location – int 
- point – - QPoint
 
 
 - Sets the uniform variable at - locationin the current context to the x and y coordinates of- point.- See also - setUniformValue(location, point)
- Parameters:
- location – int 
- point – - QPointF
 
 
 - Sets the uniform variable at - locationin the current context to the x and y coordinates of- point.- See also - setUniformValue(location, size)
- Parameters:
- location – int 
- size – - QSize
 
 
 - Sets the uniform variable at - locationin the current context to the width and height of the given- size.- See also - setUniformValue(location, size)
- Parameters:
- location – int 
- size – - QSizeF
 
 
 - Sets the uniform variable at - locationin the current context to the width and height of the given- size.- See also - setUniformValue(location, value)
- Parameters:
- location – int 
- value – - QTransform
 
 
 - Sets the uniform variable at - locationin the current context to a 3x3 transformation matrix- valuethat is specified as a QTransform value.- To set a QTransform value as a 4x4 matrix in a shader, use - setUniformValue(location, QMatrix4x4(value)).- setUniformValue(location, value)
- Parameters:
- location – int 
- value – - QVector2D
 
 
 - Sets the uniform variable at - locationin the current context to- value.- See also - setUniformValue(location, value)
- Parameters:
- location – int 
- value – - QVector3D
 
 
 - Sets the uniform variable at - locationin the current context to- value.- See also - setUniformValue(location, value)
- Parameters:
- location – int 
- value – - QVector4D
 
 
 - Sets the uniform variable at - locationin the current context to- value.- See also - setUniformValue(location, value)
- Parameters:
- location – int 
- value – - float[][]
 
 
 - setUniformValue(location, value)
- Parameters:
- location – int 
- value – - float[][]
 
 
 - setUniformValue(location, value)
- Parameters:
- location – int 
- value – - float[][]
 
 
 - setUniformValue(location, value)
- Parameters:
- location – int 
- value – float 
 
 
 - setUniformValue(location, value)
- Parameters:
- location – int 
- value – int 
 
 
 - setUniformValue(location, value)
- Parameters:
- location – int 
- value – int 
 
 
 - setUniformValue(name, x, y)
- Parameters:
- name – str 
- x – float 
- y – float 
 
 
 - setUniformValue(location, x, y)
- Parameters:
- location – int 
- x – float 
- y – float 
 
 
 - setUniformValue(name, x, y, z)
- Parameters:
- name – str 
- x – float 
- y – float 
- z – float 
 
 
 - setUniformValue(location, x, y, z)
- Parameters:
- location – int 
- x – float 
- y – float 
- z – float 
 
 
 - setUniformValue(name, x, y, z, w)
- Parameters:
- name – str 
- x – float 
- y – float 
- z – float 
- w – float 
 
 
 - setUniformValue(location, x, y, z, w)
- Parameters:
- location – int 
- x – float 
- y – float 
- z – float 
- w – float 
 
 
 - setUniformValue1f(arg__1, arg__2)¶
- Parameters:
- arg__1 – str 
- arg__2 – float 
 
 
 - setUniformValue1f(arg__1, arg__2)
- Parameters:
- arg__1 – int 
- arg__2 – float 
 
 
 - setUniformValue1i(arg__1, arg__2)¶
- Parameters:
- arg__1 – str 
- arg__2 – int 
 
 
 - setUniformValue1i(arg__1, arg__2)
- Parameters:
- arg__1 – int 
- arg__2 – int 
 
 
 - setUniformValueArray(name, values, count)¶
- Parameters:
- name – str 
- values – int 
- count – int 
 
 
 - setUniformValueArray(name, values, count)
- Parameters:
- name – str 
- values – - unsigned int
- count – int 
 
 
 - setUniformValueArray(location, values, count)
- Parameters:
- location – int 
- values – int 
- count – int 
 
 
 - setUniformValueArray(location, values, count)
- Parameters:
- location – int 
- values – - unsigned int
- count – int 
 
 
 - setUniformValueArray(name, values, count, tupleSize)
- Parameters:
- name – str 
- values – float 
- count – int 
- tupleSize – int 
 
 
 - setUniformValueArray(location, values, count, tupleSize)
- Parameters:
- location – int 
- values – float 
- count – int 
- tupleSize – int 
 
 
 - shaders()¶
- Return type:
- .list of QOpenGLShader 
 
 - Returns a list of all shaders that have been added to this shader program using - addShader().- See also - uniformLocation(name)¶
- Parameters:
- name – - QByteArray
- Return type:
- int 
 
 - This is an overloaded function. - Returns the location of the uniform variable - namewithin this shader program’s parameter list. Returns -1 if- nameis not a valid uniform variable for this shader program.- See also - uniformLocation(name)
- Parameters:
- name – str 
- Return type:
- int 
 
 - This is an overloaded function. - Returns the location of the uniform variable - namewithin this shader program’s parameter list. Returns -1 if- nameis not a valid uniform variable for this shader program.- See also - uniformLocation(name)
- Parameters:
- name – str 
- Return type:
- int 
 
 - Returns the location of the uniform variable - namewithin this shader program’s parameter list. Returns -1 if- nameis not a valid uniform variable for this shader program.- See also