@@ -41,6 +41,8 @@ struct loadedTextureInformation
41
41
42
42
std::map<uint64_t , loadedTextureInformation> loadedTextures;
43
43
44
+
45
+ // below could use splitting into multiple functions
44
46
void * __stdcall HookGlTexImage2D (GLenum target,
45
47
GLint level,
46
48
GLint internalformat,
@@ -62,7 +64,7 @@ void* __stdcall HookGlTexImage2D(GLenum target,
62
64
else if (internalformat == GL_RGB || internalformat == GL_BGR
63
65
|| internalformat == GL_RGB8)
64
66
lengthModifier = 3 ;
65
- if (HASH_ENABLED)
67
+ if (HASH_ENABLED) // =======HASHING====//
66
68
{
67
69
if (data != nullptr && width != 0 && height != 0 && lengthModifier != 0
68
70
&& width < 1024 && height < 1024 )
@@ -89,7 +91,7 @@ if(HASH_ENABLED)
89
91
boundId, high64, low64);
90
92
knownTextures.insert (std::pair (high64, TexImageInformation{
91
93
low64,static_cast <GLuint>(boundId), internalformat, width, height }));
92
- if (HASH_OUTPUT)
94
+ if (HASH_OUTPUT) // ======OUTPUT OF HASHED TEXTURES======//
93
95
{
94
96
std::string exportPath = std::string (destinationPath.string ());
95
97
exportPath.append (GetHashExtension (true ));
@@ -127,7 +129,7 @@ if(HASH_OUTPUT)
127
129
OutputDebug (" Hashing of %dx%d*%d took %lfms\n " , width, height,
128
130
lengthModifier,
129
131
static_cast <double >(std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start).count ()) / 1e6 );
130
- if (HASH_LOAD_HD)
132
+ if (HASH_LOAD_HD) // =====HASH LOAD CODE=====//
131
133
{
132
134
std::string importPath = std::string (destinationPath.string ());
133
135
importPath.append (HASH_HD_SUFFIX);
@@ -155,9 +157,16 @@ if(HASH_OUTPUT)
155
157
{
156
158
OutputDebug (" Loading custom HD texture: %s!" , destinationPath.string ().c_str ());
157
159
158
- // BUGGED BELOW, DO NOT USE DDS YET!
160
+
159
161
if (bimg::isCompressed (imageContainer->m_format ))
162
+ {
160
163
RenderTexture (imageContainer); // redundant on checking two times for compression, but whatev
164
+ // return cast to glTexImage2D but with error
165
+ return static_cast <void * (__stdcall*) (GLenum, GLint, GLint, GLsizei, GLsizei,
166
+ GLint, GLenum, GLenum, const void *)>(ogl_tex_image2d)
167
+ (target, -1 , internalformat, static_cast <GLsizei>(width)
168
+ , static_cast <GLsizei>(height), border, format, type, data);
169
+ }
161
170
else
162
171
{
163
172
loadedTextureInformation lti{};
@@ -187,6 +196,18 @@ if(HASH_OUTPUT)
187
196
}
188
197
189
198
199
+
200
+ // this is null sub- basically hooking api requires static cast to function pointer. However if there's need to
201
+ // actually call compressed texture function, this is the way to do it. I call the compressed texture method and
202
+ // then return the main texture2D method into this null function. The compressed texture and glTexImage2D are voids
203
+ // that don't return anything as they work under bindings, so compressed texture will utilize the bound texture
204
+ // while this null reroute will do nothing and not overwrite the texture
205
+ void NullHookGlTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border,
206
+ GLenum format, GLenum type, const void * data)
207
+ {
208
+ }
209
+
210
+
190
211
BYTE* cltBackAdd1;
191
212
BYTE* cltBackAdd2;
192
213
DWORD* _thisFF8 = nullptr ; // __thiscall, so this is ECX
0 commit comments