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

Method Pre

common/render_shaders_default.go:138–163  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136}
137
138func (s *basicShader) Pre() {
139 engo.Gl.Enable(engo.Gl.BLEND)
140 engo.Gl.BlendFunc(engo.Gl.SRC_ALPHA, engo.Gl.ONE_MINUS_SRC_ALPHA)
141 // Enable shader and buffer, enable attributes in shader
142 engo.Gl.UseProgram(s.program)
143 engo.Gl.BindBuffer(engo.Gl.ELEMENT_ARRAY_BUFFER, s.indexBuffer)
144 engo.Gl.EnableVertexAttribArray(s.inPosition)
145 engo.Gl.EnableVertexAttribArray(s.inTexCoords)
146 engo.Gl.EnableVertexAttribArray(s.inColor)
147
148 // The matrixProjView shader uniform is projection * view.
149 // We do the multiplication on the CPU instead of sending each matrix to the shader and letting the GPU do the multiplication,
150 // because it's likely faster to do the multiplication client side and send the result over the shader bus than to send two separate
151 // buffers over the bus and then do the multiplication on the GPU.
152 if s.projViewChange {
153 s.projViewMatrix = s.projectionMatrix.Multiply(s.viewMatrix)
154 s.projViewChange = false
155 }
156 engo.Gl.UniformMatrix3fv(s.matrixProjView, false, s.projViewMatrix.Val[:])
157
158 // 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.
159 engo.Gl.BindBuffer(engo.Gl.ARRAY_BUFFER, s.vertexBuffer)
160 engo.Gl.VertexAttribPointer(s.inPosition, 2, engo.Gl.FLOAT, false, 20, 0)
161 engo.Gl.VertexAttribPointer(s.inTexCoords, 2, engo.Gl.FLOAT, false, 20, 8)
162 engo.Gl.VertexAttribPointer(s.inColor, 4, engo.Gl.UNSIGNED_BYTE, true, 20, 16)
163}
164
165func (s *basicShader) PrepareCulling() {
166 s.projViewChange = true

Callers

nothing calls this directly

Calls 1

MultiplyMethod · 0.45

Tested by

no test coverage detected