C++ 如何找到GLSL的支持版本?

C++ 如何找到GLSL的支持版本?,c++,xcode,macos,opengl,glsl,C++,Xcode,Macos,Opengl,Glsl,这是我的代码,我正在使用OpenGL和 freeglut 3.0.0 glew 2.1.0 glfw 3.3 gsl 2.6 但我还是得到了错误图像中所显示的错误。该代码是关于如果某人可以,用C++和OpenGL库显示一个三角形。 如果有人能帮忙的话,这里有代码 #include <GL/glew.h> #include <GL/freeglut.h> #include <iostream> // Macro for indexing vertex b

这是我的代码,我正在使用OpenGL和

  • freeglut 3.0.0
  • glew 2.1.0
  • glfw 3.3
  • gsl 2.6
但我还是得到了错误图像中所显示的错误。该代码是关于如果某人可以

,用C++和OpenGL库显示一个三角形。

如果有人能帮忙的话,这里有代码

#include <GL/glew.h>
#include <GL/freeglut.h>
#include <iostream>

// Macro for indexing vertex buffer
#define BUFFER_OFFSET(i) ((char *)NULL + (i))

using namespace std;

// Vertex Shader (for convenience, it is defined in the main here, but we will be using text files for shaders in future)
// Note: Input to this shader is the vertex positions that we specified for the triangle.
// Note: gl_Position is a special built-in variable that is supposed to contain the vertex position (in X, Y, Z, W)
// Since our triangle vertices were specified as vec3, we just set W to 1.0.

static const char* pVS = "                                                    \n\
#version 330                                                                  \n\
\n\
in vec3 vPosition;                                                              \n\
in vec4 vColor;                                                                  \n\
out vec4 color;                                                                 \n\
\n\
\n\
void main()                                                                     \n\
{                                                                                \n\
gl_Position = vec4(vPosition.x, vPosition.y, vPosition.z, 1.0);  \n\
color = vColor;                            \n\
}";

// Fragment Shader
// Note: no input in this shader, it just outputs the colour of all fragments, in this case set to red (format: R, G, B, A).
static const char* pFS = "                                              \n\
#version 330                                                            \n\
\n\
out vec4 FragColor;                                                      \n\
\n\
void main()                                                               \n\
{                                                                          \n\
FragColor = vec4(1.0, 0.0, 0.0, 1.0);                                     \n\
}";
#包括
#包括
#包括
//用于索引顶点缓冲区的宏
#定义缓冲区偏移量(i)((字符*)NULL+(i))
使用名称空间std;
//顶点着色器(为了方便起见,这里主要定义了顶点着色器,但将来我们将使用文本文件作为着色器)
//注意:该着色器的输入是我们为三角形指定的顶点位置。
//注意:gl_位置是一个特殊的内置变量,它应该包含顶点位置(在X、Y、Z、W中)
//因为我们的三角形顶点被指定为vec3,所以我们只是将W设置为1.0。
静态常量char*pVS=“\n\
#版本330\n\
\n\
在vec3位置;\n\
在vec4 vColor中;\n\
输出vec4颜色;\n\
\n\
\n\
void main()\n\
{\n\
gl_Position=vec4(vPosition.x,vPosition.y,vPosition.z,1.0);\n\
颜色=vColor;\n\
}";
//片段着色器
//注意:此着色器中没有输入,它只输出所有片段的颜色,在本例中设置为红色(格式:R、G、B、A)。
静态常量char*pFS=“\n\
#版本330\n\
\n\
输出vec4 FragColor;\n\
\n\
void main()\n\
{\n\
FragColor=vec4(1.0,0.0,0.0,1.0);\n\
}";

请参阅版本:您需要哪个OpenGL版本?您能展示一下您的上下文创建代码吗?为什么要使用FreeGLUT和GLFW?OSX提供OGL版本