C++ C++;Qt";“不支持的版本”;glsl着色器的错误

C++ C++;Qt";“不支持的版本”;glsl着色器的错误,c++,qt,opengl,C++,Qt,Opengl,我正在尝试制作Qt控制台应用程序,它将启动计算着色器,但在启动时,它会给我以下错误: QOpenGLShader::compile(Compute): 0(1) : error C0201: unsupported version 44 0(1) : error C0206: invalid token "<invalid atom 284073152>" in version line 在基于Qt的程序中,我使用以下代码初始化main.cpp中的OGL上下文 QSurfaceFo

我正在尝试制作Qt控制台应用程序,它将启动计算着色器,但在启动时,它会给我以下错误:

QOpenGLShader::compile(Compute): 0(1) : error C0201: unsupported version 44
0(1) : error C0206: invalid token "<invalid atom 284073152>" in version line
在基于Qt的程序中,我使用以下代码初始化main.cpp中的OGL上下文

QSurfaceFormat surfaceFormat;
surfaceFormat.setMajorVersion(4);
surfaceFormat.setMinorVersion(4);
surfaceFormat.setProfile(QSurfaceFormat::CoreProfile);
QSurfaceFormat::setDefaultFormat(surfaceFormat);

QOpenGLContext openGLContext;
openGLContext.create();
if(!openGLContext.isValid())
{
    qDebug()<<"Failed to create openGL context";
    return 0;
}
QOffscreenSurface surface;
surface.create();
if(!surface.isValid())
{
    qDebug()<<"Failed to create surface";
}

有没有我遗漏的Qt特定的东西?

所以这个问题对我来说有点出乎意料。着色器文件由Visual Studio保存,因此它具有windows编码。OpenFrameworks程序也是由VisualStudio构建的,所以它在启动着色器时没有问题,但Qt无法处理windows编码的EOL。在UTF-8中重新保存着色器文件修复了这个问题。

实际上没有关系,但如何将缓冲区绑定到计算过滤器?我知道如何在QML中使用渲染通道,但是我遇到了麻烦,在C++中找不到任何例子。尽管我调用了
glDispatchCompute
,但我找不到任何证据表明我的计算着色器正在运行。@Matt我用QOpenGLFunctions_4_3_核心类和openGL调用重写了大部分过程,但当它更多地基于Qt包装器时,我使用了QOpenGLBuffer的create()、bind()和allocate()然后仍然是QOpenGLFunctions\u 4\u 3\u Core->glBindBufferBase()。而且着色器以前是链接和绑定的。我一直在使用
QOpenGLExtraFunctions
,我会尝试
QOpenGLExtraFunctions\u 4\u 3\u Core
我也在做
create()
bind()
allocate()
,但是
glDispatchCompute
(我
read())之后我的数据没有变化
返回缓冲区进行检查。)从您的评论中,听起来我的思路是对的。如果我不能得到它,我会写一个适当的问题;如果是这样的话,介意我在这里发表评论,再次向你寻求帮助吗?@Matt,欢迎你。我自己也在学习glsl,所以试图找到你问题的答案可能也会给我进步)太好了!谢谢你的帮助。我已经把我的代码和问题浓缩成一个很好表达的问题。我确信我的问题很小,但我没有解决。。
QSurfaceFormat surfaceFormat;
surfaceFormat.setMajorVersion(4);
surfaceFormat.setMinorVersion(4);
surfaceFormat.setProfile(QSurfaceFormat::CoreProfile);
QSurfaceFormat::setDefaultFormat(surfaceFormat);

QOpenGLContext openGLContext;
openGLContext.create();
if(!openGLContext.isValid())
{
    qDebug()<<"Failed to create openGL context";
    return 0;
}
QOffscreenSurface surface;
surface.create();
if(!surface.isValid())
{
    qDebug()<<"Failed to create surface";
}
QOpenGLShaderProgram compute;
compute.addShaderFromSourceFile(QOpenGLShader::Compute,":/shaders/cull.glsl");
compute.link();