-
Notifications
You must be signed in to change notification settings - Fork 101
/
overlay.cpp
88 lines (69 loc) · 2.5 KB
/
overlay.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "overlay.h"
#include <string>
#include <cstdarg>
//ESP stuff
void initD3D(HWND hWnd)
{
d3d = Direct3DCreate9(D3D_SDK_VERSION); // create the Direct3D interface
D3DPRESENT_PARAMETERS d3dpp; // create a struct to hold various device information
ZeroMemory(&d3dpp, sizeof(d3dpp)); // clear out the struct for use
d3dpp.Windowed = TRUE; // program windowed, not fullscreen
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames
d3dpp.hDeviceWindow = hWnd; // set the window to be used by Direct3D
d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; // set the back buffer format to 32-bit
d3dpp.BackBufferWidth = s_width; // set the width of the buffer
d3dpp.BackBufferHeight = s_height; // set the height of the buffer
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
// create a device class using this information and the info from the d3dpp stuct
d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
D3DXCreateFontA(d3ddev, 13, 0, FW_HEAVY, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &pFont);
D3DXCreateLine(d3ddev, &d3dLine);
}
void DrawString(int x, int y, DWORD color, LPD3DXFONT g_pFont, const char *fmt, ...)
{
char buf[1024] = { 0 };
va_list va_alist;
RECT FontPos = { x, y, x + 120, y + 16 };
va_start(va_alist, fmt);
vsprintf_s(buf, fmt, va_alist);
va_end(va_alist);
g_pFont->DrawTextA(NULL, buf, -1, &FontPos, DT_NOCLIP, color);
}
void DrawLine(float x, float y, float xx, float yy, D3DCOLOR color)
{
D3DXVECTOR2 dLine[2];
d3dLine->SetWidth(1.f);
dLine[0].x = x;
dLine[0].y = y;
dLine[1].x = xx;
dLine[1].y = yy;
d3dLine->Draw(dLine, 2, color);
}
void DrawBox(float x, float y, float width, float height, D3DCOLOR color)
{
D3DXVECTOR2 points[5];
points[0] = D3DXVECTOR2(x, y);
points[1] = D3DXVECTOR2(x + width, y);
points[2] = D3DXVECTOR2(x + width, y + height);
points[3] = D3DXVECTOR2(x, y + height);
points[4] = D3DXVECTOR2(x, y);
d3dLine->SetWidth(1);
d3dLine->Draw(points, 5, color);
}
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_PAINT:
render();
break;
case WM_CREATE:
DwmExtendFrameIntoClientArea(hWnd, &margin);
break;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}