Post: [C++]Engine Text and Shader Rebuilt
07-02-2015, 05:12 AM #1
SC58
Former Staff
(adsbygoogle = window.adsbygoogle || []).push({}); Hello NGU

I have been messing around with Engine text and shader functions and i thought i would just remake it and after doing it there really simple to understand, but anyways i thought i would release this as it kinda pointless but im sure alot people will find it neat and useful Happy

You will need to use these function in a function that runs every frame, i normally hook to CG_DrawNightVisionOverlay and you can find that here 0x42FC8 (as the function is pointless)


This should let u be able to do the type writter effects
    
#define cgArray 0xE22F18

int CG_GetLocalClientGlobals(int mod)
{
return *(int*)cgArray + mod; // cg_t
}

int CG_GetLocalClientTime()
{
return *(int*)(CG_GetLocalClientGlobals(0x4838C));
}


    
struct GfxCmdHeader
{
unsigned short byteCount;
char id;
char ui3d;
};

union GfxColor
{
unsigned int packed;
char array[4];
};

struct GfxCmdDrawText2D
{
GfxCmdHeader header;
int type;
float x;
float y;
float w;
float h;
float rotation;
void *font;
float xScale;
float yScale;
GfxColor color;
int maxChars;
int renderFlags;
int cursorPos;
char cursorLetter;
GfxColor glowForceColor;
int fxBirthTime;
int fxLetterTime;
int fxDecayStartTime;
int fxDecayDuration;
int fxRedactDecayStartTime;
int fxRedactDecayDuration;
void *fxMaterial;
void *fxMaterialGlow;
float padding;
char text[3];
};

struct GfxCmdStretchPic
{
GfxCmdHeader header;
void *material;
float x;
float y;
float w0;
float w;
float h;
float s0;
float t0;
float s1;
float t1;
GfxColor color;
};

0x794980 - void R_ConvertColorToBytes(const float *colorFloat, char *colorBytes);
0x769F6C - GfxCmdHeader * R_GetCommandBuffer(int renderCmd, int bytes);
0x76A9B8 - bool SetDrawText2DGlowParms(GfxCmdDrawText2D *cmd, const float *color, const float *glowColor);
0x763220 - void * Material_RegisterHandle(const char *name, int imageTrack, bool errorIfMissing, int waitTime)
0x75A2C0 - void * R_RegisterFont(const char * name, int imageTrack);
0x3DA948 - bool Dvar_GetBool(dvar_t * dvar);
0x3DA628 - dvar_t * Dvar_FindMalleableVar(const char *dvarName);

bool DvarGetBool(const char *dvarName)
{
if (Dvar_GetBool(Dvar_FindMalleableVar(dvarName)))
return true;
else
return false;
}

