Skip to main content

Renderer

The renderer provides a high-level DirectX 9 rendering interface for drawing shapes, text, gradients, and other visual elements in CS:GO.

Initialization

init

void g_render.init(IDirect3DDevice9* buffer_device);
Initializes the renderer with a DirectX device.
buffer_device
IDirect3DDevice9*
DirectX 9 device to use for rendering
Call this once during SDK initialization, typically in the EndScene hook.

State Management

setup_state / finish_state

void g_render.setup_state();
void g_render.finish_state();
Manages DirectX render state for custom drawing.
void on_frame() {
    g_render.setup_state();
    
    // Your rendering code here
    g_render.render_text(10, 10, AL_DEFAULT, FLAG_OUTLINE, "Hello", font, color::white());
    
    g_render.finish_state();
}

Font Management

create_font

void g_fonts.create_font(
    std::uint32_t hash,
    std::size_t size,
    std::size_t weight,
    bool anti_aliased,
    const char* font_name
);
Creates a font for text rendering.
hash
std::uint32_t
Unique hash identifier for this font (use FNV1A hash)
size
std::size_t
Font size in pixels
weight
std::size_t
Font weight (e.g., FW_NORMAL, FW_BOLD)
anti_aliased
bool
Enable anti-aliasing for smoother text
font_name
const char*
System font name (e.g., “Verdana”, “Arial”)

find

LPD3DXFONT g_fonts.find(std::uint32_t hashed);
LPD3DXFONT g_fonts[std::uint32_t hash]; // Operator overload
Retrieves a font by its hash identifier.
hashed
std::uint32_t
Hash of the font to retrieve
Returns: DirectX font object or nullptr if not found

Drawing Functions

render_line

void g_render.render_line(int x, int y, int width, int height, color color);
Draws a line from (x, y) to (width, height).
x
int
Starting X coordinate
y
int
Starting Y coordinate
width
int
Ending X coordinate
height
int
Ending Y coordinate
color
color
Line color

render_rectangle

void g_render.render_rectangle(int x, int y, int width, int height, color color);

template<class T = int>
void g_render.render_rectangle(const math::vec2<T>& pos, const math::vec2<T>& size, color color);
Draws a rectangle outline.
x
int
X coordinate
y
int
Y coordinate
width
int
Rectangle width
height
int
Rectangle height
color
color
Border color

render_filled_rectangle

void g_render.render_filled_rectangle(int x, int y, int width, int height, color color);

template<class T>
void g_render.render_filled_rectangle(const math::vec2<T>& pos, const math::vec2<T>& size, color color);
Draws a filled rectangle.
x
int
X coordinate
y
int
Y coordinate
width
int
Rectangle width
height
int
Rectangle height
color
color
Fill color

render_circle

void g_render.render_circle(int x, int y, int radius, int segments, color color);

template<class T = int>
void g_render.render_circle(const math::vec2<T>& pos, const math::vec2<T>& size, color color);
Draws a circle outline.
x
int
Center X coordinate
y
int
Center Y coordinate
radius
int
Circle radius in pixels
segments
int
Number of segments (higher = smoother)
color
color
Circle color

render_gradient

template<auto gradient_type = gradient_type_t::HORIZONTAL>
void g_render.render_gradient(int x, int y, int width, int height, color from, color to);

template<auto gradient_type = gradient_type_t::HORIZONTAL, class T = int>
void g_render.render_gradient(const math::vec2<T>& pos, const math::vec2<T>& size, color from, color to);
Draws a gradient-filled rectangle.
gradient_type
gradient_type_t
Gradient direction: HORIZONTAL or VERTICAL
from
color
Starting color
to
color
Ending color

Text Rendering

render_text

void g_render.render_text(
    int x, int y,
    unsigned int alignment,
    const font_flags flags,
    const char* string,
    LPD3DXFONT font,
    color color
);

template<class T = int>
void g_render.render_text(
    const math::vec2<T>& pos,
    unsigned int alignment,
    const font_flags flags,
    const char* string,
    LPD3DXFONT font,
    color color
);
Draws text with various styling options.
x
int
X coordinate
y
int
Y coordinate
alignment
unsigned int
Text alignment flags (see Font Alignment)
flags
font_flags
Text rendering flags (see Font Flags)
string
const char*
Text to render
font
LPD3DXFONT
Font to use
color
color
Text color

render_text_size

D3DXVECTOR2 g_render.render_text_size(const char* string, LPD3DXFONT font);
Calculates the size of text in pixels.
string
const char*
Text to measure
font
LPD3DXFONT
Font to use for measurement
Returns: Vector containing width (x) and height (y) in pixels

Advanced Drawing

quadratic_curve

template<class T = int>
void g_render.quadratic_curve(
    const math::vec2<T>& start,
    const math::vec2<T>& control,
    const math::vec2<T>& end,
    color color
);
Draws a quadratic Bezier curve.
start
const math::vec2<T>&
Starting point
control
const math::vec2<T>&
Control point for curve shape
end
const math::vec2<T>&
Ending point
color
color
Curve color

Viewport Management

get_viewport

D3DVIEWPORT9 g_render.get_viewport();
Retrieves the current DirectX viewport. Returns: Current viewport configuration

set_viewport

bool g_render.set_viewport(const math::vec2<int>& pos, const math::vec2<int>& size);
bool g_render.set_viewport(D3DVIEWPORT9 vp);
Sets a custom viewport for clipping rendering.
pos
const math::vec2<int>&
Viewport position
size
const math::vec2<int>&
Viewport size
Returns: true if successful

Enumerations

Font Flags

enum font_flags : unsigned {
    FLAG_NONE,
    FLAG_DROPSHADOW,
    FLAG_OUTLINE,
    FLAG_OUTLINE_SEMI
};
FLAG_NONE
0
No special rendering
FLAG_DROPSHADOW
1
Draw text with a drop shadow
FLAG_OUTLINE
2
Draw text with a full outline
FLAG_OUTLINE_SEMI
3
Draw text with a semi-transparent outline

Font Alignment

enum font_alignment : unsigned {
    AL_DEFAULT           = (1 << 0),
    AL_VERTICAL_TOP      = (1 << 1),
    AL_VERTICAL_CENTER   = (1 << 2),
    AL_HORIZONTAL_LEFT   = (1 << 3),
    AL_HORIZONTAL_CENTER = (1 << 4),
};
Alignment flags can be combined with bitwise OR.

Gradient Type

enum class gradient_type_t {
    HORIZONTAL = 0,
    VERTICAL
};

Example Usage

// Draw a filled box with outline
g_render.render_filled_rectangle(100, 100, 200, 50, color(30, 30, 30, 200));
g_render.render_rectangle(100, 100, 200, 50, color::white());

Build docs developers (and LLMs) love