Page 1 of 1

Are there plans to enlarge "image" with more functions?

Posted: Fri Mar 27, 2009 12:03 am
by Gerrit
Hey!

I'm wondering why there isn't the possibility to draw on a backbuffer first. I was going to do it like that until I discovered that all drawing functions are only for the screen. Are there plans to make it possible to create and edit images? It would make some stuff easier to do and would improve the flow. If you wonder what I'm talking about, drawing on the backbuffer could look like this:

Code: Select all

backbuffer = love.graphics.newImage( 200, 200, 32 ) -- width/height/depth
backbuffer.graphics.setBackgroundColor( 255, 255, 255 ) -- set the background white
backbuffer.graphics.setColor( 0, 0, 0 ) -- set the color to black
backbuffer.graphics.rectangle( 0, 50, 50, 50, 50 ) -- draw a rectangle
love.graphics.draw( backbuffer, getWidth() / 2, getHeight() / 2 ) -- draw the backbuffer to the screen
I really miss the possibility to create images on the fly and it's also great if you are using not the whole screen for your game. Say you have a border. Now you could draw everything on a backbuffer which is smaller then your screen and draw that into the middle. If the border is static you wouldn't need to change anything (except your backbuffer in the middle) about it every frame. So, are there plans to make this possible?

Löve Gerrit

Re: Are there plans to enlarge "image" with more functions?

Posted: Fri Mar 27, 2009 12:10 am
by osgeld
oh wow, im not the only one anymore (yay!)

Re: Are there plans to enlarge "image" with more functions?

Posted: Fri Mar 27, 2009 2:48 am
by hdon
Gerrit wrote:I'm wondering why there isn't the possibility to draw on a backbuffer first.
AFAICT, you always draw to the back buffer. Then LÖVE swaps the buffers for you automatically upon return from your draw() function.
Gerrit wrote:Are there plans to make it possible to create and edit images?
That would be nice for image compositing, but not for back-buffering. There are special memory areas of video hardware optimized for being the current framebuffer, thus "swapping" buffers is really just swapping their roles, not actually copying any memory. An API to let you create off-screen images really has very little to do with the back buffer these days.
Gerrit wrote:It would make some stuff easier to do and would improve the flow. If you wonder what I'm talking about, drawing on the backbuffer could look like this:

Code: Select all

backbuffer = love.graphics.newImage( 200, 200, 32 ) -- width/height/depth
backbuffer.graphics.setBackgroundColor( 255, 255, 255 ) -- set the background white
No, it's good the way it is. How about this, though:

Code: Select all

myImage = love.graphics.newImage(200, 200, 32)
love.graphics.beginCompositing(myImage)
love.graphics.setColor( 0, 0, 0 ) -- set the color to black
love.graphics.rectangle( 0, 50, 50, 50, 50 ) -- draw a rectangle
love.graphics.draw( backbuffer, getWidth() / 2, getHeight() / 2 ) -- draw the backbuffer to the screen
love.graphics.endCompositing()
Gerrit wrote:I really miss the possibility to create images on the fly and it's also great if you are using not the whole screen for your game. Say you have a border. Now you could draw everything on a backbuffer which is smaller then your screen and draw that into the middle. If the border is static you wouldn't need to change anything (except your backbuffer in the middle) about it every frame.
You're really worrying too much about this. Redrawing every pixel in your game's border is not very expensive on modern machines, even on handheld's. In fact, if you redrew every pixel on your screen only once, your program would absolutely fly...

I vote for image compositing

Re: Are there plans to enlarge "image" with more functions?

Posted: Fri Mar 27, 2009 11:43 am
by Gerrit
hdon wrote:
Gerrit wrote:I'm wondering why there isn't the possibility to draw on a backbuffer first.
AFAICT, you always draw to the back buffer. Then LÖVE swaps the buffers for you automatically upon return from your draw() function.
Thanks, didn't know that :)
hdon wrote: How about this, though:

Code: Select all

myImage = love.graphics.newImage(200, 200, 32)
love.graphics.beginCompositing(myImage)
love.graphics.setColor( 0, 0, 0 ) -- set the color to black
love.graphics.rectangle( 0, 50, 50, 50, 50 ) -- draw a rectangle
love.graphics.draw( myImage, getWidth() / 2, getHeight() / 2 ) -- draw the image to the screen
love.graphics.endCompositing()
That would be the easier way to implant it I guess. I'm happy with both approaches. Mine's a bit more object oriented ;)
hdon wrote: You're really worrying too much about this. Redrawing every pixel in your game's border is not very expensive on modern machines, even on handheld's. In fact, if you redrew every pixel on your screen only once, your program would absolutely fly...
Yeah, I know. Bad point. The main reason here would be that you don't have to use the whole screen if you're rendering your game screen (if you have a border). As an example: In one of my demos I have a border on both sides (left & right). Instead of subtracting the border while computing if a bullet is still on screen, you could use an image that is as big as you want the screen to be. And the main reason of course is computing images on the fly.
hdon wrote: I vote for image compositing
Thanks. Now we're three :)

PS: Sidequestion: Why does Löve always use the middle when I draw something? I'm still not used to that. Every other programming language I used before positioned objects with the top left corner, except circles of course. Is this a gaming practice or something else?

Re: Are there plans to enlarge "image" with more functions?

Posted: Fri Mar 27, 2009 1:55 pm
by bartbes
It's a developers choice.
And I think compositing should be in there.. sometime.

BTW, hdon was right, it swaps buffers after draw finishes.

And the border thingy... it's not that hard to just use the border width in your calculations, is it? (don't get used to luxury :P)

Re: Are there plans to enlarge "image" with more functions?

Posted: Fri Mar 27, 2009 2:40 pm
by osgeld
sometime in the future images will be done from the top left, we all had a little vote thing or something, it throws me off too