コード例 #1
0
 public void Render(Texture texture, float x1, float y1, float x2, float y2)
 {
     texture.Bind();
     GL.Begin(BeginMode.Quads);
     {
         GL.TexCoord2(0, 0);
         GL.Vertex2(x1, y2);
         GL.TexCoord2(texture.TextureXCoord, 0);
         GL.Vertex2(x2, y2);
         GL.TexCoord2(texture.TextureXCoord, texture.TextureYCoord);
         GL.Vertex2(x2, y1);
         GL.TexCoord2(0, texture.TextureYCoord);
         GL.Vertex2(x1, y1);
     }
     GL.End();
 }
コード例 #2
0
 public void Render(Texture texture, float x1, float y1, float x2, float y2)
 {
     texture.Bind();
     GL.Begin(BeginMode.Quads);
     {
         GL.TexCoord2(0, 0);
         GL.Vertex2(x1, y2);
         GL.TexCoord2(texture.TextureXCoord, 0);
         GL.Vertex2(x2, y2);
         GL.TexCoord2(texture.TextureXCoord, texture.TextureYCoord);
         GL.Vertex2(x2, y1);
         GL.TexCoord2(0, texture.TextureYCoord);
         GL.Vertex2(x1, y1);
     }
     GL.End();
 }
コード例 #3
0
 public void Render(Texture texture, float x, float y)
 {
     texture.Bind();
     // TODO: test this class
     GL.Begin(BeginMode.Quads);
     {
         GL.TexCoord2(0, 0);
         GL.Vertex2(x, y + texture.Height);
         GL.TexCoord2(texture.TextureXCoord, 0);
         GL.Vertex2(x + texture.Width, y + texture.Height);
         GL.TexCoord2(texture.TextureXCoord, texture.TextureYCoord);
         GL.Vertex2(x + texture.Width, y);
         GL.TexCoord2(0, texture.TextureYCoord);
         GL.Vertex2(x, y);
     }
     GL.End();
 }
コード例 #4
0
 public void Render(Texture texture, float x, float y)
 {
     texture.Bind();
     // TODO: test this class
     GL.Begin(BeginMode.Quads);
     {
         GL.TexCoord2(0, 0);
         GL.Vertex2(x, y + texture.Height);
         GL.TexCoord2(texture.TextureXCoord, 0);
         GL.Vertex2(x + texture.Width, y + texture.Height);
         GL.TexCoord2(texture.TextureXCoord, texture.TextureYCoord);
         GL.Vertex2(x + texture.Width, y);
         GL.TexCoord2(0, texture.TextureYCoord);
         GL.Vertex2(x, y);
     }
     GL.End();
 }
コード例 #5
0
        public void Render(Texture texture, float[] coords)
        {
            if (coords.Length < 8)
                throw new ArgumentOutOfRangeException("coord", "Incorrect coordinate massive");
            // TODO: thinks, it's not effective, should remake it in the future
            texture.Bind();
            Vector2 v1 = new Vector2(coords[0], coords[1]);
            Vector2 v2 = new Vector2(coords[2], coords[3]);
            Vector2 v3 = new Vector2(coords[4], coords[5]);
            Vector2 v4 = new Vector2(coords[6], coords[7]);

            GL.Begin(BeginMode.Quads);
            {
                GL.TexCoord2(0, 0);
                GL.Vertex2(v1);
                GL.TexCoord2(texture.TextureXCoord, 0);
                GL.Vertex2(v2);
                GL.TexCoord2(texture.TextureXCoord, texture.TextureYCoord);
                GL.Vertex2(v3);
                GL.TexCoord2(0, texture.TextureYCoord);
                GL.Vertex2(v4);
            }
            GL.End();
        }
コード例 #6
0
        private void DrawTexture(int x, int y, Texture texture, Texture.Rotation rotation)
        {
            Vector2 v1 = new Vector2(), v2 = new Vector2(), v3 = new Vector2(), v4 = new Vector2();
            switch (rotation)
            {
                case Texture.Rotation.Top:
                    v1 = new Vector2(x, y);
                    v2 = new Vector2(x + elementWidth, y);
                    v3 = new Vector2(x + elementWidth, y - elementHeight);
                    v4 = new Vector2(x, y - elementHeight);
                    break;
                case Texture.Rotation.Right:
                    v1 = new Vector2(x + elementWidth, y);
                    v2 = new Vector2(x + elementWidth, y - elementHeight);
                    v3 = new Vector2(x, y - elementHeight);
                    v4 = new Vector2(x, y);
                    break;
                case Texture.Rotation.Bottom:
                    v1 = new Vector2(x + elementWidth, y - elementHeight);
                    v2 = new Vector2(x, y - elementHeight);
                    v3 = new Vector2(x, y);
                    v4 = new Vector2(x + elementWidth, y);
                    break;
                case Texture.Rotation.Left:
                    v1 = new Vector2(x, y - elementHeight);
                    v2 = new Vector2(x, y);
                    v3 = new Vector2(x + elementWidth, y);
                    v4 = new Vector2(x + elementWidth, y - elementHeight);
                    break;
            }
            //Clear zone
            //GL.Begin(BeginMode.Quads);
            //{
            //    GL.Color3(Color.Black);
            //    GL.Vertex2(v1);
            //    GL.Vertex2(v2);
            //    GL.Vertex2(v3);
            //    GL.Vertex2(v4);
            //}
            //GL.End();

            //mapping texture
            texture.Bind();
            GL.Begin(BeginMode.Quads);
            {
                GL.Color4(Color4.Transparent);
                GL.TexCoord2(0, 0);
                GL.Vertex2(v1);
                GL.TexCoord2(1, 0);
                GL.Vertex2(v2);
                GL.TexCoord2(1, 1);
                GL.Vertex2(v3);
                GL.TexCoord2(0, 1);
                GL.Vertex2(v4);
            }
            GL.End();
        }