我刚刚开始学习OpenGL,并且正在学习本教程.我在编译本教程使用的GLSL文件时遇到了困难.
原来,当我试图编译它们编译器说,台面不支持GLSL版本330,所以我改变#version 330 core来#version 130.现在,当我运行它时,它给我以下错误:
3.0 Mesa 10.0.20Compiling shader : SimpleVertexShader.vertexshader
0:3(1): error: syntax error, unexpected NEW_IDENTIFIER
Compiling shader : SimpleFragmentShader.fragmentshader
Linking program
error: linking with uncompiled shader
Run Code Online (Sandbox Code Playgroud)
我在谷歌搜索过,找不到有这个问题的人.无论如何,这里是所有有问题的文件:
SimpleVertexShader.vertexshader:
#version 130
layout(location = 0) in vec3 vertexPosition_modelspace;
void main(){
gl_Position.xyz = vertexPosition_modelspace;
gl_Position.w = 1.0;
}
Run Code Online (Sandbox Code Playgroud)
SimpleFragmentShader.fragmentshader:
#version 130
out vec3 color;
void main() {
color = vec3(1,0,0);
}
Run Code Online (Sandbox Code Playgroud)
loadShader.cpp:
#include <stdio.h>
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <algorithm>
using …Run Code Online (Sandbox Code Playgroud)