Esempio n. 1
0
        public Size GetTextSize(string message)
        {
            var result = Ttf.SizeUTF8(_handle, message, out var w, out var h);

            if (result != 0)
            {
                throw new SdlException(nameof(Ttf.SizeUTF8));
            }
            return(new Size(w, h));
        }
Esempio n. 2
0
        public ISurface RenderText(string message, Color color, Color background)
        {
            var surface = Ttf.RenderUTF8_Shaded(_handle, message, color.ToSdlColor(), background.ToSdlColor());

            if (surface == IntPtr.Zero)
            {
                throw new SdlException(nameof(Ttf.RenderUTF8_Shaded));
            }
            return(new SdlSurface(surface));
        }
Esempio n. 3
0
        public ISurface RenderTextWrapped(string message, Color color, int maxWidth)
        {
            var surface = Ttf.RenderUTF8_Blended_Wrapped(_handle, message, color.ToSdlColor(), maxWidth);

            if (surface == IntPtr.Zero)
            {
                throw new SdlException(nameof(Ttf.RenderUTF8_Blended_Wrapped));
            }
            return(new SdlSurface(surface));
        }
Esempio n. 4
0
        public static Font LoadFont(string filename, int size, TtfFlags flags)
        {
            var font = Ttf.LoadFont(filename, size, flags);

            if (font == null)
            {
                throw new Exception(String.Format("LoadFont({0}, {1}, {2}) Failed", filename, size, flags));
            }
            return(font);
        }
Esempio n. 5
0
 public static void InitializeAllegro()
 {
     if (!Allegro.InstallSystem())
     {
         throw new Exception("allegro failz");
     }
     if (!Image.Init())
     {
         throw new Exception("image failz");
     }
     Font.Init();
     if (!Ttf.Init())
     {
         throw new Exception("ttf failz");
     }
     if (!Primitives.Init())
     {
         throw new Exception("primitives failz");
     }
     Display.Create(800, 600);
 }
Esempio n. 6
0
        public SdlEngine()
        {
            if (Sdl.Init(Sdl.SDL_INIT_EVERYTHING) != 0)
            {
                throw new SdlException(nameof(Sdl.Init));
            }

            if (Img.Init(IMG_InitFlags.IMG_INIT_PNG) == 0)
            {
                Sdl.Quit();
                throw new SdlException(nameof(Img.Init));
            }

            // ReSharper disable once InvertIf
            if (Ttf.Init() != 0)
            {
                Img.Quit();
                Sdl.Quit();
                throw new SdlException(nameof(Ttf.Init));
            }
        }
Esempio n. 7
0
 public bool CharacterIsProvided(char glyph)
 {
     return(Ttf.GlyphIsProvided(_handle, glyph) != 0);
 }