errorman

不积跬步,无以至千里
随笔 - 35, 文章 - 0, 评论 - 0, 阅读 - 9793

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

QOpenGLShader Class

Posted on   Clemens  阅读(84)  评论(0编辑  收藏  举报

Detailed Description

此类支持使用 OpenGL 着色语言 (GLSL) 和 OpenGL/ES 着色语言 (GLSL/ES) 编写的着色器。
QOpenGLShader 和 QOpenGLShaderProgram 使程序员免于编译和链接顶点和片段着色器的细节。
另见 QOpenGLShaderProgram。

 

Member Type Documentation

enum QOpenGLShader::ShaderTypeBit
flags QOpenGLShader::ShaderType
此枚举指定正在创建的 QOpenGLShader 的类型。
Constant Value Description
QOpenGLShader::Vertex 0x0001 用 OpenGL 着色语言 (GLSL) 编写的顶点着色器。
QOpenGLShader::Fragment 0x0002 用 OpenGL 着色语言 (GLSL) 编写的片段着色器。
QOpenGLShader::Geometry 0x0004 用 OpenGL 着色语言 (GLSL) 编写的几何着色器(需要 OpenGL >= 3.2 或 OpenGL ES >= 3.2)。
QOpenGLShader::TessellationControl 0x0008 以 OpenGL 着色语言 (GLSL) 编写的曲面细分控制着色器(需要 OpenGL >= 4.0 或 OpenGL ES >= 3.2)。
QOpenGLShader::TessellationEvaluation 0x0010 以 OpenGL 着色语言 (GLSL) 编写的细分评估着色器(需要 OpenGL >= 4.0 或 OpenGL ES >= 3.2)。
QOpenGLShader::Compute 0x0020 计算以 OpenGL 着色语言 (GLSL) 编写的着色器(需要 OpenGL >= 4.3 或 OpenGL ES >= 3.1)。

 

Member Function Documentation

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

构造一个指定type的新QOpenGLShader对象,并将其附加到父对象parent上。如果不支持着色器程序,则QOpenGLShaderProgram::hasOpenGLShaderPrograms()将返回false。

通常会在此构造函数后调用compileSourceCode()或compileSourceFile()。 该着色器将与当前的QOpenGLContext相关联。

另请参见compileSourceCode()和compileSourceFile()。

 

[virtual] QOpenGLShader::~QOpenGLShader()

删除这个着色器。如果该着色器已经附加到一个 QOpenGLShaderProgram 对象上,那么实际的着色器将一直存在,直到 QOpenGLShaderProgram 被销毁。

 

bool QOpenGLShader::compileSourceCode(const char *source)

设置该着色器的source并对其进行编译。如果成功编译了source,则返回 true,否则返回 false。

另请参见 compileSourceFile()。

 

bool QOpenGLShader::compileSourceCode(const QByteArray &source)

这是一个重载函数。

设置该着色器的source并对其进行编译。如果成功编译了source,则返回 true,否则返回 false。

另请参见 compileSourceFile()。

 

bool QOpenGLShader::compileSourceCode(const QString &source)

这是一个重载函数。

设置该着色器的source并对其进行编译。如果成功编译了source,则返回 true,否则返回 false。

另请参见 compileSourceFile()。

 

bool QOpenGLShader::compileSourceFile(const QString &fileName)

将该着色器的源代码设置为 fileName 文件的内容,并对其进行编译。如果可以打开文件并且成功编译了源代码,则返回 true,否则返回 false。

另请参见 compileSourceCode()。

 

[static] bool QOpenGLShader::hasOpenGLShaders(QOpenGLShader::ShaderType type, QOpenGLContext *context = nullptr)

如果该系统支持类型为 type 的着色器程序,则返回 true,否则返回 false。

context 参数用于解析 GLSL 扩展。如果 context 为 nullptr,则使用 QOpenGLContext::currentContext()。

 

bool QOpenGLShader::isCompiled() const

如果该着色器已编译,则返回 true,否则返回 false。

另请参见 compileSourceCode() 和 compileSourceFile()。

 

QString QOpenGLShader::log() const

返回上一次编译期间出现的错误和警告。

另请参见 compileSourceCode() 和 compileSourceFile()。

 

GLuint QOpenGLShader::shaderId() const

返回与该着色器相关联的 OpenGL 标识符。

另请参见 QOpenGLShaderProgram::programId()。

 

QOpenGLShader::ShaderType QOpenGLShader::shaderType() const

返回该着色器的类型。

 

QByteArray QOpenGLShader::sourceCode() const

返回该着色器的源代码。

另请参见 compileSourceCode()。

 

相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
点击右上角即可分享
微信分享提示