Sharplike.Frontend.Rendering.TKWindow.DrawTile C# (CSharp) Méthode

DrawTile() private méthode

private DrawTile ( DisplayTile tile, int x, int y ) : void
tile Sharplike.Core.Rendering.DisplayTile
x int
y int
Résultat void
        private void DrawTile(DisplayTile tile, int x, int y)
        {
            Int32 w = this.GlyphPalette.GlyphDimensions.Width;
            Int32 h = this.GlyphPalette.GlyphDimensions.Height;
            x *= w;
            y *= h;

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            List<IGlyphProvider> gproviders = new List<IGlyphProvider>();
            foreach (RegionTile t in tile.RegionTiles)
            {
                foreach (IGlyphProvider p in t.GlyphProviders)
                    gproviders.Add(p);
            }

            foreach (IGlyphProvider glyphpro in gproviders)
            {
                GL.Begin(BeginMode.Quads);
                GL.Color4(glyphpro.BackgroundColor);
                GL.Vertex2(x, y);
                GL.Vertex2(x + w, y);
                GL.Vertex2(x + w, h + y);
                GL.Vertex2(x, h + y);
                GL.End();

                foreach (Glyph glyph in glyphpro.Glyphs)
                {
                    int uvrow = glyph.Index / GlyphPalette.ColumnCount;
                    int uvcol = glyph.Index % GlyphPalette.ColumnCount;

                    double u = (double)uvcol / (double)GlyphPalette.ColumnCount;
                    double v = (double)uvrow / (double)GlyphPalette.RowCount;
                    double du = 1.0 / (double)GlyphPalette.ColumnCount;
                    double dv = 1.0 / (double)GlyphPalette.RowCount;

                    GL.Enable(EnableCap.Texture2D);
                    GL.BindTexture(TextureTarget.Texture2D, paletteId);

                    GL.Begin(BeginMode.Quads);
                    GL.Color4(glyph.Color);
                    GL.TexCoord2(u, v); GL.Vertex2(x, y);
                    GL.TexCoord2(du + u, v); GL.Vertex2(x + w, y);
                    GL.TexCoord2(du + u, dv + v); GL.Vertex2(x + w, h + y);
                    GL.TexCoord2(u, dv + v); GL.Vertex2(x, h + y);
                    GL.End();
                    GL.Disable(EnableCap.Texture2D);
                }
            }
            GL.Disable(EnableCap.Blend);
        }