diff --git a/src/meson.build b/src/meson.build index aa90862d..eee988e5 100644 --- a/src/meson.build +++ b/src/meson.build @@ -57,6 +57,7 @@ if ['windows', 'mingw'].contains(host_machine.system()) 'win/d3d12_hook.cpp', 'win/d3d11_hook.cpp', 'win/d3d_shared.cpp', + 'win/ogl_hook.cpp', ) endif diff --git a/src/win/kiero.cpp b/src/win/kiero.cpp index cc170268..40400020 100644 --- a/src/win/kiero.cpp +++ b/src/win/kiero.cpp @@ -28,7 +28,7 @@ #endif #if KIERO_INCLUDE_OPENGL -# include +#include #endif #if KIERO_INCLUDE_VULKAN @@ -532,7 +532,7 @@ kiero::Status::Enum kiero::init(RenderType::Enum _renderType) { return Status::ModuleNotFoundError; } - + const char* const methodsNames[] = { "glAccum", "glAlphaFunc", "glAreTexturesResident", "glArrayElement", "glBegin", "glBindTexture", "glBitmap", "glBlendFunc", "glCallList", "glCallLists", "glClear", "glClearAccum", "glClearColor", "glClearDepth", "glClearIndex", "glClearStencil", "glClipPlane", "glColor3b", "glColor3bv", "glColor3d", "glColor3dv", "glColor3f", "glColor3fv", "glColor3i", "glColor3iv", @@ -562,7 +562,7 @@ kiero::Status::Enum kiero::init(RenderType::Enum _renderType) "glTexCoord4sv", "glTexCoordPointer", "glTexEnvf", "glTexEnvfv", "glTexEnvi", "glTexEnviv", "glTexGend", "glTexGendv", "glTexGenf", "glTexGenfv", "glTexGeni", "glTexGeniv", "glTexImage1D", "glTexImage2D", "glTexParameterf", "glTexParameterfv", "glTexParameteri", "glTexParameteriv", "glTexSubImage1D", "glTexSubImage2D", "glTranslated", "glTranslatef", "glVertex2d", "glVertex2dv", "glVertex2f", "glVertex2fv", "glVertex2i", "glVertex2iv", "glVertex2s", "glVertex2sv", "glVertex3d", "glVertex3dv", "glVertex3f", "glVertex3fv", "glVertex3i", "glVertex3iv", - "glVertex3s", "glVertex3sv", "glVertex4d", "glVertex4dv", "glVertex4f", "glVertex4fv", "glVertex4i", "glVertex4iv", "glVertex4s", "glVertex4sv", "glVertexPointer", "glViewport" + "glVertex3s", "glVertex3sv", "glVertex4d", "glVertex4dv", "glVertex4f", "glVertex4fv", "glVertex4i", "glVertex4iv", "glVertex4s", "glVertex4sv", "glVertexPointer", "glViewport", "wglSwapBuffers" }; size_t size = KIERO_ARRAY_SIZE(methodsNames); diff --git a/src/win/kiero.h b/src/win/kiero.h index 3fe6c015..473d6936 100644 --- a/src/win/kiero.h +++ b/src/win/kiero.h @@ -9,7 +9,7 @@ #define KIERO_INCLUDE_D3D10 0 // 1 if you need D3D10 hook #define KIERO_INCLUDE_D3D11 1 // 1 if you need D3D11 hook #define KIERO_INCLUDE_D3D12 1 // 1 if you need D3D12 hook -#define KIERO_INCLUDE_OPENGL 0 // 1 if you need OpenGL hook +#define KIERO_INCLUDE_OPENGL 1 // 1 if you need OpenGL hook #define KIERO_INCLUDE_VULKAN 1 // 1 if you need Vulkan hook #define KIERO_USE_MINHOOK 1 // 1 if you will use kiero::bind function @@ -75,4 +75,6 @@ namespace kiero uint150_t* getMethodsTable(); } -#endif // __KIERO_H__ \ No newline at end of file +#endif // __KIERO_H__ + +extern void init_ogl(); \ No newline at end of file diff --git a/src/win/main.cpp b/src/win/main.cpp index 8bf81698..22deb591 100644 --- a/src/win/main.cpp +++ b/src/win/main.cpp @@ -59,6 +59,7 @@ int MainThread() ConsoleSetup(); printf("MangoHud Attached!\n"); renderTypes(); + init_ogl(); if (!render_types.empty()){ impl::d3d11::init(); impl::d3d12::init(); diff --git a/src/win/ogl_hook.cpp b/src/win/ogl_hook.cpp new file mode 100644 index 00000000..24326f2a --- /dev/null +++ b/src/win/ogl_hook.cpp @@ -0,0 +1,19 @@ +#include "kiero.h" +#include +#include +#include "windows.h" +#include + +BOOL __stdcall (*owglSwapBuffers)(HDC hDc); + +BOOL __stdcall hwglSwapBuffers(HDC hDc) +{ + printf("swapbuffer\n"); + return owglSwapBuffers(hDc); +} + +void init_ogl(){ + printf("init ogl\n"); + auto ret = kiero::bind(336, (void**)&owglSwapBuffers, reinterpret_cast(hwglSwapBuffers)); + assert(ret == kiero::Status::Success); +} \ No newline at end of file