QGLShader Class

The QGLShader class allows OpenGL shaders to be compiled. 更多...

頭: #include <QGLShader>
qmake: QT += opengl
Since: Qt 4.6
繼承: QObject

該類已過時。 提供它是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它。

公共類型

flags ShaderType
enum ShaderTypeBit { Vertex, Fragment, Geometry }

公共函數

QGLShader (QGLShader::ShaderType type , QObject * parent = nullptr)
QGLShader (QGLShader::ShaderType type , const QGLContext * context , QObject * parent = nullptr)
virtual ~QGLShader ()
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
QGLShader::ShaderType shaderType () const
QByteArray sourceCode () const

靜態公共成員

bool hasOpenGLShaders (QGLShader::ShaderType type , const QGLContext * context = nullptr)
const QMetaObject staticMetaObject

額外繼承成員

詳細描述

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.

注意: This class has been deprecated in favor of QOpenGLShader .

另請參閱 QGLShaderProgram .

成員類型文檔編製

enum QGLShader:: ShaderTypeBit
flags QGLShader:: ShaderType

This enum specifies the type of QGLShader that is being created.

常量 描述
QGLShader::Vertex 0x0001 Vertex shader written in the OpenGL Shading Language (GLSL).
QGLShader::Fragment 0x0002 Fragment shader written in the OpenGL Shading Language (GLSL).
QGLShader::Geometry 0x0004 Geometry shaders written in the OpenGL Shading Language (GLSL), based on the GL_EXT_geometry_shader4 extension.

The ShaderType type is a typedef for QFlags <ShaderTypeBit>. It stores an OR combination of ShaderTypeBit values.

成員函數文檔編製

QGLShader:: QGLShader ( QGLShader::ShaderType type , QObject * parent = nullptr)

構造新的 QGLShader object of the specified type and attaches it to parent . If shader programs are not supported, QGLShaderProgram::hasOpenGLShaderPrograms () 將返迴 false。

This constructor is normally followed by a call to compileSourceCode () 或 compileSourceFile ().

The shader will be associated with the current QGLContext.

另請參閱 compileSourceCode () 和 compileSourceFile ().

QGLShader:: QGLShader ( QGLShader::ShaderType type , const QGLContext * context , QObject * parent = nullptr)

構造新的 QGLShader object of the specified type and attaches it to parent . If shader programs are not supported, then QGLShaderProgram::hasOpenGLShaderPrograms () 將返迴 false。

This constructor is normally followed by a call to compileSourceCode () 或 compileSourceFile ().

The shader will be associated with context .

另請參閱 compileSourceCode () 和 compileSourceFile ().

[虛擬] QGLShader:: ~QGLShader ()

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.

bool QGLShader:: compileSourceCode (const char * source )

設置 source code for this shader and compiles it. Returns true if the source was successfully compiled, false otherwise.

另請參閱 compileSourceFile ().

bool QGLShader:: compileSourceCode (const QByteArray & source )

這是重載函數。

設置 source code for this shader and compiles it. Returns true if the source was successfully compiled, false otherwise.

另請參閱 compileSourceFile ().

bool QGLShader:: compileSourceCode (const QString & source )

這是重載函數。

設置 source code for this shader and compiles it. Returns true if the source was successfully compiled, false otherwise.

另請參閱 compileSourceFile ().

bool QGLShader:: 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.

另請參閱 compileSourceCode ().

[static] bool QGLShader:: hasOpenGLShaders ( QGLShader::ShaderType type , const QGLContext * context = 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 QGLContext::currentContext () 被使用。

該函數在 Qt 4.7 引入。

bool QGLShader:: isCompiled () const

返迴 true if this shader has been compiled; false otherwise.

另請參閱 compileSourceCode () 和 compileSourceFile ().

QString QGLShader:: log () const

Returns the errors and warnings that occurred during the last compile.

另請參閱 compileSourceCode () 和 compileSourceFile ().

GLuint QGLShader:: shaderId () const

Returns the OpenGL identifier associated with this shader.

另請參閱 QGLShaderProgram::programId ().

QGLShader::ShaderType QGLShader:: shaderType () const

Returns the type of this shader.

QByteArray QGLShader:: sourceCode () const

Returns the source code for this shader.

另請參閱 compileSourceCode ().