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

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Gerrit
Prole
Posts: 46
Joined: Wed Mar 25, 2009 7:40 pm

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

Post by Gerrit » Fri Mar 27, 2009 12:03 am

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

User avatar
osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

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

Post by osgeld » Fri Mar 27, 2009 12:10 am

oh wow, im not the only one anymore (yay!)

User avatar
hdon
Prole
Posts: 36
Joined: Tue Mar 17, 2009 10:54 pm
Location: Pittsburgh, PA, USA
Contact:

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

Post by hdon » Fri Mar 27, 2009 2:48 am

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

User avatar
Gerrit
Prole
Posts: 46
Joined: Wed Mar 25, 2009 7:40 pm

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

Post by Gerrit » Fri Mar 27, 2009 11:43 am

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?

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

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

Post by bartbes » Fri Mar 27, 2009 1:55 pm

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)

User avatar
osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

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

Post by osgeld » Fri Mar 27, 2009 2:40 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 34 guests