FPS drop from DModelPanel

So normally my fps is always 144 in gmod, but when I draw the DModelPanel I get 15 fps, is this normal?

Here is the code:


local Playermodel = vgui.Create( "DModelPanel", Panel )
Playermodel:SetSize( 440, 620 )
Playermodel:SetPos( 40, 60 )
Playermodel:SetFOV( 45 )
Playermodel:SetParent( Frame )
Playermodel:SetModel( LocalPlayer():GetModel() )

Also it crashed my gmod after having it open in 1 minute.

You are creating the panel every single frame. Instead, you should only be creating it once.

Are you creating multiple panels in a Think hook or something by any chance?

EDIT: Goddammit, should’ve refreshed before posting.

How do I create it once only? O.o

Use InitPostEntity to create the model panel.

Uhm, I have looked everywhere and cant find a way to use InitPostEntity to do that, it just spams my console with errors.

EDIT: Something about invalid GM

You are not creating a hook correctly, you have to use hook.Add, not GM:InitPostEntity

Ah, dumb me.

Try putting it a frame i made a nice on for you :slight_smile:


 
local Frame = vgui.Create("DFrame")
Frame:SetSize(300,400)
Frame:Center()
Frame:ShowCloseButton(false)
Frame:MakePopup()
function Frame:Paint()
	draw.RoundedBox(0, 0, 0, Frame:GetWide(), Frame:GetTall(), Color(60,60,60,255))	
end

local cbutton = vgui.Create("DButton", Frame)
cbutton:SetText("")
cbutton:SetSize(50,25)
cbutton.DoClick = function()
	Frame:Close()
end
function cbutton:Paint( w, h )
	draw.RoundedBox( 0, 0, 0, w, h, Color( 200,70,70,255 ) )
end

local Playermodel = vgui.Create( "DModelPanel", Frame )
Playermodel:SetSize( Frame:GetWide(), 350 )
Playermodel:SetPos( 0, 30 )
Playermodel:SetFOV( 50 )
Playermodel:SetParent( Frame )
Playermodel:SetModel( LocalPlayer():GetModel() )


:sick: