QOpenGLShaderProgram

QOpenGLShaderProgram class allows OpenGL shader programs to be linked and used. 更多

Inheritance diagram of PySide2.QtGui.QOpenGLShaderProgram

New in version 5.0.

概要

函数

虚函数

静态函数

详细描述

介绍

This class supports shader programs 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.

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 通过调用 bind() :

QOpenGLShader shader(QOpenGLShader::Vertex);
shader.compileSourceCode(code);
QOpenGLShaderProgram program(context);
program.addShader(&shader);
program.link();
program.bind();
												

编写便携式着色器

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 ,和 lowp .

QOpenGLShaderProgram class 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.

简单着色器范例

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 may be specified using glShaderBinary() on the return value from shaderId() QOpenGLShader instance 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() 函数。

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 GenericCacheLocation or CacheLocation . When support is not available, calling the cacheable function variants is equivalent to the normal ones.

注意

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.

另请参阅

QOpenGLShader

class QOpenGLShaderProgram ( [ parent=None ] )
param parent

QObject

Constructs a new shader program and attaches it to parent . The program will be invalid until addShader() 被调用。

The shader program will be associated with the current QOpenGLContext .

另请参阅

addShader()

PySide2.QtGui.QOpenGLShaderProgram. addCacheableShaderFromSourceCode ( type , source )
参数
  • type ShaderType

  • source QByteArray

返回类型

bool

PySide2.QtGui.QOpenGLShaderProgram. addCacheableShaderFromSourceCode ( type , source )
参数
  • type ShaderType

  • source – str

返回类型

bool

Registers the shader of the specified type and source to 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 AA_DisableShaderDiskCache for example, or the OpenGL context has no support for context binaries, calling this function is equivalent to addShaderFromSourceCode() .

PySide2.QtGui.QOpenGLShaderProgram. addCacheableShaderFromSourceCode ( type , source )
参数
  • type ShaderType

  • source – unicode

返回类型

bool

PySide2.QtGui.QOpenGLShaderProgram. addCacheableShaderFromSourceFile ( type , fileName )
参数
  • type ShaderType

  • fileName – unicode

返回类型

bool

Registers the shader of the specified type and fileName to 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 AA_DisableShaderDiskCache for example, or the OpenGL context has no support for context binaries, calling this function is equivalent to addShaderFromSourceFile() .

PySide2.QtGui.QOpenGLShaderProgram. addShader ( shader )
参数

shader QOpenGLShader

返回类型

bool

Adds a compiled shader to this shader program. Returns true if the shader could be added, or false otherwise.

Ownership of the shader object remains with the caller. It will not be deleted when this QOpenGLShaderProgram instance is deleted. This allows the caller to add the same shader to multiple shader programs.

PySide2.QtGui.QOpenGLShaderProgram. addShaderFromSourceCode ( type , source )
参数
  • type ShaderType

  • source QByteArray

返回类型

bool

PySide2.QtGui.QOpenGLShaderProgram. addShaderFromSourceCode ( type , source )
参数
  • type ShaderType

  • source – unicode

返回类型

bool

PySide2.QtGui.QOpenGLShaderProgram. addShaderFromSourceCode ( type , source )
参数
  • type ShaderType

  • source – str

返回类型

bool

Compiles source as a shader of the specified type and adds it to this shader program. Returns true if 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 QOpenGLShader first.

PySide2.QtGui.QOpenGLShaderProgram. addShaderFromSourceFile ( type , fileName )
参数
  • type ShaderType

  • fileName – unicode

返回类型

bool

Compiles the contents of fileName as a shader of the specified type and adds it to this shader program. Returns true if 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 QOpenGLShader first.

PySide2.QtGui.QOpenGLShaderProgram. attributeLocation ( name )
参数

name QByteArray

返回类型

int

PySide2.QtGui.QOpenGLShaderProgram. attributeLocation ( name )
参数

name – unicode

返回类型

int

PySide2.QtGui.QOpenGLShaderProgram. attributeLocation ( name )
参数

name – str

返回类型

int

Returns the location of the attribute name within this shader program’s parameter list. Returns -1 if name is not a valid attribute for this shader program.

PySide2.QtGui.QOpenGLShaderProgram. bind ( )
返回类型

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() 。返回 true if 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() .

PySide2.QtGui.QOpenGLShaderProgram. bindAttributeLocation ( name , location )
参数
  • name – unicode

  • location int

PySide2.QtGui.QOpenGLShaderProgram. bindAttributeLocation ( name , location )
参数
  • name – str

  • location int

