Update!
Fixed the error and implemented font drawing!
using System;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Drawing;
using Ravage3D;
namespace Ravage3DTest
{
public partial class Form1 : Form
{
Ravage3D.Device GameDevice = null;
public Form1()
{
InitializeComponent();
}
public void Form1_Load(object sender, EventArgs e)
{
GameDevice = new Ravage3D.Device();
GameDevice.InitDevice(this.pictureBox1.Handle, true, this.pictureBox1.Width, this.pictureBox1.Height);
Thread t = new Thread(new ThreadStart(this.Render));
t.Start();
}
public void Render()
{
while (true)
{
GameDevice.BeginRendering();
GameDevice.EngineOverlay.PrintText("Arial", 20, 60, 60, FontStyle.Italic, "Testing fonts!", Color.White);
GameDevice.EndRendering();
}
}
}
}
Currently, the engine doesn't check for any types of error nor does it even exit graciously. The next update will probably include me implementing handlers for those sorts of errors as well as handling the LostDevice exception.
Screenshot:
The current code for the Overlay.cs is
using System;
using System.Collections;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace Ravage3D
{
public class Overlay
{
public Ravage3D.Device EngineDevice = null;
public ArrayList OverlayFonts = null;
public Overlay(Ravage3D.Device Dev)
{
this.EngineDevice = Dev;
this.OverlayFonts = new ArrayList();
}
public void PrintText(String TextFont, float TextSize, Int32 X, Int32 Y, System.Drawing.FontStyle TextStyle, String Text, System.Drawing.Color TextColor)
{
System.Drawing.Font tempFont = new System.Drawing.Font(TextFont, TextSize, TextStyle);
OverlayTextC tmpText = new OverlayTextC();
tmpText.OverlayText = Text;
tmpText.OverlayColor = TextColor;
tmpText.XPos = X;
tmpText.YPos = Y;
tmpText.OverlayFont = new Microsoft.DirectX.Direct3D.Font(this.EngineDevice.EngineDevice, tempFont);
OverlayFonts.Add(tmpText);
}
public void OverlayRender()
{
Microsoft.DirectX.Direct3D.Sprite OverlaySprite2 = new Microsoft.DirectX.Direct3D.Sprite(this.EngineDevice.EngineDevice);
OverlaySprite2.Begin(Microsoft.DirectX.Direct3D.SpriteFlags.AlphaBlend);
foreach (OverlayTextC t in OverlayFonts)
{
// Rectangle tmpRect = new Rectangle(t.XPos, t.YPos, this.EngineDevice.Width, this.EngineDevice.Height);
t.OverlayFont.DrawText(OverlaySprite2, t.OverlayText, t.XPos, t.YPos, t.OverlayColor.ToArgb());
}
OverlaySprite2.End();
OverlayFonts.Clear();
}
}
public class OverlayTextC
{
public Int32 XPos;
public Int32 YPos;
public String OverlayText;
public System.Drawing.Color OverlayColor;
public Microsoft.DirectX.Direct3D.Font OverlayFont;
}
}
I don't know how pretty/ugly this is since I'm not a .NET guru so comments are very much appreciated.