mirror of
https://github.com/MobileGL-Dev/MobileGlues.git
synced 2025-09-23 03:04:03 -04:00
change code position
This commit is contained in:
parent
daef7170b9
commit
4eb4adbd26
@ -36,72 +36,3 @@ void glMultiDrawElements(GLenum mode,const GLsizei * count,GLenum type,const voi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void glDrawBuffer(GLenum buffer) {
|
|
||||||
LOG()
|
|
||||||
|
|
||||||
LOAD_GLES(glDrawBuffers, void, GLsizei n, const GLenum *bufs)
|
|
||||||
|
|
||||||
GLint currentFBO;
|
|
||||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, ¤tFBO);
|
|
||||||
|
|
||||||
if (currentFBO == 0) { // 默认帧缓冲
|
|
||||||
GLenum buffers[1] = {GL_NONE};
|
|
||||||
switch (buffer) {
|
|
||||||
case GL_FRONT:
|
|
||||||
case GL_BACK:
|
|
||||||
case GL_NONE:
|
|
||||||
buffers[0] = buffer;
|
|
||||||
gles_glDrawBuffers(1, buffers);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// 生成错误:GL_INVALID_ENUM
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else { // FBO场景
|
|
||||||
GLint maxAttachments;
|
|
||||||
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxAttachments);
|
|
||||||
|
|
||||||
if (buffer == GL_NONE) {
|
|
||||||
GLenum *buffers = (GLenum *)alloca(maxAttachments * sizeof(GLenum));
|
|
||||||
for (int i = 0; i < maxAttachments; i++) {
|
|
||||||
buffers[i] = GL_NONE;
|
|
||||||
}
|
|
||||||
gles_glDrawBuffers(maxAttachments, buffers);
|
|
||||||
} else if (buffer >= GL_COLOR_ATTACHMENT0 &&
|
|
||||||
buffer < GL_COLOR_ATTACHMENT0 + maxAttachments) {
|
|
||||||
GLenum *buffers = (GLenum *)alloca(maxAttachments * sizeof(GLenum));
|
|
||||||
for (int i = 0; i < maxAttachments; i++) {
|
|
||||||
buffers[i] = (i == (buffer - GL_COLOR_ATTACHMENT0)) ? buffer : GL_NONE;
|
|
||||||
}
|
|
||||||
gles_glDrawBuffers(maxAttachments, buffers);
|
|
||||||
} else {
|
|
||||||
// 生成错误:GL_INVALID_ENUM
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void glDrawBuffers(GLsizei n, const GLenum *bufs) {
|
|
||||||
LOG()
|
|
||||||
|
|
||||||
LOG_D("glDrawBuffers(%d, %p), [0]=0x%x", n, bufs, n ? bufs[0] : 0)
|
|
||||||
|
|
||||||
GLenum new_bufs[n];
|
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
if (bufs[i] >= GL_COLOR_ATTACHMENT0 && bufs[i] <= GL_COLOR_ATTACHMENT0 + getMaxDrawBuffers()) {
|
|
||||||
GLenum target_attachment = GL_COLOR_ATTACHMENT0 + i;
|
|
||||||
new_bufs[i] = target_attachment;
|
|
||||||
if (bufs[i] == target_attachment)
|
|
||||||
continue;
|
|
||||||
rebind_framebuffer(bufs[i], target_attachment);
|
|
||||||
} else {
|
|
||||||
new_bufs[i] = bufs[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LOAD_GLES(glDrawBuffers, void, GLsizei n, const GLenum *bufs)
|
|
||||||
gles_glDrawBuffers(n, new_bufs);
|
|
||||||
|
|
||||||
CHECK_GL_ERROR
|
|
||||||
}
|
|
@ -21,10 +21,6 @@
|
|||||||
|
|
||||||
GLAPI GLAPIENTRY void glMultiDrawElementsBaseVertex( GLenum mode, GLsizei *counts, GLenum type, const void * const *indices, GLsizei primcount, const GLint * basevertex);
|
GLAPI GLAPIENTRY void glMultiDrawElementsBaseVertex( GLenum mode, GLsizei *counts, GLenum type, const void * const *indices, GLsizei primcount, const GLint * basevertex);
|
||||||
|
|
||||||
GLAPI GLAPIENTRY void glDrawBuffer(GLenum buf);
|
|
||||||
|
|
||||||
GLAPI GLAPIENTRY void glDrawBuffers(GLsizei n, const GLenum *bufs);
|
|
||||||
|
|
||||||
GLAPI GLAPIENTRY void glMultiDrawElements(GLenum mode,const GLsizei * count,GLenum type,const void * const * indices,GLsizei primcount);
|
GLAPI GLAPIENTRY void glMultiDrawElements(GLenum mode,const GLsizei * count,GLenum type,const void * const * indices,GLsizei primcount);
|
||||||
|
|
||||||
#endif //MOBILEGLUES_DRAWING_H
|
#endif //MOBILEGLUES_DRAWING_H
|
||||||
|
@ -97,3 +97,72 @@ void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget,
|
|||||||
|
|
||||||
CHECK_GL_ERROR
|
CHECK_GL_ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void glDrawBuffer(GLenum buffer) {
|
||||||
|
LOG()
|
||||||
|
|
||||||
|
LOAD_GLES(glDrawBuffers, void, GLsizei n, const GLenum *bufs)
|
||||||
|
|
||||||
|
GLint currentFBO;
|
||||||
|
glGetIntegerv(GL_FRAMEBUFFER_BINDING, ¤tFBO);
|
||||||
|
|
||||||
|
if (currentFBO == 0) { // 默认帧缓冲
|
||||||
|
GLenum buffers[1] = {GL_NONE};
|
||||||
|
switch (buffer) {
|
||||||
|
case GL_FRONT:
|
||||||
|
case GL_BACK:
|
||||||
|
case GL_NONE:
|
||||||
|
buffers[0] = buffer;
|
||||||
|
gles_glDrawBuffers(1, buffers);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// 生成错误:GL_INVALID_ENUM
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else { // FBO场景
|
||||||
|
GLint maxAttachments;
|
||||||
|
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxAttachments);
|
||||||
|
|
||||||
|
if (buffer == GL_NONE) {
|
||||||
|
GLenum *buffers = (GLenum *)alloca(maxAttachments * sizeof(GLenum));
|
||||||
|
for (int i = 0; i < maxAttachments; i++) {
|
||||||
|
buffers[i] = GL_NONE;
|
||||||
|
}
|
||||||
|
gles_glDrawBuffers(maxAttachments, buffers);
|
||||||
|
} else if (buffer >= GL_COLOR_ATTACHMENT0 &&
|
||||||
|
buffer < GL_COLOR_ATTACHMENT0 + maxAttachments) {
|
||||||
|
GLenum *buffers = (GLenum *)alloca(maxAttachments * sizeof(GLenum));
|
||||||
|
for (int i = 0; i < maxAttachments; i++) {
|
||||||
|
buffers[i] = (i == (buffer - GL_COLOR_ATTACHMENT0)) ? buffer : GL_NONE;
|
||||||
|
}
|
||||||
|
gles_glDrawBuffers(maxAttachments, buffers);
|
||||||
|
} else {
|
||||||
|
// 生成错误:GL_INVALID_ENUM
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void glDrawBuffers(GLsizei n, const GLenum *bufs) {
|
||||||
|
LOG()
|
||||||
|
|
||||||
|
LOG_D("glDrawBuffers(%d, %p), [0]=0x%x", n, bufs, n ? bufs[0] : 0)
|
||||||
|
|
||||||
|
GLenum new_bufs[n];
|
||||||
|
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
if (bufs[i] >= GL_COLOR_ATTACHMENT0 && bufs[i] <= GL_COLOR_ATTACHMENT0 + getMaxDrawBuffers()) {
|
||||||
|
GLenum target_attachment = GL_COLOR_ATTACHMENT0 + i;
|
||||||
|
new_bufs[i] = target_attachment;
|
||||||
|
if (bufs[i] == target_attachment)
|
||||||
|
continue;
|
||||||
|
rebind_framebuffer(bufs[i], target_attachment);
|
||||||
|
} else {
|
||||||
|
new_bufs[i] = bufs[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LOAD_GLES(glDrawBuffers, void, GLsizei n, const GLenum *bufs)
|
||||||
|
gles_glDrawBuffers(n, new_bufs);
|
||||||
|
|
||||||
|
CHECK_GL_ERROR
|
||||||
|
}
|
@ -29,4 +29,8 @@ GLAPI GLAPIENTRY void glBindFramebuffer(GLenum target, GLuint framebuffer);
|
|||||||
|
|
||||||
GLAPI GLAPIENTRY void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
GLAPI GLAPIENTRY void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
||||||
|
|
||||||
|
GLAPI GLAPIENTRY void glDrawBuffer(GLenum buf);
|
||||||
|
|
||||||
|
GLAPI GLAPIENTRY void glDrawBuffers(GLsizei n, const GLenum *bufs);
|
||||||
|
|
||||||
#endif //MOBILEGLUES_FRAMEBUFFER_H
|
#endif //MOBILEGLUES_FRAMEBUFFER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user