HUD Resolution Optimization

Hi all, basically I’ve made a HUD:

I made it when my resolution was 1280 x 720, I then changed my resolution and its all over the place.

Here is the code for the HUD:



hook.Add( "HUDPaint", "right_hud", function()
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.SetMaterial( rightMat	) -- If you use Material, cache it!
	surface.DrawTexturedRect( 880, 640, 400, 80 )
end )

   local leftMat = Material( "hud/hudtest2.png" ) -- Calling Material() every frame is quite expensive

hook.Add( "HUDPaint", "left_hud", function()
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.SetMaterial( leftMat	) -- If you use Material, cache it!
	surface.DrawTexturedRect( 0, 640, 400, 80 )
end )



Any help is appreciated, my LUA is limited as I’ve recently been learning. If need be I will pay a small sum for someone to fix it.

Thanks for your time.


hook.Add( "HUDPaint", "new_hud", function()
surface.SetDrawColor( 255, 255, 255, 255 )
surface.SetMaterial( rightMat) -- If you use Material, cache it!
surface.DrawTexturedRect( ScrW() - 400, ScrH() - 80, 400, 80 )

surface.SetDrawColor( 255, 255, 255, 255 )
surface.SetMaterial( leftMat) -- If you use Material, cache it!
surface.DrawTexturedRect( 0, ScrH() - 80, 400, 80 )
end )

All good dude! Just helped you on Steam, but yeah, thought I’d put it on here!

Thanks man, my material HUD is now fixed permanently. Does anyone know how I can fix the HP bar?


draw.RoundedBox( 8, 935, ScrH() -48, 310, 17, Color( 215, 215, 215 ) )

is what I’m using at the moment but similar to the fix issue it moves when you change resolution