iw4x-client/iw4/Components/Renderer.cpp

42 lines
751 B
C++
Raw Normal View History

2015-12-23 10:56:02 -05:00
#include "..\STDInclude.hpp"
namespace Components
{
Utils::Hook Renderer::DrawFrameHook;
std::vector<Renderer::Callback> Renderer::FrameCallbacks;
void __declspec(naked) Renderer::FrameHook()
{
__asm
{
call Renderer::FrameHandler
jmp Renderer::DrawFrameHook.Original
}
}
void Renderer::FrameHandler()
{
for (auto callback : Renderer::FrameCallbacks)
{
callback();
}
}
void Renderer::OnFrame(Renderer::Callback callback)
{
Renderer::FrameCallbacks.push_back(callback);
}
Renderer::Renderer()
{
// Frame hook
Renderer::DrawFrameHook.Initialize(0x5ACB99, Renderer::FrameHook, HOOK_CALL)->Install();
}
Renderer::~Renderer()
{
Renderer::DrawFrameHook.Uninstall();
Renderer::FrameCallbacks.clear();
}
}