Esempio n. 1
0
        public static void RenderTexture(TextureInfo textureInfo, float x, float y, float orientation = 0,
            float offsetX = 0, float offsetY = 0,
            LabelStyle.HorizontalAlignmentEnum horizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Center,
            LabelStyle.VerticalAlignmentEnum verticalAlignment = LabelStyle.VerticalAlignmentEnum.Center,
            float opacity = 1f,
            float scale = 1f)
        {
            GL.Enable(All.Texture2D);
            GL.BindTexture(All.Texture2D, textureInfo.TextureId);

            GL.PushMatrix();
            GL.Translate(x, y, 0f);
            GL.Rotate(orientation, 0, 0, 1);
            GL.Scale (scale, scale, 1);

            x = offsetX + DetermineHorizontalAlignmentCorrection(horizontalAlignment, textureInfo.Width);
            y = -offsetY + DetermineVerticalAlignmentCorrection(verticalAlignment, textureInfo.Height);

            var halfWidth = textureInfo.Width / 2;
            var halfHeight = textureInfo.Height / 2;

            var vertextArray = new[]
            {
                x - halfWidth, y - halfHeight,
                x + halfWidth, y - halfHeight,
                x + halfWidth, y + halfHeight,
                x - halfWidth, y + halfHeight
            };

            RenderTextureWithoutBinding(textureInfo.TextureId, vertextArray, opacity);

            GL.PopMatrix();
            GL.BindTexture(All.Texture2D, 0);
            GL.Disable(All.Texture2D);
        }
Esempio n. 2
0
        public static TextureInfo LoadTexture(Stream textureData)
        {
            var textureInfo = new TextureInfo();

            GL.Enable(All.Texture2D);
            GL.GenTextures(1, out textureInfo.TextureId);
            GL.BindTexture(All.Texture2D, textureInfo.TextureId);

            SetParameters();

            PlatformTextureLoader.TexImage2D(textureData, out textureInfo.Width, out textureInfo.Height);

            GL.BindTexture(All.Texture2D, 0);

            return textureInfo;
        }