diff --git a/include/prediction.hpp b/include/prediction.hpp index 8d8171f2..a625cce4 100755 --- a/include/prediction.hpp +++ b/include/prediction.hpp @@ -1,4 +1,4 @@ -/* + /* * prediction.h * * Created on: Dec 5, 2016 diff --git a/include/visual/drawex.hpp b/include/visual/drawex.hpp index f23a70c9..7a93f96a 100755 --- a/include/visual/drawex.hpp +++ b/include/visual/drawex.hpp @@ -26,7 +26,7 @@ namespace api struct font_handle_t { - glez_font_t handle; + glez_font_t handle{ GLEZ_FONT_INVALID }; std::string filename; float size; }; diff --git a/src/hooks/visual/PaintTraverse.cpp b/src/hooks/visual/PaintTraverse.cpp index 202fc1bf..89416fa7 100644 --- a/src/hooks/visual/PaintTraverse.cpp +++ b/src/hooks/visual/PaintTraverse.cpp @@ -104,8 +104,6 @@ DEFINE_HOOKED_METHOD(PaintTraverse, void, vgui::IPanel *this_, original::PaintTraverse(this_, panel, force, allow_force); // To avoid threading problems. - PROF_SECTION(PT_total); - if (panel == panel_top) draw_flag = true; if (!cathook) @@ -161,7 +159,6 @@ DEFINE_HOOKED_METHOD(PaintTraverse, void, vgui::IPanel *this_, #if ENABLE_GUI g_pGUI->Update(); #endif - PROF_SECTION(PT_active); draw::UpdateWTS(); } } \ No newline at end of file diff --git a/src/hooks/visual/SDL_GL_SwapWindow.cpp b/src/hooks/visual/SDL_GL_SwapWindow.cpp index 985c4011..749700c3 100644 --- a/src/hooks/visual/SDL_GL_SwapWindow.cpp +++ b/src/hooks/visual/SDL_GL_SwapWindow.cpp @@ -8,31 +8,34 @@ #include #include "HookedMethods.hpp" +static bool init{ false }; +static bool init_wminfo{ false }; +static SDL_SysWMinfo wminfo{}; + +int static_init_wminfo = (wminfo.version.major = 2, wminfo.version.minor = 0, 1); + +typedef SDL_bool (*SDL_GetWindowWMInfo_t)(SDL_Window * window, + SDL_SysWMinfo * info); +static SDL_GetWindowWMInfo_t GetWindowWMInfo = nullptr; +static SDL_GLContext tf2_sdl = nullptr; + namespace hooked_methods { DEFINE_HOOKED_METHOD(SDL_GL_SwapWindow, void, SDL_Window *window) { - static SDL_SysWMinfo wminfo; - wminfo.version.major = 2; - wminfo.version.minor = 0; - typedef SDL_bool (*SDL_GetWindowWMInfo_t)(SDL_Window * window, - SDL_SysWMinfo * info); - static SDL_GetWindowWMInfo_t GetWindowWMInfo = - *reinterpret_cast( - sharedobj::libsdl().Pointer(0xFD4D8)); - static bool init_wminfo{ false }; if (!init_wminfo) { + GetWindowWMInfo = *reinterpret_cast( + sharedobj::libsdl().Pointer(0xFD4D8)); GetWindowWMInfo(window, &wminfo); init_wminfo = true; } if (!sdl_hooks::window) sdl_hooks::window = window; - static bool init{ false }; - - static SDL_GLContext tf2_sdl = SDL_GL_GetCurrentContext(); + if (!tf2_sdl) + tf2_sdl = SDL_GL_GetCurrentContext(); if (cathook && !disable_visuals) { @@ -46,7 +49,7 @@ DEFINE_HOOKED_METHOD(SDL_GL_SwapWindow, void, SDL_Window *window) } { PROF_SECTION(SWAPWINDOW_tf2); - SDL_GL_MakeCurrent(window, tf2_sdl); + //SDL_GL_MakeCurrent(window, tf2_sdl); original::SDL_GL_SwapWindow(window); // glXMakeContextCurrent(wminfo.info.x11.display, // wminfo.info.x11.window, diff --git a/src/visual/drawex.cpp b/src/visual/drawex.cpp index cd36e0cc..81ddaae1 100755 --- a/src/visual/drawex.cpp +++ b/src/visual/drawex.cpp @@ -37,7 +37,7 @@ font_handle_t create_font(const char *path, float size) font_handle_t result; result.filename = std::string(path); result.size = size; - result.handle = 0; + result.handle = GLEZ_FONT_INVALID; return result; } @@ -78,7 +78,7 @@ void initialize() } xoverlay_show(); #else - context = SDL_GL_CreateContext(sdl_hooks::window); + //context = SDL_GL_CreateContext(sdl_hooks::window); glClearColor(1.0, 0.0, 0.0, 0.5); glewExperimental = GL_TRUE; glewInit(); @@ -124,7 +124,7 @@ void draw_circle(float x, float y, float radius, const rgba_t &rgba, void draw_string(float x, float y, const char *string, font_handle_t &font, const rgba_t &rgba) { - if (!font.handle) + if (font.handle == GLEZ_FONT_INVALID) font.handle = glez_font_load(font.filename.c_str(), font.size); glez_string(x, y, string, font.handle, *reinterpret_cast(&rgba), nullptr, @@ -135,7 +135,7 @@ void draw_string_with_outline(float x, float y, const char *string, font_handle_t &font, const rgba_t &rgba, const rgba_t &rgba_outline, float thickness) { - if (!font.handle) + if (font.handle == GLEZ_FONT_INVALID) font.handle = glez_font_load(font.filename.c_str(), font.size); glez_string_with_outline( x, y, string, font.handle, @@ -149,7 +149,7 @@ void draw_string_with_outline(float x, float y, const char *string, void get_string_size(const char *string, font_handle_t &font, float *x, float *y) { - if (!font.handle) + if (font.handle == GLEZ_FONT_INVALID) font.handle = glez_font_load(font.filename.c_str(), font.size); glez_font_string_size(font.handle, string, x, y); } @@ -160,16 +160,29 @@ void draw_begin() #if EXTERNAL_DRAWING xoverlay_draw_begin(); #else - SDL_GL_MakeCurrent(sdl_hooks::window, context); + { + PROF_SECTION(draw_begin__SDL_GL_MakeCurrent); + //SDL_GL_MakeCurrent(sdl_hooks::window, context); + } #endif - glez_begin(); + { + glActiveTexture(GL_TEXTURE0); + PROF_SECTION(draw_begin__glez_end) + glez_begin(); + } } void draw_end() { PROF_SECTION(DRAWEX_draw_end); - glez_end(); - SDL_GL_MakeCurrent(sdl_hooks::window, nullptr); + { + PROF_SECTION(draw_end__glez_end); + glez_end(); + } + { + PROF_SECTION(draw_end__SDL_GL_MakeCurrent); + //SDL_GL_MakeCurrent(sdl_hooks::window, nullptr); + } #if EXTERNAL_DRAWING xoverlay_draw_end(); #endif diff --git a/src/visual/drawmgr.cpp b/src/visual/drawmgr.cpp index 80e9f24c..af68de7b 100644 --- a/src/visual/drawmgr.cpp +++ b/src/visual/drawmgr.cpp @@ -15,7 +15,10 @@ void render_cheat_visuals() { - BeginCheatVisuals(); + { + PROF_SECTION(BeginCheatVisuals); + BeginCheatVisuals(); + } // xoverlay_draw_rect(300, 300, 100, 100, xoverlay_rgba(200, 100, 100, // 255)); // draw_api::draw_string(100, 100, "Testing", fonts::main_font, @@ -25,8 +28,14 @@ void render_cheat_visuals() // "TestingSTR", fh.handle, *reinterpret_cast(&colors::white), 0, 0); // xoverlay_draw_string_with_outline(100, 20, "Testing2", ) - DrawCheatVisuals(); - EndCheatVisuals(); + { + PROF_SECTION(DrawCheatVisuals); + DrawCheatVisuals(); + } + { + PROF_SECTION(EndCheatVisuals); + EndCheatVisuals(); + } } void BeginCheatVisuals()