I'm trying to render a simple quad in a few different ways.
I can do this very easily when everything is stored in one class. But I want to be able to render more than a single object on the screen so I'm starting to take the code apart and put various bits of functionality in separate classes. The problem is, when I put the rendering functionality in the Entity class, I start getting an error.
This is the function, which is is a VertexArrayObject class:
public void render(){
glBindVertexArray(vaoID);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboiID);
this.exitOnGLError("Before render");
glDrawElements(GL_TRIANGLES, indicesCount, GL_UNSIGNED_BYTE, 0);
this.exitOnGLError("After render");
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
glBindVertexArray(0);
this.exitOnGLError("error rendering vao");
}
Again, all I have done is move this from the main class into a class that manages the VAO and theoretically renders it.
It's giving me error value 1285, and the error call that gets the error is the one labeled "After render". (exitOnGLError() is an error checking method).
Error 1285 apparently means "Out of memory" which is patently absurd since I'm using a 1 megabyte image file and...I just can't imagine my four vertex float buffer is filling up all my VRAM.
What else could be causing this error?
FYI I had this same error, and it was caused by the fact that I failed to add the call to glBufferData, which is where you actually "send the data" to opengl.
glBufferData(GL_ARRAY_BUFFER, sizeof(GLSL_XYZNDUV_Item)*p->iNum_verts,p->pVerts,GL_STATIC_DRAW);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLushort)*p->iNum_tris*2,p->pIndices, GL_STATIC_DRAW);
Sharing a possible answer for those coming here from Google.
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, indexBuffer ); glBufferData( GL_ARRAY_BUFFER, sizeof( indices ), &indices[0], GL_STATIC_DRAW );
Note the copypaste error in bold. This caused error 1285 and quite a bit of head scratching for quite some time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With