Page 3 of 3

Re: Paint program

Posted: Thu Oct 24, 2013 10:19 pm
by iPoisonxL
Yes, but remember; canvases are not an option right now.

All I'm looking for is that the FPS just boosts a little bit more. I'm currently locked at 13 FPS, and I need 25-30. It's not really meant to be a smooth drawing thing, it's meant to have some kind of input lag.

EDIT: FPS shifts from 13-18.

Re: Paint program

Posted: Fri Oct 25, 2013 5:55 am
by micha
You should definitely try to go with imageData. They reason, why drawing it is faster, is because you only need to call one drawing-function. While for the pixel-by-pixel approach you call a drawing-command for each pixel. Besides the drawing, each function call has some overhead (communication between LÖVE and OpenGL), which makes this approach so slow.

Re: Paint program

Posted: Fri Oct 25, 2013 11:06 am
by iPoisonxL
micha wrote:Besides the drawing, each function call has some overhead (communication between LÖVE and OpenGL), which makes this approach so slow.
Thanks for explaining this to me. I'll try out imageData.

Re: Paint program

Posted: Fri Oct 25, 2013 1:30 pm
by Luke100000
Maybe something like that:

Code: Select all

pixels={}
function love.update(dt)
   if love.mouse.isDown("l") and pixels[mouse.x][mouse.y]==nil then
      pixels[mouse.x][mouse.y]=true
   end
end

Re: Paint program

Posted: Fri Oct 25, 2013 6:32 pm
by tavuntu
Yeah but with that last example you only can draw a pixel once (it's an example, I know, just saying).

Re: Paint program

Posted: Fri Oct 25, 2013 8:01 pm
by iPoisonxL
Luke100000 wrote:Maybe something like that:

Code: Select all

pixels={}
function love.update(dt)
   if love.mouse.isDown("l") and pixels[mouse.x][mouse.y]==nil then
      pixels[mouse.x][mouse.y]=true
   end
end
This is how it is right now (well, something like that). The love.update process isn't what's lagging it, it's the drawing process. Not sure why, someone else says it's because LOVE does an OpenGL thingy every pixel. (480,000)

Oh, and also I added 9 shades and 5 colors to play around with. I kinda like the lagginess, I can make Space Creation Simulator 2013. It might be a bit hard to see the colors, but they're in there.
SCS2013.png
SCS2013.png (18.5 KiB) Viewed 5269 times
lol

P.S. I went from love.graphics.point(x,y) to love.graphics.rectangle(x,y,1,1) to make brighter pixels.

Re: Paint program

Posted: Mon Oct 28, 2013 3:57 pm
by Luke100000
tavuntu wrote:Yeah but with that last example you only can draw a pixel once (it's an example, I know, just saying).
If you mean me:
you can write:

Code: Select all

pixels={}
function love.update(dt)
   if love.mouse.isDown("l") and pixels[mouse.x][mouse.y]==nil then
      for x=-5, 5 do
         for y=-5, 5 do
            pixels[mouse.x+x][mouse.y+y]=true
         end
      end
   end
end
Now you can draw an big rectangle.
Only circles are the problem. :awesome:

Re: Paint program

Posted: Mon Oct 28, 2013 4:33 pm
by DaedalusYoung
That's still drawing every pixel individually. Not in the update function, but in the draw function. And that's what's making it slow. If you had to make a drawing on paper, would you rather make a rectangle by drawing 25 dots, or would you draw 4 lines?

Re: Paint program

Posted: Mon Oct 28, 2013 6:46 pm
by Ranguna259
How about every 5 seconds or by adding an array limit to the pixel table the screen gets saved into an ImageData, cleans the pixel table and draws the imageData ?

I'm going to try that.

EDIT: Nah, it re-draws every single pixel anyways :/

EDIT2: Actualy.. It has a limit because calling screenshot on every frame would slow down the FPS.
imageData with pixel limiter.love
(474 Bytes) Downloaded 209 times
EDIT3: Got a new ideia, everytime the mouse gets released then the current pixels get drawn to the imageData.
EDIT4: And that's paint for you, dunno why it get's alpha'ed every time it takes a screenshot.. That's up to you to fix ;)

Re: Paint program

Posted: Tue Oct 29, 2013 1:46 pm
by iPoisonxL
Wow, that's pretty cool! I like the first file you provided, since it's some kind of space creation software. I'll try to learn from that, makes sense. Thanks lots.