Exception thrown at 0x0000000000000000 when running glBindBuffer()


//Create a new VBO and use the variable id to store the VBO id
glGenBuffers(1, &m_vbo);

//Make the new VBO active
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);

//Upload vertex data to the video device
glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW);

//Make the new VBO active. Repeat here incase changed since initialisation
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);

glVertexPointer(3, GL_FLOAT, 0, NULL);


glBindBuffer(GL_ARRAY_BUFFER, 0);

gives: Exception thrown at 0x0000000000000000

Are you checking for GL errors? If not, add that.

I have a callback but nothing gets printed.

One of your function pointers is NULL. Check the code you’re using to load them.

I don’t understand what that means

This error message:

suggests a NULL pointer dereference.

I believe your error message refers to trying to “execute” at address 0, not perform a data access (read or write) at address 0. This can be because you have not performed proper context initialization, resulting (on Windows) in most of your OpenGL function pointers still being set to NULL (0). This is on Windows, so that’s a fair bet.

On Linux, much of this function pointer fetching is typically unnecessary as you get reasonable function pointers from the link. This “gotta fetch the GL function pointers” annoyance is mostly a Windows thing.

See where this exception occurs in your code. Then print the function pointer for the GL function you just tried to call (e.g. glGenBuffers). I bet you’ll find that it’s NULL. For instance:

fprintf( stderr, "glGenBuffers = %p\n", glGenBuffers );

To fix, you either need to:

  1. Just use a GL function loader library and call its init routine(s), or
  2. Query those GL function pointers you’re using yourself (wglGetProcAddress(), …), or

Re #1, with GLEW for instance…

Or with GLAD…:

This is my code that I always had:



		window = glfwCreateWindow(600, 500, title.c_str(), NULL, NULL);

		if (!window) {
			AC_CORE_ASSERT("GLFW failed to create the window.");

		AC_CORE_INFO("Successfully created GLFW window.");


		if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
			AC_CORE_ASSERT("GLAD failed to initialize.");

		AC_CORE_INFO("Successfully initialized GLAD");

		// During init, enable debug output
		glDebugMessageCallback(MessageCallback, 0);

I don’t see a glfwInit() here. That said, I’m no GLFW expert either.

I didn’t show that but it is just a if with the function and a error message if it failed.

Fixed it. Just a problem with the way I run my code. Sorry for all the trouble :sweat_smile:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.