RenderSetup is called by the renderer before drawing the geometry.
(gs *gls.GLS)
| 514 | |
| 515 | // RenderSetup is called by the renderer before drawing the geometry. |
| 516 | func (g *Geometry) RenderSetup(gs *gls.GLS) { |
| 517 | |
| 518 | // First time initialization |
| 519 | if g.gs == nil { |
| 520 | // Generate VAO |
| 521 | g.handleVAO = gs.GenVertexArray() |
| 522 | // Generate buffer for indices |
| 523 | g.handleIndices = gs.GenBuffer() |
| 524 | // Save pointer to gs indicating initialization was done |
| 525 | g.gs = gs |
| 526 | } |
| 527 | |
| 528 | // Update VBOs |
| 529 | gs.BindVertexArray(g.handleVAO) |
| 530 | for _, vbo := range g.vbos { |
| 531 | vbo.Transfer(gs) |
| 532 | } |
| 533 | |
| 534 | // Update Indices buffer if necessary |
| 535 | if g.indices.Size() > 0 && g.updateIndices { |
| 536 | gs.BindBuffer(gls.ELEMENT_ARRAY_BUFFER, g.handleIndices) |
| 537 | gs.BufferData(gls.ELEMENT_ARRAY_BUFFER, g.indices.Bytes(), g.indices.ToUint32(), gls.STATIC_DRAW) |
| 538 | g.updateIndices = false |
| 539 | } |
| 540 | } |
nothing calls this directly
no test coverage detected