OpenGL钩,如何修改3D模型颜色?

发布于 2025-02-06 23:59:04 字数 304 浏览 2 评论 0原文

挂钩游戏是CS 1.6

Hook的Glbegin功能,

我想为角色模型渲染分配颜色,但是代码无效

寻求帮助

void APIENTRY hkGLBegin(GLenum mode)
{
    if (mode==5)
    {
        
        glEnable(GL_TEXTURE_2D);
        glColor4f(0, 0, 0, 0); //TODO FIXME failed
        glDisable(GL_TEXTURE_2D);
    }
}

Hook game is cs 1.6

Hook's glbegin function

I want to assign colors to the character model rendering, but the code is invalid

Ask for help

void APIENTRY hkGLBegin(GLenum mode)
{
    if (mode==5)
    {
        
        glEnable(GL_TEXTURE_2D);
        glColor4f(0, 0, 0, 0); //TODO FIXME failed
        glDisable(GL_TEXTURE_2D);
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听你说爱我 2025-02-13 23:59:04

我不熟悉这种GL黑客攻击,所以我可能错了...但是

您的代码是什么意思是无效的?是否有任何错误消息编译时间或运行时?也许您只需要添加:

#include <gl.h>

#include <gl\gl.h>

与您的编译器相关的任何其他缩写...

我不认为glenable(gl_texture_2d); gldisable(gl_texture_2d);glbegin/glend中允许...

如果挂钩在glbegin之前,则启用和禁用纹理也将在Hook不调用原始glbegin您也可能要添加它...

因此,我只剩下glcolor 并删除纹理语句,它们与颜色无关。 ..

如果它不起作用,则可能表明CS使用自己的Glcolor呼叫或照明尚未启用glenable(gl_color_material);,因此请尝试添加它。 ..

为什么使用模式== 5而不是mode == gl_triangle_strip?这是从gl.h中获取的,

#define GL_POINTS                           0x0000
#define GL_LINES                            0x0001
#define GL_LINE_LOOP                        0x0002
#define GL_LINE_STRIP                       0x0003
#define GL_TRIANGLES                        0x0004
#define GL_TRIANGLE_STRIP                   0x0005
#define GL_TRIANGLE_FAN                     0x0006
#define GL_QUADS                            0x0007
#define GL_QUAD_STRIP                       0x0008
#define GL_POLYGON                          0x0009

您还确定CS仅使用该原始性吗?如果不是,您也应该处理其他人...

所以我将更改为:

#include <gl.h> // optional if compile errors present
void APIENTRY hkGLBegin(GLenum mode)
   {
   if (mode==GL_TRIANGLE_STRIP)
      {
      glEnable(GL_COLOR_MATERIAL); // optional if color is not changed by glColor on textured surfaces
      glColor4f(0, 0, 0, 0);      
      }
   glBegin(mode); // optional if nothing is rendered
   }

I am not familiar with this kind of GL hacking so I might be wrong... however

What do you mean by code is invalid? Is there any error message compile time or runtime ? Maybe you just need to add:

#include <gl.h>

or

#include <gl\gl.h>

or any other abbreviation related to your compiler ...

I do not think glEnable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D); are allowed inside glBegin/glEnd ...

In case the hook is before glBegin then enabling and disabling texture will disable texture also if the hook does not call original glBegin you might want to add that too...

So I would leave just glColor and remove the texture statement they have nothing to do with color anyway...

If it does not work it might suggest that the CS is overiding it with own glColor calls or lighting has not enabled glEnable(GL_COLOR_MATERIAL); so try to add it ...

Why use mode == 5 instead of mode == GL_TRIANGLE_STRIP ? This is taken from gl.h

#define GL_POINTS                           0x0000
#define GL_LINES                            0x0001
#define GL_LINE_LOOP                        0x0002
#define GL_LINE_STRIP                       0x0003
#define GL_TRIANGLES                        0x0004
#define GL_TRIANGLE_STRIP                   0x0005
#define GL_TRIANGLE_FAN                     0x0006
#define GL_QUADS                            0x0007
#define GL_QUAD_STRIP                       0x0008
#define GL_POLYGON                          0x0009

Also are you sure CS is using that primitive only? if not you should also handle the others too ...

so I would change to:

#include <gl.h> // optional if compile errors present
void APIENTRY hkGLBegin(GLenum mode)
   {
   if (mode==GL_TRIANGLE_STRIP)
      {
      glEnable(GL_COLOR_MATERIAL); // optional if color is not changed by glColor on textured surfaces
      glColor4f(0, 0, 0, 0);      
      }
   glBegin(mode); // optional if nothing is rendered
   }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文