linux - 在 Linux 中编译 GLSL 着色器时出错

标签 linux compiler-errors glsl shader

我最近在我的 Windows 机器上使用 OpenGL 编写了一个基本的渲染引擎,在那一端一切运行良好。不幸的是,当我试图将它带到我运行 Ubuntu 12.04 的笔记本电脑上时,出现了一些复杂情况,最初是链接设置和库的问题,但我设法解决了所有问题,我当前的问题是编译 GLSL 着色器,当我编译顶点着色器和片段着色器时出现以下错误。

'0:2(14): 预处理器错误:语法错误,意外的 IDENTIFIER,期待 NEWLINE
'

这是我的顶点着色器的代码。

#version 330 core

layout(location = 0) in vec3 position;
layout(location = 1) in vec2 uv;
layout(location = 2) in vec3 normal;

struct DirectionalLight{
    vec3 direction;
    vec3 color;
    vec3 ambient;
};

uniform mat4 modelMatrix;
uniform mat4 viewMatrix;
uniform mat4 projectionMatrix;
uniform DirectionalLight dLight;

out vec2 iUv;
out vec3 iPosition;
out vec3 iNormal;
out vec3 lightDir;

void main()
{
    iUv = uv;
    iPosition = vec3(viewMatrix * modelMatrix * vec4(position,1));
    iNormal = normal;
    lightDir = vec3(normalize(viewMatrix * vec4(dLight.direction, 0)));

    gl_Position =  projectionMatrix * viewMatrix * modelMatrix * vec4(position,1);
}

有什么想法吗?

最佳答案

在我的情况下改变

#version 330 core

#version 330

有帮助。

关于linux - 在 Linux 中编译 GLSL 着色器时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12106044/

相关文章:

Excel VBA : Missing Project or Library on Chr?

c++ - GLSL - 无法访问多个灯光的 SSBO 数组的第二个索引

linux - 单声道WCF客户端异常: The requested feature is not implemented

c - 从 `setuid` 进程检测父进程死亡

c++ - C++中没有匹配的函数: constant tag added to calling function

c++ - 如何将 C++ 编译器错误 "cannot convert ' Type' 修复为 'const Type*' "?

opengl - 是否可以确保对于远处的物体,OpenGL 中至少渲染 1 个像素?

c++ - Blinn-Phong 照明 - 全色的最佳计算是什么

c++ - 从另一个线程访问线程本地

在 Linux for Mac 上交叉编译简单的标准 C 程序