/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GlControl_Load(object sender, EventArgs e) { if (DesignMode) { return; } //HACK: this method is called twice... Strange... if (SpriteBatch != null) { MessageBox.Show("[MonsterControl] : Double call to GlControlLoad(), Oops !"); } GlControl.MakeCurrent(); Display.ViewPort = new Rectangle(new Point(), GlControl.Size); Display.Init(); Display.ClearBuffers(); // Preload background texture resource CheckerBoard = new Texture2D(ResourceManager.GetInternalResource("ArcEngine.Resources.checkerboard.png")); CheckerBoard.HorizontalWrap = TextureWrapFilter.Repeat; CheckerBoard.VerticalWrap = TextureWrapFilter.Repeat; SpriteBatch = new SpriteBatch(); Draw(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Font2dForm_Load(object sender, EventArgs e) { GlControl.MakeCurrent(); Display.Init(); Batch = new SpriteBatch(); CheckerBoard = new Texture2D(ResourceManager.GetInternalResource("ArcEngine.Resources.checkerboard.png")); CheckerBoard.VerticalWrap = TextureWrapFilter.Repeat; CheckerBoard.HorizontalWrap = TextureWrapFilter.Repeat; }
/// <summary> /// OnPaint /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GlControl_Paint(object sender, PaintEventArgs e) { DrawTimer.Stop(); GlControl.MakeCurrent(); Display.ClearBuffers(); Batch.Begin(); // Background texture Rectangle dst = new Rectangle(Point.Empty, GlControl.Size); Batch.Draw(CheckerBoard, dst, dst, Color.White);; Batch.DrawString(CurrentFont, Point.Empty, Color.White, PreviewTextBox.Text); Batch.End(); DrawTimer.Start(); GlControl.SwapBuffers(); }
/// <summary> /// Render the monster visual /// </summary> void Draw() { try { GlControl.MakeCurrent(); Display.ClearBuffers(); if (SpriteBatch != null) { SpriteBatch.Begin(); // Background texture Rectangle dst = new Rectangle(Point.Empty, GlControl.Size); SpriteBatch.Draw(CheckerBoard, dst, dst, Color.White); if (Monster != null && TileSet != null) { Tile tile = TileSet.GetTile(Monster.Tile); if (tile != null) { Point pos = new Point((GlControl.Width - tile.Size.Width) / 2, (GlControl.Height - tile.Size.Height) / 2); pos.Offset(tile.Pivot); SpriteBatch.DrawTile(TileSet, Monster.Tile, pos); } } SpriteBatch.End(); } GlControl.SwapBuffers(); } catch (Exception e) { } }
/// <summary> /// Control resize /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GlControl_Resize(object sender, EventArgs e) { GlControl.MakeCurrent(); Display.ViewPort = new Rectangle(new Point(), GlControl.Size); }