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
}