👑
Impulse documentation
  • Getting started
  • Examples
    • Console
    • Window
  • enviornment
    • Globals
      • Lua globals
      • Impulse globals
    • Libraries
      • Win32
      • Direct X
      • Renderer
      • Input
      • Crypt
      • Memory
      • File system
      • Debug
  • Enumerations
    • Key codes
    • Cursor style
    • Primitive topology
  • Data types
    • Vector2
    • Vector3
    • Vertex
    • Color
    • Draw command
Powered by GitBook

Impulse links

  • GitHub
  • Project
  • Discord

© 2025 Impulse

On this page
  1. enviornment
  2. Libraries

Renderer

PreviousDirect XNextInput

Last updated 3 months ago

A window with an attached graphics library is required for this to function.

renderer.write_to_buffer

renderer.write_to_buffer(primitive_topology: integer, vertices: table, indices: table) -> draw_command
  • primitive_topology (integer) – Specifies the type of primitive to be rendered. It determines how the vertices will be connected (e.g., triangles, lines, etc.).

  • vertices (table) – A table containing objects, each defining a point in 2D or 3D space with position, color, and other attributes.

  • indices (table) – A table of integers representing the order in which vertices should be connected to form the desired shape.

Returns a , which can be used to change the primitive_topology, vertices, and indices later on.

Example code
WriteToBuffer.lua
local window_ref: number = win32.create_window("window", 
    1280, -- width
    720, -- height
    false -- fullscreen
)

direct_x.initiate( 
    window_ref, 
    true -- v_sync
)

local position: vector2 = vector2.new(10, 10)
local size: vector2 = vector2.new(100, 100)
local clr: color = color.new(255, 255, 255, 255)

local command: draw_command = renderer.write_to_buffer(
    D3D_PRIMITIVE_TOPOLOGY.LINE_STRIP,
    
    { -- vertices
        vertex.new(
            position.x, -- x
            position.y, -- y
            0,          -- z
            1,          -- rhw
            0,          -- u
            0,          -- v
            clr.hex     -- color
        ),
        
        vertex.new(
            position.x + size.x, -- x
            position.y,          -- y
            0,                   -- z
            1,                   -- rhw
            0,                   -- u
            0,                   -- v
            clr.hex              -- color
        ),
        
        vertex.new(
            position.x + size.x, -- x
            position.y + size.y, -- y
            0,                   -- z
            1,                   -- rhw
            0,                   -- u
            0,                   -- v
            clr.hex              -- color
        ),
        
        vertex.new(
            position.x,          -- x
            position.y + size.y, -- y
            0,                   -- z
            1,                   -- rhw
            0,                   -- u
            0,                   -- v
            clr.hex              -- color
        )
    },
    
    { -- indices
        0, 1, 2, 3, 0
    },

    1 -- z_index
)
Vertex
draw_command