So yeah I'm trying to get my own textures in the game.
Here are the functions I made using the Valve SDK, thy are working aswell
Code:
unsigned int CreateNewTextureID(bool meh)
{
typedef unsigned int(__thiscall* OriginalFn)(void*, bool);
return getvfunc<OriginalFn>(this, 43)(this, meh);
}
void DrawSetTextureRGBA(int TextureId, unsigned char const* rawRGBA, int W, int T, int h, bool f)
{
typedef void(__thiscall* OriginalFn)(void*, int, unsigned char const*, int, int, int, bool);
return getvfunc<OriginalFn>(this, 37)(this, TextureId, rawRGBA, W, T, h , f);
}
bool IsTextureIDValid(int TextureID)
{
typedef bool(__thiscall* OriginalFn)(void*, int);
return getvfunc<OriginalFn>(this, 42)(this, TextureID);
}
void DrawSetTexture(int TextureID)
{
typedef void(__thiscall* OriginalFn)(void*, int);
return getvfunc<OriginalFn>(this, 38)(this, TextureID);
}
void DrawTexturedRect(int x0, int y0, int W, int T)
{
typedef void(__thiscall* OriginalFn)(void*, int, int, int, int);
return getvfunc<OriginalFn>(this, 41)(this, x0, y0, W, T);
}
My only issue is, I can't load the .raw file of the image correctly in my csgo.
I use Visual studio 2013 Ultimate, and if I try to use fopen
It just wont load all of the image.
Anyone got any idea?
Also here is the function I made to actualy create and draw the Texture
Code:
void kappa(int w, int h)
{
bool m_bValid = false;
unsigned int m_iTexture;
if (last_texture == 0 || !Surface->IsTextureIDValid(last_texture))
{
m_iTexture = Surface->CreateNewTextureID(true);
if (!m_iTexture)
return;
Surface->DrawSetTextureRGBA(m_iTexture, allah, (unsigned int)w, (unsigned int)h, 0, 1);
if (Surface->IsTextureIDValid(m_iTexture)) m_bValid = true;
last_texture = m_iTexture;
}
else{
m_iTexture = last_texture;
}
Surface->DrawSetColor(RGBA(255, 255, 255, 255));
Surface->DrawSetTexture(m_iTexture);
int s_W, s_H; EngineClient->GetScreenSize(s_W, s_H);
Surface->DrawTexturedRect(s_W - w, s_H - h, s_W, s_H);
}
And yes I know my coding style isn't good, please dont cry about it
Any help is appreciated