Наследование: IDisposable
Пример #1
0
        public void RenderGlyph(float x, float y, char c, bool isDropShadow)
        {
            var glyph = fontData.CharSetMapping[c];

            if (isDropShadow)
            {
                x -= (int)(glyph.rect.Width * 0.5f);
                y -= (int)(glyph.rect.Height * 0.5f + glyph.yOffset);
            }


            //note can cast drop shadow offset to int, but then you can't move the shadow smoothly...
            if (fontData.dropShadow != null && options.DropShadowActive)
            {
                fontData.dropShadow.RenderGlyph(
                    x + (fontData.meanGlyphWidth * options.DropShadowOffset.X + glyph.rect.Width * 0.5f),
                    y + (fontData.meanGlyphWidth * options.DropShadowOffset.Y + glyph.rect.Height * 0.5f + glyph.yOffset), c, true);
            }



            if (isDropShadow)
            {
                GL.Color4(1.0f, 1.0f, 1.0f, options.DropShadowOpacity);
            }
            else
            {
                GL.Color4(options.Colour);
            }


            TexturePage sheet = fontData.Pages[glyph.page];

            GL.BindTexture(TextureTarget.Texture2D, sheet.GLTexID);


            float tx1 = (float)(glyph.rect.X) / sheet.Width;
            float ty1 = (float)(glyph.rect.Y) / sheet.Height;
            float tx2 = (float)(glyph.rect.X + glyph.rect.Width) / sheet.Width;
            float ty2 = (float)(glyph.rect.Y + glyph.rect.Height) / sheet.Height;

            GL.Begin(BeginMode.Quads);
            GL.TexCoord2(tx1, ty1); GL.Vertex2(x, y + glyph.yOffset);
            GL.TexCoord2(tx1, ty2); GL.Vertex2(x, y + glyph.yOffset + glyph.rect.Height);
            GL.TexCoord2(tx2, ty2); GL.Vertex2(x + glyph.rect.Width, y + glyph.yOffset + glyph.rect.Height);
            GL.TexCoord2(tx2, ty1); GL.Vertex2(x + glyph.rect.Width, y + glyph.yOffset);
            GL.End();
        }
Пример #2
0
        public void RenderGlyph(float x, float y, char c, bool isDropShadow)
        {
            var glyph = fontData.CharSetMapping[c];

            //note: it's not immediately obvious, but this combined with the paramteters to
            //RenderGlyph for the shadow mean that we render the shadow centrally (despite it being a different size)
            //under the glyph
            if (isDropShadow)
            {
                x -= (int)(glyph.rect.Width * 0.5f);
                y -= (int)(glyph.rect.Height * 0.5f + glyph.yOffset);
            }


            RenderDropShadow(x, y, c, glyph);


            if (isDropShadow)
            {
                GL.Color4(1.0f, 1.0f, 1.0f, Options.DropShadowOpacity);
            }
            else
            {
                GL.Color4(Options.Colour);
            }


            TexturePage sheet = fontData.Pages[glyph.page];

            GL.BindTexture(TextureTarget.Texture2D, sheet.GLTexID);


            float tx1 = (float)(glyph.rect.X) / sheet.Width;
            float ty1 = (float)(glyph.rect.Y) / sheet.Height;
            float tx2 = (float)(glyph.rect.X + glyph.rect.Width) / sheet.Width;
            float ty2 = (float)(glyph.rect.Y + glyph.rect.Height) / sheet.Height;

            GL.Begin(PrimitiveType.Quads);
            GL.TexCoord2(tx1, ty1); GL.Vertex2(x, y + glyph.yOffset);
            GL.TexCoord2(tx1, ty2); GL.Vertex2(x, y + glyph.yOffset + glyph.rect.Height);
            GL.TexCoord2(tx2, ty2); GL.Vertex2(x + glyph.rect.Width, y + glyph.yOffset + glyph.rect.Height);
            GL.TexCoord2(tx2, ty1); GL.Vertex2(x + glyph.rect.Width, y + glyph.yOffset);
            GL.End();
        }
