Ejemplo n.º 1
0
        public void flush()
        {
            flushNum += 1;

            vao.registerAttribute(0, vertBuffer, Vector3.SizeInBytes, 3);
            vao.registerAttribute(1, texBuffer, Vector2.SizeInBytes, 2);

            vao.bind();

            Shader.start();

            Matrix4 translationToOrigin = Matrix4.CreateTranslation(-1 * vertBuffer[0].X,
                                                                    -1 * vertBuffer[0].Y, 0);
            Matrix4 scale = Matrix4.CreateScale(2 * Camera.Zoom / (float)Window.Width,
                                                2 * Camera.Zoom / (float)Window.Height, 1);
            Matrix4 translationToFinalSpot = Matrix4.CreateTranslation(2 * Camera.Zoom * (vertBuffer[0].X - Camera.Position.X - Window.Width / 2) / Window.Width,
                                                                       2 * Camera.Zoom * (vertBuffer[0].Y - Camera.Position.Y - Window.Height / 2) / Window.Height, 0);

            Matrix4 world = Matrix4.Mult(translationToOrigin, scale);

            world = Matrix4.Mult(world, translationToFinalSpot);

            Shader.loadWorldRef(world);

            GL.BindTexture(TextureTarget.Texture2D, tex);
            GL.DrawArrays(PrimitiveType.Quads, 0, idx);


            Shader.stop();
            vao.unbind();

            idx = 0;
        }
 public override void end()
 {
     vao.unbind();
     Shader.stop();
 }