fixed trash-texture-upon-first-redraw and crash-at-resize bug.

This commit is contained in:
rachytski 2011-03-08 01:04:33 +02:00 committed by Alex Zolotarev
parent 8c5dcd829f
commit 1fdbf36a02
4 changed files with 24 additions and 5 deletions

View file

@ -245,7 +245,7 @@ void RenderQueueRoutine::Do()
m_threadDrawer = make_shared_ptr(new DrawerYG(m_skinName, params));
yg::gl::Screen::Params auxParams;
auxParams.m_frameBuffer = m_frameBuffer;
auxParams.m_frameBuffer = make_shared_ptr(new yg::gl::FrameBuffer());
auxParams.m_resourceManager = m_resourceManager;
m_auxScreen = make_shared_ptr(new yg::gl::Screen(auxParams));
@ -351,12 +351,12 @@ void RenderQueueRoutine::Do()
if (m_currentRenderCommand != 0)
{
m_threadDrawer->beginFrame();
/// this fixes some strange issue with multisampled framebuffer.
/// setRenderTarget should be made here.
m_threadDrawer->screen()->setRenderTarget(m_renderState->m_backBufferLayers.front());
m_threadDrawer->beginFrame();
m_threadDrawer->screen()->enableClipRect(true);
m_threadDrawer->screen()->setClipRect(textureRect);
m_threadDrawer->clear();

View file

@ -84,6 +84,9 @@ namespace yg
utils::setupCoordinates(width(), height(), true);
if (m_depthBuffer)
m_depthBuffer->attachToFrameBuffer();
/// !!! it's a must for a correct work.
checkStatus();
}
void FrameBuffer::setRenderTarget(shared_ptr<RenderTarget> const & renderTarget)
@ -136,5 +139,20 @@ namespace yg
m_width = width;
m_height = height;
}
void FrameBuffer::checkStatus()
{
#ifdef OMIM_GL_ES
GLenum res = glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
if (res != GL_FRAMEBUFFER_COMPLETE_OES)
LOG(LERROR, ("incomplete framebuffer"));
#else
GLenum res = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (res == GL_FRAMEBUFFER_UNSUPPORTED)
LOG(LINFO, ("unsupported combination of attached target formats. could be possibly skipped"));
else if (res != GL_FRAMEBUFFER_COMPLETE_EXT)
LOG(LERROR, ("incomplete framebuffer"));
#endif
}
}
}

View file

@ -47,6 +47,8 @@ namespace yg
static unsigned current();
static void pushCurrent();
static void popCurrent();
void checkStatus();
};
}
}

View file

@ -5,6 +5,7 @@
#include "renderbuffer.hpp"
#include "resource_manager.hpp"
#include "internal/opengl.hpp"
#include "../base/logging.hpp"
namespace yg
{
@ -97,8 +98,6 @@ namespace yg
#else
/// Somehow this does the trick with the "trash-texture" upon first application redraw.
OGLCHECK(glBindFramebuffer(GL_READ_FRAMEBUFFER, m_multiSampledFrameBuffer->id()));
OGLCHECK(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_frameBuffer->id()));
OGLCHECK(glBlitFramebuffer(0, 0, width(), height(),