()
| 115 | } |
| 116 | |
| 117 | func (l *textShader) Pre() { |
| 118 | engo.Gl.Enable(engo.Gl.BLEND) |
| 119 | engo.Gl.BlendFunc(engo.Gl.SRC_ALPHA, engo.Gl.ONE_MINUS_SRC_ALPHA) |
| 120 | |
| 121 | // Bind shader and buffer, enable attributes |
| 122 | engo.Gl.UseProgram(l.program) |
| 123 | engo.Gl.BindBuffer(engo.Gl.ELEMENT_ARRAY_BUFFER, l.indicesRectanglesVBO) |
| 124 | engo.Gl.EnableVertexAttribArray(l.inPosition) |
| 125 | engo.Gl.EnableVertexAttribArray(l.inTexCoords) |
| 126 | engo.Gl.EnableVertexAttribArray(l.inColor) |
| 127 | |
| 128 | if engo.ScaleOnResize() { |
| 129 | l.projectionMatrix[0] = 1 / (engo.GameWidth() / 2) |
| 130 | l.projectionMatrix[4] = 1 / (-engo.GameHeight() / 2) |
| 131 | } else { |
| 132 | l.projectionMatrix[0] = 1 / (engo.CanvasWidth() / (2 * engo.CanvasScale())) |
| 133 | l.projectionMatrix[4] = 1 / (-engo.CanvasHeight() / (2 * engo.CanvasScale())) |
| 134 | } |
| 135 | |
| 136 | if l.cameraEnabled { |
| 137 | l.viewMatrix[1], l.viewMatrix[0] = math.Sincos(l.camera.angle * math.Pi / 180) |
| 138 | l.viewMatrix[3] = -l.viewMatrix[1] |
| 139 | l.viewMatrix[4] = l.viewMatrix[0] |
| 140 | l.viewMatrix[6] = -l.camera.x |
| 141 | l.viewMatrix[7] = -l.camera.y |
| 142 | l.viewMatrix[8] = l.camera.z |
| 143 | } else { |
| 144 | l.viewMatrix[6] = -1 / l.projectionMatrix[0] |
| 145 | l.viewMatrix[7] = 1 / l.projectionMatrix[4] |
| 146 | } |
| 147 | |
| 148 | engo.Gl.UniformMatrix3fv(l.matrixProjection, false, l.projectionMatrix) |
| 149 | engo.Gl.UniformMatrix3fv(l.matrixView, false, l.viewMatrix) |
| 150 | } |
| 151 | |
| 152 | func (l *textShader) updateBuffer(ren *RenderComponent, space *SpaceComponent) { |
| 153 | txt, ok := ren.Drawable.(Text) |
nothing calls this directly
no test coverage detected