Toffbrown Posted May 8, 2014 Share Posted May 8, 2014 i am using an image, as a background for my login GUI and it covers the whole screen but it lags a tonne, i do not know why it lags so much, could it be the sizing or the quality of the image causing this lagging? local x, y, _ = interpolateBetween ( x1, y1, 0, x2, y2, 0, progress, "OutBounce" ) ---dxDrawRectangle ( x, y, width, height, tocolor ( 0, 0, 0, 45 ) ) dxDrawImage( x, y, width, height, "jjlogo.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) ----guiCreateStaticImage( 0.0,0.0,1920.0,1080.0, "bg.png", true ) ---dxDrawImage( 0.0, 0.0, width, height, "bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) function background() guiCreateStaticImage( x, y, width, height, "bg.png", false ) guiBringToFront(background) end addEventHandler ( "onClientRender", root, background ) end ) Note this is not full script just might i add with the image its kinda like, you know when you are lacking memory and you like drag what ever windows app around and it like lags, like 3d effect is this the image or is it the use of using a dx with gui? i have used DX and plain simple GUI together and no errors Link to comment
MIKI785 Posted May 8, 2014 Share Posted May 8, 2014 Its becquse youre creating a new image every frame.. use dxDrawImage instead. Link to comment
Dealman Posted May 8, 2014 Share Posted May 8, 2014 You're creating a new image and putting it at front 30-60 times per second. Thus, it lags. Link to comment
Toffbrown Posted May 10, 2014 Author Share Posted May 10, 2014 i tried dxDrawImage but lagg still occurs it seems to be just that image because i tried others and it has no FPS issues ever and i am using onClientRender could this cause it? Link to comment
Karuzo Posted May 10, 2014 Share Posted May 10, 2014 You have to use onClientRender event since dx drawings have to be rendered every frame otherwise you would only see them for one frame. So normally tha shouldn't cause laggs. Please show us your current code Link to comment
Toffbrown Posted May 10, 2014 Author Share Posted May 10, 2014 local sx, sy = guiGetScreenSize ( ) local width, height = 600, 500 local point_start = { (sx/2-width/2), -height } local point_end = { (sx/2-width/2), (sy/2-height/2) } addEventHandler ( "onClientRender", root, function ( ) if not startTime then startTime = getTickCount ( ) end if not endTime then endTime = getTickCount ( ) + 3000 end local now = getTickCount() local elapsedTime = now - startTime local duration = endTime - startTime local progress = elapsedTime / duration local setback = guiBringToFront () x1, y1 = unpack ( point_start ) x2, y2 = unpack ( point_end ) local x, y, _ = interpolateBetween ( x1, y1, 0, x2, y2, 0, progress, "OutBounce" ) ---dxDrawRectangle ( x, y, width, height, tocolor ( 0, 0, 0, 45 ) ) dxDrawImage(x, y, width, height, "jjlogo.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) guiBringToFront(setback) ---dxDrawImage(172, 70, 720, 538, "bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) --dxDrawImage( x, y, width, height, "jjlogo.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) ----guiCreateStaticImage( 0.0,0.0,1920.0,1080.0, "bg.png", true ) ---dxDrawImage( 0.0, 0.0, width, height, "bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) --function background() --dxDrawImage(0.0, 0.0, 1024, 768, "bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) -- guiBringToFront(background) --end --addEventHandler ( "onClientRender", root, background ) end ) function background() dxDrawImage(309, 142, 414, 325, "bg.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) end addEventHandler ( "onClientRender", root, background )--]] ---[[addEventHandler("onClientResourceStart", resourceRoot, -- function() -- end --)---- --addEventHandler("onClientRender", root, -- function() --dxDrawImage(309, 142, 414, 325, "test.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) -- end --) Very messy sorry about that its kinda my notes Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now