find gl symbols runtime - some gl's support the feature but havent

standardised symbols! (bad gl! bad!)



SVN revision: 43857
This commit is contained in:
Carsten Haitzler 2009-11-21 10:51:51 +00:00
parent 1cf4a25eed
commit a6dea7be9b
6 changed files with 63 additions and 11 deletions

View File

@ -48,7 +48,7 @@ evas_gl_font.c
#evas_gl_polygon.c \
#
libevas_engine_gl_common_la_LIBADD = @EINA_LIBS@ @evas_engine_gl_common_libs@
libevas_engine_gl_common_la_LIBADD = @EINA_LIBS@ @evas_engine_gl_common_libs@ @dlopen_libs@
endif
EXTRA_DIST = \

View File

@ -21,17 +21,18 @@
#ifdef BUILD_ENGINE_GL_QUARTZ
# include <OpenGL/gl.h>
# include <OpenGL/glext.h>
#else
# if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
# if defined(GLES_VARIETY_S3C6410)
# include <GLES2/gl2.h>
//// this changed. this was the old style. above the new style
//# include <GLES/gl.h>
# elif defined(GLES_VARIETY_SGX)
# include <GLES2/gl2.h>
# include <GLES2/gl2ext.h>
# endif
# else
# include <GL/gl.h>
# include <GL/glext.h>
# endif
#endif
@ -293,6 +294,11 @@ void evas_gl_font_texture_free(Evas_GL_Texture *ft);
void evas_gl_font_texture_draw(Evas_GL_Context *gc, void *surface, RGBA_Draw_Context *dc, RGBA_Font_Glyph *fg, int x, int y);
void (*glsym_glGenFramebuffers) (GLsizei a, GLuint *b);
void (*glsym_glBindFramebuffer) (GLenum a, GLuint b);
void (*glsym_glFramebufferTexture2D) (GLenum a, GLenum b, GLenum c, GLuint d, GLint e);
void (*glsym_glDeleteFramebuffers) (GLsizei a, const GLuint *b);

View File

@ -1,5 +1,44 @@
#include "evas_gl_private.h"
static int sym_done = 0;
void (*glsym_glGenFramebuffers) (GLsizei a, GLuint *b) = NULL;
void (*glsym_glBindFramebuffer) (GLenum a, GLuint b) = NULL;
void (*glsym_glFramebufferTexture2D) (GLenum a, GLenum b, GLenum c, GLuint d, GLint e) = NULL;
void (*glsym_glDeleteFramebuffers) (GLsizei a, const GLuint *b) = NULL;
static void
sym_missing(void)
{
printf("EVAS ERROR - GL symbols missing!\n");
}
static void
gl_symbols(void)
{
if (sym_done) return;
sym_done = 1;
#define FINDSYM(dst, sym) if (!dst) dst = dlsym(RTLD_DEFAULT, sym)
#define FALLBAK(dst) if (!dst) dst = (void *)sym_missing;
FINDSYM(glsym_glGenFramebuffers, "glGenFramebuffers");
FINDSYM(glsym_glGenFramebuffers, "glGenFramebuffersEXT");
FALLBAK(glsym_glGenFramebuffers);
FINDSYM(glsym_glBindFramebuffer, "glBindFramebuffer");
FINDSYM(glsym_glBindFramebuffer, "glBindFramebufferEXT");
FALLBAK(glsym_glBindFramebuffer);
FINDSYM(glsym_glFramebufferTexture2D, "glFramebufferTexture2D");
FINDSYM(glsym_glFramebufferTexture2D, "glFramebufferTexture2DEXT");
FALLBAK(glsym_glFramebufferTexture2D);
FINDSYM(glsym_glDeleteFramebuffers, "glDeleteFramebuffers");
FINDSYM(glsym_glDeleteFramebuffers, "glDeleteFramebuffersEXT");
FALLBAK(glsym_glDeleteFramebuffers);
}
static void shader_array_flush(Evas_GL_Context *gc);
static Evas_GL_Context *_evas_gl_common_context = NULL;
@ -118,6 +157,7 @@ evas_gl_common_context_new(void)
{
Evas_GL_Context *gc;
gl_symbols();
#if 1
if (_evas_gl_common_context)
{
@ -315,9 +355,9 @@ evas_gl_common_context_target_surface_set(Evas_GL_Context *gc,
# endif
#endif
if (gc->shader.surface == gc->def_surface)
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glsym_glBindFramebuffer(GL_FRAMEBUFFER, 0);
else
glBindFramebuffer(GL_FRAMEBUFFER, surface->tex->pt->fb);
glsym_glBindFramebuffer(GL_FRAMEBUFFER, surface->tex->pt->fb);
_evas_gl_common_viewport_set(gc);
}

View File

@ -2,4 +2,6 @@
#define _EVAS_GL_PRIVATE_H
#include "evas_gl_common.h"
#include <dlfcn.h> /* dlopen,dlclose,etc */
#endif

View File

@ -290,10 +290,12 @@ _pool_tex_render_new(Evas_GL_Context *gc, int w, int h, int intformat, int forma
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
_tex_2d(pt->intformat, w, h, pt->format, pt->dataformat);
glGenFramebuffers(1, &(pt->fb));
glBindFramebuffer(GL_FRAMEBUFFER, pt->fb);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pt->texture, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glsym_glGenFramebuffers(1, &(pt->fb));
glsym_glBindFramebuffer(GL_FRAMEBUFFER, pt->fb);
glsym_glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pt->texture, 0);
glsym_glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindTexture(GL_TEXTURE_2D, gc->shader.cur_tex);
return pt;
}
@ -389,7 +391,7 @@ pt_unref(Evas_GL_Texture_Pool *pt)
pt->gc->shared->tex.atlas [pt->slot][pt->fslot] =
eina_list_remove(pt->gc->shared->tex.atlas[pt->slot][pt->fslot], pt);
glDeleteTextures(1, &(pt->texture));
if (pt->fb) glDeleteFramebuffers(1, &(pt->fb));
if (pt->fb) glsym_glDeleteFramebuffers(1, &(pt->fb));
free(pt);
}

View File

@ -24,6 +24,7 @@
# define SUPPORT_X11 1
# include <EGL/egl.h>
# include <GLES2/gl2.h>
# include <GLES2/gl2ext.h>
# include <X11/Xlib.h>
# include <X11/Xatom.h>
# include <X11/Xutil.h>
@ -36,6 +37,7 @@
# include <X11/Xutil.h>
# include <X11/extensions/Xrender.h>
# include <GL/gl.h>
# include <GL/glext.h>
# include <GL/glx.h>
# endif
#endif