Exemplo n.º 1
0
        private void DrawDirect()
        {
            CheckErrors();
            GL.MatrixMode(MatrixMode.Projection);
            CheckErrors();
            GL.LoadIdentity();
            CheckErrors();
            GL.Ortho(0, 1200, 0, 800, -1, 1);
            CheckErrors();
            GL.MatrixMode(MatrixMode.Modelview);
            CheckErrors();
            GL.LoadIdentity();
            CheckErrors();
            GL.UseProgram(shaderProgram);
            CheckErrors();

            _quad[0] = new GLVertex(new Vector2(500, 200), _bottomLeft, SKColors.Blue);
            _quad[1] = new GLVertex(new Vector2(900, 200), _bottomRight, SKColors.Blue);
            _quad[2] = new GLVertex(new Vector2(900, 500), _topRight, SKColors.Blue);
            _quad[3] = new GLVertex(new Vector2(500, 500), _topLeft, SKColors.Blue);

            GL.BindTexture(TextureTarget.Texture2D, textureIdDirect);
            CheckErrors();

            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(GLVertex.Size * _quad.Length),
                          _quad, BufferUsageHint.StreamDraw);
            CheckErrors();

            GL.VertexPointer(2, VertexPointerType.Float, GLVertex.Size, 0);
            CheckErrors();
            GL.TexCoordPointer(2, TexCoordPointerType.Float, GLVertex.Size, Vector2.SizeInBytes);
            CheckErrors();
            GL.ColorPointer(4, ColorPointerType.Float, GLVertex.Size, Vector2.SizeInBytes * 2);
            CheckErrors();

            GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(sizeof(short) * _quadIndices.Length),
                          _quadIndices, BufferUsageHint.StreamDraw);
            CheckErrors();

            GL.DrawElements(PrimitiveType.Triangles, 6, DrawElementsType.UnsignedShort, IntPtr.Zero);
            CheckErrors();

            GL.UseProgram(0);
            CheckErrors();
        }
Exemplo n.º 2
0
 public GLTriangle(GLVertex v1, GLVertex v2, GLVertex v3)
 {
     fVertex1 = v1;
     fVertex2 = v2;
     fVertex3 = v3;
 }
Exemplo n.º 3
0
 public GLTriangle(float3 v1, float3 v2, float3 v3, ColorRGBA aColor)
 {
     fVertex1 = new GLVertex(v1, aColor);
     fVertex2 = new GLVertex(v1, aColor);
     fVertex3 = new GLVertex(v1, aColor);
 }