public EventQueue() { _handle = Allegro.CreateEventQueue(); if (_handle == IntPtr.Zero) { throw new Exception("No events. Ever"); } Allegro.RegisterEventSource(_handle, Allegro.GetKeyboardEventSource()); }
public Font(string filename, int size) { _handle = Allegro.LoadFont(filename, size, 0); if (_handle == IntPtr.Zero) { Console.WriteLine("errno = {0}", Allegro.GetErrNo()); throw new Exception("Font could not be loaded HAHA."); } }
public Display(string title, int width, int height) { _handle = Allegro.CreateDisplay(width, height); if (_handle == IntPtr.Zero) { throw new Exception("No display for you!"); } Allegro.SetWindowTitle(_handle, title); Width = width; Height = height; }
static void Main(string[] args) { Allegro.Init(); using (var display = new Display("NOT SHIT", 1280, 720)) { using (var queue = new EventQueue()) { using (var font = new Font("fonts/DejaVuSansMono.ttf", 16)) { Main(display, queue, font); } } } }
public void Clear(Color color) { SetAsTarget(); Allegro.ClearToColor(color.AllegroColor); }
public void SetAsTarget() { Allegro.SetTargetBackbuffer(_handle); }
public void Flip() { Allegro.FlipDisplay(); }
public void Dispose() { Allegro.DestroyDisplay(_handle); }
public Allegro.IEvent NextEvent() { return(Allegro.GetNextEvent(_handle)); }
public void Dispose() { Allegro.DestroyEventQueue(_handle); }
public void Draw(string text, float x, float y, Color?color = null) { Allegro.DrawText(_handle, (color ?? Color.White).AllegroColor, x, y, 0, text); }
public void Measure(string text, out int x, out int y, out int width, out int height) { Allegro.GetTextDimensions(_handle, text, out x, out y, out width, out height); }
public void Dispose() { Allegro.DestroyFont(_handle); }