MCPcopy
hub / github.com/EngoEngine/engo / flush

Method flush

common/render_shaders_default.go:296–312  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

294}
295
296func (s *basicShader) flush() {
297 // If we haven't rendered anything yet, no point in flushing.
298 if s.idx == 0 {
299 return
300 }
301 engo.Gl.BufferData(engo.Gl.ARRAY_BUFFER, s.vertices, engo.Gl.STATIC_DRAW)
302 // We only want to draw the indicies up to the number of sprites in the current batch.
303 count := s.idx / 20 * 6
304 engo.Gl.DrawElements(engo.Gl.TRIANGLES, count, engo.Gl.UNSIGNED_SHORT, 0)
305 s.idx = 0
306 // We need to reset the vertex buffer so that when we start drawing again, we don't accidentally use junk data.
307 // The "simpler" way to do this would be to just create a new slice with make(), however that would cause the
308 // previous slice to be marked for garbage collection and we'd prefer to keep the GC activity to a minimum.
309 for i := range s.vertices {
310 s.vertices[i] = 0
311 }
312}
313
314func (s *basicShader) updateBuffer(ren *RenderComponent, space *SpaceComponent) {
315 // For backwards compatibility, ren.Buffer is set to the VBO and ren.BufferContent

Callers 2

DrawMethod · 0.95
PostMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected