improved glez performance
This commit is contained in:
parent
43cf73ef2b
commit
7d51035d98
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* prediction.h
|
* prediction.h
|
||||||
*
|
*
|
||||||
* Created on: Dec 5, 2016
|
* Created on: Dec 5, 2016
|
||||||
|
@ -26,7 +26,7 @@ namespace api
|
|||||||
|
|
||||||
struct font_handle_t
|
struct font_handle_t
|
||||||
{
|
{
|
||||||
glez_font_t handle;
|
glez_font_t handle{ GLEZ_FONT_INVALID };
|
||||||
std::string filename;
|
std::string filename;
|
||||||
float size;
|
float size;
|
||||||
};
|
};
|
||||||
|
@ -104,8 +104,6 @@ DEFINE_HOOKED_METHOD(PaintTraverse, void, vgui::IPanel *this_,
|
|||||||
original::PaintTraverse(this_, panel, force, allow_force);
|
original::PaintTraverse(this_, panel, force, allow_force);
|
||||||
// To avoid threading problems.
|
// To avoid threading problems.
|
||||||
|
|
||||||
PROF_SECTION(PT_total);
|
|
||||||
|
|
||||||
if (panel == panel_top)
|
if (panel == panel_top)
|
||||||
draw_flag = true;
|
draw_flag = true;
|
||||||
if (!cathook)
|
if (!cathook)
|
||||||
@ -161,7 +159,6 @@ DEFINE_HOOKED_METHOD(PaintTraverse, void, vgui::IPanel *this_,
|
|||||||
#if ENABLE_GUI
|
#if ENABLE_GUI
|
||||||
g_pGUI->Update();
|
g_pGUI->Update();
|
||||||
#endif
|
#endif
|
||||||
PROF_SECTION(PT_active);
|
|
||||||
draw::UpdateWTS();
|
draw::UpdateWTS();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,31 +8,34 @@
|
|||||||
#include <visual/SDLHooks.hpp>
|
#include <visual/SDLHooks.hpp>
|
||||||
#include "HookedMethods.hpp"
|
#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
|
namespace hooked_methods
|
||||||
{
|
{
|
||||||
|
|
||||||
DEFINE_HOOKED_METHOD(SDL_GL_SwapWindow, void, SDL_Window *window)
|
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<SDL_GetWindowWMInfo_t *>(
|
|
||||||
sharedobj::libsdl().Pointer(0xFD4D8));
|
|
||||||
static bool init_wminfo{ false };
|
|
||||||
if (!init_wminfo)
|
if (!init_wminfo)
|
||||||
{
|
{
|
||||||
|
GetWindowWMInfo = *reinterpret_cast<SDL_GetWindowWMInfo_t *>(
|
||||||
|
sharedobj::libsdl().Pointer(0xFD4D8));
|
||||||
GetWindowWMInfo(window, &wminfo);
|
GetWindowWMInfo(window, &wminfo);
|
||||||
init_wminfo = true;
|
init_wminfo = true;
|
||||||
}
|
}
|
||||||
if (!sdl_hooks::window)
|
if (!sdl_hooks::window)
|
||||||
sdl_hooks::window = window;
|
sdl_hooks::window = window;
|
||||||
|
|
||||||
static bool init{ false };
|
if (!tf2_sdl)
|
||||||
|
tf2_sdl = SDL_GL_GetCurrentContext();
|
||||||
static SDL_GLContext tf2_sdl = SDL_GL_GetCurrentContext();
|
|
||||||
|
|
||||||
if (cathook && !disable_visuals)
|
if (cathook && !disable_visuals)
|
||||||
{
|
{
|
||||||
@ -46,7 +49,7 @@ DEFINE_HOOKED_METHOD(SDL_GL_SwapWindow, void, SDL_Window *window)
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
PROF_SECTION(SWAPWINDOW_tf2);
|
PROF_SECTION(SWAPWINDOW_tf2);
|
||||||
SDL_GL_MakeCurrent(window, tf2_sdl);
|
//SDL_GL_MakeCurrent(window, tf2_sdl);
|
||||||
original::SDL_GL_SwapWindow(window);
|
original::SDL_GL_SwapWindow(window);
|
||||||
// glXMakeContextCurrent(wminfo.info.x11.display,
|
// glXMakeContextCurrent(wminfo.info.x11.display,
|
||||||
// wminfo.info.x11.window,
|
// wminfo.info.x11.window,
|
||||||
|
@ -37,7 +37,7 @@ font_handle_t create_font(const char *path, float size)
|
|||||||
font_handle_t result;
|
font_handle_t result;
|
||||||
result.filename = std::string(path);
|
result.filename = std::string(path);
|
||||||
result.size = size;
|
result.size = size;
|
||||||
result.handle = 0;
|
result.handle = GLEZ_FONT_INVALID;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ void initialize()
|
|||||||
}
|
}
|
||||||
xoverlay_show();
|
xoverlay_show();
|
||||||
#else
|
#else
|
||||||
context = SDL_GL_CreateContext(sdl_hooks::window);
|
//context = SDL_GL_CreateContext(sdl_hooks::window);
|
||||||
glClearColor(1.0, 0.0, 0.0, 0.5);
|
glClearColor(1.0, 0.0, 0.0, 0.5);
|
||||||
glewExperimental = GL_TRUE;
|
glewExperimental = GL_TRUE;
|
||||||
glewInit();
|
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,
|
void draw_string(float x, float y, const char *string, font_handle_t &font,
|
||||||
const rgba_t &rgba)
|
const rgba_t &rgba)
|
||||||
{
|
{
|
||||||
if (!font.handle)
|
if (font.handle == GLEZ_FONT_INVALID)
|
||||||
font.handle = glez_font_load(font.filename.c_str(), font.size);
|
font.handle = glez_font_load(font.filename.c_str(), font.size);
|
||||||
glez_string(x, y, string, font.handle,
|
glez_string(x, y, string, font.handle,
|
||||||
*reinterpret_cast<const glez_rgba_t *>(&rgba), nullptr,
|
*reinterpret_cast<const glez_rgba_t *>(&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,
|
font_handle_t &font, const rgba_t &rgba,
|
||||||
const rgba_t &rgba_outline, float thickness)
|
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);
|
font.handle = glez_font_load(font.filename.c_str(), font.size);
|
||||||
glez_string_with_outline(
|
glez_string_with_outline(
|
||||||
x, y, string, font.handle,
|
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,
|
void get_string_size(const char *string, font_handle_t &font, float *x,
|
||||||
float *y)
|
float *y)
|
||||||
{
|
{
|
||||||
if (!font.handle)
|
if (font.handle == GLEZ_FONT_INVALID)
|
||||||
font.handle = glez_font_load(font.filename.c_str(), font.size);
|
font.handle = glez_font_load(font.filename.c_str(), font.size);
|
||||||
glez_font_string_size(font.handle, string, x, y);
|
glez_font_string_size(font.handle, string, x, y);
|
||||||
}
|
}
|
||||||
@ -160,16 +160,29 @@ void draw_begin()
|
|||||||
#if EXTERNAL_DRAWING
|
#if EXTERNAL_DRAWING
|
||||||
xoverlay_draw_begin();
|
xoverlay_draw_begin();
|
||||||
#else
|
#else
|
||||||
SDL_GL_MakeCurrent(sdl_hooks::window, context);
|
{
|
||||||
|
PROF_SECTION(draw_begin__SDL_GL_MakeCurrent);
|
||||||
|
//SDL_GL_MakeCurrent(sdl_hooks::window, context);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
glez_begin();
|
{
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
PROF_SECTION(draw_begin__glez_end)
|
||||||
|
glez_begin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_end()
|
void draw_end()
|
||||||
{
|
{
|
||||||
PROF_SECTION(DRAWEX_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
|
#if EXTERNAL_DRAWING
|
||||||
xoverlay_draw_end();
|
xoverlay_draw_end();
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,7 +15,10 @@
|
|||||||
|
|
||||||
void render_cheat_visuals()
|
void render_cheat_visuals()
|
||||||
{
|
{
|
||||||
BeginCheatVisuals();
|
{
|
||||||
|
PROF_SECTION(BeginCheatVisuals);
|
||||||
|
BeginCheatVisuals();
|
||||||
|
}
|
||||||
// xoverlay_draw_rect(300, 300, 100, 100, xoverlay_rgba(200, 100, 100,
|
// xoverlay_draw_rect(300, 300, 100, 100, xoverlay_rgba(200, 100, 100,
|
||||||
// 255));
|
// 255));
|
||||||
// draw_api::draw_string(100, 100, "Testing", fonts::main_font,
|
// draw_api::draw_string(100, 100, "Testing", fonts::main_font,
|
||||||
@ -25,8 +28,14 @@ void render_cheat_visuals()
|
|||||||
// "TestingSTR", fh.handle, *reinterpret_cast<const xoverlay_rgba_t
|
// "TestingSTR", fh.handle, *reinterpret_cast<const xoverlay_rgba_t
|
||||||
// *>(&colors::white), 0, 0);
|
// *>(&colors::white), 0, 0);
|
||||||
// xoverlay_draw_string_with_outline(100, 20, "Testing2", )
|
// xoverlay_draw_string_with_outline(100, 20, "Testing2", )
|
||||||
DrawCheatVisuals();
|
{
|
||||||
EndCheatVisuals();
|
PROF_SECTION(DrawCheatVisuals);
|
||||||
|
DrawCheatVisuals();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
PROF_SECTION(EndCheatVisuals);
|
||||||
|
EndCheatVisuals();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BeginCheatVisuals()
|
void BeginCheatVisuals()
|
||||||
|
Reference in New Issue
Block a user