IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QGLShader Class

The QGLShader class allows OpenGL shaders to be compiled.

This class was introduced in Qt 4.6.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QGLShader Class

  • Header: QGLShader

  • Since: Qt 4.6

  • qmake: QT += opengl

  • Inherits: QObject

  • Group: QGLShader is part of painting-3D

This class is deprecated. We strongly advise against using it in new code.

Detailed Description

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.

See Also

See also QGLShaderProgram

Member Type Documentation

 

enum QGLShader::ShaderTypeBit

flags QGLShader::ShaderType

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

Constant

Value

Description

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.

Member Function Documentation

 

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

Constructs a new QGLShader object of the specified type and attaches it to parent. If shader programs are not supported, QGLShaderProgram::hasOpenGLShaderPrograms() will return false.

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

The shader will be associated with the current QGLContext.

See Also

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

Constructs a new QGLShader object of the specified type and attaches it to parent. If shader programs are not supported, then QGLShaderProgram::hasOpenGLShaderPrograms() will return false.

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

The shader will be associated with context.

See Also

[virtual] 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)

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

See Also

See also compileSourceCode()

[static, since 4.7] bool QGLShader::hasOpenGLShaders(QGLShader::ShaderType type, const QGLContext *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 null, then QGLContext::currentContext() is used.

This function was introduced in Qt 4.7.

bool QGLShader::isCompiled() const

Returns true if this shader has been compiled; false otherwise.

See Also

QString QGLShader::log() const

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

See Also

GLuint QGLShader::shaderId() const

Returns the OpenGL identifier associated with this shader.

See Also

QGLShader::ShaderType QGLShader::shaderType() const

Returns the type of this shader.

QByteArray QGLShader::sourceCode() const

Returns the source code for this shader.

See Also

See also compileSourceCode()

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+