MCPcopy
hub / github.com/g3n/engine / RenderSetup

Method RenderSetup

graphic/skybox.go:72–97  ·  view source on GitHub ↗

RenderSetup is called by the engine before drawing the skybox geometry It is responsible to updating the current shader uniforms with the model matrices.

(gs *gls.GLS, rinfo *core.RenderInfo)

Source from the content-addressed store, hash-verified

70// It is responsible to updating the current shader uniforms with
71// the model matrices.
72func (skybox *Skybox) RenderSetup(gs *gls.GLS, rinfo *core.RenderInfo) {
73
74 mvm := *skybox.ModelViewMatrix()
75
76 // Clear translation
77 mvm[12] = 0
78 mvm[13] = 0
79 mvm[14] = 0
80 // mvm.ExtractRotation(&rinfo.ViewMatrix) // TODO <- ExtractRotation does not work as expected?
81
82 // Transfer mvp uniform
83 location := skybox.uniMVm.Location(gs)
84 gs.UniformMatrix4fv(location, 1, false, &mvm[0])
85
86 // Calculates model view projection matrix and updates uniform
87 var mvpm math32.Matrix4
88 mvpm.MultiplyMatrices(&rinfo.ProjMatrix, &mvm)
89 location = skybox.uniMVPm.Location(gs)
90 gs.UniformMatrix4fv(location, 1, false, &mvpm[0])
91
92 // Calculates normal matrix and updates uniform
93 var nm math32.Matrix3
94 nm.GetNormalMatrix(&mvm)
95 location = skybox.uniNm.Location(gs)
96 gs.UniformMatrix3fv(location, 1, false, &nm[0])
97}

Callers

nothing calls this directly

Calls 6

MultiplyMatricesMethod · 0.95
GetNormalMatrixMethod · 0.95
ModelViewMatrixMethod · 0.80
LocationMethod · 0.80
UniformMatrix4fvMethod · 0.45
UniformMatrix3fvMethod · 0.45

Tested by

no test coverage detected