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.
(adsbygoogle = window.adsbygoogle || []).push({});

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-18-2015, 12:55 AM #20
SC58
Former Staff
Originally posted by Vuvor View Post
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;


do a memory dump of the game and search fonts/ and ull find bunch of font names

u need to call engine text on a hook
07-18-2015, 01:03 AM #21
Vuvor
Save Point
Originally posted by SC58 View Post
do a memory dump of the game and search fonts/ and ull find bunch of font names

u need to call engine text on a hook


I am hooking it in the nightvision overlay everything works i see text i see shaders i just cant change the font anyway thanks alot for this post i feel like im wasting your time so ill try and figure it out on my own thanks alot for your help!
07-18-2015, 01:11 AM #22
SC58
Former Staff
Originally posted by Vuvor View Post
I am hooking it in the nightvision overlay everything works i see text i see shaders i just cant change the font anyway thanks alot for this post i feel like im wasting your time so ill try and figure it out on my own thanks alot for your help!


do a full mem dump and u can get all the fonts
07-18-2015, 02:27 AM #23
Exelo
Banned
Nice release man Smile
Awesome as always. Winky Winky
09-05-2015, 08:29 PM #24
so this is how desire engine and other non host menus are made...?
09-06-2015, 01:18 AM #25
Humble
Little One
awesome release man Happy
12-15-2015, 05:45 PM #26
Originally posted by SC58 View Post

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.

The links broken so here.
    

DVARs (BO2)
Jump to: navigation, search

/* dvar->flags */
#define DVAR_ARCHIVE (1 << 0) // 0x0001
#define DVAR_USERINFO (1 << 1) // 0x0002
#define DVAR_SERVERINFO (1 << 2) // 0x0004
#define DVAR_SYSTEMINFO (1 << 3) // 0x0008
#define DVAR_INIT (1 << 4) // 0x0010
#define DVAR_LATCH (1 << 5) // 0x0020
#define DVAR_ROM (1 << 6) // 0x0040
#define DVAR_CHEAT (1 << 7) // 0x0080
#define DVAR_DEVELOPER (1 << Cool Man (aka Tustin) // 0x0100
#define DVAR_SAVED (1 << 9) // 0x0200
#define DVAR_NORESTART (1 << 10) // 0x0400
#define DVAR_CHANGEABLE_RESET (1 << 12) // 0x1000
#define DVAR_EXTERNAL (1 << 14) // 0x4000
#define DVAR_AUTOEXEC (1 << 15) // 0x8000

/* dvar->type */
#define DVAR_TYPE_BOOL 1
#define DVAR_TYPE_FLOAT 2
#define DVAR_TYPE_FLOAT_2 3
#define DVAR_TYPE_FLOAT_3 4
#define DVAR_TYPE_FLOAT_4 5
#define DVAR_TYPE_INT 6
#define DVAR_TYPE_ENUM 7
#define DVAR_TYPE_STRING 8
#define DVAR_TYPE_COLOR 9
#define DVAR_TYPE_INT64 10
#define DVAR_TYPE_LINEAR_COLOR_RGB 11
#define DVAR_TYPE_COLOR_XYZ 12

union DvarLimits
{
struct {
int stringCount;
const char **strings;
} enumeration;

struct {
int min;
int max;
} integer;

struct {
float min;
float max;
} value, vector;

struct {
unsigned long long min;
unsigned long long max;
} integer64;
};

union DvarValue
{
bool enabled;
int integer;
unsigned int unsignedInt;
unsigned long long integer64;
float value;
float vector[4];
const char *string;
char color[4];
};

#pragma pack(push, 4)
struct dvar_s
{
const char *name;
const char *unknown1; // description?
int hashForName;
int flags;
int type;
bool modified;
DvarValue current;
DvarValue latched;
DvarValue reset;
DvarValue unknown2;
DvarLimits limits;
dvar_s *next;
int unknown3;
};
#pragma pack(pop)
12-20-2015, 01:09 PM #27
2pac
Banned
Thanks mate

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo