What changes about the map?kefka wrote:I am, because I'm looking for a solution where I can dynamically display the map. However I suppose what I can do is only call newPoint on the framebuffer when a tile's data changes.kikito wrote:Are you generating the framebuffer on every frame, by any chance?
Thanks for all the suggestions, I will profile this method against the ImageData method and post my results.
Drawing a large number of individual pixels per frame
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Drawing a large number of individual pixels per frame
Re: Drawing a large number of individual pixels per frame
Good question. The map is randomly generated by a cave-digging algorithm. I'd like to provide an interface to modify parameters of the algorithm and display the generation realtime.kraftman wrote:What changes about the map?kefka wrote:I am, because I'm looking for a solution where I can dynamically display the map. However I suppose what I can do is only call newPoint on the framebuffer when a tile's data changes.kikito wrote:Are you generating the framebuffer on every frame, by any chance?
Thanks for all the suggestions, I will profile this method against the ImageData method and post my results.
Re: Drawing a large number of individual pixels per frame
In that case I would recommend frame buffers. Using image data, you would need to create a new image to display each time new terrain is generated, while using frame buffers you can add extra info to the same frame buffer. I haven't used spritebatches yet, but I think you could do something similar with them.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Drawing a large number of individual pixels per frame
If he used the ImageData method, he could use ImageData:setPixel to add the changes to the map. He wouldn't have to re-generate the whole map every frame.
I wouldn't recommend spritebatches for this, as you WOULD need to re-generate it all the time (you can only add more and more to a spritebatch, not change or remove graphics from it).
I wouldn't recommend spritebatches for this, as you WOULD need to re-generate it all the time (you can only add more and more to a spritebatch, not change or remove graphics from it).
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Drawing a large number of individual pixels per frame
You do have to call love.graphics.newImage(imagedata) every time you change it, which creates a whole new image from the imagedata. This will create huge amounts of RAM if you aren't careful, AFAIK.Taehl wrote:If he used the ImageData method, he could use ImageData:setPixel to add the changes to the map. He wouldn't have to re-generate the whole map every frame.
I wouldn't recommend spritebatches for this, as you WOULD need to re-generate it all the time (you can only add more and more to a spritebatch, not change or remove graphics from it).
Regenerating spritebatches is generally pretty efficient, comparatively. Doing a streaming spritebatch (re-creating every frame) can be faster than drawing each image individually, and an infrequently-updated (less than once per frame) spritebatch is pretty much always faster than drawing individual images.
Re: Drawing a large number of individual pixels per frame
Well, it shouldn't be using all that much RAM unless you're storing all the images. It will make the garbage collector go nuts, though, which is never a good thing. I'm not sure how good the GC is in Lua (if it were Android, it would've made the app unusable (although I think they improved the GC in Android 2.3))slime wrote:You do have to call love.graphics.newImage(imagedata) every time you change it, which creates a whole new image from the imagedata. This will create huge amounts of RAM if you aren't careful, AFAIK.Taehl wrote:If he used the ImageData method, he could use ImageData:setPixel to add the changes to the map. He wouldn't have to re-generate the whole map every frame.
I wouldn't recommend spritebatches for this, as you WOULD need to re-generate it all the time (you can only add more and more to a spritebatch, not change or remove graphics from it).
Regenerating spritebatches is generally pretty efficient, comparatively. Doing a streaming spritebatch (re-creating every frame) can be faster than drawing each image individually, and an infrequently-updated (less than once per frame) spritebatch is pretty much always faster than drawing individual images.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Drawing a large number of individual pixels per frame
I did a test, setting a pixel / newImage-ing / drawing a 256x256 image at about a thousand times per second, and didn't see Love's RAM usage go over 26 megs.slime wrote:This will create huge amounts of RAM if you aren't careful, AFAIK.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: Drawing a large number of individual pixels per frame
It's still less efficient to create a new image each time than to just add the extra data to the same framebuffer
Re: Drawing a large number of individual pixels per frame
Unless I'm misunderstanding you, I don't think you can do this in Love 0.7.2, since framebuffers are cleared automatically each time you draw to them. (Though I believe this is fixed in 0.8.0).kraftman wrote:It's still less efficient to create a new image each time than to just add the extra data to the same framebuffer
Who is online
Users browsing this forum: Bing [Bot] and 4 guests