How to use Framebuffer:renderTo() properly

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.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by TechnoCat »

Robin wrote:Does it need to be PO2?
It is my experience that, yes, they need to be PO2. Or else you get implementation errors on some (many it seems) systems.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by Robin »

TechnoCat wrote:
Robin wrote:Does it need to be PO2?
It is my experience that, yes, they need to be PO2. Or else you get implementation errors on some (many it seems) systems.
Oh, ok. I wouldn't know.
Help us help you: attach a .love.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by kikito »

vrld wrote:
kikito wrote:Is that a bug or a feature?
Neither. It's a constraint set by OpenGL.

To understand why, think of the framebuffer as an offscreen... screen. In a 3D world, you don't handle pixels, but only shapes (that may have some nice textures on them). These shapes are projected onto a screen, like in a shadow theater.
Now you always want to project the shapes in a way that the whole screen will be filled. If you take a bigger screen and set it up so that it will show the same shadows as the small screen, the shadows will obviously be larger.
When creating a framebuffer, OpenGL will ensure you see the same content on the buffer as you do on your main screen.

The way LÖVE handles 2D is basically to have only flat shapes in the same plane. Images are just surfaces with the image as texture on them. If you project that to a bigger screen, the image will appear to be upscaled.
The scaling with love.graphics.scale is somewhat like moving the screen further away (or closer to) from the objects that are projected onto the screen.
Sounds complicated.

So I take that on a tile-based game, spriteBatches are more appropiate for rendering the level than framebuffers then. Specially if they involve scrolling, perhaps?

-__- I'm still very 0.6-oriented.
When I write def I mean function.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by TechnoCat »

kikito wrote:Sounds complicated.

So I take that on a tile-based game, spriteBatches are more appropiate for rendering the level than framebuffers then. Specially if they involve scrolling, perhaps?

-__- I'm still very 0.6-oriented.
Don't sprite batches still draw each object every frame?

Anyways, still curious about this PO2 stretching issue.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by Robin »

TechnoCat wrote:Anyways, still curious about this PO2 stretching issue.
Congrats on your 600th post. :P

And you could try some things, see what they do?
Help us help you: attach a .love.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by TechnoCat »

Easiest solution is to make the window po2 too. But then forget full screen.

Disclaimer: Framebuffer and screen size will be independent soon. http://bitbucket.org/rude/love/changeset/4deb61ae7d2c
Last edited by TechnoCat on Thu Nov 18, 2010 3:33 pm, edited 1 time in total.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by TechnoCat »

LOVE was fixed to not stretch framebuffer windows to the main window. I'm waiting on a build with that before I continue using framebuffers.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by Jasoco »

How would I use this to:

Copy the contents of the main visible screen to a separate buffer
Manipulate the pixels of the separate newly copied buffer, say make all the pixels greyscale
Then use that separate buffer as an image to paste onto the main screen

?
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by TechnoCat »

Jasoco wrote:How would I use this to:

Copy the contents of the main visible screen to a separate buffer
Manipulate the pixels of the separate newly copied buffer, say make all the pixels greyscale
Then use that separate buffer as an image to paste onto the main screen

?
Sounds more like a job for a shader.

but maybe, screenshot, greyscale mappixel, draw
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: How to use Framebuffer:renderTo() properly

Post by Jasoco »

Well, mostly the first and third steps. Can I copy from one frame to another? Then can I take another and use it as image data?

That's mainly what I want. Or just how do I draw to another buffer and use that buffer on my main screen? I don't understand the code provided. Anyone have a working example .love file?
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 69 guests