So, in my project I am using a seperate class to create buffers called Buffer.cpp. Here is the constructor
#define GLEW_STATIC
#define GLEW_NO_GLU
#define GLFW_NO_GLU
#include "GL/glew.h"
#include "GL/glfw.h"
Buffer::Buffer(GLenum _type, const void *data, GLsizei _size, GLenum usage) : type(_type), size(_size)
{
...
//Generate Buffer
glGenBuffers(1, &buffer);
...
}
And the definitions of the members:
GLuint buffer;
const GLsizei size;
const GLenum type;
Buffer(GLenum, const void*, GLsizei, GLenum);
The problem is that when I try to generate a buffer using for example this command:
Buffer vBuffer(GL_ARRAY_BUFFER, vertexPositions, sizeof(vertexPositions), GL_STATIC_DRAW);
the program crashes at glGenBuffers() with termination status "-1073741819". I tried debugging the program and this is what I got:
Program received signal SIGSEGV, Segmentation fault.
My card supports OpenGL 1.5 so that's not the case.
It is also worth to note that I compiled a static glew library myself.
EDIT: I finally fixed the problem. The problem was that I was calling glewInit() before creating an OpenGL rendering context.
glewInit()
'd GL context by the time you get to thatglGenBuffers()
call? – Mimamsa