how fast is getpixel and setpixel?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
plymouth
Prole
Posts: 6
Joined: Tue Dec 29, 2009 10:43 am

how fast is getpixel and setpixel?

Post by plymouth »

hi,

if i use setpixel on an image is this change reflected in a later call to getpixel? also, how fast is setpixel? and how are you keeping the local image data in sync with the opengl textures? Are you keeping a local copy of the image data and then reading/writing to that? or are you doing everything to the opengl texture itself? (which i imagine would be slow)

i just plan to write a fairly getpixel/setpixel intensive game (a la worms) so i need to know the performance characteristics, thanks :)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: how fast is getpixel and setpixel?

Post by bartbes »

I thought get/setPixel acted on ImageData, so I don't think that an image object created before the setPixel call will change when you call setPixel. About the speed, in my relatively simple tests it was pretty fast, but the simple answer is: nobody knows.
plymouth
Prole
Posts: 6
Joined: Tue Dec 29, 2009 10:43 am

Re: how fast is getpixel and setpixel?

Post by plymouth »

@bartbes

hmm, sorry im new to Love. So i cannot directly modify an Image? My problem is i need to modify an image that i am displaying on screen. How do i do this? or must i convert between Image and ImageData (which i imagine would be slow...?)

thanks
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: how fast is getpixel and setpixel?

Post by bartbes »

Well, of course there's love.graphics.point, which might be what you're looking for, and ImageData -> Image is done using love.graphics.newImage.
plymouth
Prole
Posts: 6
Joined: Tue Dec 29, 2009 10:43 am

Re: how fast is getpixel and setpixel?

Post by plymouth »

@bartbes, it seems that graphics.point draws a pixel on the framebuffer? what i want is to set and get pixels on an Image that i am currently displaying.

I assume this is not yet possible? (at least with very good performance)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: how fast is getpixel and setpixel?

Post by bartbes »

I don't see the purpose, doesn't either setPixel or love.graphics.point work?
plymouth
Prole
Posts: 6
Joined: Tue Dec 29, 2009 10:43 am

Re: how fast is getpixel and setpixel?

Post by plymouth »

The purpose is that i need to manipulate a particular image (not just draw on the framebuffer) and that i need also to be able to do a getpixel on the image. Say for example i have an image that is landscape, and i want the ability to blow up the landscape then i want to be able to do a setpixel on the image. But because it is landscape i also need to move over it using pixelperfect collisions, so i also need to have a getpixel on the image. So i need both a fast setpixel and getpixel for a regular image and it needs to be very fast (so i cant imagine converting between imagedata and image is going to be fast enough :/)
User avatar
kalle2990
Party member
Posts: 245
Joined: Sat Sep 12, 2009 1:17 pm
Location: Sweden

Re: how fast is getpixel and setpixel?

Post by kalle2990 »

One solution could be having a table with exploded pixels, and after the terrain is drawn draw the background again at those pixels. If collisions are important you could let the physic function (which I guess is self made) skip collisions with those pixels. It would speed up the game even when more than half of the landscape is blown up :)
plymouth
Prole
Posts: 6
Joined: Tue Dec 29, 2009 10:43 am

Re: how fast is getpixel and setpixel?

Post by plymouth »

@kalle thanks :) However it does seem like quite a weird limitation with Love that i cannot do some simple image manipulation like i want.. :)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: how fast is getpixel and setpixel?

Post by Robin »

plymouth wrote:it does seem like quite a weird limitation with Love that i cannot do some simple image manipulation like i want.. :)
I think that's a design choice: pixel manipulation is very low-level, far from the ultra rapid game development LÖVE was made for.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: No registered users and 155 guests