Check for EXT_discard_framebuffer

This commit is contained in:
Henrik Rydgard 2013-01-10 23:48:28 +01:00
parent 135ae4faf5
commit 7ceecd22b4
3 changed files with 31 additions and 28 deletions

View File

@ -3,6 +3,7 @@
#include "base/logging.h"
#include "gfx_es2/fbo.h"
#include "gfx/gl_common.h"
#include "gfx_es2/gl_state.h"
#if defined(USING_GLES2)
#define GL_READ_FRAMEBUFFER GL_FRAMEBUFFER
@ -16,33 +17,6 @@
#endif
#endif
// TODO: Breakout this GL extension checker in its own file.
struct GLExtensions {
bool OES_depth24;
bool OES_packed_depth_stencil;
bool OES_depth_texture;
};
GLExtensions gl_extensions;
void CheckExtensions() {
static bool done = false;
if (done)
return;
done = true;
memset(&gl_extensions, 0, sizeof(gl_extensions));
const char *extString = (const char *)glGetString(GL_EXTENSIONS);
gl_extensions.OES_packed_depth_stencil = strstr(extString, "GL_OES_packed_depth_stencil");
gl_extensions.OES_depth24 = strstr(extString, "GL_OES_depth24");
gl_extensions.OES_depth_texture = strstr(extString, "GL_OES_depth_texture");
}
struct FBO {
GLuint handle;
GLuint color_texture;
@ -59,7 +33,7 @@ struct FBO {
// On Android, we try to use what's available.
FBO *fbo_create(int width, int height, int num_color_textures, bool z_stencil) {
CheckExtensions();
CheckGLExtensions();
FBO *fbo = new FBO();
fbo->width = width;

View File

@ -1,6 +1,7 @@
#include "gl_state.h"
OpenGLState glstate;
GLExtensions gl_extensions;
void OpenGLState::Initialize() {
if(initialized) return;
@ -26,3 +27,20 @@ void OpenGLState::Restore() {
depthRange.restore();
depthFunc.restore();
}
void CheckGLExtensions() {
static bool done = false;
if (done)
return;
done = true;
memset(&gl_extensions, 0, sizeof(gl_extensions));
const char *extString = (const char *)glGetString(GL_EXTENSIONS);
gl_extensions.OES_packed_depth_stencil = strstr(extString, "GL_OES_packed_depth_stencil") != 0;
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;
}

View File

@ -158,3 +158,14 @@ public:
#undef STATE2
extern OpenGLState glstate;
struct GLExtensions {
bool OES_depth24;
bool OES_packed_depth_stencil;
bool OES_depth_texture;
bool EXT_discard_framebuffer;
};
extern GLExtensions gl_extensions;
void CheckGLExtensions();