diff --git a/Plugins/Renderer/gl_hooks.cpp b/Plugins/Renderer/gl_hooks.cpp index b443a8a4..beb7dd07 100644 --- a/Plugins/Renderer/gl_hooks.cpp +++ b/Plugins/Renderer/gl_hooks.cpp @@ -7451,6 +7451,7 @@ static hook_t *g_phook_Mod_LoadBrushModel = NULL; static hook_t *g_phook_Mod_UnloadSpriteTextures = NULL; static hook_t *g_phook_triapi_RenderMode = NULL; static hook_t *g_phook_triapi_BoxInPVS = NULL; +static hook_t* g_phook_triapi_GetMatrix = NULL; //static hook_t *g_phook_triapi_Color4f = NULL; static hook_t *g_phook_Draw_MiptexTexture = NULL; static hook_t *g_phook_BuildGammaTable = NULL; @@ -7493,6 +7494,7 @@ void R_UninstallHooksForEngineDLL(void) Uninstall_Hook(Mod_UnloadSpriteTextures); Uninstall_Hook(triapi_RenderMode); Uninstall_Hook(triapi_BoxInPVS); + Uninstall_Hook(triapi_GetMatrix); Uninstall_Hook(Draw_MiptexTexture); Uninstall_Hook(BuildGammaTable); Uninstall_Hook(R_CullBox); @@ -7538,6 +7540,7 @@ void R_InstallHooks(void) Install_InlineHook(Mod_UnloadSpriteTextures); Install_InlineHook(triapi_RenderMode); Install_InlineHook(triapi_BoxInPVS); + Install_InlineHook(triapi_GetMatrix); Install_InlineHook(Draw_MiptexTexture); Install_InlineHook(BuildGammaTable); Install_InlineHook(R_CullBox); diff --git a/Plugins/Renderer/gl_local.h b/Plugins/Renderer/gl_local.h index 9989a334..9dcdcefb 100644 --- a/Plugins/Renderer/gl_local.h +++ b/Plugins/Renderer/gl_local.h @@ -391,6 +391,7 @@ void GL_DisableMultitexture(void); void GL_EnableMultitexture(void); void triapi_RenderMode(int mode); int triapi_BoxInPVS(float* mins, float* maxs); +void triapi_GetMatrix(const int pname, float* matrix); //void triapi_Color4f(float x, float y, float z, float w); void GL_UnloadTextureByIdentifier(const char* identifier, bool notify_callback); void GL_UnloadTextures(void); diff --git a/Plugins/Renderer/gl_rmain.cpp b/Plugins/Renderer/gl_rmain.cpp index 257b22dd..9dc42b4e 100644 --- a/Plugins/Renderer/gl_rmain.cpp +++ b/Plugins/Renderer/gl_rmain.cpp @@ -738,6 +738,22 @@ mbasenode_t* R_PVSNode(mbasenode_t* basenode, vec3_t emins, vec3_t emaxs) return NULL; } +void triapi_GetMatrix(const int pname, float* matrix) +{ + if (pname == GL_MODELVIEW_MATRIX) + { + memcpy(matrix, r_world_matrix, sizeof(float[16])); + return; + } + else if (pname == GL_PROJECTION_MATRIX) + { + memcpy(matrix, r_projection_matrix, sizeof(float[16])); + return; + } + + return gPrivateFuncs.triapi_GetMatrix(pname, matrix); +} + int triapi_BoxInPVS(float* mins, float* maxs) { return R_PVSNode(r_worldmodel->nodes, mins, maxs) != NULL; @@ -2920,7 +2936,7 @@ void R_AdjustScopeFOVForViewModel(float *fov) } } -void R_UseLegacyOpenGLMatrixForViewModel() +void R_LoadLegacyOpenGLMatrixForViewModel() { glMatrixMode(GL_PROJECTION); glLoadMatrixf(r_viewmodel_projection_matrix); @@ -2928,7 +2944,7 @@ void R_UseLegacyOpenGLMatrixForViewModel() glLoadMatrixf(r_world_matrix); } -void R_UseLegacyOpenGLMatrixForWorld() +void R_LoadLegacyOpenGLMatrixForWorld() { glMatrixMode(GL_PROJECTION); glLoadMatrixf(r_projection_matrix); @@ -2936,7 +2952,7 @@ void R_UseLegacyOpenGLMatrixForWorld() glLoadMatrixf(r_world_matrix); } -void R_UseProjMatrixForViewModel(void) +void R_UploadProjMatrixForViewModel(void) { scene_ubo_t SceneUBO; memcpy(SceneUBO.projMatrix, r_viewmodel_projection_matrix, sizeof(mat4)); @@ -2956,7 +2972,7 @@ void R_UseProjMatrixForViewModel(void) } } -void R_UseProjMatrixForWorld(void) +void R_LoadProjMatrixForWorld(void) { scene_ubo_t SceneUBO; memcpy(SceneUBO.projMatrix, r_projection_matrix, sizeof(mat4)); @@ -3025,7 +3041,7 @@ void R_SetupGLForViewModel(void) InvertMatrix(r_viewmodel_projection_matrix, r_viewmodel_projection_matrix_inv); - R_UseProjMatrixForViewModel(); + R_UploadProjMatrixForViewModel(); } } @@ -3543,7 +3559,7 @@ void R_EndRenderOpaque(void) } //For backward compatibility, some Mods may use Legacy OpenGL 1.x Matrix - R_UseLegacyOpenGLMatrixForWorld(); + R_LoadLegacyOpenGLMatrixForWorld(); } void ClientDLL_DrawNormalTriangles(void)