Reading Back/Front buffer?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Zerowalker
Posts: 20
Joined: Mon Feb 16, 2015 3:05 pm

Reading Back/Front buffer?

Post by Zerowalker »

Is it possible to do so?
I want to be able to "print screen" and just save the buffer.

I know i can set everything to render to a texture, but i don't see how that's actually good as i have to do everything twice, so it's better to just copy the buffer instead of making a "new one".
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Reading Back/Front buffer?

Post by hendu »

createScreenshot()
Zerowalker
Posts: 20
Joined: Mon Feb 16, 2015 3:05 pm

Re: Reading Back/Front buffer?

Post by Zerowalker »

Can that be used for making video recordings as well? (getting 60fps = 60images, and then of course some other code for the video stuff).

EDIT:

Seems like it pretty much takes screenshots like windows does, cause if windows get behind something the screenshot is of that instead.
So it's no copying the buffer i guess:S
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Reading Back/Front buffer?

Post by CuteAlien »

No it's not copying the buffer - and it's even very slow (creating a new Image each time). Screenshot functionality should be improved. But as alternative - try using render-to-texture. Maybe it's faster than this.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Zerowalker
Posts: 20
Joined: Mon Feb 16, 2015 3:05 pm

Re: Reading Back/Front buffer?

Post by Zerowalker »

but in order to use that, don't i have to double the drawing?
Cause when i render to texture buffer is blank, can i render to both at the same time without having to double the code and doing the drawing twice?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Reading Back/Front buffer?

Post by CuteAlien »

You could use the rendered texture and draw that. So you render the scene once - and then draw that texture on a screen-quad (search for XEffects in this forum, it has a screenquad node I think).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Asimov
Posts: 246
Joined: Thu Dec 04, 2014 7:41 pm
Contact:

Re: Reading Back/Front buffer?

Post by Asimov »

Hi Zerowalker,

Probably obvious, but when I want to save a screen shot I just hit the printscreen button. I have it linked to dropbox, so as soon as I hit the printscreen button it saves the screen to dropbox. Then I sometimes crop it in photoshop.
Zerowalker
Posts: 20
Joined: Mon Feb 16, 2015 3:05 pm

Re: Reading Back/Front buffer?

Post by Zerowalker »

Well the thing isn't about just print screening, it's supposed to be automatic and also be possible to record a video with it (though that's more complex and it's nothing i will try to achieve now;P).
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Reading Back/Front buffer?

Post by Mel »

There is a way to read (more correctly said, undersample) the backbuffer to a texture, a rendertarget anyway, in DX you can use the stretchrect function, i don't know in GL. But I also guess that for both options it would be better to modify the engine on your own so you added that method to the video driver. It is much faster than the create screenshot option and retains the MSAA from the backbuffer.

Or the render to texture option, which is quite valid as well, keep in mind that the render may happen only once, and you can draw the results to the screen any number of times you want, or you may access afterwards the data, just keep in mind that if you do that later, you will be moving the data back and forth from the video memory to the system memory, and that is the slowest part, so, if you have to do it, make it count.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Zerowalker
Posts: 20
Joined: Mon Feb 16, 2015 3:05 pm

Re: Reading Back/Front buffer?

Post by Zerowalker »

Well i guess modifying the engine somehow is the way to go. Sadly that's a bit out of my knowledge.
But i guess if i can understand it a bit it shouldn't be that hard to be able to grab a pointer to it.
Zerowalker
Posts: 20
Joined: Mon Feb 16, 2015 3:05 pm

Re: Reading Back/Front buffer?

Post by Zerowalker »

Okay trying to figure out how to implement this:

http://www.codeproject.com/Articles/505 ... the-screen

As i guess that's pretty much what we want right?
Though i get linking error even though d3d9.lib should be there, so yeah..stuck;P

it complains on: extern IDirect3DDevice9* g_pd3dDevice;

And that even works on my own application, so confused how it can't be working on the irrlicht source code.


EDIT:

i got the pointer and all, not sure what i am supposed to do with stretchrect as i needs to copy from one rect to another, which means i have to use the first method anyway to get the first surface?
Post Reply