(w *ecs.World)
| 33 | } |
| 34 | |
| 35 | func (l *textShader) Setup(w *ecs.World) error { |
| 36 | var err error |
| 37 | l.program, err = LoadShader(` |
| 38 | attribute vec2 in_Position; |
| 39 | attribute vec2 in_TexCoords; |
| 40 | attribute vec4 in_Color; |
| 41 | |
| 42 | uniform mat3 matrixProjection; |
| 43 | uniform mat3 matrixView; |
| 44 | uniform mat3 matrixModel; |
| 45 | |
| 46 | varying vec4 var_Color; |
| 47 | varying vec2 var_TexCoords; |
| 48 | |
| 49 | void main() { |
| 50 | var_Color = in_Color; |
| 51 | var_TexCoords = in_TexCoords; |
| 52 | |
| 53 | vec3 matr = matrixProjection * matrixView * matrixModel * vec3(in_Position, 1.0); |
| 54 | gl_Position = vec4(matr.xy, 0, matr.z); |
| 55 | } |
| 56 | `, ` |
| 57 | #ifdef GL_ES |
| 58 | #define LOWP lowp |
| 59 | precision mediump float; |
| 60 | #else |
| 61 | #define LOWP |
| 62 | #endif |
| 63 | |
| 64 | varying vec4 var_Color; |
| 65 | varying vec2 var_TexCoords; |
| 66 | |
| 67 | uniform sampler2D uf_Texture; |
| 68 | |
| 69 | void main (void) { |
| 70 | gl_FragColor = var_Color * texture2D(uf_Texture, var_TexCoords); |
| 71 | }`) |
| 72 | |
| 73 | if err != nil { |
| 74 | return err |
| 75 | } |
| 76 | |
| 77 | // Create and populate indices buffer |
| 78 | l.indicesRectangles = make([]uint16, 6*bufferSize) |
| 79 | for i, j := 0, 0; i < bufferSize*6; i, j = i+6, j+4 { |
| 80 | l.indicesRectangles[i+0] = uint16(j + 0) |
| 81 | l.indicesRectangles[i+1] = uint16(j + 1) |
| 82 | l.indicesRectangles[i+2] = uint16(j + 2) |
| 83 | l.indicesRectangles[i+3] = uint16(j + 0) |
| 84 | l.indicesRectangles[i+4] = uint16(j + 2) |
| 85 | l.indicesRectangles[i+5] = uint16(j + 3) |
| 86 | } |
| 87 | l.indicesRectanglesVBO = engo.Gl.CreateBuffer() |
| 88 | engo.Gl.BindBuffer(engo.Gl.ELEMENT_ARRAY_BUFFER, l.indicesRectanglesVBO) |
| 89 | engo.Gl.BufferData(engo.Gl.ELEMENT_ARRAY_BUFFER, l.indicesRectangles, engo.Gl.STATIC_DRAW) |
| 90 | |
| 91 | // Define things that should be read from the texture buffer |
| 92 | l.inPosition = engo.Gl.GetAttribLocation(l.program, "in_Position") |
nothing calls this directly
no test coverage detected