DrawPoly SetMaterial not working

Hi all,

I’ve recently started using the surface.DrawPoly function and got the shape I wanted, however when I try to apply a material ( using surface.SetMaterial ) it just goes black.

Is there a way I can use DrawPoly with a material ?

Thanks,
Computer600

Which material are you using? iirc VertexLit materials don’t play nice with 2d drawing.
Also, are you resetting the draw colour to white?

Not too sure if it’s a VertexLit material but I do reset the color to white here’s a snippet of my code:



// At the top of the file
local gradient = Material("gui/gradient")


Later on in a HUDPaint function:



	surface.SetDrawColor( color_white )
	surface.SetMaterial(gradient)
	surface.DrawPoly( righthudpoly )


I think you need to use SetTexture instead of SetMaterial for drawing polygons.

Make sure you reset the texture prior to drawing a poly, although by setting one you should be fine – use this if it is transparent: draw.NoTexture( )