mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-01-24 17:26:41 +00:00
fix issues with glDrawBuffersARB() code path in prev commit
This commit is contained in:
parent
5b57d4d6ff
commit
f7090f33d5
2 changed files with 15 additions and 9 deletions
|
@ -33,6 +33,7 @@ struct FBOStack
|
||||||
|
|
||||||
static FBOStack s_fbostack[4]; // first entry is always unused
|
static FBOStack s_fbostack[4]; // first entry is always unused
|
||||||
static size_t s_stackpos = 0;
|
static size_t s_stackpos = 0;
|
||||||
|
static unsigned s_lastFBO = 0;
|
||||||
|
|
||||||
|
|
||||||
static bool isOnTop(const FrameBuffer *fbo)
|
static bool isOnTop(const FrameBuffer *fbo)
|
||||||
|
@ -192,6 +193,7 @@ void FrameBuffer::unloadDevice()
|
||||||
|
|
||||||
if (glDeleteFramebuffersEXT == NULL)
|
if (glDeleteFramebuffersEXT == NULL)
|
||||||
{
|
{
|
||||||
|
s_lastFBO = 0;
|
||||||
debugLog("Already shut down the GL, don't delete framebuffers");
|
debugLog("Already shut down the GL, don't delete framebuffers");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -199,6 +201,8 @@ void FrameBuffer::unloadDevice()
|
||||||
for(size_t i = 0; i < Countof(_texs); ++i)
|
for(size_t i = 0; i < Countof(_texs); ++i)
|
||||||
if (_fbos[i])
|
if (_fbos[i])
|
||||||
{
|
{
|
||||||
|
if(s_lastFBO == _fbos[i])
|
||||||
|
s_lastFBO = 0;
|
||||||
debugLog("frameBuffer handle present, deleting");
|
debugLog("frameBuffer handle present, deleting");
|
||||||
glDeleteFramebuffersEXT(1, &_fbos[i]);
|
glDeleteFramebuffersEXT(1, &_fbos[i]);
|
||||||
_fbos[i] = 0;
|
_fbos[i] = 0;
|
||||||
|
@ -220,6 +224,7 @@ void FrameBuffer::reloadDevice()
|
||||||
{
|
{
|
||||||
if(!_numpages)
|
if(!_numpages)
|
||||||
return;
|
return;
|
||||||
|
s_lastFBO = 0;
|
||||||
debugLog("frameBuffer::reloadDevice");
|
debugLog("frameBuffer::reloadDevice");
|
||||||
init(_w, _h, _numpages);
|
init(_w, _h, _numpages);
|
||||||
}
|
}
|
||||||
|
@ -228,19 +233,19 @@ void FrameBuffer::_bind(unsigned page) const
|
||||||
{
|
{
|
||||||
assert(page < _numpages);
|
assert(page < _numpages);
|
||||||
_curpage = page + 1;
|
_curpage = page + 1;
|
||||||
|
unsigned fbo = _numfbos == 1 ? _fbos[0] : _fbos[page];
|
||||||
|
assert(fbo);
|
||||||
|
if(fbo != s_lastFBO)
|
||||||
|
{
|
||||||
|
s_lastFBO = fbo;
|
||||||
|
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
|
||||||
|
}
|
||||||
|
|
||||||
if(glDrawBuffersARB)
|
if(glDrawBuffersARB)
|
||||||
{
|
{
|
||||||
assert(_numfbos == 1);
|
|
||||||
if(!isOnTop(this))
|
|
||||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fbos[0]);
|
|
||||||
GLenum buf = GL_COLOR_ATTACHMENT0_EXT + page;
|
GLenum buf = GL_COLOR_ATTACHMENT0_EXT + page;
|
||||||
glDrawBuffersARB(1, &buf);
|
glDrawBuffersARB(1, &buf);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
assert(_fbos[page]);
|
|
||||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _fbos[page]);
|
|
||||||
}
|
|
||||||
|
|
||||||
glViewport(0,0,viewportW,viewportH);
|
glViewport(0,0,viewportW,viewportH);
|
||||||
}
|
}
|
||||||
|
@ -267,6 +272,7 @@ unsigned FrameBuffer::popCapture() const
|
||||||
prev.fbo->_bind(prev.page);
|
prev.fbo->_bind(prev.page);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
s_lastFBO = 0;
|
||||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||||
if(glDrawBuffersARB)
|
if(glDrawBuffersARB)
|
||||||
glDrawBuffer(GL_BACK);
|
glDrawBuffer(GL_BACK);
|
||||||
|
|
|
@ -181,7 +181,7 @@ bool lookup_all_glsyms()
|
||||||
glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)SDL_GL_GetProcAddress("glGenFramebuffersEXT");
|
glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)SDL_GL_GetProcAddress("glGenFramebuffersEXT");
|
||||||
glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)SDL_GL_GetProcAddress("glCheckFramebufferStatusEXT");
|
glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)SDL_GL_GetProcAddress("glCheckFramebufferStatusEXT");
|
||||||
glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)SDL_GL_GetProcAddress("glFramebufferTexture2DEXT");
|
glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)SDL_GL_GetProcAddress("glFramebufferTexture2DEXT");
|
||||||
glDrawBuffersARB = NULL;//(PFNGLDRAWBUFFERSARBPROC)SDL_GL_GetProcAddress("glDrawBuffersARB");
|
glDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC)SDL_GL_GetProcAddress("glDrawBuffersARB");
|
||||||
|
|
||||||
// GL 4.3+, but maybe available as an extension
|
// GL 4.3+, but maybe available as an extension
|
||||||
glCopyImageSubDataEXT = (PFNGLCOPYIMAGESUBDATAEXTPROC)SDL_GL_GetProcAddress("glCopyImageSubDataEXT");
|
glCopyImageSubDataEXT = (PFNGLCOPYIMAGESUBDATAEXTPROC)SDL_GL_GetProcAddress("glCopyImageSubDataEXT");
|
||||||
|
|
Loading…
Reference in a new issue