我正在尝试制作Qt控制台应用程序,它将启动计算着色器,但在启动时会出现以下错误:
QOpenGLShader::compile(Compute): 0(1) : error C0201: unsupported version 44
0(1) : error C0206: invalid token "<invalid atom 284073152>" in version line着色器经过测试并正确(它在我的基于openFrameworks的程序中工作得很好),并从
#version 440在基于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";
}然后编译着色器
QOpenGLShaderProgram compute;
compute.addShaderFromSourceFile(QOpenGLShader::Compute,":/shaders/cull.glsl");
compute.link();我遗漏了什么特定于Qt的东西吗?
发布于 2017-01-18 07:37:29
所以这个问题对我来说有点出乎意料。Shader文件由Visual保存,因此它具有windows编码。OpenFrameworks程序也是由Visual构建的,因此它在启动着色器方面没有问题,但是Qt无法处理windows编码的EOLs。拯救着色文件在UTF-8固定的问题。
https://stackoverflow.com/questions/41713296
复制相似问题