Access to back buffer

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!

Postby BlindSide » Wed Jul 21, 2010 5:39 am

You're supposed to expose it to IVideoDriver, it's the only way to access it... The other drivers can just do nothing.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
BlindSide
Admin
 
Posts: 2804
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Postby slavik262 » Sat Jul 31, 2010 4:27 pm

I'm running into further problems.

When I do my initial render to the frame buffer (to copy into my RT system), I don't call beginScene() or endScene() to avoid it from being actually synced to the screen. This works perfectly fine (see my beautiful screenshot below with bloom)...

Image

Except... calling ISceneManager::drawAll() causes this to appear in the MSVC output console:

First-chance exception at 0x75b49617 in Postprocessing.exe: Microsoft C++ exception: long at memory location 0x0028f090.


I'm positive that this is related to me not calling beginScene() and endScene() and not some other memory issue (putting begin and end scene back in gets rid of the problem right away).

Then, when I go to drop the device, calling drop() throws an access violation exception (again, I'm positive that this is directly related to the being/end scene issue, as putting those calls in solves the problem).

I'm half-tempted to just ignore these problems since everything else works perfectly, but why is this happening?
User avatar
slavik262
 
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Postby Mel » Sat Oct 16, 2010 5:04 pm

So, Is this actually working correctly?
http://santiagong.daportfolio.com/
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
User avatar
Mel
Competition winner
 
Posts: 1809
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Postby slavik262 » Sat Oct 16, 2010 5:15 pm

It turned out that the exception was due to me deleting a shader callback class, not realizing that it inherited IReferenceCounted. Everything else works, but I'm not copying the backbuffer anymore since you can't render in HDR using it (since the highest range format the backbuffer supports is A8R8G8B8).
User avatar
slavik262
 
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Postby Mel » Sat Oct 16, 2010 10:40 pm

So, no antialiasing under DX9 and HDR for the moment, unless you render to a bigger rendertarget?. This is a bit uncomfortable, to be honest.

In DX the rendertargets can be created with multisample and in floating point precison, the only issue seems to be that the RT isn't lockable, probably because it will only exist in the graphics card.

I don't know, this confuses me. Some places say RTT can't have multisample, other say it is posible.

At least, the MSDN says it is possible.
http://msdn.microsoft.com/en-us/library ... 85%29.aspx
http://santiagong.daportfolio.com/
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
User avatar
Mel
Competition winner
 
Posts: 1809
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Postby slavik262 » Sun Oct 17, 2010 7:33 pm

I'm using MRT for deferred shading, so I can't use MSAA anyways.
User avatar
slavik262
 
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Postby Mel » Mon Oct 18, 2010 5:07 pm

I've been seeing the sources, and i've got a question regarding the back buffer and the usage of the textures and rendertargets. What is the diference between creating the RTT with the "CreateTexture" call, with the usage "RENDERTARGET TEXTURE" and the "CreateRenderTarget" call?

CreateTexture doesn't have multisampling, but CreateRenderTarget indeed seems to suport it.
http://santiagong.daportfolio.com/
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
User avatar
Mel
Competition winner
 
Posts: 1809
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Access to back buffer

Postby dzordz » Wed Feb 01, 2012 10:25 pm

I rebuilt irrlicht and libs, but now I don't know what to do. What code should I use for make AA works with postprocessing?
dzordz
 
Posts: 6
Joined: Sun Dec 26, 2010 5:36 pm
Location: Poland

Re: Access to back buffer

Postby Mel » Mon Feb 06, 2012 11:56 am

Search for a function in the forums which is able to copy and downsample the backbuffer to a rendertarget. This only works in DirectX, but it allows for multisampled postprocessing. Or else, look for a postprocessing that is able to make antialiasing, like FXAA or MLAA, or similar.
http://santiagong.daportfolio.com/
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
User avatar
Mel
Competition winner
 
Posts: 1809
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Access to back buffer

Postby robmar » Fri May 03, 2013 1:55 pm

Just tried the opengl version of copyBackBufferTo with 1.7.3. and the blit fails with GL_INVALID_FRAMEBUFFER_OPERATION

Checked FBO status and its complete, so why should this error occur?
robmar
 
Posts: 799
Joined: Sun Aug 14, 2011 11:30 pm

Re: Access to back buffer

Postby robmar » Sat May 04, 2013 12:48 pm

I had to change the code to get it to work:-

cpp Code: Select all
bool COpenGLDriver::copyBackBufferTo(ITexture* dest)        // To render target (which has a FB and texture)
{
    GLenum error = 0;
    error = glGetError();       // Clear any old error
   //if (dest->getDriverType() != EDT_OPENGL)
   //   return false;
 
    GLenum status = extGlCheckFramebufferStatus(GL_FRAMEBUFFER_EXT);
    if ( status != GL_FRAMEBUFFER_COMPLETE )
        goto returnFALSE;
 
#ifdef _DEBUG
static bool bDo = false;
if ( bDo )
{
    glDisable(GL_BLEND);
    error = glGetError();
    if ( error != GL_NO_ERROR )
        goto returnFALSE;
    glDisable(GL_DEPTH_TEST);
    error = glGetError();
    if ( error != GL_NO_ERROR )
        goto returnFALSE;
    glDisable(GL_ALPHA_TEST);
    error = glGetError();
    if ( error != GL_NO_ERROR )
        goto returnFALSE;
    glDisable(GL_MULTISAMPLE_ARB);
    error = glGetError();
    if ( error != GL_NO_ERROR )
        goto returnFALSE;
    glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
    error = glGetError();
    if ( error != GL_NO_ERROR )
        goto returnFALSE;
//  glEnable(GL_DEPTH_TEST);
//  glDisable(GL_TEXTURE_2D);
}
#endif
 
    GLint oldFBO = 0;
    glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFBO);
    error = glGetError();
 
    COpenGLTexture* tex = (COpenGLTexture*)dest;
    GLuint name =  tex->getOpenGLTextureName();
 
    core::dimension2du bSize = this->getScreenSize();
 
    glReadBuffer(GL_BACK);   // Moved to here else error, Robmar
    error = glGetError();
    extGlBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
    error = glGetError();
    extGlBindFramebuffer(GL_DRAW_FRAMEBUFFER, name);
    error = glGetError();
 
    extGlFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, name, 0);  // Added this, Robmar
    error = glGetError();
    glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
    error = glGetError();
 
    extGlBlitFramebuffer(   0, 0, bSize.Width, bSize.Height,
        0, 0, bSize.Width, bSize.Height,
        GL_COLOR_BUFFER_BIT, GL_NEAREST);
    error = glGetError();
 
    extGlBindFramebuffer(GL_FRAMEBUFFER, oldFBO);
    error = glGetError();
   
    return true;
returnFALSE:
    return false;
 
}
robmar
 
Posts: 799
Joined: Sun Aug 14, 2011 11:30 pm

Previous

Return to Advanced Help

Who is online

Users browsing this forum: No registered users and 1 guest