ray icon indicating copy to clipboard operation
ray copied to clipboard

How to render a Drawable only once ?

Open illtellyoulater opened this issue 11 years ago • 2 comments

If I write a render block like: render { |win| win.draw shape }

then it looks like everything in it it's continuosly redrawn to the screen? If I put a debug puts line in it, it will continuosly output to console.

This sucks a lot of cpu for static scenes which just need to be drawn once.

Is there a way to specify wheter something will be rendered just once or it will continuosly be re-drawn, like in most game/graphics framework where you have a main and a update function?

illtellyoulater avatar Nov 29 '13 07:11 illtellyoulater

Hey,

Indeed, the render block will be called at every frame. If you have a lot of static geometry to render, you can store it in an image (rendering it on an image target only once).

Did you actually run in a situation where this behaviour caused an issue?

Mon-Ouie avatar Nov 29 '13 19:11 Mon-Ouie

It's been 7 years so I can't remember! :) I'm replying now as I don't think it was polite to leave your question unanswered :)

illtellyoulater avatar Feb 14 '20 20:02 illtellyoulater