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-02-2015, 05:15 AM #2
RTE
Keep it real!
Nice release bro :yes:
07-02-2015, 07:25 AM #3
Chris
Former Staff
Once again another great release dude, keep up the good work.
07-02-2015, 09:19 AM #4
Default Avatar
Kas
Guest
Great work as always SC Tiphat
07-02-2015, 06:36 PM #5
SC58
Former Staff
Originally posted by Kas View Post
Great work as always SC Tiphat


Originally posted by Natsu View Post
Once again another great release dude, keep up the good work.


Originally posted by ResistTheEarth View Post
Nice release bro :yes:


Thanks Happy
07-02-2015, 07:35 PM #6
Default Avatar
Remy
Guest
Very nice SC58 Winky Winky
07-02-2015, 10:47 PM #7
SC58
Former Staff
Originally posted by iDMiS View Post
Very nice SC58 Winky Winky


Thanks buddy Smile
07-04-2015, 05:08 PM #8
Wow, great release! This will definitely be very useful!
07-05-2015, 10:21 AM #9
Adrian
Adrian is back!
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.


nice release man Smile
07-05-2015, 08:54 PM #10
SC58
Former Staff
Originally posted by .Adrian View Post
nice release man Smile


Originally posted by FeverDEX View Post
Wow, great release! This will definitely be very useful!


Thanks Happy

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo