Problem with drawing beams

I’m working on my first STool, and rather than drawing a ghost, I’m drawing an outline of something with beams. I have all the vectors set up, but for some reason the beams won’t show up.

Here’s my draw code. It’s being called in the TOOL:Think() function.
[lua]
function TOOL:DrawWallOutline()

if !CLIENT then return end

local p = {}
for i = 1, 8 do
	p* = self.Weapon:GetNWVector("p"..i)
end

render.SetMaterial( Material( "cable/redlaser" ) )
render.StartBeam( 17 )

for i = 1, 4 do
	
	local tcoord = CurTime() + ( 1 / 12 ) * i;
	local pnext = i+1
	local ptop = i+5
	
	if i == 4 then
		pnext = 1
		ptop = 5
	end
	
	render.AddBeam(
		p*,
		32,
		tcoord,
		Color( 64, 255, 64, 255 )
	)
	
	render.AddBeam(
		p[pnext],
		32,
		tcoord,
		Color( 64, 255, 64, 255 )
	)
	
	render.AddBeam(
		p[i+4],
		32,
		tcoord,
		Color( 64, 255, 64, 255 )
	)
	
	render.AddBeam(
		p[ptop],
		32,
		tcoord,
		Color( 64, 255, 64, 255 )
	)
	
	render.AddBeam(
		p[pnext],
		32,
		tcoord,
		Color( 64, 255, 64, 255 )
	)
	
end

// finish up the beam
render.EndBeam();

end
[/lua]
In short, this should draw an outlined cube.

What’s more, I get this in console highlighted in red:



CMaterial::DrawElements: No bound shader
CMaterial::DrawElements: No bound shader
CMaterial::DrawElements: No bound shader
CMaterial::DrawElements: No bound shader
CMaterial::DrawElements: No bound shader
CMaterial::DrawElements: No bound shader
CMaterial::DrawElements: No bound shader
CMaterial::DrawElements: No bound shader
CMaterial::DrawElements: No bound shader


I could understand this happening with a custom texture, but redlaser is used in other STools and works fine. I have no visible Lua errors.

Help?

I’m pretty sure that, for the beams to work, they need to be drawn in a rendering function and not Think.

Yeah, but STools don’t appear to have a rendering function. I can’t remember what hooks it works in other than ENT:Draw().

PostDrawOpaqueRenderables has always worked for me.

Still not quite working for me.
[lua]
function TOOL:DrawWallOutline()

if !CLIENT then return end

local p = {}
for i = 1, 8 do
	p* = self.Weapon:GetNWVector("p"..i)
end
local outlinemat = Material( "cable/redlaser" )

local function DrawOutline()

render.SetMaterial( outlinemat )
render.StartBeam( 17 )

for i = 1, 4 do
	
	local tcoord = CurTime() + ( 1 / 12 ) * i;
	local pnext = i+1
	local ptop = i+5
	
	if i == 4 then
		pnext = 1
		ptop = 5
	end
	
	render.AddBeam(
		p*,
		32,
		tcoord,
		Color( 64, 255, 64, 255 )
	)
	
	render.AddBeam(
		p[pnext],
		32,
		tcoord,
		Color( 64, 255, 64, 255 )
	)
	
	render.AddBeam(
		p[i+4],
		32,
		tcoord,
		Color( 64, 255, 64, 255 )
	)
	
	render.AddBeam(
		p[ptop],
		32,
		tcoord,
		Color( 64, 255, 64, 255 )
	)
	
	render.AddBeam(
		p[pnext],
		32,
		tcoord,
		Color( 64, 255, 64, 255 )
	)
	
end

// finish up the beam
render.EndBeam();

end
hook.Add("PostDrawOpaqueRenderables","WallMakerOutlineRender",DrawOutline)

end
[/lua]

It’s pretty early in the morning for me, so I’m probably doing something stupid.