/// <summary> /// Setup OpenGL and load resources here. /// </summary> /// <param name="e">Not used.</param> protected override void OnLoad(EventArgs e) { GL.ClearColor(Color.MidnightBlue); renderer = new Gwen.Renderer.OpenTK(); skin = new Gwen.Skin.TexturedBase(renderer, "DefaultSkin.png"); skin.DefaultFont = new Font(renderer, "Arial", 10); canvas = new Canvas(skin); input = new Input.OpenTK(this); input.Initialize(canvas); canvas.SetSize (1024, 768); canvas.ShouldDrawBackground = true; canvas.BackgroundColor = Color.FromArgb(255, 150, 170, 170); //canvas.KeyboardInputEnabled = true; test = new UnitTest.UnitTest(canvas); stopwatch.Restart(); lastTime = 0; }
/// <summary> /// Setup OpenGL and load resources here. /// </summary> /// <param name="e">Not used.</param> protected override void OnLoad(EventArgs e) { GL.ClearColor(Color.MidnightBlue); renderer = new Gwen.Renderer.OpenTK(); skin = new Gwen.Skin.TexturedBase(renderer, "DefaultSkin.png"); skin.DefaultFont = new Font(renderer, "Arial", 10); canvas = new Canvas(skin); input = new Input.OpenTK(this); input.Initialize(canvas); canvas.SetSize(Width, Height); canvas.ShouldDrawBackground = true; canvas.BackgroundColor = Color.FromArgb(255, 150, 170, 170); ////canvas.KeyboardInputEnabled = true; //Control.TreeControl ctrl = new Control.TreeControl(canvas); //ctrl.AddNode("Node One"); //ctrl.AddNode("Node Two").AddNode("Node Two Inside"); //ctrl.SetBounds(20, 20, 400, 400); test = new UnitTest.UnitTest(canvas); //var button = new Button(canvas); //button.Font = new Font(renderer, "Times New Roman", 30); //button.AutoSizeToContents = false; //button.Text = "Hello I am a\n test button!"; //button.SetPosition(500, 500); //button.SetSize(200, 30); stopwatch.Restart(); lastTime = 0; }
public void Init(GameWindow gamewindow) { renderer = new Gwen.Renderer.OpenTK(); skin = new Gwen.Skin.TexturedBase (renderer, "DefaultSkin.png"); canvas = new Gwen.Control.Canvas (skin); canvas.SetSize (gamewindow.Width, gamewindow.Height); canvas.ShouldDrawBackground = true; canvas.BackgroundColor = System.Drawing.Color.FromArgb (255, 225, 225, 225); input = new Gwen.Input.OpenTK (gamewindow); input.Initialize (canvas); gamewindow.Keyboard.KeyDown += (s, e) => { input.ProcessKeyDown (e); }; gamewindow.Keyboard.KeyUp += (s, e) => { input.ProcessKeyUp (e); }; gamewindow.Mouse.ButtonDown += (s, e) => { input.ProcessMouseMessage (e); }; gamewindow.Mouse.ButtonUp += (s, e) => { input.ProcessMouseMessage (e); }; gamewindow.Mouse.Move += (s, e) => { input.ProcessMouseMessage (e); }; gamewindow.Mouse.WheelChanged += (s, e) => { input.ProcessMouseMessage (e); }; gamewindow.Load += (s, e) => { PreLoad(); gamewindow.VSync = VSyncMode.On; PostLoad(); }; gamewindow.Resize += (s, e) => { GL.Viewport (0, 0, gamewindow.Width, gamewindow.Height); GL.MatrixMode (MatrixMode.Projection); GL.LoadIdentity(); GL.Ortho (0, gamewindow.Width, gamewindow.Height, 0, -1, 1); canvas.SetSize (gamewindow.Width, gamewindow.Height); }; gamewindow.UpdateFrame += (s, e) => { PreUpdate(); if (renderer.TextCacheSize > 1000) renderer.FlushTextCache(); PostUpdate(); }; gamewindow.RenderFrame += (s, e) => { gamewindow.MakeCurrent(); PreRender(); canvas.RenderCanvas(); PostRender(); gamewindow.SwapBuffers(); }; }
/// <summary> /// Draws the specified string to the backing store. /// </summary> /// <param name="text">The <see cref="System.String"/> to draw.</param> /// <param name="font">The <see cref="System.Drawing.Font"/> that will be used.</param> /// <param name="brush">The <see cref="System.Drawing.Brush"/> that will be used.</param> /// <param name="point">The location of the text on the backing store, in 2d pixel coordinates. /// The origin (0, 0) lies at the top-left corner of the backing store.</param> public void DrawString(string text, System.Drawing.Font font, Brush brush, Point point, StringFormat format) { gfx.DrawString(text, font, brush, point, format); // render text on the bitmap OpenTK.LoadTextureInternal(texture, bmp); // copy bitmap to gl texture }