void R_AddCmdDrawTextInternal(const char *text, const char *fontName, float x, float y, float scale, const float *color)
{
if (*text)
{
int len = strlen(text);
GfxCmdDrawText2D * cmd = (GfxCmdDrawText2D *)R_GetCommandBuffer(0x10, (len + 0x6Cool Man (aka Tustin) & 0xFFFFFFFC);
if (cmd)
{
cmd->type = 0;
cmd->x = x;
cmd->y = y;
cmd->w = 1;
cmd->rotation = 0;
cmd->xScale = scale;
cmd->yScale = scale;
cmd->font = R_RegisterFont(fontName, 0);
if (DvarGetBool("r_dualPlayActive"))
cmd->yScale = (cmd->yScale) * .5;
R_ConvertColorToBytes(color, (char *)&cmd->color);
cmd->maxChars = 0x7FFFFFFF;
cmd->renderFlags = 0;
memcpy(cmd->text, (char *)text, len);
cmd->text[len] = 0;
}
}
}

void R_AddCmdDrawTextWithEffectsInternal(const char *text, const char *fontName, float x, float y, float scale, const float *color, const float *glowColor, int fxBirthTime, int fxLetterTime, int fxDecayStartTime, int fxDecayDuration)
{
if (*text)
{
int len = strlen(text);
GfxCmdDrawText2D * cmd = (GfxCmdDrawText2D *)R_GetCommandBuffer(0x10, (len + 0x6Cool Man (aka Tustin) & 0xFFFFFFFC);
if (cmd)
{
cmd->type = 0;
cmd->x = x;
cmd->y = y;
cmd->w = 1;
cmd->rotation = 0;
cmd->xScale = scale;
cmd->yScale = scale;
cmd->font = R_RegisterFont(fontName, 0);
if (DvarGetBool("r_dualPlayActive"))
cmd->yScale = (cmd->yScale) * .5;
R_ConvertColorToBytes(color, (char *)&cmd->color);
cmd->maxChars = 0x7FFFFFFF;
cmd->renderFlags = 0;
memcpy(cmd->text, (char *)text, len);
cmd->text[len] = 0;
if (SetDrawText2DGlowParms(cmd, color, glowColor))
{
if (fxBirthTime)
{
cmd->renderFlags |= 0x880;
cmd->fxMaterial = NULL;
cmd->fxMaterialGlow = NULL;
cmd->fxBirthTime = fxBirthTime;
cmd->fxLetterTime = fxLetterTime;
cmd->fxDecayStartTime = fxDecayStartTime;
cmd->fxDecayDuration = fxDecayDuration;
cmd->padding = 0;
}
}
}
}
}

void R_AddCmdDrawStretchPicInternal(float x, float y, float width, float height, const float *color, const char *material)
{
GfxCmdStretchPic * cmd = (GfxCmdStretchPic *)R_GetCommandBuffer(0xA, 0x30);
if (cmd)
{
cmd->material = Material_RegisterHandle(material, 0, 0, 0);
cmd->x = x;
cmd->y = y;
cmd->w0 = 1;
cmd->w = width;
cmd->h = height;
cmd->s0 = 0;
cmd->t0 = 0;
cmd->s1 = 1;
cmd->t1 = 1;
R_ConvertColorToBytes(color, (char *)&cmd->color);
}
}


You will also need the dvar_t struct in order to use the DvarGetBool function i made, You can find them here You must login or register to view this content.

You must login or register to view this content.
Last edited by SC58 ; 07-22-2016 at 07:30 AM.

The following 19 users say thank you to SC58 for this useful post:

-Numb, 01cedricv2, Bigmoneyhustlin, Chris, Exelo, HiddenHour, Joren, ksa_7ooo7, MemoryPointers, John, RTE, Shark, basshead4ever, SyGnUs, Tustin, uykjtrhgewa
07-06-2015, 06:00 AM #11
RF0oDxM0Dz
You talkin to me?
thanks SC58
07-07-2015, 03:56 PM #12
Originally posted by SC58 View Post
Hello NGU

I have been messing around with Engine text and shader functions and i thought i would just remake it and after doing it there really simple to understand, but anyways i thought i would release this as it kinda pointless but im sure alot people will find it neat and useful Happy

You will need to use these function in a function that runs every frame, i normally hook to CG_DrawNightVisionOverlay and you can find that here 0x42FC8 (as the function is pointless)


This should let u be able to do the type writter effects
    
#define cgArray 0xE22F18

int CG_GetLocalClientGlobals(int mod)
{
return *(int*)cgArray + mod; // cg_s
}

int GetLocalLevelTime()
{
return *(int*)(CG_GetLocalClientGlobals(0x69D1Cool Man (aka Tustin));
}


    
struct GfxCmdHeader
{
unsigned short byteCount;
char id;
char ui3d;
};

union GfxColor
{
unsigned int packed;
char array[4];
};

struct GfxCmdDrawText2D
{
GfxCmdHeader header;
int type;
float x;
float y;
float w;
float h;
float rotation;
void *font;
float xScale;
float yScale;
GfxColor color;
int maxChars;
int renderFlags;
int cursorPos;
char cursorLetter;
GfxColor glowForceColor;
int fxBirthTime;
int fxLetterTime;
int fxDecayStartTime;
int fxDecayDuration;
int fxRedactDecayStartTime;
int fxRedactDecayDuration;
void *fxMaterial;
void *fxMaterialGlow;
float padding;
char text[3];
};

struct GfxCmdStretchPic
{
GfxCmdHeader header;
void *material;
float x;
float y;
float w0;
float w;
float h;
float s0;
float t0;
float s1;
float t1;
GfxColor color;
};

0x794980 - void R_ConvertColorToBytes(const float *colorFloat, char *colorBytes);
0x769F6C - GfxCmdHeader * R_GetCommandBuffer(int renderCmd, int bytes);
0x76A9B8 - bool SetDrawText2DGlowParms(GfxCmdDrawText2D *cmd, const float *color, const float *glowColor);
0x763220 - void * Material_RegisterHandle(const char *name, int imageTrack, bool errorIfMissing, int waitTime)
0x75A2C0 - void * R_RegisterFont(const char * name, int imageTrack);
0x3DA948 - bool Dvar_GetBool(dvar_t * dvar);
0x3DA628 - dvar_t * Dvar_FindMalleableVar(const char *dvarName);

bool DvarGetBool(const char *dvarName)
{
if (Dvar_GetBool(Dvar_FindMalleableVar(dvarName)))
return true;
else
return false;
}

void R_AddCmdDrawTextInternal(const char *text, const char *fontName, float x, float y, float scale, const float *color)
{
if (*text)
{
int len = strlen(text);
GfxCmdDrawText2D * cmd = (GfxCmdDrawText2D *)R_GetCommandBuffer(0x10, (len + 0x6Cool Man (aka Tustin) & 0xFFFFFFFC);
if (cmd)
{
cmd->type = 0;
cmd->x = x;
cmd->y = y;
cmd->w = 1;
cmd->rotation = 0;
cmd->xScale = scale;
cmd->yScale = scale;
cmd->font = R_RegisterFont(fontName, 0);
if (DvarGetBool("r_dualPlayActive"))
cmd->yScale = (cmd->yScale) * .5;
R_ConvertColorToBytes(color, (char *)&cmd->color);
cmd->maxChars = 0x7FFFFFFF;
cmd->renderFlags = 0;
memcpy(cmd->text, (char *)text, len);
cmd->text[len] = 0;
}
}
}

void R_AddCmdDrawTextWithEffectsInternal(const char *text, const char *fontName, float x, float y, float scale, const float *color, const float *glowColor, int fxBirthTime, int fxLetterTime, int fxDecayStartTime, int fxDecayDuration)
{
if (*text)
{
int len = strlen(text);
GfxCmdDrawText2D * cmd = (GfxCmdDrawText2D *)R_GetCommandBuffer(0x10, (len + 0x6Cool Man (aka Tustin) & 0xFFFFFFFC);
if (cmd)
{
cmd->type = 0;
cmd->x = x;
cmd->y = y;
cmd->w = 1;
cmd->rotation = 0;
cmd->xScale = scale;
cmd->yScale = scale;
cmd->font = R_RegisterFont(fontName, 0);
if (DvarGetBool("r_dualPlayActive"))
cmd->yScale = (cmd->yScale) * .5;
R_ConvertColorToBytes(color, (char *)&cmd->color);
cmd->maxChars = 0x7FFFFFFF;
cmd->renderFlags = 0;
memcpy(cmd->text, (char *)text, len);
cmd->text[len] = 0;
if (SetDrawText2DGlowParms(cmd, color, glowColor))
{
if (fxBirthTime)
{
cmd->renderFlags |= 0x880;
cmd->fxMaterial = NULL;
cmd->fxMaterialGlow = NULL;
cmd->fxBirthTime = fxBirthTime;
cmd->fxLetterTime = fxLetterTime;
cmd->fxDecayStartTime = fxDecayStartTime;
cmd->fxDecayDuration = fxDecayDuration;
cmd->padding = 0;
}
}
}
}
}

void R_AddCmdDrawStretchPicInternal(float x, float y, float width, float height, const float *color, const char *material)
{
GfxCmdStretchPic * cmd = (GfxCmdStretchPic *)R_GetCommandBuffer(0xA, 0x30);
if (cmd)
{
cmd->material = Material_RegisterHandle(material, 0, 0, 0);
cmd->x = x;
cmd->y = y;
cmd->w0 = 1;
cmd->w = width;
cmd->h = height;
cmd->s0 = 0;
cmd->t0 = 0;
cmd->s1 = 1;
cmd->t1 = 1;
R_ConvertColorToBytes(color, (char *)&cmd->color);
}
}


You will also need the dvar_t struct in order to use the DvarGetBool function i made, You can find them here You must login or register to view this content.

You must login or register to view this content.


Great release, SC!
07-08-2015, 11:16 AM #13
SC58
Former Staff
Originally posted by Joren View Post
Great release, SC!


Thanks bud!

Originally posted by SNB View Post
thanks SC58


No problem Happy
07-17-2015, 06:13 AM #14
Vuvor
Save Point
hey anyone help me out this part of the code is giving me an error am i supposed to make my own functions??

0x794980 - void R_ConvertColorToBytes(const float *colorFloat, char *colorBytes);
0x769F6C - GfxCmdHeader * R_GetCommandBuffer(int renderCmd, int bytes);
0x76A9B8 - bool SetDrawText2DGlowParms(GfxCmdDrawText2D *cmd, const float *color, const float *glowColor);
0x763220 - void * Material_RegisterHandle(const char *name, int imageTrack, bool errorIfMissing, int waitTime)
0x75A2C0 - void * R_RegisterFont(const char * name, int imageTrack);
0x3DA948 - bool Dvar_GetBool(dvar_t * dvar);
0x3DA628 - dvar_t * Dvar_FindMalleableVar(const char *dvarName);

Edit

opd_s R_RegisterFont_s = { 0x75A2C0, TOC };
void*(*R_RegisterFont)(const char * font, int imageTrac) = (void*(*)(const char *, int))&R_RegisterFont_s;
opd_s Material_RegisterHandle_s = { 0x763220, TOC };
void*(*Material_RegisterHandle)(const char *name, int imageTrack, bool errorIfMissing, int waitTime) = (void*(*)(const char *, int, bool, int))&Material_RegisterHandle_s;
opd_s R_ConvertColorToBytes_s = { 0x794980, TOC };
void(*R_ConvertColorToBytes)(const float *colorFloat, char *colorBytes) = (void(*)(const float *, char*))&R_ConvertColorToBytes_s;
opd_s R_GetCommandBuffer_s = { 0x769F6C, TOC };
GfxCmdHeader*(*R_GetCommandBuffer)(int renderCmd, int bytes) = (GfxCmdHeader*(*)(int,int))&R_GetCommandBuffer_s;

i made those and now it works thanks for this post sc58!!!
Last edited by Vuvor ; 07-17-2015 at 08:34 AM.
07-17-2015, 10:36 AM #15
Vuvor
Save Point
For whatever reason when i use a diffrent font like fonts/boldfont it stays the same? Anyone have a clue how to fix this?
07-17-2015, 10:03 PM #16
SC58
Former Staff
Originally posted by Vuvor View Post
For whatever reason when i use a diffrent font like fonts/boldfont it stays the same? Anyone have a clue how to fix this?


Everything works for me, the problem is on your end
07-17-2015, 10:49 PM #17
Vuvor
Save Point
Originally posted by SC58 View Post
Everything works for me, the problem is on your end


How do you get it working without editing the functions?? Maybe thats my issue

Edit
And what fonts did you use??
07-17-2015, 11:08 PM #18
SC58
Former Staff
Originally posted by Vuvor View Post
How do you get it working without editing the functions?? Maybe thats my issue

Edit
And what fonts did you use??


every font works, ull just need to make the function into a function that will work for sprx
07-18-2015, 12:45 AM #19
Vuvor
Save Point
Originally posted by SC58 View Post
every font works, ull just need to make the function into a function that will work for sprx


I was using these and it dosent seme to be working is there anything you can see thats wrong with them? And can you name a couple cause i got fonts/bigDevFont to work maybe im using the wrong fonts

opd_s R_RegisterFont_s = { 0x75A2C0, TOC };
void*(*R_RegisterFont)(const char * font, int imageTrac) = (void*(*)(const char *, int))&R_RegisterFont_s;
opd_s Material_RegisterHandle_s = { 0x763220, TOC };
void*(*Material_RegisterHandle)(const char *name, int imageTrack, bool errorIfMissing, int waitTime) = (void*(*)(const char *, int, bool, int))&Material_RegisterHandle_s;
opd_s R_ConvertColorToBytes_s = { 0x794980, TOC };
void(*R_ConvertColorToBytes)(const float *colorFloat, char *colorBytes) = (void(*)(const float *, char*))&R_ConvertColorToBytes_s;
opd_s R_GetCommandBuffer_s = { 0x769F6C, TOC };
GfxCmdHeader*(*R_GetCommandBuffer)(int renderCmd, int bytes) = (GfxCmdHeader*(*)(int,int))&R_GetCommandBuffer_s;

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo