While looping through all objects I want to render in my 3D-engine, I get an error when trying to call
glDrawArrays(mesh->primitiveType, 0, mesh->vertexCount);
Because it tries to read from location 0x0000000, so apparently the pointer bound to the mesh->vertexBuffer index points to zero. This all happens within my RenderableObject class. Instances of this class have a mesh bound to them, and this mesh contains an index that should link to the VertexArray. But apparently
glBindBuffer(GL_ARRAY_BUFFER, mesh->vertexBuffer);
Is failing.
The strange thing is, that it will run on my mac, and various other windows computers - but it won't run on this (windows) computer. Because I'm testing I removed all 3D models, and found it's the primitives that are causing the problem, somehow the MSVC++ compiler "optimized" my code, to remove everything after
glGenBuffers(1, &CubeMesh.vertexBuffer);
And that's probably why nothing got bound, or so I thought. I disabled linker/compiler optimizations, and I could see allbreakpoints would get hit now - but I still get the same exception, and I'm absolutely clueless as to why it doesn't work.
The entire source of the project can be found @ https://github.com/Wrap/TwinGame/tree/master/src , as far as I can tell the problem is in the Primitives.cpp, and/or the RenderableObject.cpp (specifically the RenderableObject::Draw(); method) file. Am I trying to read something that is protected, what is wrong with the LoadPrimitives(); method?
Thanks for taking the time to read this.
glBufferData(GL_ARRAY_BUFFER, sizeof(cubeVertices), &cubeVertices, GL_STATIC_DRAW);
is wrong, you don't want&cubeVertices
, justcubeVertices
– Ornithischian