Adding Image to a HUD

Hi,

How can I add an image to a HUD ? (Not like an icon for wanted/gun license for DarkRP an actual image).

Where can I store this image and I don’t know what code to use. ( If you can link me to the post on the gmod wiki )

Heres an example:




local image = Material( "imagepath" )
surface.SetMaterial( image )

surface.SetDrawColor( 255, 255, 255 )

surface.DrawTexturedRect( 0, 0, 100, 100 )


-snip- better way below

:what:

Thank you, so I just store the image in materials/ folder and put in imagepath - material/imageexample.png right?

Assuming that’s to be put in a HUDPaint hook, that’s not the most efficient way to do it.

First cache the material, then draw it, otherwise it’ll be creating a material each frame.



local Image = Material( "image/path" )

hook.Add( "HUDPaint", "ImagePaint", function()

    surface.SetMaterial( Image )
    surface.SetDrawColor( 255, 255, 255 )
    surface.DrawTexturedRect( 0, 0, 100, 100 )

end )


Something wrong?

In


 surface.SetMaterial( Image )

in the ( Image ) do I put something there or just leave like that ?

Leave it. You are setting “Image” to the material defined in the local Image line.

Just set the path to the material you want.