0

This is my code and I am working on Macbook with OpenGL with

  • freeglut 3.0.0
  • glew 2.1.0
  • glfw 3.3
  • gsl 2.6

but still I am getting the error as posted in the error image. The code is about displaying a triangle using c++ and OpenGL library if someone can

Error Image

So here is the code If someone can help please

#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\
}";
genpfault
  • 51,148
  • 11
  • 85
  • 139

0 Answers0