I have a Renderer component which can render a Scene. Assume the scene is just a container for Renderable objects. A Renderable is composed by a Geometry and a Material. I call that a Mesh. When rendering the multiple renderables, that's essentially what I do, for each renderable:

var (
    vbo      uint32
    ibo      *opengl.IndexBuffer
    geometry = renderable.GetGeometry()


gl.GenBuffers(1, &vbo)
gl.BindBuffer(gl.ARRAY_BUFFER, vbo)
gl.BufferData(gl.ARRAY_BUFFER, int(unsafe.Sizeof(geometry.GetVertices())*VertexSize), nil, gl.DYNAMIC_DRAW)

ibo = opengl.NewIndexBuffer(geometry.GetIndices(), uint32(len(geometry.GetIndices())))

gl.DrawElements(gl.TRIANGLES, int32(ibo.Count), gl.UNSIGNED_INT, gl.Ptr(geometry.GetIndices()))

gl.BindBuffer(gl.ARRAY_BUFFER, 0)

opengl.IndexBuffer is my implementation of an index buffer. It simply does:

gl.GenBuffers(1, &indexBuffer.ID)
gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer.ID)
gl.BufferData(gl.ELEMENT_ARRAY_BUFFER, int(count)*4, gl.Ptr(&data[0]), gl.STATIC_DRAW)

However, I can't seem to draw my geometry. What am I doing wrong?

  • 1
    \$\begingroup\$ Is this your actual render function (memory leak and all) or is it code culled from multiple functions? \$\endgroup\$ Jul 16, 2017 at 13:01
  • \$\begingroup\$ It's just a first version. I'm aware of the leaks and it's not necessarily one function. \$\endgroup\$ Jul 16, 2017 at 14:08
  • \$\begingroup\$ This is actually important; ignore the leaks for now and show the actual code, because your index buffer unbinding could be what's at fault depending on the split between creation code and drawing code. \$\endgroup\$ Jul 16, 2017 at 14:38


You must log in to answer this question.

Browse other questions tagged .