This is some code out of my COD 4 Hack
Drawing.h:
Code:
#pragma once
#include "d3d9.h"
static class Drawing
{
public:
static void Draw_Text(LPCSTR TextToDraw, int x, int y, D3DCOLOR Colour, LPD3DXFONT m_font);
void Drawing::CreateFont(IDirect3DDevice9 *d3dDevice, std::string choiceFont);
LPD3DXFONT m_font;
}
Drawing.cpp:
Code:
#include "Drawing.h"
void Drawing::Draw_Text(LPCSTR TextToDraw, int x, int y, D3DCOLOR Colour, LPD3DXFONT m_font)
{
// Create a rectangle to indicate where on the screen it should be drawn
RECT rct = {x- 120, y, x+ 120, y + 15};
m_font->DrawText(NULL, TextToDraw, -1, &rct, DT_NOCLIP, Colour );
};
How to use:
Code:
void Drawing::CreateFont(IDirect3DDevice9 *d3dDevice, std::string choiceFont) //To create the font
{
D3DXCreateFont( d3dDevice, 20, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
choiceFont.c_str(), &m_font );
}
To draw the Text:
Code:
Drawing.CreateFont(m_pD3Ddev, "Arial");
Drawing::Draw_Text("Hi there", 20, 30, D3DCOLOR_ARGB(255, 255, 255, 255), m_font);
Hope this helps