![]() |
Home · All Classes · All Functions · Overviews |
The QGLShader class allows OpenGL shaders to be compiled. More...
#include <QGLShader>
This class is not part of the Qt GUI Framework Edition.
Inherits QObject.
This class was introduced in Qt 4.6.
flags | ShaderType |
enum | ShaderTypeBits { VertexShader, FragmentShader, PartialVertexShader, PartialFragmentShader } |
QGLShader ( QGLShader::ShaderType type, QObject * parent = 0 ) | |
QGLShader ( const QString & fileName, QGLShader::ShaderType type, QObject * parent = 0 ) | |
QGLShader ( QGLShader::ShaderType type, const QGLContext * context, QObject * parent = 0 ) | |
QGLShader ( const QString & fileName, QGLShader::ShaderType type, const QGLContext * context, QObject * parent = 0 ) | |
virtual | ~QGLShader () |
bool | compile ( const char * source ) |
bool | compile ( const QByteArray & source ) |
bool | compile ( const QString & source ) |
bool | compileFile ( const QString & fileName ) |
bool | isCompiled () const |
QString | log () const |
bool | setShaderBinary ( GLenum format, const void * binary, int length ) |
bool | setShaderBinary ( QGLShader & otherShader, GLenum format, const void * binary, int length ) |
GLuint | shaderId () const |
QGLShader::ShaderType | shaderType () const |
QByteArray | sourceCode () const |
QList<GLenum> | shaderBinaryFormats () |
The QGLShader 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).
QGLShader and QGLShaderProgram shelter the programmer from the details of compiling and linking vertex and fragment shaders.
See also QGLShaderProgram.
This enum specifies the type of QGLShader that is being created.
Constant | Value | Description |
---|---|---|
QGLShader::VertexShader | 0x0001 | Vertex shader written in the OpenGL Shading Language (GLSL). |
QGLShader::FragmentShader | 0x0002 | Fragment shader written in the OpenGL Shading Language (GLSL). |
QGLShader::PartialVertexShader | PartialShader | VertexShader | Partial vertex shader that will be concatenated with all other partial vertex shaders at link time. |
QGLShader::PartialFragmentShader | PartialShader | FragmentShader | Partial fragment shader that will be concatenated with all other partial fragment shaders at link time. |
The ShaderType type is a typedef for QFlags<ShaderTypeBits>. It stores an OR combination of ShaderTypeBits values.
Constructs a new QGLShader object of the specified type and attaches it to parent. If shader programs are not supported, QGLShaderProgram::hasShaderPrograms() will return false.
This constructor is normally followed by a call to compile() or compileFile().
The shader will be associated with the current QGLContext.
See also compile() and compileFile().
Constructs a new QGLShader object of the specified type from the source code in fileName and attaches it to parent. If the shader could not be loaded, then isCompiled() will return false.
The shader will be associated with the current QGLContext.
See also isCompiled().
Constructs a new QGLShader object of the specified type and attaches it to parent. If shader programs are not supported, then QGLShaderProgram::hasShaderPrograms() will return false.
This constructor is normally followed by a call to compile() or compileFile().
The shader will be associated with context.
See also compile() and compileFile().
Constructs a new QGLShader object of the specified type from the source code in fileName and attaches it to parent. If the shader could not be loaded, then isCompiled() will return false.
The shader will be associated with context.
See also isCompiled().
Deletes this shader. If the shader has been attached to a QGLShaderProgram object, then the actual shader will stay around until the QGLShaderProgram is destroyed.
Sets the source code for this shader and compiles it. Returns true if the source was successfully compiled, false otherwise.
If shaderType() is PartialVertexShader or PartialFragmentShader, then this function will always return true, even if the source code is invalid. Partial shaders are compiled when QGLShaderProgram::link() is called.
See also compileFile().
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.
If shaderType() is PartialVertexShader or PartialFragmentShader, then this function will always return true, even if the source code is invalid. Partial shaders are compiled when QGLShaderProgram::link() is called.
See also compileFile().
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.
If shaderType() is PartialVertexShader or PartialFragmentShader, then this function will always return true, even if the source code is invalid. Partial shaders are compiled when QGLShaderProgram::link() is called.
See also compileFile().
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.
If shaderType() is PartialVertexShader or PartialFragmentShader, then this function will always return true, even if the source code is invalid. Partial shaders are compiled when QGLShaderProgram::link() is called.
See also compile().
Returns true if this shader has been compiled; false otherwise.
See also compile().
Returns the errors and warnings that occurred during the last compile.
See also compile().
Sets the binary code for this shader to the length bytes from the array binary. The format specifies how the binary data should be interpreted by the OpenGL engine. Returns true if the binary was set on the shader; false otherwise.
This function cannot be used with PartialVertexShader or PartialFragmentShader.
If this function succeeds, then the shader will be considered compiled.
See also shaderBinaryFormats().
Sets the binary code for this shader to the length bytes from the array binary. The format specifies how the binary data should be interpreted by the OpenGL engine. Returns true if the binary was set on the shader; false otherwise.
The otherShader will also have binary code set on it. This is for the case where binary contains both vertex and fragment shader code.
This function cannot be used with PartialVertexShader or PartialFragmentShader.
If this function succeeds, then the shader will be considered compiled.
See also shaderBinaryFormats().
Returns a list of all binary formats that are supported by setShaderBinary() on this system.
See also setShaderBinary().
Returns the OpenGL identifier associated with this shader.
If shaderType() is PartialVertexShader or PartialFragmentShader, this function will always return zero. Partial shaders are created and compiled when QGLShaderProgram::link() is called.
See also QGLShaderProgram::programId().
Returns the type of this shader.
Returns the source code for this shader.
See also compile().
Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) | Trademarks | Qt 4.6.0 |