forked from Diavonir/Overwatch-2-Cheat-Aimbot-Esp
/
Render.cpp
173 lines (138 loc) · 6.16 KB
/
Render.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#include "render.h"
#include <imgui_internal.h>
#include <sstream>
#include <Vector.h>
ImFont* m_pTahomaFont;
ImFont* m_pTahomaFontLarge;
Renderer* g_Renderer;
void Renderer::Initialize(ImFont* Font, ImFont* LargeFont)
{
m_pTahomaFont = Font;
m_pTahomaFontLarge = LargeFont;
}
void Renderer::BeginScene()
{
ImGuiIO& io = ImGui::GetIO();
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 0.0f, 0.0f });
ImGui::PushStyleColor(ImGuiCol_WindowBg, { 0.0f, 0.0f, 0.0f, 0.0f });
ImGui::Begin("##Backbuffer", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoInputs);
ImGui::SetWindowPos(ImVec2(0, 0), ImGuiCond_Always);
ImGui::SetWindowSize(ImVec2(io.DisplaySize.x, io.DisplaySize.y), ImGuiCond_Always);
}
void Renderer::EndScene()
{
ImGuiWindow* window = ImGui::GetCurrentWindow();
window->DrawList->PushClipRectFullScreen();
ImGui::End();
ImGui::PopStyleColor();
ImGui::PopStyleVar(2);
}
float Renderer::RenderText(const std::string& text, const ImVec2& position, float size, uint32_t color, bool center, bool Large)
{
ImGuiWindow* window = ImGui::GetCurrentWindow();
float a = (color >> 24) & 0xff;
float r = (color >> 16) & 0xff;
float g = (color >> 8) & 0xff;
float b = (color) & 0xff;
std::stringstream stream(text);
std::string line;
float y = 0.0f;
int i = 0;
ImFont* Font;
if (Large)
Font = m_pTahomaFontLarge;
else
Font = m_pTahomaFont;
while (std::getline(stream, line))
{
ImVec2 textSize = m_pTahomaFont->CalcTextSizeA(size, FLT_MAX, 0.0f, line.c_str());
if (center)
{
window->DrawList->AddText(Font, size, { (position.x - textSize.x / 2.0f) + 1.0f, (position.y + textSize.y * i) + 1.0f }, ImGui::GetColorU32({ 0.0f, 0.0f, 0.0f, a / 255.0f }), line.c_str());
window->DrawList->AddText(Font, size, { (position.x - textSize.x / 2.0f) - 1.0f, (position.y + textSize.y * i) - 1.0f }, ImGui::GetColorU32({ 0.0f, 0.0f, 0.0f, a / 255.0f }), line.c_str());
window->DrawList->AddText(Font, size, { (position.x - textSize.x / 2.0f) + 1.0f, (position.y + textSize.y * i) - 1.0f }, ImGui::GetColorU32({ 0.0f, 0.0f, 0.0f, a / 255.0f }), line.c_str());
window->DrawList->AddText(Font, size, { (position.x - textSize.x / 2.0f) - 1.0f, (position.y + textSize.y * i) + 1.0f }, ImGui::GetColorU32({ 0.0f, 0.0f, 0.0f, a / 255.0f }), line.c_str());
window->DrawList->AddText(Font, size, { position.x - textSize.x / 2.0f, position.y + textSize.y * i }, ImGui::GetColorU32({ r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f }), line.c_str());
}
else
{
window->DrawList->AddText(Font, size, { (position.x) + 1.0f, (position.y + textSize.y * i) + 1.0f }, ImGui::GetColorU32({ 0.0f, 0.0f, 0.0f, a / 255.0f }), line.c_str());
window->DrawList->AddText(Font, size, { (position.x) - 1.0f, (position.y + textSize.y * i) - 1.0f }, ImGui::GetColorU32({ 0.0f, 0.0f, 0.0f, a / 255.0f }), line.c_str());
window->DrawList->AddText(Font, size, { (position.x) + 1.0f, (position.y + textSize.y * i) - 1.0f }, ImGui::GetColorU32({ 0.0f, 0.0f, 0.0f, a / 255.0f }), line.c_str());
window->DrawList->AddText(Font, size, { (position.x) - 1.0f, (position.y + textSize.y * i) + 1.0f }, ImGui::GetColorU32({ 0.0f, 0.0f, 0.0f, a / 255.0f }), line.c_str());
window->DrawList->AddText(Font, size, { position.x, position.y + textSize.y * i }, ImGui::GetColorU32({ r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f }), line.c_str());
}
y = position.y + textSize.y * (i + 1);
i++;
}
return y;
}
void Renderer::RenderLine(const ImVec2& from, const ImVec2& to, uint32_t color, float thickness)
{
ImGuiWindow* window = ImGui::GetCurrentWindow();
float a = (color >> 24) & 0xff;
float r = (color >> 16) & 0xff;
float g = (color >> 8) & 0xff;
float b = (color) & 0xff;
window->DrawList->AddLine(from, to, ImGui::GetColorU32({ r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f }), thickness);
}
void Renderer::RenderCircle(const ImVec2& position, float radius, uint32_t color, float thickness, uint32_t segments)
{
ImGuiWindow* window = ImGui::GetCurrentWindow();
float a = (color >> 24) & 0xff;
float r = (color >> 16) & 0xff;
float g = (color >> 8) & 0xff;
float b = (color) & 0xff;
window->DrawList->AddCircle(position, radius, ImGui::GetColorU32({ r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f }), segments, thickness);
}
void Renderer::RenderCircleFilled(const ImVec2& position, float radius, uint32_t color, uint32_t segments)
{
ImGuiWindow* window = ImGui::GetCurrentWindow();
float a = (color >> 24) & 0xff;
float r = (color >> 16) & 0xff;
float g = (color >> 8) & 0xff;
float b = (color) & 0xff;
window->DrawList->AddCircleFilled(position, radius, ImGui::GetColorU32({ r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f }), segments);
}
void Renderer::RenderRect(const ImVec2& from, const ImVec2& to, uint32_t color, float rounding, uint32_t roundingCornersFlags, float thickness)
{
ImGuiWindow* window = ImGui::GetCurrentWindow();
float a = (color >> 24) & 0xFF;
float r = (color >> 16) & 0xFF;
float g = (color >> 8) & 0xFF;
float b = (color) & 0xFF;
window->DrawList->AddRect(from, to, ImGui::GetColorU32({ r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f }), rounding, roundingCornersFlags, thickness);
}
void Renderer::RenderRectFilled(const ImVec2& from, const ImVec2& to, uint32_t color, float rounding, uint32_t roundingCornersFlags)
{
ImGuiWindow* window = ImGui::GetCurrentWindow();
float a = (color >> 24) & 0xFF;
float r = (color >> 16) & 0xFF;
float g = (color >> 8) & 0xFF;
float b = (color) & 0xFF;
window->DrawList->AddRectFilled(from, to, ImGui::GetColorU32({ r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f }), rounding, roundingCornersFlags);
}
Vector FromHSB(float hue, float saturation, float brightness)
{
float h = hue == 1.0f ? 0 : hue * 6.0f;
float f = h - (int)h;
float p = brightness * (1.0f - saturation);
float q = brightness * (1.0f - saturation * f);
float t = brightness * (1.0f - (saturation * (1.0f - f)));
int hh = int(floor(h));
switch (hh) {
case 0:
return Vector(brightness, t, p);
case 1:
return Vector(q, brightness, p);
case 2:
return Vector(p, brightness, t);
case 3:
return Vector(p, q, brightness);
case 4:
return Vector(t, p, brightness);
default:
return Vector(brightness, p, q);
}
}