Garry's Mod Wiki

render.DrawBox

  render.DrawBox( Vector position, Angle angles, Vector mins, Vector maxs, table color = Color( 255, 255, 255 ) )

Description

Draws a box in 3D space.

This is a rendering function that requires a 3d rendering context.

This means that it will only work in 3d Rendering Hooks.

Arguments

1 Vector position
Origin of the box.
2 Angle angles
Orientation of the box.
3 Vector mins
Start position of the box, relative to origin.
4 Vector maxs
End position of the box, relative to origin.
5 table color = Color( 255, 255, 255 )
The color of the box. Uses the Color.

Example

Draws a white box at the position you are looking.

local x = Vector( 5, 5, 5 ) hook.Add( "PostDrawTranslucentRenderables", "Boxxie", function() local pos = LocalPlayer():GetEyeTrace().HitPos -- position to render box at render.SetColorMaterial() -- white material for easy coloring cam.IgnoreZ( true ) -- makes next draw calls ignore depth and draw on top render.DrawBox( pos, angle_zero, x, -x, color_white ) -- draws the box cam.IgnoreZ( false ) -- disables previous call end )
Output:
image.png