The QOpenGLShader class allows OpenGL shaders to be compiled. 更多...
| 頭: | #include <QOpenGLShader> |
| qmake: | QT += gui |
| Since: | Qt 5.0 |
| 繼承: | QObject |
| flags | ShaderType |
| enum | ShaderTypeBit { Vertex, Fragment, Geometry, TessellationControl, TessellationEvaluation, Compute } |
| QOpenGLShader (QOpenGLShader::ShaderType type , QObject * parent = Q_NULLPTR) | |
| virtual | ~QOpenGLShader () |
| bool | compileSourceCode (const char * source ) |
| bool | compileSourceCode (const QByteArray & source ) |
| bool | compileSourceCode (const QString & source ) |
| bool | compileSourceFile (const QString & fileName ) |
| bool | isCompiled () const |
| QString | log () const |
| GLuint | shaderId () const |
| QOpenGLShader::ShaderType | shaderType () const |
| QByteArray | sourceCode () const |
| bool | hasOpenGLShaders (ShaderType type , QOpenGLContext * context = Q_NULLPTR) |
The QOpenGLShader class allows OpenGL shaders to be compiled.
This class supports shaders written in the OpenGL Shading Language (GLSL) and in the OpenGL/ES Shading Language (GLSL/ES).
QOpenGLShader and QOpenGLShaderProgram shelter the programmer from the details of compiling and linking vertex and fragment shaders.
另請參閱 QOpenGLShaderProgram .
This enum specifies the type of QOpenGLShader that is being created.
| 常量 | 值 | 描述 |
|---|---|---|
QOpenGLShader::Vertex
|
0x0001
|
Vertex shader written in the OpenGL Shading Language (GLSL). |
QOpenGLShader::Fragment
|
0x0002
|
Fragment shader written in the OpenGL Shading Language (GLSL). |
QOpenGLShader::Geometry
|
0x0004
|
Geometry shaders written in the OpenGL Shading Language (GLSL) based on the OpenGL core feature (requires OpenGL >= 3.2). |
QOpenGLShader::TessellationControl
|
0x0008
|
Tessellation control shaders written in the OpenGL shading language (GLSL), based on the core feature (requires OpenGL >= 4.0). |
QOpenGLShader::TessellationEvaluation
|
0x0010
|
Tessellation evaluation shaders written in the OpenGL shading language (GLSL), based on the core feature (requires OpenGL >= 4.0). |
QOpenGLShader::Compute
|
0x0020
|
Compute shaders written in the OpenGL shading language (GLSL), based on the core feature (requires OpenGL >= 4.3). |
The ShaderType type is a typedef for QFlags <ShaderTypeBit>. It stores an OR combination of ShaderTypeBit values.
構造新的 QOpenGLShader object of the specified type and attaches it to parent . If shader programs are not supported, QOpenGLShaderProgram::hasOpenGLShaderPrograms () 將返迴 false。
This constructor is normally followed by a call to compileSourceCode () 或 compileSourceFile ().
The shader will be associated with the current QOpenGLContext .
另請參閱 compileSourceCode () 和 compileSourceFile ().
[虛擬]
QOpenGLShader::
~QOpenGLShader
()
Deletes this shader. If the shader has been attached to a QOpenGLShaderProgram object, then the actual shader will stay around until the QOpenGLShaderProgram 被銷毀。
設置
source
code for this shader and compiles it. Returns
true
if the source was successfully compiled, false otherwise.
另請參閱 compileSourceFile ().
這是重載函數。
設置
source
code for this shader and compiles it. Returns
true
if the source was successfully compiled, false otherwise.
另請參閱 compileSourceFile ().
這是重載函數。
設置
source
code for this shader and compiles it. Returns
true
if the source was successfully compiled, false otherwise.
另請參閱 compileSourceFile ().
Sets the source code for this shader to the contents of
fileName
and compiles it. Returns
true
if the file could be opened and the source compiled, false otherwise.
另請參閱 compileSourceCode ().
[static]
bool
QOpenGLShader::
hasOpenGLShaders
(
ShaderType
type
,
QOpenGLContext
*
context
= Q_NULLPTR)
返迴
true
if shader programs of type
type
are supported on this system; false otherwise.
The context is used to resolve the GLSL extensions. If context is null, then QOpenGLContext::currentContext () 被使用。
返迴
true
if this shader has been compiled; false otherwise.
另請參閱 compileSourceCode () 和 compileSourceFile ().
Returns the errors and warnings that occurred during the last compile.
另請參閱 compileSourceCode () 和 compileSourceFile ().
Returns the OpenGL identifier associated with this shader.
另請參閱 QOpenGLShaderProgram::programId ().
Returns the type of this shader.
Returns the source code for this shader.
另請參閱 compileSourceCode ().