mirror of
https://github.com/bloeys/nterm.git
synced 2025-12-29 14:38:19 +00:00
Use bufferSubData and dynamic buffer in when drawing glyphs
This commit is contained in:
@ -365,8 +365,9 @@ func (gr *GlyphRend) Draw() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
gr.InstancedBuf.SetData(gr.GlyphVBO[:gr.GlyphCount*floatsPerGlyph])
|
gl.BindVertexArray(gr.InstancedBuf.VAOID)
|
||||||
gr.InstancedBuf.Bind()
|
gl.BindBuffer(gl.ARRAY_BUFFER, gr.InstancedBuf.BufID)
|
||||||
|
gl.BufferSubData(gl.ARRAY_BUFFER, 0, int(gr.GlyphCount*floatsPerGlyph)*4, gl.Ptr(&gr.GlyphVBO[:gr.GlyphCount*floatsPerGlyph][0]))
|
||||||
gr.GlyphMat.Bind()
|
gr.GlyphMat.Bind()
|
||||||
|
|
||||||
//We need to disable depth testing so that nearby characters don't occlude each other
|
//We need to disable depth testing so that nearby characters don't occlude each other
|
||||||
@ -551,6 +552,9 @@ func NewGlyphRend(fontFile string, fontOptions *truetype.Options, screenWidth, s
|
|||||||
gl.VertexAttribPointer(5, scaleEle.ElementType.CompCount(), scaleEle.ElementType.GLType(), false, gr.InstancedBuf.Stride, gl.PtrOffset(scaleEle.Offset))
|
gl.VertexAttribPointer(5, scaleEle.ElementType.CompCount(), scaleEle.ElementType.GLType(), false, gr.InstancedBuf.Stride, gl.PtrOffset(scaleEle.Offset))
|
||||||
gl.VertexAttribDivisor(5, 1)
|
gl.VertexAttribDivisor(5, 1)
|
||||||
|
|
||||||
|
//Fill buffer with zeros and set to dynamic so in the actual draw calls we use bufferSubData which makes things a lot faster
|
||||||
|
gl.BufferData(gl.ARRAY_BUFFER, len(gr.GlyphVBO)*4, gl.Ptr(&gr.GlyphVBO[0]), buffers.BufUsage_Dynamic.ToGL())
|
||||||
|
|
||||||
gl.BindBuffer(gl.ARRAY_BUFFER, 0)
|
gl.BindBuffer(gl.ARRAY_BUFFER, 0)
|
||||||
gr.InstancedBuf.UnBind()
|
gr.InstancedBuf.UnBind()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user