forked from organicmaps/organicmaps
added glDiscardFramebufferFn OpenGL function.
This commit is contained in:
parent
85e1093729
commit
6d7ed36628
5 changed files with 43 additions and 0 deletions
|
@ -92,6 +92,7 @@ namespace yg
|
|||
void (OPENGL_CALLING_CONVENTION * glGenFramebuffersFn) (GLsizei n, GLuint *framebuffers);
|
||||
void (OPENGL_CALLING_CONVENTION * glDeleteFramebuffersFn) (GLsizei n, const GLuint *framebuffers);
|
||||
GLenum (OPENGL_CALLING_CONVENTION * glCheckFramebufferStatusFn) (GLenum target);
|
||||
void (OPENGL_CALLING_CONVENTION * glDiscardFramebufferFn)(GLenum target, GLsizei numAttachments, GLenum const * attachements) = 0;
|
||||
|
||||
void (OPENGL_CALLING_CONVENTION * glGenRenderbuffersFn) (GLsizei n, GLuint *renderbuffers);
|
||||
void (OPENGL_CALLING_CONVENTION * glDeleteRenderbuffersFn) (GLsizei n, const GLuint *renderbuffers);
|
||||
|
|
|
@ -127,6 +127,7 @@ namespace yg
|
|||
extern void (OPENGL_CALLING_CONVENTION * glGenFramebuffersFn) (GLsizei n, GLuint *framebuffers);
|
||||
extern void (OPENGL_CALLING_CONVENTION * glDeleteFramebuffersFn) (GLsizei n, const GLuint *framebuffers);
|
||||
extern GLenum (OPENGL_CALLING_CONVENTION * glCheckFramebufferStatusFn) (GLenum target);
|
||||
extern void (OPENGL_CALLING_CONVENTION * glDiscardFramebufferFn)(GLenum target, GLsizei numAttachments, GLenum const * attachements);
|
||||
|
||||
// renderbuffer extensions
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ namespace yg
|
|||
glGenFramebuffersFn = &glGenFramebuffers;
|
||||
glDeleteFramebuffersFn = &glDeleteFramebuffers;
|
||||
glCheckFramebufferStatusFn = &glCheckFramebufferStatus;
|
||||
glDiscardFramebufferFn = &glDiscardFramebufferEXT;
|
||||
|
||||
g_isRenderbufferSupported = g_isFramebufferSupported;
|
||||
|
||||
|
|
|
@ -84,6 +84,36 @@ namespace yg
|
|||
processCommand(make_shared_ptr(new UnbindRenderTarget(m_renderTarget)));
|
||||
}
|
||||
|
||||
Renderer::DiscardFramebuffer::DiscardFramebuffer(bool doDiscardColor, bool doDiscardDepth)
|
||||
: m_doDiscardColor(doDiscardColor), m_doDiscardDepth(doDiscardDepth)
|
||||
{}
|
||||
|
||||
void Renderer::DiscardFramebuffer::perform()
|
||||
{
|
||||
static bool firstReport = true;
|
||||
if (firstReport && !glDiscardFramebufferFn)
|
||||
LOG(LINFO, ("GL_EXT_discard_framebuffer is unsupported"));
|
||||
|
||||
firstReport = false;
|
||||
|
||||
if (glDiscardFramebufferFn)
|
||||
{
|
||||
GLenum attachements[2];
|
||||
int numAttachements = 0;
|
||||
if (m_doDiscardColor)
|
||||
attachements[numAttachements++] = GL_COLOR_ATTACHMENT0_MWM;
|
||||
if (m_doDiscardDepth)
|
||||
attachements[numAttachements++] = GL_DEPTH_ATTACHMENT_MWM;
|
||||
|
||||
glDiscardFramebufferFn(GL_FRAMEBUFFER_MWM, numAttachements, attachements);
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::discardFramebuffer(bool doDiscardColor, bool doDiscardDepth)
|
||||
{
|
||||
processCommand(make_shared_ptr(new DiscardFramebuffer(doDiscardColor, doDiscardDepth)));
|
||||
}
|
||||
|
||||
void Renderer::endFrame()
|
||||
{
|
||||
if (m_doUnbindRT && m_renderTarget)
|
||||
|
|
|
@ -66,6 +66,14 @@ namespace yg
|
|||
void perform();
|
||||
};
|
||||
|
||||
struct DiscardFramebuffer : Command
|
||||
{
|
||||
bool m_doDiscardColor;
|
||||
bool m_doDiscardDepth;
|
||||
DiscardFramebuffer(bool doDiscardColor, bool doDiscardDepth);
|
||||
void perform();
|
||||
};
|
||||
|
||||
struct FinishCommand : Command
|
||||
{
|
||||
void perform();
|
||||
|
@ -130,6 +138,8 @@ namespace yg
|
|||
shared_ptr<RenderBuffer> const & depthBuffer() const;
|
||||
void resetDepthBuffer();
|
||||
|
||||
void discardFramebuffer(bool doDiscardColor, bool doDiscardDepth);
|
||||
|
||||
/// @param clearRT - should we clear the renderTarget data (visible pixels)?
|
||||
/// @param clearDepth - should we clear depthBuffer data?
|
||||
/// @warning this function respects the clipping rect set and enabled(!)
|
||||
|
|
Loading…
Add table
Reference in a new issue