| 388 | } |
| 389 | |
| 390 | func (s *blendmapShader) flush() { |
| 391 | // If we haven't rendered anything yet, no point in flushing. |
| 392 | if s.idx == 0 { |
| 393 | return |
| 394 | } |
| 395 | engo.Gl.BufferData(engo.Gl.ARRAY_BUFFER, s.vertices, engo.Gl.STATIC_DRAW) |
| 396 | // We only want to draw the indicies up to the number of sprites in the current batch. |
| 397 | count := s.idx / 20 * 6 |
| 398 | engo.Gl.DrawElements(engo.Gl.TRIANGLES, count, engo.Gl.UNSIGNED_SHORT, 0) |
| 399 | s.idx = 0 |
| 400 | // We need to reset the vertex buffer so that when we start drawing again, we don't accidentally use junk data. |
| 401 | // The "simpler" way to do this would be to just create a new slice with make(), however that would cause the |
| 402 | // previous slice to be marked for garbage collection and we'd prefer to keep the GC activity to a minimum. |
| 403 | for i := range s.vertices { |
| 404 | s.vertices[i] = 0 |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | func (s *blendmapShader) updateBuffer(ren *RenderComponent, space *SpaceComponent) { |
| 409 | // For backwards compatibility, ren.Buffer is set to the VBO and ren.BufferContent |