MCPcopy Create free account
hub / github.com/EngoEngine/engo / Pre

Method Pre

common/render_shaders_blendmap.go:191–219  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

189}
190
191func (s *blendmapShader) Pre() {
192 engo.Gl.Enable(engo.Gl.BLEND)
193 engo.Gl.BlendFunc(engo.Gl.SRC_ALPHA, engo.Gl.ONE_MINUS_SRC_ALPHA)
194 // Enable shader and buffer, enable attributes in shader
195 engo.Gl.UseProgram(s.program)
196 engo.Gl.BindBuffer(engo.Gl.ELEMENT_ARRAY_BUFFER, s.indexBuffer)
197 engo.Gl.EnableVertexAttribArray(s.inPosition)
198 engo.Gl.EnableVertexAttribArray(s.inTexCoords)
199 engo.Gl.EnableVertexAttribArray(s.inColor)
200
201 engo.Gl.Uniform1i(s.uf_BlendMap, 0)
202 engo.Gl.Uniform1i(s.uf_Fallback, 1)
203 engo.Gl.Uniform1i(s.uf_RChannel, 2)
204 engo.Gl.Uniform1i(s.uf_GChannel, 3)
205 engo.Gl.Uniform1i(s.uf_BChannel, 4)
206
207 // The matrixProjView shader uniform is projection * view.
208 // We do the multiplication on the CPU instead of sending each matrix to the shader and letting the GPU do the multiplication,
209 // because it's likely faster to do the multiplication client side and send the result over the shader bus than to send two separate
210 // buffers over the bus and then do the multiplication on the GPU.
211 pv := s.projectionMatrix.Multiply(s.viewMatrix)
212 engo.Gl.UniformMatrix3fv(s.matrixProjView, false, pv.Val[:])
213
214 // Since we are batching client side, we only have one VBO, so we can just bind it now and use it for the entire frame.
215 engo.Gl.BindBuffer(engo.Gl.ARRAY_BUFFER, s.vertexBuffer)
216 engo.Gl.VertexAttribPointer(s.inPosition, 2, engo.Gl.FLOAT, false, 20, 0)
217 engo.Gl.VertexAttribPointer(s.inTexCoords, 2, engo.Gl.FLOAT, false, 20, 8)
218 engo.Gl.VertexAttribPointer(s.inColor, 4, engo.Gl.UNSIGNED_BYTE, true, 20, 16)
219}
220
221func (s *blendmapShader) PrepareCulling() {
222 // (Re)initialize the projection matrix.

Callers

nothing calls this directly

Calls 1

MultiplyMethod · 0.45

Tested by

no test coverage detected