• Very low FPS when using HUD
    11 replies, posted
Hey. The problem is as follows. When you create a fashion collided with a strange problem. Created HUD easy to write code, and because it takes off the game and FPS does not rise above 30. Normally 200. Change settings nichgeo graphics certainly does not change. Trips HUD fixes probelmy. [CODE]local HUDS = { ["CHudHealth"] = true, ["CHudAmmo"] = true, ["CHudSecondaryAmmo"] = true, ["CHudBattery"] = true } local function HUDShouldDraw(name) if ( HUDS[name] ) then return false end end hook.Add( "HUDShouldDraw", "HUDShouldDraw", HUDShouldDraw ) function PlayerHUD() local hp = LocalPlayer():Health() / 100 local ar = LocalPlayer():Armor() / 100 draw.RoundedBox( 1, 130, ScrH() - 80, 110, 50, Color( 0, 0, 0, 200 ) ) draw.RoundedBox( 1, 132, ScrH() - 78, 106 * hp, 46, Color( 200, 0, 0, 200 ) ) draw.DrawText( tostring( LocalPlayer():Health() ), "Default", 180, ScrH() - 60, color_white, 0 ) draw.RoundedBox( 1, 250, ScrH() - 80, 110, 50, Color( 0, 0, 0, 200 ) ) draw.RoundedBox( 1, 252, ScrH() - 78, 106 * ar, 46, Color( 0, 0, 200, 200 ) ) draw.DrawText( tostring( LocalPlayer():Armor() ), "Default", 300, ScrH() - 60, color_white, 0 ) local survivalhud = vgui.Create( "DImage" ) survivalhud:SetPos( 36, ScrH() - 120 ) survivalhud:SetSize( 400, 100 ) survivalhud:SetImage( "survivalhud/hud" ) survivalhud:SetDrawBackground( false ) surface.CreateFont( "SurvivalHUD", { font = "Chiller", extended = false, size = 40, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, strikeout = false, symbol = false, rotary = false, shadow = true, additive = true, outline = true, } ) surface.SetTextColor( 255, 255, 255, 255 ) surface.SetTextPos( 40, (ScrH()/1.17) ) surface.SetFont("SurvivalHUD") surface.DrawText( Entity(1):Nick() ) local Avatar = vgui.Create( "AvatarImage", Panel ) Avatar:SetSize( 77, 77 ) Avatar:SetPos( 43, ScrH() - 113 ) Avatar:SetPlayer( LocalPlayer(), 120 ) draw.RoundedBox( 1, ScrW() / 2 - 300, ScrH() - 70, 600, 60, Color( 0, 0, 0, 200 ) ) end hook.Add( "HUDPaint", "PlayerHUD", PlayerHUD )[/CODE] Explain what the problem code. There is also a problem of blinking HUD material. You can check the code in the game and see the problem.
The DImage is being drew multiple times like mine did. Change the image code to: [CODE]local wave = Material( "survivalhud/hud" ) surface.SetMaterial(wave) surface.DrawTexturedRect(36, ScrH() - 120, 400, 100)[/CODE]
You are creating 2 panels + 1 font every frame Take example on this thread: [url]https://facepunch.com/showthread.php?t=1529218[/url] It's funny that the exact same mistake pop in this forum at least 3 time this day....
[QUOTE=Renzr;50822098]The DImage is being drew multiple times like mine did. Change the image code to: [CODE]local wave = Material( "survivalhud/hud" ) surface.SetMaterial(wave) surface.DrawTexturedRect(36, ScrH() - 120, 400, 100)[/CODE][/QUOTE] Crashes and low FPS left. HUDis now simply a shadow.
[QUOTE=!SmeRT!;50822133]Crashes and low FPS left. HUDis now simply a shadow.[/QUOTE] Is survivalhud/hud a png?
You're creating a font in a HUDPaint hook, the wiki example for surface.CreateFont specifically says not to do this You're also creating a vgui element in there Basically, HUDPaint is a hook/function that is ran every frame, this means you're repeatedly creating fonts and an image - place them outside
[QUOTE=Renzr;50822169]Is survivalhud/hud a png?[/QUOTE] If this were the PNG, that I would be sent in Russian saying "На хуй". [editline]3rd August 2016[/editline] [QUOTE=NiandraLades;50822223]You're creating a font in a HUDPaint hook, the wiki example for surface.CreateFont specifically says not to do this You're also creating a vgui element in there Basically, HUDPaint is a hook/function that is ran every frame, this means you're repeatedly creating fonts and an image - place them outside[/QUOTE] Guigui has explained and I understood. [editline]3rd August 2016[/editline] Although the question still remained. Inserting VTF in HUD? Either I'm looking bad on wiki.garrismod.com or simply do not exist, which is impossible. Tell me.
PNG works for definate I know that. Maybe have it as a PNG use the code I gave Make sure to add resource.AddFile("materials/survivalhud/hud.png")
I think i have to use Surface.SetTexture and Surface.DrawTexturedRect. Yes? [editline]3rd August 2016[/editline] [QUOTE=Renzr;50822937]PNG works for definate I know that. Maybe have it as a PNG use the code I gave Make sure to add resource.AddFile("materials/survivalhud/hud.png")[/QUOTE] Voy.... It is intresting... I'll try like anything. If it works, then it definitely makes it easier to process. I kind of like the code seen in one of the gamemod another 12 GMOD. [editline]3rd August 2016[/editline] i used Surface.DrawTexturedRect and now thin displays without loss of FPS, but still flashes. Maybe not correctly compiled VMT... Last question. Texture of course I put in, but what an avatar? The same LocalPlayer(), but it is not considered material. [editline]3rd August 2016[/editline] Strange it turns out ... Image Surface.DrawTexturedRect through and through an avatar that does not work. And if the image is done through the local wave = Material ( "survivalhud / hud"), the FPS drops, and if an avatar is not.
Tvoyu mat'. I can help you with this, dodo
[QUOTE=iJohnny;50823190]Tvoyu mat'. I can help you with this, dodo[/QUOTE] Да да..Твою мать Джонии. Wrong Project? Я Разобрался со всем. Сейчас заниматься буду самым сложным... И думаю врятли получится... Если хочешь, то давай вместе попробуем. [URL="Steam Profile"]http://steamcommunity.com/id/SmeRT_Kungur/[/URL]
Cyka Blyat
Sorry, you need to Log In to post a reply to this thread.