QOpenGLShaderProgram¶
The
QOpenGLShaderProgramclass allows OpenGL shader programs to be linked and used. More…

New in version 5.0.
Synopsis¶
Functions¶
def
addCacheableShaderFromSourceCode(type, source)def
addCacheableShaderFromSourceCode(type, source)def
addCacheableShaderFromSourceCode(type, source)def
addCacheableShaderFromSourceFile(type, fileName)def
addShader(shader)def
addShaderFromSourceCode(type, source)def
addShaderFromSourceCode(type, source)def
addShaderFromSourceCode(type, source)def
addShaderFromSourceFile(type, fileName)def
attributeLocation(name)def
attributeLocation(name)def
attributeLocation(name)def
bind()def
bindAttributeLocation(name, location)def
bindAttributeLocation(name, location)def
bindAttributeLocation(name, location)def
create()def
disableAttributeArray(location)def
disableAttributeArray(name)def
enableAttributeArray(location)def
enableAttributeArray(name)def
isLinked()def
log()def
maxGeometryOutputVertices()def
patchVertexCount()def
programId()def
release()def
removeAllShaders()def
removeShader(shader)def
setAttributeArray(location, type, values, tupleSize[, stride=0])def
setAttributeArray(location, values, tupleSize[, stride=0])def
setAttributeArray(name, type, values, tupleSize[, stride=0])def
setAttributeArray(name, values, tupleSize[, stride=0])def
setAttributeBuffer(location, type, offset, tupleSize[, stride=0])def
setAttributeBuffer(name, type, offset, tupleSize[, stride=0])def
setAttributeValue(location, value)def
setAttributeValue(location, value)def
setAttributeValue(location, value)def
setAttributeValue(location, value)def
setAttributeValue(location, value)def
setAttributeValue(location, values, columns, rows)def
setAttributeValue(location, x, y)def
setAttributeValue(location, x, y, z)def
setAttributeValue(location, x, y, z, w)def
setAttributeValue(name, value)def
setAttributeValue(name, value)def
setAttributeValue(name, value)def
setAttributeValue(name, value)def
setAttributeValue(name, value)def
setAttributeValue(name, values, columns, rows)def
setAttributeValue(name, x, y)def
setAttributeValue(name, x, y, z)def
setAttributeValue(name, x, y, z, w)def
setDefaultInnerTessellationLevels(levels)def
setDefaultOuterTessellationLevels(levels)def
setPatchVertexCount(count)def
setUniformValue1f(arg__1, arg__2)def
setUniformValue1f(arg__1, arg__2)def
setUniformValue1i(arg__1, arg__2)def
setUniformValue1i(arg__1, arg__2)def
setUniformValue(location, color)def
setUniformValue(location, point)def
setUniformValue(location, point)def
setUniformValue(location, size)def
setUniformValue(location, size)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, value)def
setUniformValue(location, x, y)def
setUniformValue(location, x, y, z)def
setUniformValue(location, x, y, z, w)def
setUniformValue(name, color)def
setUniformValue(name, point)def
setUniformValue(name, point)def
setUniformValue(name, size)def
setUniformValue(name, size)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, value)def
setUniformValue(name, x, y)def
setUniformValue(name, x, y, z)def
setUniformValue(name, x, y, z, w)def
setUniformValueArray(location, values, count)def
setUniformValueArray(location, values, count)def
setUniformValueArray(location, values, count, tupleSize)def
setUniformValueArray(name, values, count)def
setUniformValueArray(name, values, count)def
setUniformValueArray(name, values, count, tupleSize)def
shaders()def
uniformLocation(name)def
uniformLocation(name)def
uniformLocation(name)
Virtual functions¶
def
link()
Static functions¶
def
hasOpenGLShaderPrograms([context=None])
Detailed Description¶
Introduction¶
This class supports shader programs written in the OpenGL Shading Language (GLSL) and in the OpenGL/ES Shading Language (GLSL/ES).
QOpenGLShaderandQOpenGLShaderProgramshelter 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 currentQOpenGLContextby callingbind():QOpenGLShader shader(QOpenGLShader::Vertex); shader.compileSourceCode(code); QOpenGLShaderProgram program(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 qualifiershighp,mediump, andlowp.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 lowpThis 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(); int vertexLocation = program.attributeLocation("vertex"); int matrixLocation = program.uniformLocation("matrix"); int colorLocation = program.uniformLocation("color");With the above shader program active, we can draw a green triangle as follows:
static GLfloat const triangleVertices[] = { 60.0f, 10.0f, 0.0f, 110.0f, 110.0f, 0.0f, 10.0f, 110.0f, 0.0f }; QColor color(0, 255, 0, 255); QMatrix4x4 pmvMatrix; 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 fromshaderId(). TheQOpenGLShaderinstance containing the binary can then be added to the shader program withaddShader()and linked in the usual fashion withlink().Binary programs may be specified using
glProgramBinaryOES()on the return value fromprogramId(). Then the application should calllink(), 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 thecreate()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()andaddCacheableShaderFromSourceFile(). With an OpenGL ES 3.x context or support forGL_ARB_get_program_binary, this will transparently cache program binaries underGenericCacheLocationorCacheLocation. 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
- class PySide2.QtGui.QOpenGLShaderProgram([parent=None])¶
- param parent:
Constructs a new shader program and attaches it to
parent. The program will be invalid untiladdShader()is called.The shader program will be associated with the current
QOpenGLContext.See also
- PySide2.QtGui.QOpenGLShaderProgram.addCacheableShaderFromSourceCode(type, source)¶
- Parameters:
type –
ShaderTypesource –
PySide2.QtCore.QByteArray
- Return type:
bool
- PySide2.QtGui.QOpenGLShaderProgram.addCacheableShaderFromSourceCode(type, source)
- Parameters:
type –
ShaderTypesource – str
- Return type:
bool
Registers the shader of the specified
typeandsourceto this program. UnlikeaddShaderFromSourceCode(), this function does not perform compilation. Compilation is deferred tolink(), and may not happen at all, becauselink()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
AA_DisableShaderDiskCachefor example, or the OpenGL context has no support for context binaries, calling this function is equivalent toaddShaderFromSourceCode().
- PySide2.QtGui.QOpenGLShaderProgram.addCacheableShaderFromSourceCode(type, source)
- Parameters:
type –
ShaderTypesource – str
- Return type:
bool
- PySide2.QtGui.QOpenGLShaderProgram.addCacheableShaderFromSourceFile(type, fileName)¶
- Parameters:
type –
ShaderTypefileName – str
- Return type:
bool
Registers the shader of the specified
typeandfileNameto this program. UnlikeaddShaderFromSourceFile(), this function does not perform compilation. Compilation is deferred tolink(), and may not happen at all, becauselink()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
AA_DisableShaderDiskCachefor example, or the OpenGL context has no support for context binaries, calling this function is equivalent toaddShaderFromSourceFile().
- PySide2.QtGui.QOpenGLShaderProgram.addShader(shader)¶
- Parameters:
shader –
PySide2.QtGui.QOpenGLShader- Return type:
bool
Adds a compiled
shaderto this shader program. Returnstrueif the shader could be added, or false otherwise.Ownership of the
shaderobject remains with the caller. It will not be deleted when thisQOpenGLShaderPrograminstance is deleted. This allows the caller to add the same shader to multiple shader programs.
- PySide2.QtGui.QOpenGLShaderProgram.addShaderFromSourceCode(type, source)¶
- Parameters:
type –
ShaderTypesource –
PySide2.QtCore.QByteArray
- Return type:
bool
- PySide2.QtGui.QOpenGLShaderProgram.addShaderFromSourceCode(type, source)
- Parameters:
type –
ShaderTypesource – str
- Return type:
bool
- PySide2.QtGui.QOpenGLShaderProgram.addShaderFromSourceCode(type, source)
- Parameters:
type –
ShaderTypesource – str
- Return type:
bool
Compiles
sourceas a shader of the specifiedtypeand adds it to this shader program. Returnstrueif compilation was successful, false otherwise. The compilation errors and warnings will be made available vialog().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.
- PySide2.QtGui.QOpenGLShaderProgram.addShaderFromSourceFile(type, fileName)¶
- Parameters:
type –
ShaderTypefileName – str
- Return type:
bool
Compiles the contents of
fileNameas a shader of the specifiedtypeand adds it to this shader program. Returnstrueif compilation was successful, false otherwise. The compilation errors and warnings will be made available vialog().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
- PySide2.QtGui.QOpenGLShaderProgram.attributeLocation(name)¶
- Parameters:
name –
PySide2.QtCore.QByteArray- Return type:
int
- PySide2.QtGui.QOpenGLShaderProgram.attributeLocation(name)
- Parameters:
name – str
- Return type:
int
- PySide2.QtGui.QOpenGLShaderProgram.attributeLocation(name)
- Parameters:
name – str
- Return type:
int
Returns the location of the attribute
namewithin this shader program’s parameter list. Returns -1 ifnameis not a valid attribute for this shader program.See also
- PySide2.QtGui.QOpenGLShaderProgram.bind()¶
- Return type:
bool
Binds this shader program to the active
QOpenGLContextand makes it the current shader program. Any previously bound shader program is released. This is equivalent to callingglUseProgram()onprogramId(). Returnstrueif 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 calllink().
- PySide2.QtGui.QOpenGLShaderProgram.bindAttributeLocation(name, location)¶
- Parameters:
name – str
location – int
- PySide2.QtGui.QOpenGLShaderProgram.bindAttributeLocation(name, location)
- Parameters:
name – str
location – int
Binds the attribute
nameto the specifiedlocation. 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
- PySide2.QtGui.QOpenGLShaderProgram.bindAttributeLocation(name, location)
- Parameters:
name –
PySide2.QtCore.QByteArraylocation – int
- PySide2.QtGui.QOpenGLShaderProgram.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, likeGL_OES_get_program_binary.When the shader program is used normally, the shader program’s id will be created on demand.
See also
- PySide2.QtGui.QOpenGLShaderProgram.defaultInnerTessellationLevels()¶
- Return type:
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
QVectorof 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.
- PySide2.QtGui.QOpenGLShaderProgram.defaultOuterTessellationLevels()¶
- Return type:
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
QVectorof 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.
- PySide2.QtGui.QOpenGLShaderProgram.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 toenableAttributeArray().
- PySide2.QtGui.QOpenGLShaderProgram.disableAttributeArray(location)
- Parameters:
location – int
Disables the vertex array at
locationin this shader program that was enabled by a previous call toenableAttributeArray().
- PySide2.QtGui.QOpenGLShaderProgram.enableAttributeArray(location)¶
- Parameters:
location – int
Enables the vertex array at
locationin this shader program so that the value set bysetAttributeArray()onlocationwill be used by the shader program.
- PySide2.QtGui.QOpenGLShaderProgram.enableAttributeArray(name)
- Parameters:
name – str
This is an overloaded function.
Enables the vertex array called
namein this shader program so that the value set bysetAttributeArray()onnamewill be used by the shader program.
- static PySide2.QtGui.QOpenGLShaderProgram.hasOpenGLShaderPrograms([context=None])¶
- Parameters:
context –
PySide2.QtGui.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. IfcontextisNone, thencurrentContext()is used.
- PySide2.QtGui.QOpenGLShaderProgram.isLinked()¶
- Return type:
bool
Returns
trueif this shader program has been linked; false otherwise.See also
- PySide2.QtGui.QOpenGLShaderProgram.link()¶
- Return type:
bool
Links together the shaders that were added to this program with
addShader(). Returnstrueif the link was successful or false otherwise. If the link failed, the error messages can be retrieved withlog().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()oraddCacheableShaderFromSourceFile(), program binaries are supported, and a cached binary is available on disk, actual compilation and linking are skipped. Instead, 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
- PySide2.QtGui.QOpenGLShaderProgram.log()¶
- Return type:
str
Returns the errors and warnings that occurred during the last
link()oraddShader()with explicitly specified source code.See also
- PySide2.QtGui.QOpenGLShaderProgram.maxGeometryOutputVertices()¶
- Return type:
int
Returns the hardware limit for how many vertices a geometry shader can output.
- PySide2.QtGui.QOpenGLShaderProgram.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
- PySide2.QtGui.QOpenGLShaderProgram.programId()¶
- Return type:
GLuint
Returns the OpenGL identifier associated with this shader program.
See also
- PySide2.QtGui.QOpenGLShaderProgram.release()¶
Releases the active shader program from the current
QOpenGLContext. This is equivalent to callingglUseProgram(0).See also
- PySide2.QtGui.QOpenGLShaderProgram.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 byQOpenGLShaderProgramwill be deleted.See also
- PySide2.QtGui.QOpenGLShaderProgram.removeShader(shader)¶
- Parameters:
shader –
PySide2.QtGui.QOpenGLShader
Removes
shaderfrom this shader program. The object is not deleted.The shader program must be valid in the current
QOpenGLContext.See also
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeArray(name, type, values, tupleSize[, stride=0])¶
- Parameters:
name – str
type –
GLenumvalues –
voidtupleSize – int
stride – int
This is an overloaded function.
Sets an array of vertex
valueson the attribute callednamein this shader program. Thestrideindicates the number of bytes between vertices. A defaultstridevalue of zero indicates that the vertices are densely packed invalues.The
typeindicates the type of elements in thevaluesarray, usuallyGL_FLOAT,GL_UNSIGNED_BYTE, etc. ThetupleSizeindicates the number of components per vertex: 1, 2, 3, or 4.The array will become active when
enableAttributeArray()is called on thename. Otherwise the value specified withsetAttributeValue()fornamewill be used.The
setAttributeBuffer()function can be used to set the attribute array to an offset within a vertex buffer.
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeArray(name, values, tupleSize[, stride=0])
- Parameters:
name – str
values –
GLfloattupleSize – int
stride – int
This is an overloaded function.
Sets an array of vertex
valueson the attribute callednamein this shader program. ThetupleSizeindicates the number of components per vertex (1, 2, 3, or 4), and thestrideindicates the number of bytes between vertices. A defaultstridevalue of zero indicates that the vertices are densely packed invalues.The array will become active when
enableAttributeArray()is called onname. Otherwise the value specified withsetAttributeValue()fornamewill be used.
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeArray(location, type, values, tupleSize[, stride=0])
- Parameters:
location – int
type –
GLenumvalues –
voidtupleSize – int
stride – int
Sets an array of vertex
valueson the attribute atlocationin this shader program. Thestrideindicates the number of bytes between vertices. A defaultstridevalue of zero indicates that the vertices are densely packed invalues.The
typeindicates the type of elements in thevaluesarray, usuallyGL_FLOAT,GL_UNSIGNED_BYTE, etc. ThetupleSizeindicates the number of components per vertex: 1, 2, 3, or 4.The array will become active when
enableAttributeArray()is called on thelocation. Otherwise the value specified withsetAttributeValue()forlocationwill be used.The
setAttributeBuffer()function can be used to set the attribute array to an offset within a vertex buffer.Note
Normalization will be enabled. If this is not desired, call glVertexAttribPointer directly through
QOpenGLFunctions.
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeArray(location, values, tupleSize[, stride=0])
- Parameters:
location – int
values –
GLfloattupleSize – int
stride – int
Sets an array of vertex
valueson the attribute atlocationin this shader program. ThetupleSizeindicates the number of components per vertex (1, 2, 3, or 4), and thestrideindicates the number of bytes between vertices. A defaultstridevalue of zero indicates that the vertices are densely packed invalues.The array will become active when
enableAttributeArray()is called on thelocation. Otherwise the value specified withsetAttributeValue()forlocationwill be used.
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeBuffer(name, type, offset, tupleSize[, stride=0])¶
- Parameters:
name – str
type –
GLenumoffset – int
tupleSize – int
stride – int
This is an overloaded function.
Sets an array of vertex values on the attribute called
namein this shader program, starting at a specificoffsetin the currently bound vertex buffer. Thestrideindicates the number of bytes between vertices. A defaultstridevalue of zero indicates that the vertices are densely packed in the value array.The
typeindicates the type of elements in the vertex value array, usuallyGL_FLOAT,GL_UNSIGNED_BYTE, etc. ThetupleSizeindicates the number of components per vertex: 1, 2, 3, or 4.The array will become active when
enableAttributeArray()is called on thename. Otherwise the value specified withsetAttributeValue()fornamewill be used.See also
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeBuffer(location, type, offset, tupleSize[, stride=0])
- Parameters:
location – int
type –
GLenumoffset – int
tupleSize – int
stride – int
Sets an array of vertex values on the attribute at
locationin this shader program, starting at a specificoffsetin the currently bound vertex buffer. Thestrideindicates the number of bytes between vertices. A defaultstridevalue of zero indicates that the vertices are densely packed in the value array.The
typeindicates the type of elements in the vertex value array, usuallyGL_FLOAT,GL_UNSIGNED_BYTE, etc. ThetupleSizeindicates the number of components per vertex: 1, 2, 3, or 4.The array will become active when
enableAttributeArray()is called on thelocation. Otherwise the value specified withsetAttributeValue()forlocationwill be used.Note
Normalization will be enabled. If this is not desired, call glVertexAttribPointer directly through
QOpenGLFunctions.See also
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(location, value)¶
- Parameters:
location – int
value –
PySide2.QtGui.QVector4D
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QVector3D
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QVector2D
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QColor
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(location, values, columns, rows)
- Parameters:
location – int
values –
GLfloatcolumns – int
rows – int
Sets the attribute at
locationin the current context to the contents ofvalues, which containscolumnselements, each consisting ofrowselements. Therowsvalue should be 1, 2, 3, or 4. This function is typically used to set matrix values and column vectors.See also
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(location, x, y, z, w)
- Parameters:
location – int
x –
GLfloaty –
GLfloatz –
GLfloatw –
GLfloat
Sets the attribute at
locationin the current context to the 4D vector (x,y,z,w).See also
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(location, x, y, z)
- Parameters:
location – int
x –
GLfloaty –
GLfloatz –
GLfloat
Sets the attribute at
locationin the current context to the 3D vector (x,y,z).See also
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QVector3D
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(location, x, y)
- Parameters:
location – int
x –
GLfloaty –
GLfloat
Sets the attribute at
locationin the current context to the 2D vector (x,y).See also
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QVector4D
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QVector2D
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QColor
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(name, values, columns, rows)
- Parameters:
name – str
values –
GLfloatcolumns – int
rows – int
This is an overloaded function.
Sets the attribute called
namein the current context to the contents ofvalues, which containscolumnselements, each consisting ofrowselements. Therowsvalue should be 1, 2, 3, or 4. This function is typically used to set matrix values and column vectors.See also
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(name, x, y, z, w)
- Parameters:
name – str
x –
GLfloaty –
GLfloatz –
GLfloatw –
GLfloat
This is an overloaded function.
Sets the attribute called
namein the current context to the 4D vector (x,y,z,w).See also
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(name, x, y, z)
- Parameters:
name – str
x –
GLfloaty –
GLfloatz –
GLfloat
This is an overloaded function.
Sets the attribute called
namein the current context to the 3D vector (x,y,z).See also
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(name, x, y)
- Parameters:
name – str
x –
GLfloaty –
GLfloat
This is an overloaded function.
Sets the attribute called
namein the current context to the 2D vector (x,y).See also
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(name, value)
- Parameters:
name – str
value –
GLfloat
This is an overloaded function.
Sets the attribute called
namein the current context tovalue.See also
- PySide2.QtGui.QOpenGLShaderProgram.setAttributeValue(location, value)
- Parameters:
location – int
value –
GLfloat
Sets the attribute at
locationin the current context tovalue.See also
- PySide2.QtGui.QOpenGLShaderProgram.setDefaultInnerTessellationLevels(levels)¶
- Parameters:
levels –
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 aQVectorconsisting 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, asQOpenGLShaderProgramwill 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.
- PySide2.QtGui.QOpenGLShaderProgram.setDefaultOuterTessellationLevels(levels)¶
- Parameters:
levels –
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 aQVectorconsisting 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, asQOpenGLShaderProgramwill 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.
- PySide2.QtGui.QOpenGLShaderProgram.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 aQOpenGLShaderProgramcontaining tessellation stage shaders. When using OpenGL tessellation, the only primitive that can be rendered withglDraw*()functions isGL_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, asQOpenGLShaderProgramwill not apply this for you. This is purely a convenience function.See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, x, y, z)¶
- Parameters:
location – int
x –
GLfloaty –
GLfloatz –
GLfloat
Sets the uniform variable at
locationin the current context to the 3D vector (x,y,z).See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, x, y)
- Parameters:
location – int
x –
GLfloaty –
GLfloat
Sets the uniform variable at
locationin the current context to the 2D vector (x,y).See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
GLfloat
Sets the uniform variable at
locationin the current context tovalue.See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, x, y, z, w)
- Parameters:
location – int
x –
GLfloaty –
GLfloatz –
GLfloatw –
GLfloat
Sets the uniform variable at
locationin the current context to the 4D vector (x,y,z,w).See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
GLint
Sets the uniform variable at
locationin the current context tovalue.See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
GLuint
Sets the uniform variable at
locationin the current context tovalue. This function should be used when setting sampler values.Note
This function is not aware of unsigned int support in modern OpenGL versions and therefore treats
valueas a GLint and calls glUniform1i.See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
GLfloat[][]
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
GLfloat[][]
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
GLfloat[][]
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, color)
- Parameters:
location – int
color –
PySide2.QtGui.QColor
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QMatrix2x2
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QMatrix2x3
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QMatrix2x4
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QMatrix3x2
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QMatrix3x3
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QMatrix3x4
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QMatrix4x2
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QMatrix4x3
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QMatrix4x4
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, point)
- Parameters:
location – int
point –
PySide2.QtCore.QPoint
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, point)
- Parameters:
location – int
point –
PySide2.QtCore.QPointF
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, size)
- Parameters:
location – int
size –
PySide2.QtCore.QSize
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, size)
- Parameters:
location – int
size –
PySide2.QtCore.QSizeF
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QTransform
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QVector2D
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QVector3D
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(location, value)
- Parameters:
location – int
value –
PySide2.QtGui.QVector4D
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QVector3D
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
GLfloat
This is an overloaded function.
Sets the uniform variable called
namein the current context tovalue.See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, x, y)
- Parameters:
name – str
x –
GLfloaty –
GLfloat
This is an overloaded function.
Sets the uniform variable called
namein the current context to the 2D vector (x,y).See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, x, y, z)
- Parameters:
name – str
x –
GLfloaty –
GLfloatz –
GLfloat
This is an overloaded function.
Sets the uniform variable called
namein the current context to the 3D vector (x,y,z).See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, x, y, z, w)
- Parameters:
name – str
x –
GLfloaty –
GLfloatz –
GLfloatw –
GLfloat
This is an overloaded function.
Sets the uniform variable called
namein the current context to the 4D vector (x,y,z,w).See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
GLint
This is an overloaded function.
Sets the uniform variable called
namein the current context tovalue.See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
GLuint
This is an overloaded function.
Sets the uniform variable called
namein the current context tovalue. This function should be used when setting sampler values.Note
This function is not aware of unsigned int support in modern OpenGL versions and therefore treats
valueas a GLint and calls glUniform1i.See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
GLfloat[][]
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
GLfloat[][]
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
GLfloat[][]
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, color)
- Parameters:
name – str
color –
PySide2.QtGui.QColor
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QMatrix2x2
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QMatrix2x3
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QMatrix2x4
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QMatrix3x3
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QMatrix3x4
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QMatrix4x2
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QMatrix4x3
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QMatrix4x4
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, point)
- Parameters:
name – str
point –
PySide2.QtCore.QPoint
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, point)
- Parameters:
name – str
point –
PySide2.QtCore.QPointF
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, size)
- Parameters:
name – str
size –
PySide2.QtCore.QSize
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, size)
- Parameters:
name – str
size –
PySide2.QtCore.QSizeF
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QTransform
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QVector2D
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QVector4D
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue(name, value)
- Parameters:
name – str
value –
PySide2.QtGui.QMatrix3x2
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue1f(arg__1, arg__2)¶
- Parameters:
arg__1 – str
arg__2 – float
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue1f(arg__1, arg__2)
- Parameters:
arg__1 – int
arg__2 – float
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue1i(arg__1, arg__2)¶
- Parameters:
arg__1 – int
arg__2 – int
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValue1i(arg__1, arg__2)
- Parameters:
arg__1 – str
arg__2 – int
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValueArray(name, values, count, tupleSize)¶
- Parameters:
name – str
values –
GLfloatcount – int
tupleSize – int
This is an overloaded function.
Sets the uniform variable array called
namein the current context to thecountelements ofvalues. Each element hastupleSizecomponents. ThetupleSizemust be 1, 2, 3, or 4.See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValueArray(name, values, count)
- Parameters:
name – str
values –
GLintcount – int
This is an overloaded function.
Sets the uniform variable array called
namein the current context to thecountelements ofvalues.See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValueArray(name, values, count)
- Parameters:
name – str
values –
GLuintcount – int
This is an overloaded function.
Sets the uniform variable array called
namein the current context to thecountelements ofvalues. This overload should be used when setting an array of sampler values.See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValueArray(location, values, count, tupleSize)
- Parameters:
location – int
values –
GLfloatcount – int
tupleSize – int
Sets the uniform variable array at
locationin the current context to thecountelements ofvalues. Each element hastupleSizecomponents. ThetupleSizemust be 1, 2, 3, or 4.See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValueArray(location, values, count)
- Parameters:
location – int
values –
GLintcount – int
Sets the uniform variable array at
locationin the current context to thecountelements ofvalues.See also
- PySide2.QtGui.QOpenGLShaderProgram.setUniformValueArray(location, values, count)
- Parameters:
location – int
values –
GLuintcount – int
Sets the uniform variable array at
locationin the current context to thecountelements ofvalues. This overload should be used when setting an array of sampler values.Note
This function is not aware of unsigned int support in modern OpenGL versions and therefore treats
valuesas a GLint and calls glUniform1iv.See also
- PySide2.QtGui.QOpenGLShaderProgram.shaders()¶
- Return type:
Returns a list of all shaders that have been added to this shader program using
addShader().See also
- PySide2.QtGui.QOpenGLShaderProgram.uniformLocation(name)¶
- Parameters:
name –
PySide2.QtCore.QByteArray- Return type:
int
- PySide2.QtGui.QOpenGLShaderProgram.uniformLocation(name)
- Parameters:
name – str
- Return type:
int
- PySide2.QtGui.QOpenGLShaderProgram.uniformLocation(name)
- Parameters:
name – str
- Return type:
int
Returns the location of the uniform variable
namewithin this shader program’s parameter list. Returns -1 ifnameis not a valid uniform variable for this shader program.See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.