Binds the attribute name 到指定 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.

PySide2.QtGui.QOpenGLShaderProgram. bindAttributeLocation ( name , location )
参数
  • name QByteArray

  • location int

PySide2.QtGui.QOpenGLShaderProgram. create ( )
返回类型

bool

Requests the shader program’s id to be created immediately. Returns true if successful; false 否则。

This function is primarily useful when combining QOpenGLShaderProgram with 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.

另请参阅

programId()

PySide2.QtGui.QOpenGLShaderProgram. defaultInnerTessellationLevels ( )
返回类型

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 .

返回 QVector 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.

注意

This returns the global OpenGL state value. It is not specific to this QOpenGLShaderProgram 实例。

注意

This function is only supported with OpenGL >= 4.0 and will not return valid results with OpenGL ES 3.2.

PySide2.QtGui.QOpenGLShaderProgram. defaultOuterTessellationLevels ( )
返回类型

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 .

返回 QVector 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.

注意

This returns the global OpenGL state value. It is not specific to this QOpenGLShaderProgram 实例。

注意

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 )
参数

name – str

这是重载函数。

Disables the vertex array called name in this shader program that was enabled by a previous call to enableAttributeArray() .

PySide2.QtGui.QOpenGLShaderProgram. disableAttributeArray ( location )
参数

location int

Disables the vertex array at location in this shader program that was enabled by a previous call to enableAttributeArray() .

PySide2.QtGui.QOpenGLShaderProgram. enableAttributeArray ( location )
参数

location int

Enables the vertex array at location in this shader program so that the value set by setAttributeArray() on location will be used by the shader program.

PySide2.QtGui.QOpenGLShaderProgram. enableAttributeArray ( name )
参数

name – str

这是重载函数。

Enables the vertex array called name in this shader program so that the value set by setAttributeArray() on name will be used by the shader program.

static PySide2.QtGui.QOpenGLShaderProgram. hasOpenGLShaderPrograms ( [ context=None ] )
参数

context QOpenGLContext

返回类型

bool

返回 true if shader programs written in the OpenGL Shading Language (GLSL) are supported on this system; false otherwise.

context is used to resolve the GLSL extensions. If context is None ,那么 currentContext() 被使用。

PySide2.QtGui.QOpenGLShaderProgram. isLinked ( )
返回类型

bool

返回 true if this shader program has been linked; false otherwise.

另请参阅

link()

返回类型

bool

Links together the shaders that were added to this program with addShader() 。返回 true if 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, 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.

PySide2.QtGui.QOpenGLShaderProgram. log ( )
返回类型

unicode

Returns the errors and warnings that occurred during the last link() or addShader() with explicitly specified source code.

另请参阅

link()

PySide2.QtGui.QOpenGLShaderProgram. maxGeometryOutputVertices ( )
返回类型

int

Returns the hardware limit for how many vertices a geometry shader can output.

PySide2.QtGui.QOpenGLShaderProgram. patchVertexCount ( )
返回类型

int

Returns the number of vertices per-patch to be used when rendering.

注意

This returns the global OpenGL state value. It is not specific to this QOpenGLShaderProgram 实例。

PySide2.QtGui.QOpenGLShaderProgram. programId ( )
返回类型

GLuint

Returns the OpenGL identifier associated with this shader program.

另请参阅

shaderId()

PySide2.QtGui.QOpenGLShaderProgram. release ( )

Releases the active shader program from the current QOpenGLContext . This is equivalent to calling glUseProgram(0) .

另请参阅

bind()

PySide2.QtGui.QOpenGLShaderProgram. removeAllShaders ( )

Removes all of the shaders that were added to this program previously. The QOpenGLShader objects for the shaders will not be deleted if they were constructed externally. QOpenGLShader objects that are constructed internally by QOpenGLShaderProgram will be deleted.

PySide2.QtGui.QOpenGLShaderProgram. removeShader ( shader )
参数

shader QOpenGLShader

移除 shader from this shader program. The object is not deleted.

The shader program must be valid in the current QOpenGLContext .

PySide2.QtGui.QOpenGLShaderProgram. setAttributeArray ( name , type , values , tupleSize [ , stride=0 ] )
参数
  • name – str

  • type GLenum

  • values void

  • tupleSize int

  • stride int

这是重载函数。

Sets an array of vertex values on the attribute called name in this shader program. The stride indicates the number of bytes between vertices. A default stride value of zero indicates that the vertices are densely packed in values .

