Unless I am mistaken, "Access violation reading location 0x00000000" means you are trying to deference a pointer that has yet to be initialized, which is why I'm stumped at this error. Pasted below is my code, with a comment indicating where the visual studio debugger tells me the error is occurring. It confuses me because none of the arguments I pass into the function are pointers. Any ideas?
void Mesh::Render(Shader* shader)
{
glBindVertexArray(m_vao);
glEnableVertexAttribArray(shader->GetAttributeLocation("position"));
glVertexAttribPointer(0, 3, GL_FALSE, GL_FALSE, sizeof(Vertex), 0);
glDrawElements(GL_TRIANGLES, m_size, GL_UNSIGNED_INT, 0); // error here
glDisableVertexAttribArray(shader->GetAttributeLocation("position"));
glBindVertexArray(0);
}
m_size
is declared as a non pointer integer
And if it helps at all, the debugger takes me to some source that is not available, and so the debugger instead points to this line in the disassembly:
001DFEC7 mov edi,dword ptr [esi]
I don't know assembly so I'm not sure if that is even of any help.
EDIT
In case anyone was wondering, I am binding the element array buffer required for using VAOs. The rest of the Mesh
class is below
Mesh::Mesh()
{
glGenVertexArrays(1, &m_vao);
glGenBuffers(1, &m_vbo);
glGenBuffers(1, &m_ibo);
m_size = 0;
}
Mesh::~Mesh()
{
glDeleteVertexArrays(1, &m_vao);
glDeleteBuffers(1, &m_vbo);
glDeleteBuffers(1, &m_ibo);
}
void Mesh::AddVertices(Vertex* vertices, int vertSize, int* indices, int indexSize)
{
m_size = indexSize;
glBindVertexArray(m_vao);
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
glBufferData(GL_ARRAY_BUFFER, vertSize * sizeof(Vertex), vertices, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ibo);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexSize * sizeof(int), indices, GL_STATIC_DRAW);
}