簡體   English   中英

glsl着色器的C ++ Qt“不受支持的版本”錯誤

[英]C++ Qt “unsupported version” error for glsl shader

我正在嘗試制作Qt控制台應用程序,它將啟動計算着色器,但是在啟動時會出現以下錯誤:

QOpenGLShader::compile(Compute): 0(1) : error C0201: unsupported version 44
0(1) : error C0206: invalid token "<invalid atom 284073152>" in version line

Shader經過測試且正確(在我的基於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特定的東西嗎?

所以這個問題對我來說有點出乎意料。 着色器文件由Visual Studio保存,因此具有Windows編碼。 OpenFrameworks程序也是由Visual Studio構建的,因此啟動着色器沒有問題,但是Qt無法處理Windows編碼的EOL。 在UTF-8中修復着色器文件已解決的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM