QOpenGLShader Class▲
-
Header: QOpenGLShader
-
Since: Qt 5.0
-
CMake:
find_package(Qt6 REQUIRED COMPONENTS OpenGL)
target_link_libraries(mytarget PRIVATE Qt6::OpenGL)
-
qmake: QT += opengl
-
Inherits: QObject
-
Group: QOpenGLShader is part of painting-3D
Detailed Description▲
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.
See Also▲
See also QOpenGLShaderProgram
Member Type Documentation▲
enum QOpenGLShader::ShaderTypeBit▲
flags QOpenGLShader::ShaderType
This enum specifies the type of QOpenGLShader that is being created.
Constant |
Value |
Description |
---|---|---|
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) (requires OpenGL >= 3.2 or OpenGL ES >= 3.2). |
QOpenGLShader::TessellationControl |
0x0008 |
Tessellation control shaders written in the OpenGL shading language (GLSL) (requires OpenGL >= 4.0 or OpenGL ES >= 3.2). |
QOpenGLShader::TessellationEvaluation |
0x0010 |
Tessellation evaluation shaders written in the OpenGL shading language (GLSL) (requires OpenGL >= 4.0 or OpenGL ES >= 3.2). |
QOpenGLShader::Compute |
0x0020 |
Compute shaders written in the OpenGL shading language (GLSL) (requires OpenGL >= 4.3 or OpenGL ES >= 3.1). |
The ShaderType type is a typedef for QFlags<ShaderTypeBit>. It stores an OR combination of ShaderTypeBit values.
Member Function Documentation▲
[explicit] QOpenGLShader::QOpenGLShader(QOpenGLShader::ShaderType type, QObject *parent = nullptr)▲
Constructs a new QOpenGLShader object of the specified type and attaches it to parent. If shader programs are not supported, QOpenGLShaderProgram::hasOpenGLShaderPrograms() will return false.
This constructor is normally followed by a call to compileSourceCode() or compileSourceFile().
The shader will be associated with the current QOpenGLContext.
See Also▲
See also compileSourceCode(), compileSourceFile()
[virtual] 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 is destroyed.
bool QOpenGLShader::compileSourceCode(const char *source)▲
Sets the source code for this shader and compiles it. Returns true if the source was successfully compiled, false otherwise.
See Also▲
See also compileSourceFile()
bool QOpenGLShader::compileSourceCode(const QByteArray &source)▲
This is an overloaded function.
Sets the source code for this shader and compiles it. Returns true if the source was successfully compiled, false otherwise.
See Also▲
See also compileSourceFile()
bool QOpenGLShader::compileSourceCode(const QString &source)▲
This is an overloaded function.
Sets the source code for this shader and compiles it. Returns true if the source was successfully compiled, false otherwise.
See Also▲
See also compileSourceFile()
bool QOpenGLShader::compileSourceFile(const QString &fileName)▲
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.
See Also▲
See also compileSourceCode()
[static] bool QOpenGLShader::hasOpenGLShaders(QOpenGLShader::ShaderType type, QOpenGLContext *context = nullptr)▲
Returns true if shader programs of type type are supported on this system; false otherwise.
The context is used to resolve the GLSL extensions. If context is nullptr, then QOpenGLContext::currentContext() is used.
bool QOpenGLShader::isCompiled() const▲
Returns true if this shader has been compiled; false otherwise.
See Also▲
See also compileSourceCode(), compileSourceFile()
QString QOpenGLShader::log() const▲
Returns the errors and warnings that occurred during the last compile.
See Also▲
See also compileSourceCode(), compileSourceFile()
GLuint QOpenGLShader::shaderId() const▲
Returns the OpenGL identifier associated with this shader.
See Also▲
See also QOpenGLShaderProgram::programId()
QOpenGLShader::ShaderType QOpenGLShader::shaderType() const▲
Returns the type of this shader.