func initScene() { halfW, halfH := float32(Width)*0.5, float32(Height)*0.5 Projection = mgl.Ortho2D(-halfW, halfW, -halfH, halfH).Mul4( mgl.Translate3D(-halfW, -halfH, 0)) ModelView = mgl.Ident4f().Mul4(mgl.Scale3D(100, 100, 0)) MVP <- Projection.Mul4(ModelView) gl.Disable(gl.DEPTH_TEST) gl.DepthMask(false) program := Program(FragmentShader(fsh), VertexShader(vsh)) gl.UseProgram(uint(program)) uMVP = gl.GetUniformLocation(program, "uMVP") attrPos = gl.GetAttribLocation(program, "pos") attrColor = gl.GetAttribLocation(program, "color") gl.EnableVertexAttribArray(uint(attrPos)) gl.EnableVertexAttribArray(uint(attrColor)) gl.ClearColor(0.0, 0.0, 0.0, 1.0) gl.VertexAttribPointer(uint(attrPos), 2, gl.FLOAT, false, 0, uintptr(gl.Void(&POSITION[0]))) gl.VertexAttribPointer(uint(attrColor), 4, gl.FLOAT, false, 0, uintptr(gl.Void(&COLOR[0]))) }
func reshape(w *glfw.Window, width, height int) { gl.Viewport(0, 0, width, height) halfW, halfH := float32(width)*0.5, float32(height)*0.5 Projection = mgl.Ortho2D(-halfW, halfW, -halfH, halfH).Mul4( mgl.Translate3D(-halfW, -halfH, 0)) go func(m mgl.Mat4f) { MVP <- m }(Projection.Mul4(ModelView)) }