Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --@name
- --@author
- --@shared
- if CLIENT then
- render.createRenderTarget("screen_rt") -- Create render target, so the screen won't clear itself on each frame
- hook.add("render", "", function()
- render.selectRenderTarget("screen_rt") -- Draw to the render target
- -- While cpu usage is less than 20%
- while quotaUsed() / quotaMax() < 0.2 do
- coroutine.resume(renderCoroutine) -- Continue drawing
- end
- render.selectRenderTarget()
- render.setRGBA(255, 0, 0, 255)
- render.drawRect(0, 0, 512, 512)
- render.setRGBA(255, 255, 255, 255)
- render.setRenderTargetTexture("screen_rt") -- Bind the rendertarget texture and draw it
- render.drawTexturedRect(0, 0, 1024, 1024) -- RT's texture is 1024x1024 in size
- end)
- function yieldedRender()
- while true do
- for x = 0, 512 - 1 do
- for y = 0, 512 - 1 do
- render.setColor(Color(math.random()* 255, math.random()* 255, math.random()* 255))
- render.drawRect(x, y, 1, 1)
- coroutine.yield() -- Pause the function
- end
- end
- end
- end
- renderCoroutine = coroutine.create(yieldedRender) -- Create a new coroutine
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement