I’m trying to add VBOs to an old OpenGL program, however I have a small problem. glBufferSubData() is always failing and returning GL_INVALID_OPERATION. This is a MFC program with 4 splitter views, and it uses a shared rendering context among all of them. So, along with the shared RC, each view has its own RC.
Now, whenever I create, delete, or modify VBOs, I use wglMakeCurrent() to switch back to the shared RC. When I’m done, I switch back to the previous RC. From what I understand, glBufferSubData() should work, but it doesn’t work for me. I also tried modifying VBOs with glMapBuffer() and glUnmapBuffer(), but I always get back a NULL pointer.
I tested the same situation with all three buffers types, GL_STREAM_DRAW, GL_STATIC_DRAW, and GL_DYNAMIC_DRAW. glBufferSubData() and glMapBuffer() still failed. I tested all VBOs with glGetBufferParameteriv() and GL_BUFFER_MAPPED. They all returned zero.
I have also downloaded a simple VBO demo program, that uses all the VBO functions that I use, and both glMapBuffer() and glBufferSubData() works. So, this problem has nothing to do with my computer, drivers, or graphics card. But, this demo doesn’t use a shared RC.
I was just wondering if anyone has experienced a problem like this before, and what did you do to resolve it. I don’t know what else to check. Thanks.