Пример #3
0
        /// <summary>
        /// Renders the glyph at the position given.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="c">The character to print.</param>
        internal void RenderGlyph(float x, float y, char c, QFont font, IList <QVertex> store, Rectangle clippingRectangle)
        {
            QFontGlyph glyph = font.FontData.CharSetMapping[c];

            //note: it's not immediately obvious, but this combined with the paramteters to
            //RenderGlyph for the shadow mean that we render the shadow centrally (despite it being a different size)
            //under the glyph
            if (font.FontData.isDropShadow)
            {
                x -= (int)(glyph.rect.Width * 0.5f);
                y -= (int)(glyph.rect.Height * 0.5f + glyph.yOffset);
            }
            else
            {
                RenderDropShadow(x, y, c, glyph, font.FontData.dropShadowFont, ref clippingRectangle);
            }

            y = -y;

            TexturePage sheet = font.FontData.Pages[glyph.page];

            float tx1 = (float)(glyph.rect.X) / sheet.Width;
            float ty1 = (float)(glyph.rect.Y) / sheet.Height;
            float tx2 = (float)(glyph.rect.X + glyph.rect.Width) / sheet.Width;
            float ty2 = (float)(glyph.rect.Y + glyph.rect.Height) / sheet.Height;

            float vx      = x + PrintOffset.X;
            float vy      = y - glyph.yOffset + PrintOffset.Y;
            float vwidth  = glyph.rect.Width;
            float vheight = glyph.rect.Height;

            if (clippingRectangle != default(Rectangle) && ScissorsTest(ref vx, ref vy, ref vwidth, ref vheight, ref tx1, ref ty1, ref tx2, ref ty2, clippingRectangle))
            {
                return;
            }

            var tv1 = new Vector2(tx1, ty1);
            var tv2 = new Vector2(tx1, ty2);
            var tv3 = new Vector2(tx2, ty2);
            var tv4 = new Vector2(tx2, ty1);

            Vector3 v1 = new Vector3(vx, vy, PrintOffset.Z);
            Vector3 v2 = new Vector3(vx, vy - vheight, PrintOffset.Z);
            Vector3 v3 = new Vector3(vx + vwidth, vy - vheight, PrintOffset.Z);
            Vector3 v4 = new Vector3(vx + vwidth, vy, PrintOffset.Z);

            Color color;

            if (font.FontData.isDropShadow)
            {
                color = this.Options.DropShadowColour;
            }
            else
            {
                color = this.Options.Colour;
            }

            Vector4 colour = Helper.ToVector4(color);

            store.Add(new QVertex()
            {
                Position = v1, TextureCoord = tv1, VertexColor = colour
            });
            store.Add(new QVertex()
            {
                Position = v2, TextureCoord = tv2, VertexColor = colour
            });
            store.Add(new QVertex()
            {
                Position = v3, TextureCoord = tv3, VertexColor = colour
            });

            store.Add(new QVertex()
            {
                Position = v1, TextureCoord = tv1, VertexColor = colour
            });
            store.Add(new QVertex()
            {
                Position = v3, TextureCoord = tv3, VertexColor = colour
            });
            store.Add(new QVertex()
            {
                Position = v4, TextureCoord = tv4, VertexColor = colour
            });
        }
Пример #4
0
        public void RenderGlyph(float x, float y, char c, bool isDropShadow)
        {
            var glyph = fontData.CharSetMapping[c];

            //note: it's not immediately obvious, but this combined with the paramteters to
            //RenderGlyph for the shadow mean that we render the shadow centrally (despite it being a different size)
            //under the glyph
            if (isDropShadow)
            {
                x -= (int)(glyph.rect.Width * 0.5f);
                y -= (int)(glyph.rect.Height * 0.5f + glyph.yOffset);
            }

            RenderDropShadow(x, y, c, glyph);

            TexturePage sheet = fontData.Pages[glyph.page];

            float tx1 = (float)(glyph.rect.X) / sheet.Width;
            float ty1 = (float)(glyph.rect.Y) / sheet.Height;
            float tx2 = (float)(glyph.rect.X + glyph.rect.Width) / sheet.Width;
            float ty2 = (float)(glyph.rect.Y + glyph.rect.Height) / sheet.Height;

            var tv1 = new Vector2(tx1, ty1);
            var tv2 = new Vector2(tx1, ty2);
            var tv3 = new Vector2(tx2, ty2);
            var tv4 = new Vector2(tx2, ty1);

            var v1 = PrintOffset + new Vector3(x, y + glyph.yOffset, 0);
            var v2 = PrintOffset + new Vector3(x, y + glyph.yOffset + glyph.rect.Height, 0);
            var v3 = PrintOffset + new Vector3(x + glyph.rect.Width, y + glyph.yOffset + glyph.rect.Height, 0);
            var v4 = PrintOffset + new Vector3(x + glyph.rect.Width, y + glyph.yOffset, 0);

            Color color = Options.Colour;

            if (isDropShadow)
            {
                color = Color.FromArgb((int)(Options.DropShadowOpacity * 255f), Color.White);
            }

            if (UsingVertexBuffers)
            {
                var normal = new Vector3(0, 0, -1);

                int argb = Helper.ToRgba(color);

                var vbo = VertexBuffers[glyph.page];

                vbo.AddVertex(v1, normal, tv1, argb);
                vbo.AddVertex(v2, normal, tv2, argb);
                vbo.AddVertex(v3, normal, tv3, argb);

                vbo.AddVertex(v1, normal, tv1, argb);
                vbo.AddVertex(v3, normal, tv3, argb);
                vbo.AddVertex(v4, normal, tv4, argb);
            }

            // else use immediate mode
            else
            {
                GL.Color4(color);
                GL.BindTexture(TextureTarget.Texture2D, sheet.GLTexID);

                GL.Begin(PrimitiveType.Quads);
                GL.TexCoord2(tv1); GL.Vertex3(v1);
                GL.TexCoord2(tv2); GL.Vertex3(v2);
                GL.TexCoord2(tv3); GL.Vertex3(v3);
                GL.TexCoord2(tv4); GL.Vertex3(v4);
                GL.End();
                GL.BindTexture(TextureTarget.Texture2D, 0);
            }
        }