func DrawVBO(buffer *MeshBuffer) { vertexSize := buffer.CalcVertexSize() buffer.VertexBuffer.Bind(gl.ARRAY_BUFFER) buffer.IndiceBuffer.Bind(gl.ELEMENT_ARRAY_BUFFER) gl.EnableClientState(gl.VERTEX_ARRAY) gl.VertexPointerVBO(3, gl.FLOAT, vertexSize, 0) if (buffer.Buffers & BUF_NORMAL) != 0 { off := buffer.CalcVertexOffset(BUF_NORMAL) gl.EnableClientState(gl.NORMAL_ARRAY) gl.NormalPointerVBO(gl.FLOAT, vertexSize, off) } if (buffer.Buffers & BUF_COLOUR) != 0 { off := buffer.CalcVertexOffset(BUF_COLOUR) gl.EnableClientState(gl.COLOR_ARRAY) gl.ColorPointerVBO(4, gl.UNSIGNED_BYTE, vertexSize, off) } if (buffer.Buffers & BUF_TEX_COORD0) != 0 { off := buffer.CalcVertexOffset(BUF_TEX_COORD0) gl.EnableClientState(gl.TEXTURE_COORD_ARRAY) gl.TexCoordPointerVBO(2, gl.FLOAT, vertexSize, off) } gl.DrawElementsVBO(gl.TRIANGLES, gl.UNSIGNED_SHORT, buffer.IndiceCount) if (buffer.Buffers & BUF_NORMAL) != 0 { gl.DisableClientState(gl.NORMAL_ARRAY) } if (buffer.Buffers & BUF_COLOUR) != 0 { gl.DisableClientState(gl.COLOR_ARRAY) } if (buffer.Buffers & BUF_TEX_COORD0) != 0 { gl.DisableClientState(gl.TEXTURE_COORD_ARRAY) } gl.DisableClientState(gl.VERTEX_ARRAY) gl.BufferUnbind(gl.ARRAY_BUFFER) gl.BufferUnbind(gl.ELEMENT_ARRAY_BUFFER) }
func DrawArray(buffer *MeshBuffer) { vertexSize := buffer.CalcVertexSize() gl.EnableClientState(gl.VERTEX_ARRAY) gl.VertexPointerTyped(3, gl.FLOAT, vertexSize, buffer.vertexArray) if (buffer.Buffers & BUF_NORMAL) != 0 { off := buffer.CalcVertexOffset(BUF_NORMAL) gl.EnableClientState(gl.NORMAL_ARRAY) gl.NormalPointerTyped(gl.FLOAT, vertexSize, buffer.vertexArray[off:]) } if (buffer.Buffers & BUF_COLOUR) != 0 { off := buffer.CalcVertexOffset(BUF_COLOUR) gl.EnableClientState(gl.COLOR_ARRAY) gl.ColorPointerTyped(4, gl.UNSIGNED_BYTE, vertexSize, buffer.vertexArray[off:]) } if (buffer.Buffers & BUF_TEX_COORD0) != 0 { off := buffer.CalcVertexOffset(BUF_TEX_COORD0) gl.EnableClientState(gl.TEXTURE_COORD_ARRAY) gl.TexCoordPointerTyped(2, gl.FLOAT, vertexSize, buffer.vertexArray[off:]) } gl.DrawElementsTyped(gl.TRIANGLES, buffer.IndiceCount, gl.UNSIGNED_SHORT, buffer.indiceArray) if (buffer.Buffers & BUF_NORMAL) != 0 { gl.DisableClientState(gl.NORMAL_ARRAY) } if (buffer.Buffers & BUF_COLOUR) != 0 { gl.DisableClientState(gl.COLOR_ARRAY) } if (buffer.Buffers & BUF_TEX_COORD0) != 0 { gl.DisableClientState(gl.TEXTURE_COORD_ARRAY) } gl.DisableClientState(gl.VERTEX_ARRAY) }