Exception thrown at 0x0000000000000000 when running glBindBuffer()

Running:

//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);

glEnableClientState(GL_VERTEX_ARRAY);

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:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
		glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);

		//glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
		//glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
		//glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);

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

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

		glfwMakeContextCurrent(window);
		AC_CORE_INFO("Successfully created GLFW window.");

		//gladLoadGL();

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

		AC_CORE_INFO("Successfully initialized GLAD");

		// During init, enable debug output
		glEnable(GL_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: