OpenGL编译的着色器损坏 [英] OpenGL Compiled Shader was corrupt

查看:294
本文介绍了OpenGL编译的着色器损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在OpenGL 3.2中编译着色器程序,但出现一个奇怪的链接错误.

I'm trying to compile a shader program in OpenGL 3.2, but I'm getting a strange linking error.

在创建顶点着色器和片段着色器并将其附加后,我尝试将它们链接到程序中,但是出现以下信息日志错误:

After creating the vertex and fragment shaders compiling and attaching them, I try to link them into a program but I get the following infolog error:

ERROR: Compiled vertex shader was corrupt.
ERROR: Compiled fragment shader was corrupt.

我完全不知道这意味着什么,而我在Google上唯一能找到的就是忽略它.但是,当我glUseProgram()时,我得到了一个无效的操作,因此我不能仅仅忽略此错误.

I have absolutely no idea what it means and the only thing I could find on google was to ignore it. However, when I glUseProgram() it I get an invalid operation, so I can't just ignore this error.

此外,我刚刚更新到XCode 5,并且相同的代码/着色器源也在工作.不过不知道该如何关联.

Moreover, I just updated to XCode 5 and the very same code/shader source was working. Don't know how it can be related though..

着色器源

顶点:

#version 150

in vec3 position;

uniform mat4 worldMatrix;
uniform float time;

out vec3 outPos;
void main(){
    gl_Position = worldMatrix*vec4(position, 1.0);
    outPos = position;
}

片段:

#version 150

out vec4 outColor;
uniform float time;
uniform float red;
uniform float green;
uniform float blue;

void main(){
    outColor=vec4(red, green, blue,1.0);
}

推荐答案

使其正常工作.

起初,我用另一个编辑器(文本伴侣)重写了着色器,然后有时起作用了.然后,我确保将其正确终止为null,并且每次都可以使用.

At first I rewrote the shaders with another editor (text mate) and then it worked sometimes. Then I made sure that it was properly null terminated and it worked every time.

也许有某种像Andon M. Coleman建议的非印刷字符.

Maybe somehow there were non-printing characters like Andon M. Coleman suggested.

这篇关于OpenGL编译的着色器损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