-
Notifications
You must be signed in to change notification settings - Fork 0
/
EndScene.h
218 lines (173 loc) · 7.01 KB
/
EndScene.h
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#include "Hooks.h"
#include "Menu.h"
#include "imgui\imgui_impl_dx9.h"
#include "imgui\imgui_impl_win32.h"
#include "imgui\imgui_freetype.h"
#include <d3dx9tex.h>
#include "AntiAims.h"
#include "Eventlog.h"
#include "protect/encoding.hpp"
#include <chrono>
#include "manrope_meduim_ttf.h"
#include "fonts/SMALLEST_PIXEL-7.c"
#include "fonts/OpenSans-SemiBold.c"
#include "fonts/OpenSans-Bold.c"
#include "fonts/undefeated.h"
void InitRender(IDirect3DDevice9* pDevice)
{
if (!vars.menu.guiinited)
{
ImGui::CreateContext();
ImGui_ImplWin32_Init(csgo->Init.Window);
ImGui_ImplDX9_Init(pDevice);
ImGuiIO& io = ImGui::GetIO();
ImGuiStyle& style = ImGui::GetStyle();
style.AntiAliasedFill = false;
style.AntiAliasedLines = false;
ImFontConfig cfg;
cfg.OversampleH = 3;
cfg.OversampleV = 1;
fonts::esp_name = io.Fonts->AddFontFromMemoryTTF(OpenSans_Bold, sizeof(OpenSans_Bold), 14.f, &cfg, io.Fonts->GetGlyphRangesCyrillic());
fonts::esp_logs = io.Fonts->AddFontFromMemoryTTF(OpenSans_Bold, sizeof(OpenSans_Bold), 13.f, &cfg, io.Fonts->GetGlyphRangesCyrillic());
fonts::esp_info = io.Fonts->AddFontFromMemoryTTF(OpenSans_Bold, sizeof(OpenSans_Bold), 12.f, &cfg, io.Fonts->GetGlyphRangesCyrillic());
fonts::esp_icons = io.Fonts->AddFontFromMemoryCompressedTTF(
undefeated_compressed_data,
undefeated_compressed_size,
20.f,
&cfg,
io.Fonts->GetGlyphRangesCyrillic());
fonts::esp_icons_big = io.Fonts->AddFontFromMemoryCompressedTTF(
undefeated_compressed_data,
undefeated_compressed_size,
28.f,
&cfg,
io.Fonts->GetGlyphRangesCyrillic());
int old_fl = cfg.RasterizerFlags;
cfg.RasterizerFlags = ImGuiFreeType::RasterizerFlags::MonoHinting | ImGuiFreeType::RasterizerFlags::Monochrome;
fonts::very_small = io.Fonts->AddFontFromMemoryTTF(smallest_pixel_7, sizeof(smallest_pixel_7), 10, &cfg, io.Fonts->GetGlyphRangesCyrillic());
cfg.RasterizerFlags = old_fl;
fonts::menu_desc = io.Fonts->AddFontFromMemoryTTF(OpenSans_Bold, sizeof(OpenSans_Bold), 16.f, &cfg, io.Fonts->GetGlyphRangesCyrillic());
fonts::menu_main = io.Fonts->AddFontFromMemoryTTF(OpenSans_Bold, sizeof(OpenSans_Bold), 16.f, &cfg, io.Fonts->GetGlyphRangesCyrillic());
fonts::lby_indicator = io.Fonts->AddFontFromFileTTF(str("C:/windows/fonts/verdanab.ttf"), 20.f, &cfg, io.Fonts->GetGlyphRangesCyrillic());
ImGuiFreeType::BuildFontAtlas(io.Fonts, 0x0);
vars.menu.guiinited = true;
}
}
LPDIRECT3DTEXTURE9 img = nullptr;
LPD3DXSPRITE sprite = nullptr;
void DrawTaserRange() {
if (!csgo->should_draw_taser_range || !vars.visuals.taser_range)
return;
static float rainbow = 0.f;
rainbow += 0.001f;
if (rainbow > 1.f)
rainbow = 0.f;
std::pair<Vector, Vector> last = std::pair(Vector(0.f, 0.f, 0.f), Vector(0.f, 0.f, 0.f));
color_t last_color = color_t(0, 0, 0, 0);
color_t first_color = color_t(255, 255, 255, 0);
constexpr size_t size = 106;
for (size_t i = 0; i < size; i++)
{
auto& trace = csgo->taser_ranges[i];
float r = rainbow + float(i + 1) / size;
while (r >= 1.f) r -= 1.f;
while (r < 0.f) r += 1.f;
color_t clr = color_t::hsb(r, 1.f, 1.f);
if (i == 0) first_color = clr;
std::pair<Vector, Vector> buf;
if (last.first != Vector(0.f, 0.f, 0.f) && last.second != Vector(0.f, 0.f, 0.f)) {
Vector v1, v2;
if (Math::WorldToScreen(trace.first, v1) && Math::WorldToScreen(trace.second, v2)) {
if (i == 105)
last_color = first_color;
auto flags_backup = g_Render->_drawList->Flags;
g_Render->_drawList->Flags |= ImDrawListFlags_AntiAliasedFill | ImDrawListFlags_AntiAliasedLines;
if (vars.visuals.taser_range == 1)
g_Render->_drawList->AddQuadFilledMultiColor(
ImVec2(last.second.x, last.second.y), ImVec2(v2.x, v2.y), ImVec2(v1.x, v1.y),
ImVec2(last.first.x, last.first.y),
last_color.manage_alpha(0).u32(), clr.manage_alpha(0).u32(),
clr.manage_alpha(255).u32(), last_color.manage_alpha(255).u32());
else
g_Render->_drawList->AddQuadFilledMultiColor(
ImVec2(last.second.x, last.second.y), ImVec2(v2.x, v2.y), ImVec2(v1.x, v1.y),
ImVec2(last.first.x, last.first.y),
vars.visuals.taser_range_color.manage_alpha(0).u32(), vars.visuals.taser_range_color.manage_alpha(0).u32(),
vars.visuals.taser_range_color.u32(), vars.visuals.taser_range_color.u32());
g_Render->_drawList->Flags = flags_backup;
}
}
last_color = clr;
Math::WorldToScreen(trace.first, last.first);
Math::WorldToScreen(trace.second, last.second);
}
}
HRESULT __stdcall Hooked_EndScene(IDirect3DDevice9* device)
{
static auto EndScene = g_pDirectHook->GetOriginal<EndSceneFn>(g_HookIndices[fnva1(hs::Hooked_EndScene.s().c_str())]);
if (csgo->DoUnload)
return EndScene(device);
DWORD colorwrite, srgbwrite;
IDirect3DVertexDeclaration9* vert_dec = nullptr;
IDirect3DVertexShader9* vert_shader = nullptr;
DWORD dwOld_D3DRS_COLORWRITEENABLE = NULL;
device->GetRenderState(D3DRS_COLORWRITEENABLE, &colorwrite);
device->GetRenderState(D3DRS_SRGBWRITEENABLE, &srgbwrite);
device->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, FALSE);
device->SetRenderState(D3DRS_ANTIALIASEDLINEENABLE, FALSE);
device->SetRenderState(D3DRS_COLORWRITEENABLE, 0xffffffff);
//removes the source engine color correction
device->SetRenderState(D3DRS_SRGBWRITEENABLE, false);
device->GetVertexDeclaration(&vert_dec);
device->GetVertexShader(&vert_shader);
device->SetRenderState(D3DRS_COLORWRITEENABLE, 0xffffffff);
device->SetRenderState(D3DRS_SRGBWRITEENABLE, false);
device->SetSamplerState(NULL, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
device->SetSamplerState(NULL, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
device->SetSamplerState(NULL, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP);
device->SetSamplerState(NULL, D3DSAMP_SRGBTEXTURE, NULL);
InitRender(device);
csgo->render_device = device;
g_Render->PreRender(device);
g_Render->SetupPresent(device);
{
{
g_Menu->draw_indicators();
g_Visuals->Draw();
g_Hitmarker->Paint();
DrawTaserRange();
g_Visuals->DrawLocalVisuals();
auto flags_backup = g_Render->_drawList->Flags;
g_Render->_drawList->Flags |= ImDrawListFlags_AntiAliasedFill | ImDrawListFlags_AntiAliasedLines;
run_callback("render");
g_Render->_drawList->Flags = flags_backup;
g_Eventlog->Draw();
g_Menu->render();
}
}
ImGui::EndFrame();
ImGui::Render();
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
device->SetRenderState(D3DRS_COLORWRITEENABLE, colorwrite);
device->SetRenderState(D3DRS_SRGBWRITEENABLE, srgbwrite);
device->SetVertexDeclaration(vert_dec);
device->SetVertexShader(vert_shader);
csgo->mtx.lock();
for (auto& texture : csgo->outdated_textures)
texture.second->Release();
csgo->outdated_textures.clear();
csgo->mtx.unlock();
return EndScene(device);
}
HRESULT D3DAPI Hooked_Reset(IDirect3DDevice9* device, D3DPRESENT_PARAMETERS* params)
{
static auto Reset = g_pDirectHook->GetOriginal<ResetFn>(g_HookIndices[fnva1(hs::Hooked_Reset.s().c_str())]);
if (csgo->DoUnload)
return Reset(device, params);
g_Render->InvalidateObjects();
auto hr = Reset(device, params);
if (hr >= 0) {
g_Render->CreateObjects(device);
}
return hr;
}