public TestSpriteClassState(TextureManager textureManager)
        {
            _textureManager = textureManager;
            _testSprite.Texture = _textureManager.Get("face_alpha");
            _testSprite.SetHeight(256*0.5f);

            _testSprite2.Texture = _textureManager.Get("face_alpha");
            _testSprite2.SetPosition(-256, -256);
            _testSprite2.SetColor(new Color(1, 0, 0, 1));
        }
Exemple #2
0
        public TestSpriteClassState(TextureManager textureManager)
        {
            _textureManager     = textureManager;
            _testSprite.Texture = _textureManager.Get("face_alpha");
            _testSprite.SetHeight(256 * 0.5f);

            _testSprite2.Texture = _textureManager.Get("face_alpha");
            _testSprite2.SetPosition(-256, -256);
            _testSprite2.SetColor(new Color(1, 0, 0, 1));
        }
Exemple #3
0
        public void Render()
        {
            double height     = 200;
            double width      = 200;
            var    halfHeight = height / 2;
            var    halfWidth  = width / 2;

            double x = 0,
                   y = 0,
                   z = 0;

            float topUV    = 0;
            float bottomUV = 1;
            float leftUV   = 0;
            float rightUV  = 1;

            float red   = 1;
            float green = 0;
            float blue  = 0;
            float alpha = 1;

            var texture = _textureManager.Get("face_alpha");

            GL.Enable(EnableCap.Texture2D);
            GL.BindTexture(TextureTarget.Texture2D, texture.Id);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            GL.ClearColor(0f, 0f, 0f, 1f);
            GL.Clear(ClearBufferMask.ColorBufferBit);
            GL.Begin(PrimitiveType.Triangles);
            {
                GL.Color4(red, green, blue, alpha);
                GL.TexCoord2(leftUV, topUV);
                GL.Vertex3(x - halfWidth, y + halfHeight, z); //top left
                GL.TexCoord2(rightUV, topUV);
                GL.Vertex3(x + halfWidth, y + halfHeight, z); //top right
                GL.TexCoord2(leftUV, bottomUV);
                GL.Vertex3(x - halfWidth, y - halfHeight, z); //bottom left

                GL.TexCoord2(rightUV, topUV);
                GL.Vertex3(x + halfWidth, y + halfHeight, z); //top right
                GL.TexCoord2(rightUV, bottomUV);
                GL.Vertex3(x + halfWidth, y - halfHeight, z); //bottom right
                GL.TexCoord2(leftUV, bottomUV);
                GL.Vertex3(x - halfWidth, y - halfHeight, z); //bottom left
            }
            GL.End();
        }