mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Feat] (ShittilyDrawing): Implement DrawBuffer. Ensure read fbo is bound.
This commit is contained in:
@@ -23,7 +23,7 @@ namespace MG_GL::GL {
|
|||||||
if (outFormat)
|
if (outFormat)
|
||||||
*outFormat = format;
|
*outFormat = format;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_DEPTH_COMPONENT24:
|
case GL_DEPTH_COMPONENT24:
|
||||||
if (outInternalFormat)
|
if (outInternalFormat)
|
||||||
*outInternalFormat = internalFormat;
|
*outInternalFormat = internalFormat;
|
||||||
@@ -646,7 +646,7 @@ namespace MG_GL::GL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static GLuint lastBoundProgram = 0;
|
static GLuint lastBoundProgram = 0;
|
||||||
static GLuint lastBoundFBO[2] = {0};
|
static GLuint lastBoundFBO[2] = {0}; // 0: DRAW FBO, 1: READ FBO
|
||||||
static std::array<GLuint, 32> lastBoundTextures;
|
static std::array<GLuint, 32> lastBoundTextures;
|
||||||
|
|
||||||
void RealizeFBOState(GLenum fbtype) {
|
void RealizeFBOState(GLenum fbtype) {
|
||||||
@@ -1026,6 +1026,7 @@ namespace MG_GL::GL {
|
|||||||
|
|
||||||
// Framebuffer
|
// Framebuffer
|
||||||
RealizeFBOState(GL_DRAW_FRAMEBUFFER);
|
RealizeFBOState(GL_DRAW_FRAMEBUFFER);
|
||||||
|
RealizeFBOState(GL_READ_FRAMEBUFFER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawArraysSHITTILY(GLenum mode, GLint first, GLsizei count) {
|
void DrawArraysSHITTILY(GLenum mode, GLint first, GLsizei count) {
|
||||||
@@ -1109,6 +1110,7 @@ namespace MG_GL::GL {
|
|||||||
SyncAllTexturesToGLES(textureState);
|
SyncAllTexturesToGLES(textureState);
|
||||||
|
|
||||||
RealizeFBOState(GL_DRAW_FRAMEBUFFER);
|
RealizeFBOState(GL_DRAW_FRAMEBUFFER);
|
||||||
|
RealizeFBOState(GL_READ_FRAMEBUFFER);
|
||||||
|
|
||||||
static GLfloat lastClearColor[4] = {-1.0f, -1.0f, -1.0f, -1.0f};
|
static GLfloat lastClearColor[4] = {-1.0f, -1.0f, -1.0f, -1.0f};
|
||||||
if (memcmp(lastClearColor, commonState->clearColor, sizeof(lastClearColor)) != 0) {
|
if (memcmp(lastClearColor, commonState->clearColor, sizeof(lastClearColor)) != 0) {
|
||||||
@@ -1227,4 +1229,45 @@ namespace MG_GL::GL {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawBuffer(GLenum buf) {
|
||||||
|
SyncAllToGLES();
|
||||||
|
RealizeFBOState(GL_READ_FRAMEBUFFER);
|
||||||
|
RealizeFBOState(GL_READ_FRAMEBUFFER);
|
||||||
|
|
||||||
|
GLint currentFBO;
|
||||||
|
CallAndCheck(::GLES::glGetIntegerv(GL_FRAMEBUFFER_BINDING, ¤tFBO);)
|
||||||
|
|
||||||
|
if (currentFBO == 0) {
|
||||||
|
GLenum buffers[1] = {GL_NONE};
|
||||||
|
switch (buf) {
|
||||||
|
case GL_FRONT:
|
||||||
|
case GL_BACK:
|
||||||
|
case GL_NONE:
|
||||||
|
buffers[0] = buf;
|
||||||
|
CallAndCheck(::GLES::glDrawBuffers(1, buffers);)
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
GLint maxAttachments;
|
||||||
|
CallAndCheck(::GLES::glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxAttachments);)
|
||||||
|
|
||||||
|
if (buf == GL_NONE) {
|
||||||
|
auto *buffers = (GLenum *)alloca(maxAttachments * sizeof(GLenum));
|
||||||
|
for (int i = 0; i < maxAttachments; i++) {
|
||||||
|
buffers[i] = GL_NONE;
|
||||||
|
}
|
||||||
|
CallAndCheck(::GLES::glDrawBuffers(maxAttachments, buffers);)
|
||||||
|
} else if (buf >= GL_COLOR_ATTACHMENT0 &&
|
||||||
|
buf < GL_COLOR_ATTACHMENT0 + maxAttachments) {
|
||||||
|
auto *buffers = (GLenum *)alloca(maxAttachments * sizeof(GLenum));
|
||||||
|
for (int i = 0; i < maxAttachments; i++) {
|
||||||
|
buffers[i] = (i == (buf - GL_COLOR_ATTACHMENT0)) ? buf : GL_NONE;
|
||||||
|
}
|
||||||
|
CallAndCheck(::GLES::glDrawBuffers(maxAttachments, buffers);)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ namespace MG_GL::GL {
|
|||||||
void DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
|
void DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
|
||||||
void MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const *indices, GLsizei drawcount);
|
void MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const *indices, GLsizei drawcount);
|
||||||
void MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const *indices, GLsizei drawcount, const GLint *basevertex);
|
void MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const *indices, GLsizei drawcount, const GLint *basevertex);
|
||||||
|
void DrawBuffer(GLenum buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //MOBILEGL_GL_DRAWING_H
|
#endif //MOBILEGL_GL_DRAWING_H
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ DECLARE_GL_FUNCTION_STUB_HEAD(void, EdgeFlag, GLboolean flag ) DECLARE_GL_FUNCTI
|
|||||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, EdgeFlagv, const GLboolean *flag ) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, EdgeFlagv,flag)
|
DECLARE_GL_FUNCTION_STUB_HEAD(void, EdgeFlagv, const GLboolean *flag ) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, EdgeFlagv,flag)
|
||||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, ClipPlane, GLenum plane, const GLdouble *equation ) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ClipPlane,plane,equation)
|
DECLARE_GL_FUNCTION_STUB_HEAD(void, ClipPlane, GLenum plane, const GLdouble *equation ) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ClipPlane,plane,equation)
|
||||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetClipPlane, GLenum plane, GLdouble *equation ) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetClipPlane,plane,equation)
|
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetClipPlane, GLenum plane, GLdouble *equation ) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetClipPlane,plane,equation)
|
||||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, DrawBuffer, GLenum mode ) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DrawBuffer,mode)
|
DECLARE_GL_FUNCTION_HEAD(void, DrawBuffer, GLenum mode ) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DrawBuffer,mode)
|
||||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, EnableClientState, GLenum cap ) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, EnableClientState,cap)
|
DECLARE_GL_FUNCTION_STUB_HEAD(void, EnableClientState, GLenum cap ) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, EnableClientState,cap)
|
||||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, DisableClientState, GLenum cap ) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DisableClientState,cap)
|
DECLARE_GL_FUNCTION_STUB_HEAD(void, DisableClientState, GLenum cap ) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DisableClientState,cap)
|
||||||
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetDoublev, GLenum pname, GLdouble *params ) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetDoublev,pname,params)
|
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetDoublev, GLenum pname, GLdouble *params ) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetDoublev,pname,params)
|
||||||
|
|||||||
Reference in New Issue
Block a user