From 6a014ab92d970b337351c42d70e4dfd433e94e54 Mon Sep 17 00:00:00 2001 From: tpu Date: Sat, 30 Mar 2013 15:34:13 +0800 Subject: [PATCH] add condition define for USING_GLES2 --- gfx_es2/fbo.cpp | 15 ++++++++++++++- gfx_es2/gl_state.cpp | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gfx_es2/fbo.cpp b/gfx_es2/fbo.cpp index a4f1624625..27ecaa92b1 100644 --- a/gfx_es2/fbo.cpp +++ b/gfx_es2/fbo.cpp @@ -38,6 +38,7 @@ struct FBO { // On PC, we always use GL_DEPTH24_STENCIL8. // On Android, we try to use what's available. +#ifndef USING_GLES2 FBO *fbo_ext_create(int width, int height, int num_color_textures, bool z_stencil, FBOColorDepth colorDepth) { FBO *fbo = new FBO(); fbo->width = width; @@ -110,11 +111,15 @@ FBO *fbo_ext_create(int width, int height, int num_color_textures, bool z_stenci glBindTexture(GL_TEXTURE_2D, 0); return fbo; } +#endif FBO *fbo_create(int width, int height, int num_color_textures, bool z_stencil, FBOColorDepth colorDepth) { CheckGLExtensions(); - if(gl_extensions.FBO_ARB==false) + +#ifndef USING_GLES2 + if(!gl_extensions.FBO_ARB) return fbo_ext_create(width, height, num_color_textures, z_stencil, colorDepth); +#endif FBO *fbo = new FBO(); fbo->width = width; @@ -231,7 +236,9 @@ void fbo_unbind() { if(gl_extensions.FBO_ARB){ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); }else{ +#ifndef USING_GLES2 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); +#endif } #ifdef IOS bindDefaultFBO(); @@ -242,7 +249,9 @@ void fbo_bind_as_render_target(FBO *fbo) { if(gl_extensions.FBO_ARB){ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo->handle); }else{ +#ifndef USING_GLES2 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo->handle); +#endif } } @@ -250,7 +259,9 @@ void fbo_bind_for_read(FBO *fbo) { if(gl_extensions.FBO_ARB){ glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo->handle); }else{ +#ifndef USING_GLES2 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo->handle); +#endif } } @@ -267,12 +278,14 @@ void fbo_destroy(FBO *fbo) { glDeleteFramebuffers(1, &fbo->handle); glDeleteRenderbuffers(1, &fbo->z_stencil_buffer); }else{ +#ifndef USING_GLES2 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo->handle); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER_EXT, 0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glDeleteFramebuffersEXT(1, &fbo->handle); glDeleteRenderbuffersEXT(1, &fbo->z_stencil_buffer); +#endif } glDeleteTextures(1, &fbo->color_texture); diff --git a/gfx_es2/gl_state.cpp b/gfx_es2/gl_state.cpp index 77f33319c7..ee84087ed0 100644 --- a/gfx_es2/gl_state.cpp +++ b/gfx_es2/gl_state.cpp @@ -59,6 +59,11 @@ void CheckGLExtensions() { gl_extensions.OES_depth24 = strstr(extString, "GL_OES_depth24") != 0; gl_extensions.OES_depth_texture = strstr(extString, "GL_OES_depth_texture") != 0; gl_extensions.EXT_discard_framebuffer = strstr(extString, "GL_EXT_discard_framebuffer") != 0; +#ifdef USING_GLES2 + gl_extensions.FBO_ARB = true; + gl_extensions.FBO_EXT = false; +#else gl_extensions.FBO_ARB = strstr(extString, "GL_ARB_framebuffer_object") != 0; gl_extensions.FBO_EXT = strstr(extString, "GL_EXT_framebuffer_object") != 0; +#endif }