public OverlayForm() {
InitializeComponents();
this.Doublebuffered = true;
}
private static overlayTimer_Tick(object sender, EventArgs e) {
Graphics dc = this.CreateGraphics();
// render your stuff
}
Device device;
PresentParameters pparams;
Direct3D d3dObj;
SlimDX.Direct3D9.Font font;
Line line;
private void InitD3D(IntPtr hWnd, int width, int height)
{
d3dObj = new Direct3D();
pparams = new PresentParameters();
pparams.SwapEffect = SwapEffect.Discard;
pparams.Windowed = true;
pparams.EnableAutoDepthStencil = false;
pparams.BackBufferHeight = height;
pparams.BackBufferWidth = width;
pparams.DeviceWindowHandle = this.Handle;
pparams.BackBufferCount = 2;
pparams.BackBufferFormat = Format.A8R8G8B8;
device = new Device(d3dObj, 0, DeviceType.Hardware, this.Handle, CreateFlags.HardwareVertexProcessing, pparams);
line = new Line(device);
font = new SlimDX.Direct3D9.Font(device, new System.Drawing.Font("Calibri", 14));
}
void DrawLine(float x1, float y1, float x2, float y2, int thickness, Color color)
{
Vector2[] vertices =
{
new Vector2(x1, y1),
new Vector2(x2, y2)
};
line.Width = thickness;
line.Draw(vertices, (Color4)color);
}
void Draw2DBox(int x, int y, int w, int h, Color color)
{
Vector2[] vertices =
{
new Vector2(x, y),
new Vector2(x + w, y),
new Vector2(x + w, y + h),
new Vector2(x, y + h),
new Vector2(x, y)
};
line.Draw(vertices, (Color4)color);
}line.Draw(vertices, (Color4)color);
}