/// <summary> /// Creates the root console. /// </summary> /// <param name="bitmapFile">Path to bitmap file.</param> /// <param name="width">Width in characters of the console.</param> /// <param name="height">Height in characters of the console.</param> /// <param name="charWidth">Width of the characters.</param> /// <param name="charHeight">Height of the characters.</param> /// <param name="scale">Scale the window by this value.</param> /// <param name="title">Title of the window.</param> public RLRootConsole(string bitmapFile, int width, int height, int charWidth, int charHeight, float scale = 1f, string title = "RLNET Console") : base(width, height) { RLSettings settings = new RLSettings(); settings.BitmapFile = bitmapFile; settings.Width = width; settings.Height = height; settings.CharWidth = charWidth; settings.CharHeight = charHeight; settings.Scale = scale; settings.Title = title; Init(settings); }
private void Init(RLSettings settings) { if (settings == null) { throw new ArgumentNullException("settings"); } if (settings.BitmapFile == null) { throw new ArgumentNullException("BitmapFile"); } if (settings.Title == null) { throw new ArgumentNullException("Title"); } if (settings.Width <= 0) { throw new ArgumentException("Width cannot be zero or less"); } if (settings.Height <= 0) { throw new ArgumentException("Height cannot be zero or less"); } if (settings.CharWidth <= 0) { throw new ArgumentException("CharWidth cannot be zero or less"); } if (settings.CharHeight <= 0) { throw new ArgumentException("CharHeight cannot be zero or less"); } if (settings.Scale <= 0) { throw new ArgumentException("Scale cannot be zero or less"); } if (System.IO.File.Exists(settings.BitmapFile) == false) { throw new System.IO.FileNotFoundException("cannot find bitmapFile"); } this.scale = settings.Scale; this.scale3 = new Vector3(scale, scale, 1f); this.charWidth = settings.CharWidth; this.charHeight = settings.CharHeight; this.resizeType = settings.ResizeType; window = new GameWindow((int)(settings.Width * charWidth * scale), (int)(settings.Height * charHeight * scale), GraphicsMode.Default); window.WindowBorder = (WindowBorder)settings.WindowBorder; if (settings.StartWindowState == RLWindowState.Fullscreen || settings.StartWindowState == RLWindowState.Maximized) { window.WindowState = (WindowState)settings.StartWindowState; } window.Title = settings.Title; window.RenderFrame += window_RenderFrame; window.UpdateFrame += window_UpdateFrame; window.Load += window_Load; window.Resize += window_Resize; window.Closed += window_Closed; window.Closing += window_Closing; Mouse = new RLMouse(window); Keyboard = new RLKeyboard(window); LoadTexture2d(settings.BitmapFile); vboId = GL.GenBuffer(); iboId = GL.GenBuffer(); tcboId = GL.GenBuffer(); foreColorId = GL.GenBuffer(); backColorId = GL.GenBuffer(); CalcWindow(true); }
/// <summary> /// Creates the root console. /// </summary> /// <param name="settings">Settings for the RLRootConsole.</param> public RLRootConsole(RLSettings settings) : base(settings.Width, settings.Height) { Init(settings); }