Advertisement
szymski

Untitled

Jun 13th, 2017
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. --@name
  2. --@author
  3. --@shared
  4.  
  5. if CLIENT then
  6.  
  7. render.createRenderTarget("screen_rt") -- Create render target, so the screen won't clear itself on each frame
  8.  
  9. hook.add("render", "", function()
  10. render.selectRenderTarget("screen_rt") -- Draw to the render target
  11.  
  12. -- While cpu usage is less than 20%
  13. while quotaUsed() / quotaMax() < 0.2 do
  14. coroutine.resume(renderCoroutine) -- Continue drawing
  15. end
  16.  
  17. render.selectRenderTarget()
  18.  
  19. render.setRGBA(255, 0, 0, 255)
  20. render.drawRect(0, 0, 512, 512)
  21.  
  22. render.setRGBA(255, 255, 255, 255)
  23. render.setRenderTargetTexture("screen_rt") -- Bind the rendertarget texture and draw it
  24. render.drawTexturedRect(0, 0, 1024, 1024) -- RT's texture is 1024x1024 in size
  25. end)
  26.  
  27. function yieldedRender()
  28. while true do
  29. for x = 0, 512 - 1 do
  30. for y = 0, 512 - 1 do
  31. render.setColor(Color(math.random()* 255, math.random()* 255, math.random()* 255))
  32. render.drawRect(x, y, 1, 1)
  33. coroutine.yield() -- Pause the function
  34. end
  35. end
  36. end
  37. end
  38.  
  39. renderCoroutine = coroutine.create(yieldedRender) -- Create a new coroutine
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement