Page 1 of 1

How to cache drawing operations?

Posted: Sun Mar 06, 2011 7:51 am
by appleide
I'm trying to draw antialiased arcs and circles but they slow down the environment alot. So i thought of trying to cache them by drawing them to an image or something.

I looked through the documentation and turns out there is a way - draw to a framebuffer. I tried it but I got an error message "not supported by your opengl implementation". Even if my computer would support it, it meant that the feature isn't portable. =\

I thought of drawing to an image, but there is no way to redirect drawing operations to images... that means I have to come up with a copy of every love.graphics drawing operation, (polygon, rectangle, line, etc...).

Maybe I should just switch to a computer with a complete opengl driver...

Re: How to cache drawing operations?

Posted: Sun Mar 06, 2011 8:21 am
by BlackBulletIV
Your computer may yet support framebuffers. Make sure not to create a framebuffer with a non-Po2 resolution. Create one with something like 32x32, 64x64, 128x128 ... 1024x1024.
appleide wrote:I thought of drawing to an image, but there is no way to redirect drawing operations to images... that means I have to come up with a copy of every love.graphics drawing operation, (polygon, rectangle, line, etc...).
ImageData might be what you're looking for. You can then convert an ImageData object into an Image to be drawn. Make sure you don't do this heaps, it's not the fastest thing in the world.

Re: How to cache drawing operations?

Posted: Sun Mar 06, 2011 8:43 am
by appleide
BlackBulletIV wrote:Your computer may yet support framebuffers. Make sure not to create a framebuffer with a non-Po2 resolution. Create one with something like 32x32, 64x64, 128x128 ... 1024x1024.
appleide wrote:I thought of drawing to an image, but there is no way to redirect drawing operations to images... that means I have to come up with a copy of every love.graphics drawing operation, (polygon, rectangle, line, etc...).
ImageData might be what you're looking for. You can then convert an ImageData object into an Image to be drawn. Make sure you don't do this heaps, it's not the fastest thing in the world.
Yeah, but then I'd have to rewrite all those functions for use on images... :/

Also, noticed there's no way to convert framebuffers into imagedata; You can't seem to save stuff from the screen into a file?

Re: How to cache drawing operations?

Posted: Sun Mar 06, 2011 8:49 am
by TechnoCat
appleide wrote:Also, noticed there's no way to convert framebuffers into imagedata; You can't seem to save stuff from the screen into a file?
http://love2d.org/wiki/Framebuffer:getImageData
http://love2d.org/wiki/love.graphics.newScreenshot
and http://love2d.org/forums/viewtopic.php? ... ving+image

Re: How to cache drawing operations?

Posted: Sun Mar 06, 2011 9:15 am
by appleide
TechnoCat wrote:
appleide wrote:Also, noticed there's no way to convert framebuffers into imagedata; You can't seem to save stuff from the screen into a file?
http://love2d.org/wiki/Framebuffer:getImageData
http://love2d.org/wiki/love.graphics.newScreenshot
and http://love2d.org/forums/viewtopic.php? ... ving+image
:emo: I just wasn't looking hard enough before I made that comment.

Re: How to cache drawing operations?

Posted: Sun Mar 06, 2011 3:58 pm
by NÖÖB
Here's another example of drawing to an image:
http://love2d.org/forums/viewtopic.php?f=5&t=2576