type indicates the type of elements in the values array, usually GL_FLOAT , GL_UNSIGNED_BYTE , etc. The tupleSize indicates the number of components per vertex: 1, 2, 3, or 4.

The array will become active when enableAttributeArray() is called on the name . Otherwise the value specified with setAttributeValue() for name 会被使用。

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 ] )
参数
  • name – str

  • values GLfloat

  • tupleSize int

  • stride int

这是重载函数。

Sets an array of vertex values on the attribute called name in this shader program. The tupleSize indicates the number of components per vertex (1, 2, 3, or 4), and the stride indicates the number of bytes between vertices. A default stride value of zero indicates that the vertices are densely packed in values .

The array will become active when enableAttributeArray() is called on name . Otherwise the value specified with setAttributeValue() for name 会被使用。

PySide2.QtGui.QOpenGLShaderProgram. setAttributeArray ( location , type , values , tupleSize [ , stride=0 ] )
参数
  • location int

  • type GLenum

  • values void

  • tupleSize int

  • stride int

Sets an array of vertex values on the attribute at location in this shader program. The stride indicates the number of bytes between vertices. A default stride value of zero indicates that the vertices are densely packed in values .

type indicates the type of elements in the values array, usually GL_FLOAT , GL_UNSIGNED_BYTE , etc. The tupleSize indicates the number of components per vertex: 1, 2, 3, or 4.

The array will become active when enableAttributeArray() is called on the location . Otherwise the value specified with setAttributeValue() for location 会被使用。

setAttributeBuffer() function can be used to set the attribute array to an offset within a vertex buffer.

注意

Normalization will be enabled. If this is not desired, call glVertexAttribPointer directly through QOpenGLFunctions .

PySide2.QtGui.QOpenGLShaderProgram. setAttributeArray ( location , values , tupleSize [ , stride=0 ] )
参数
  • location int

  • values GLfloat

  • tupleSize int

  • stride int

Sets an array of vertex values on the attribute at location in this shader program. The tupleSize indicates the number of components per vertex (1, 2, 3, or 4), and the stride indicates the number of bytes between vertices. A default stride value of zero indicates that the vertices are densely packed in values .

The array will become active when enableAttributeArray() is called on the location . Otherwise the value specified with setAttributeValue() for location 会被使用。

PySide2.QtGui.QOpenGLShaderProgram. setAttributeBuffer ( name , type , offset , tupleSize [ , stride=0 ] )
参数
  • name – str

  • type GLenum

  • offset int

  • tupleSize int

  • stride int

这是重载函数。

Sets an array of vertex values on the attribute called name in this shader program, starting at a specific offset in the currently bound vertex buffer. The stride indicates the number of bytes between vertices. A default stride value of zero indicates that the vertices are densely packed in the value array.

type indicates the type of elements in the vertex value array, usually GL_FLOAT , GL_UNSIGNED_BYTE , etc. The tupleSize indicates the number of components per vertex: 1, 2, 3, or 4.

The array will become active when enableAttributeArray() is called on the name . Otherwise the value specified with setAttributeValue() for name 会被使用。

PySide2.QtGui.QOpenGLShaderProgram. setAttributeBuffer ( location , type , offset , tupleSize [ , stride=0 ] )
参数
  • location int

  • type GLenum

  • offset int

  • tupleSize int

  • stride int

Sets an array of vertex values on the attribute at location in this shader program, starting at a specific offset in the currently bound vertex buffer. The stride indicates the number of bytes between vertices. A default stride value of zero indicates that the vertices are densely packed in the value array.

type indicates the type of elements in the vertex value array, usually GL_FLOAT , GL_UNSIGNED_BYTE , etc. The tupleSize indicates the number of components per vertex: 1, 2, 3, or 4.

The array will become active when enableAttributeArray() is called on the location . Otherwise the value specified with setAttributeValue() for location 会被使用。

注意

Normalization will be enabled. If this is not desired, call glVertexAttribPointer directly through QOpenGLFunctions .

PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( location , values , columns , rows )
参数
  • location int

  • values GLfloat

  • columns int

  • rows int

Sets the attribute at location in the current context to the contents of values , which contains columns elements, each consisting of rows 元素。 rows value should be 1, 2, 3, or 4. This function is typically used to set matrix values and column vectors.

另请参阅

setUniformValue()

PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( location , x , y , z , w )
参数
  • location int

  • x GLfloat

  • y GLfloat

  • z GLfloat

  • w GLfloat

Sets the attribute at location in the current context to the 4D vector ( x , y , z , w ).

另请参阅

setUniformValue()

PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( location , x , y , z )
参数
  • location int

  • x GLfloat

  • y GLfloat

  • z GLfloat

Sets the attribute at location in the current context to the 3D vector ( x , y , z ).

另请参阅

setUniformValue()

PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( location , x , y )
参数
  • location int

  • x GLfloat

  • y GLfloat

Sets the attribute at location in the current context to the 2D vector ( x , y ).

另请参阅

setUniformValue()

PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( name , values , columns , rows )
参数
  • name – str

  • values GLfloat

  • columns int

  • rows int

这是重载函数。

Sets the attribute called name in the current context to the contents of values , which contains columns elements, each consisting of rows 元素。 rows value should be 1, 2, 3, or 4. This function is typically used to set matrix values and column vectors.

另请参阅

setUniformValue()

PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( name , x , y , z , w )
参数
  • name – str

  • x GLfloat

  • y GLfloat

  • z GLfloat

  • w GLfloat

这是重载函数。

Sets the attribute called name in the current context to the 4D vector ( x , y , z , w ).

另请参阅

setUniformValue()

PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( name , x , y , z )
参数
  • name – str

  • x GLfloat

  • y GLfloat

  • z GLfloat

这是重载函数。

Sets the attribute called name in the current context to the 3D vector ( x , y , z ).

另请参阅

setUniformValue()

PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( name , x , y )
参数
  • name – str

  • x GLfloat

  • y GLfloat

这是重载函数。

Sets the attribute called name in the current context to the 2D vector ( x , y ).

另请参阅

setUniformValue()

PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( name , value )
参数
  • name – str

  • value GLfloat

这是重载函数。

Sets the attribute called name in the current context to value .

另请参阅

setUniformValue()

PySide2.QtGui.QOpenGLShaderProgram. setAttributeValue ( location , value )
参数
  • location int

  • value GLfloat

Sets the attribute at location in the current context to value .

另请参阅

setUniformValue()

PySide2.QtGui.QOpenGLShaderProgram. setDefaultInnerTessellationLevels ( levels )
参数

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 .

levels argument should be a QVector 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.

注意

This modifies global OpenGL state and is not specific to this QOpenGLShaderProgram instance. You should call this in your render function when needed, as QOpenGLShaderProgram will not apply this for you. This is purely a convenience function.

注意

This function is only available with OpenGL >= 4.0 and is not supported with OpenGL ES 3.2.

PySide2.QtGui.QOpenGLShaderProgram. setDefaultOuterTessellationLevels ( levels )
参数

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 .

levels argument should be a QVector 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.

注意

This modifies global OpenGL state and is not specific to this QOpenGLShaderProgram instance. You should call this in your render function when needed, as QOpenGLShaderProgram will not apply this for you. This is purely a convenience function.

注意

This function is only available with OpenGL >= 4.0 and is not supported with OpenGL ES 3.2.

PySide2.QtGui.QOpenGLShaderProgram. setPatchVertexCount ( count )
参数

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 QOpenGLShaderProgram containing 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).

注意

This modifies global OpenGL state and is not specific to this QOpenGLShaderProgram instance. You should call this in your render function when needed, as QOpenGLShaderProgram will not apply this for you. This is purely a convenience function.

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , x , y , z )
参数
  • location int

  • x GLfloat

  • y GLfloat

  • z GLfloat

Sets the uniform variable at location in the current context to the 3D vector ( x , y , z ).

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , x , y )
参数
  • location int

  • x GLfloat

  • y GLfloat

Sets the uniform variable at location in the current context to the 2D vector ( x , y ).

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
  • location int

  • value GLfloat

Sets the uniform variable at location in the current context to value .

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , x , y , z , w )
参数
  • location int

  • x GLfloat

  • y GLfloat

  • z GLfloat

  • w GLfloat

Sets the uniform variable at location in the current context to the 4D vector ( x , y , z , w ).

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
  • location int

  • value GLint

Sets the uniform variable at location in the current context to value .

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
  • location int

  • value GLuint

Sets the uniform variable at location in the current context to value . This function should be used when setting sampler values.

注意

This function is not aware of unsigned int support in modern OpenGL versions and therefore treats value as a GLint and calls glUniform1i.

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
  • location int

  • value GLfloat[][]

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
  • location int

  • value GLfloat[][]

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
  • location int

  • value GLfloat[][]

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , color )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , point )
参数
  • location int

  • point QPoint

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , point )
参数
  • location int

  • point QPointF

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , size )
参数
  • location int

  • size QSize

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , size )
参数
  • location int

  • size QSizeF

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( location , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
  • name – str

  • value GLfloat

这是重载函数。

Sets the uniform variable called name in the current context to value .

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , x , y )
参数
  • name – str

  • x GLfloat

  • y GLfloat

这是重载函数。

Sets the uniform variable called name in the current context to the 2D vector ( x , y ).

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , x , y , z )
参数
  • name – str

  • x GLfloat

  • y GLfloat

  • z GLfloat

这是重载函数。

Sets the uniform variable called name in the current context to the 3D vector ( x , y , z ).

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , x , y , z , w )
参数
  • name – str

  • x GLfloat

  • y GLfloat

  • z GLfloat

  • w GLfloat

这是重载函数。

Sets the uniform variable called name in the current context to the 4D vector ( x , y , z , w ).

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
  • name – str

  • value GLint

这是重载函数。

Sets the uniform variable called name in the current context to value .

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
  • name – str

  • value GLuint

这是重载函数。

Sets the uniform variable called name in the current context to value . This function should be used when setting sampler values.

注意

This function is not aware of unsigned int support in modern OpenGL versions and therefore treats value as a GLint and calls glUniform1i.

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
  • name – str

  • value GLfloat[][]

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
  • name – str

  • value GLfloat[][]

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
  • name – str

  • value GLfloat[][]

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , color )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , point )
参数
  • name – str

  • point QPoint

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , point )
参数
  • name – str

  • point QPointF

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , size )
参数
  • name – str

  • size QSize

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , size )
参数
  • name – str

  • size QSizeF

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue ( name , value )
参数
PySide2.QtGui.QOpenGLShaderProgram. setUniformValue1f ( arg__1 , arg__2 )
参数
  • arg__1 – str

  • arg__2 float

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue1f ( arg__1 , arg__2 )
参数
  • arg__1 int

  • arg__2 float

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue1i ( arg__1 , arg__2 )
参数
  • arg__1 int

  • arg__2 int

PySide2.QtGui.QOpenGLShaderProgram. setUniformValue1i ( arg__1 , arg__2 )
参数
  • arg__1 – str

  • arg__2 int

PySide2.QtGui.QOpenGLShaderProgram. setUniformValueArray ( name , values , count , tupleSize )
参数
  • name – str

  • values GLfloat

  • count int

  • tupleSize int

这是重载函数。

Sets the uniform variable array called name in the current context to the count elements of values . Each element has tupleSize components. The tupleSize must be 1, 2, 3, or 4.

PySide2.QtGui.QOpenGLShaderProgram. setUniformValueArray ( name , values , count )
参数
  • name – str

  • values GLint

  • count int

这是重载函数。

Sets the uniform variable array called name in the current context to the count elements of values .

PySide2.QtGui.QOpenGLShaderProgram. setUniformValueArray ( name , values , count )
参数
  • name – str

  • values GLuint

  • count int

这是重载函数。

Sets the uniform variable array called name in the current context to the count elements of values . This overload should be used when setting an array of sampler values.

PySide2.QtGui.QOpenGLShaderProgram. setUniformValueArray ( location , values , count , tupleSize )
参数
  • location int

  • values GLfloat

  • count int

  • tupleSize int

Sets the uniform variable array at location in the current context to the count elements of values . Each element has tupleSize components. The tupleSize must be 1, 2, 3, or 4.

PySide2.QtGui.QOpenGLShaderProgram. setUniformValueArray ( location , values , count )
参数
  • location int

  • values GLint

  • count int

Sets the uniform variable array at location in the current context to the count elements of values .

PySide2.QtGui.QOpenGLShaderProgram. setUniformValueArray ( location , values , count )
参数
  • location int

  • values GLuint

  • count int

Sets the uniform variable array at location in the current context to the count elements of values . This overload should be used when setting an array of sampler values.

注意

This function is not aware of unsigned int support in modern OpenGL versions and therefore treats values as a GLint and calls glUniform1iv.

PySide2.QtGui.QOpenGLShaderProgram. shaders ( )
返回类型

Returns a list of all shaders that have been added to this shader program using addShader() .

PySide2.QtGui.QOpenGLShaderProgram. uniformLocation ( name )
参数

name QByteArray

返回类型

int

PySide2.QtGui.QOpenGLShaderProgram. uniformLocation ( name )
参数

name – unicode

返回类型

int

PySide2.QtGui.QOpenGLShaderProgram. uniformLocation ( name )
参数

name – str

返回类型

int

Returns the location of the uniform variable name within this shader program’s parameter list. Returns -1 if name is not a valid uniform variable for this shader program.