mirror of
https://github.com/MobileGL-Dev/MobileGlues.git
synced 2025-09-21 18:22:19 -04:00
fix potential bugs
This commit is contained in:
parent
3fdd673aae
commit
571a7b74cb
@ -89,7 +89,7 @@ void glDrawBuffers(GLsizei n, const GLenum *bufs) {
|
||||
GLenum new_bufs[n];
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (bufs[i] >= GL_COLOR_ATTACHMENT0 && bufs <= GL_COLOR_ATTACHMENT0 + getMaxDrawBuffers()) {
|
||||
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)
|
||||
|
@ -20,6 +20,9 @@ GLint getMaxDrawBuffers() {
|
||||
}
|
||||
|
||||
void rebind_framebuffer(GLenum old_attachment, GLenum target_attachment) {
|
||||
if (!bound_framebuffer || !bound_framebuffer->attachment)
|
||||
return;
|
||||
|
||||
struct attachment_t attachment = bound_framebuffer->attachment[old_attachment - GL_COLOR_ATTACHMENT0];
|
||||
|
||||
LOAD_GLES(glFramebufferTexture2D, void, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
|
||||
@ -34,8 +37,10 @@ void glBindFramebuffer(GLenum target, GLuint framebuffer) {
|
||||
LOAD_GLES(glBindFramebuffer, void, GLenum target, GLuint framebuffer)
|
||||
gles_glBindFramebuffer(target, framebuffer);
|
||||
|
||||
bound_framebuffer = NULL;
|
||||
bound_framebuffer = malloc(sizeof(struct framebuffer_t));
|
||||
if (!bound_framebuffer)
|
||||
bound_framebuffer = malloc(sizeof(struct framebuffer_t));
|
||||
free(bound_framebuffer->attachment);
|
||||
bound_framebuffer->attachment = malloc(getMaxDrawBuffers() * sizeof(struct attachment_t));
|
||||
bound_framebuffer->target = target;
|
||||
|
||||
CHECK_GL_ERROR
|
||||
@ -46,9 +51,11 @@ void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget,
|
||||
|
||||
LOG_D("glFramebufferTexture2D(0x%x, 0x%x, 0x%x, %d, %d)", target, attachment, textarget, texture, level)
|
||||
|
||||
bound_framebuffer->attachment[attachment - GL_COLOR_ATTACHMENT0].textarget = textarget;
|
||||
bound_framebuffer->attachment[attachment - GL_COLOR_ATTACHMENT0].texture = texture;
|
||||
bound_framebuffer->attachment[attachment - GL_COLOR_ATTACHMENT0].level = level;
|
||||
if (bound_framebuffer && bound_framebuffer->attachment) {
|
||||
bound_framebuffer->attachment[attachment - GL_COLOR_ATTACHMENT0].textarget = textarget;
|
||||
bound_framebuffer->attachment[attachment - GL_COLOR_ATTACHMENT0].texture = texture;
|
||||
bound_framebuffer->attachment[attachment - GL_COLOR_ATTACHMENT0].level = level;
|
||||
}
|
||||
|
||||
LOAD_GLES(glFramebufferTexture2D, void, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
|
||||
gles_glFramebufferTexture2D(target, attachment, textarget, texture, level);
|
||||
|
@ -15,7 +15,7 @@ struct attachment_t {
|
||||
|
||||
struct framebuffer_t {
|
||||
GLenum target;
|
||||
struct attachment_t attachment[];
|
||||
struct attachment_t* attachment;
|
||||
};
|
||||
|
||||
extern struct framebuffer_t* bound_framebuffer;
|
||||
|
Loading…
x
Reference in New Issue
Block a user