Gfx_RenderLine

Draw a colored line between two points.

Synopsis

void HGE::Gfx_RenderLine(float x1, float y1, float x2, float y2, 
                          DWORD color = 0xFFFFFFFF, float z = 0.5f);

Parameters

  • x1, y1 — Starting point coordinates
  • x2, y2 — Ending point coordinates
  • color — Line color in ARGB format (default: white, fully opaque)
  • z — Z-depth value (default: 0.5)

Description

Draws a line from (x1, y1) to (x2, y2) with the specified color. Useful for debugging, simple graphics, and UI elements.

Color Format

Colors use 32-bit ARGB format:

// 0xAARRGGBB
DWORD white   = 0xFFFFFFFF;  // Fully opaque white
DWORD red     = 0xFFFF0000;  // Fully opaque red
DWORD green   = 0xFF00FF00;  // Fully opaque green
DWORD blue    = 0xFF0000FF;  // Fully opaque blue
DWORD yellow  = 0xFFFFFF00;  // Fully opaque yellow
DWORD semiRed = 0x80FF0000;  // 50% transparent red

You can use the ARGB helper macro:

DWORD color = ARGB(alpha, red, green, blue);

Example

bool RenderFunc()
{
    hge->Gfx_BeginScene();
    hge->Gfx_Clear(0);
    
    // Draw a white diagonal line
    hge->Gfx_RenderLine(100, 100, 300, 200);
    
    // Draw a red horizontal line
    hge->Gfx_RenderLine(100, 250, 300, 250, 0xFFFF0000);
    
    // Draw a grid
    for (int x = 0; x < 800; x += 50)
        hge->Gfx_RenderLine(x, 0, x, 600, 0x40FFFFFF);
    for (int y = 0; y < 600; y += 50)
        hge->Gfx_RenderLine(0, y, 800, y, 0x40FFFFFF);
    
    hge->Gfx_EndScene();
    return false;
}

Drawing Shapes

Combine multiple lines for shapes:

// Draw a rectangle outline
void DrawRect(float x, float y, float w, float h, DWORD color)
{
    hge->Gfx_RenderLine(x, y, x+w, y, color);       // Top
    hge->Gfx_RenderLine(x+w, y, x+w, y+h, color);   // Right
    hge->Gfx_RenderLine(x+w, y+h, x, y+h, color);   // Bottom
    hge->Gfx_RenderLine(x, y+h, x, y, color);       // Left
}

// Draw a cross for debugging
void DrawCross(float x, float y, float size, DWORD color)
{
    hge->Gfx_RenderLine(x-size, y, x+size, y, color);
    hge->Gfx_RenderLine(x, y-size, x, y+size, color);
}

See Also