Intercept any DrawBuffers enums and convert GL_BACK/GL_FRONT

This commit is contained in:
Baldur Karlsson
2014-06-19 15:23:27 +01:00
parent 07e9855f0e
commit 9ef2fceba9
4 changed files with 43 additions and 6 deletions
+1
View File
@@ -31,6 +31,7 @@
enum RDCGLenum
{
eGL_UNKNOWN_ENUM = 0x0,
eGL_NONE = 0x0,
eERROR_INCOMPATIBLE_AFFINITY_MASKS_NV = 0x20D0,
eERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB = 0x2054,
eERROR_INVALID_PIXEL_TYPE_ARB = 0x2043,
+27 -5
View File
@@ -100,8 +100,6 @@ void GLRenderState::FetchState()
for(GLuint i=0; i < (GLuint)ARRAY_COUNT(Scissors); i++)
m_Real->glGetIntegeri_v(eGL_SCISSOR_BOX, i, &Scissors[i].x);
m_Real->glGetIntegerv(eGL_DRAW_BUFFER, (GLint *)&DrawBuffer);
for(size_t i=0; i < ARRAY_COUNT(DrawBuffers); i++)
m_Real->glGetIntegerv(GLenum(eGL_DRAW_BUFFER0 + i), (GLint *)&DrawBuffers[i]);
@@ -220,8 +218,33 @@ void GLRenderState::ApplyState()
m_Real->glScissorArrayv(0, ARRAY_COUNT(Scissors), &Scissors[0].x);
m_Real->glDrawBuffer(DrawBuffer);
m_Real->glDrawBuffers(8, DrawBuffers);
GLenum DBs[8] = { eGL_UNKNOWN_ENUM };
uint32_t numDBs = 0;
for(GLuint i=0; i < (GLuint)ARRAY_COUNT(DrawBuffers); i++)
{
if(DrawBuffers[i] != eGL_NONE)
{
numDBs++;
DBs[i] = DrawBuffers[i];
// since we are faking the default framebuffer with our own
// to see the results, replace back/front/left/right with color attachment 0
if(DBs[i] == eGL_BACK_LEFT || DBs[i] == eGL_BACK_RIGHT ||
DBs[i] == eGL_FRONT_LEFT || DBs[i] == eGL_FRONT_RIGHT)
DBs[i] = eGL_COLOR_ATTACHMENT0;
// These aren't valid for glDrawBuffers but can be returned when we call glGet,
// assume they mean left implicitly
if(DBs[i] == eGL_BACK ||
DBs[i] == eGL_FRONT)
DBs[i] = eGL_COLOR_ATTACHMENT0;
}
else
{
break;
}
}
m_Real->glDrawBuffers(numDBs, DBs);
m_Real->glHint(eGL_FRAGMENT_SHADER_DERIVATIVE_HINT, Hints.Derivatives);
m_Real->glHint(eGL_LINE_SMOOTH_HINT, Hints.LineSmooth);
@@ -375,7 +398,6 @@ void GLRenderState::Serialise(LogState state, GLResourceManager *rm)
m_pSerialiser->Serialise("GL_VIEWPORT.h", Scissors[i].height);
}
m_pSerialiser->Serialise("GL_DRAWBUFFER", DrawBuffer);
m_pSerialiser->Serialise<8>("GL_DRAWBUFFERS", DrawBuffers);
m_pSerialiser->Serialise("GL_FRAGMENT_SHADER_DERIVATIVE_HINT", Hints.Derivatives);
-1
View File
@@ -68,7 +68,6 @@ struct GLRenderState
int32_t x, y, width, height;
} Scissors[16];
GLenum DrawBuffer;
GLenum DrawBuffers[8];
// TODO:
@@ -380,6 +380,12 @@ bool WrappedOpenGL::Serialise_glDrawBuffer(GLenum buf)
if(m_State < WRITING)
{
// since we are faking the default framebuffer with our own
// to see the results, replace back/front/left/right with color attachment 0
if(b == eGL_BACK_LEFT || b == eGL_BACK_RIGHT || b == eGL_BACK ||
b == eGL_FRONT_LEFT || b == eGL_FRONT_RIGHT || b == eGL_FRONT)
b = eGL_COLOR_ATTACHMENT0;
m_Real.glDrawBuffer(b);
}
@@ -407,6 +413,15 @@ bool WrappedOpenGL::Serialise_glFramebufferDrawBuffersEXT(GLuint framebuffer, GL
if(m_State < WRITING)
{
for(uint32_t i=0; i < num; i++)
{
// since we are faking the default framebuffer with our own
// to see the results, replace back/front/left/right with color attachment 0
if(buffers[i] == eGL_BACK_LEFT || buffers[i] == eGL_BACK_RIGHT || buffers[i] == eGL_BACK ||
buffers[i] == eGL_FRONT_LEFT || buffers[i] == eGL_FRONT_RIGHT || buffers[i] == eGL_FRONT)
buffers[i] = eGL_COLOR_ATTACHMENT0;
}
m_Real.glFramebufferDrawBuffersEXT(GetResourceManager()->GetLiveResource(Id).name, num, buffers);
}