aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/modules/engines/software_generic
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-23 23:30:42 +1000
committerDavid Walter Seikel2012-01-23 23:30:42 +1000
commit825a3d837a33f226c879cd02ad15c3fba57e8b2c (patch)
tree75f57bd9c4253508d338dc79ba8e57a7abc42255 /libraries/evas/src/modules/engines/software_generic
parentAdd ability to disable the test harness, or the Lua compile test. (diff)
downloadSledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.zip
SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.gz
SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.bz2
SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.xz
Update the EFL to what I'm actually using, coz I'm using some stuff not yet released.
Diffstat (limited to 'libraries/evas/src/modules/engines/software_generic')
-rw-r--r--libraries/evas/src/modules/engines/software_generic/Makefile.in8
-rw-r--r--libraries/evas/src/modules/engines/software_generic/evas_engine.c1612
2 files changed, 1608 insertions, 12 deletions
diff --git a/libraries/evas/src/modules/engines/software_generic/Makefile.in b/libraries/evas/src/modules/engines/software_generic/Makefile.in
index 6d75f23..4f66536 100644
--- a/libraries/evas/src/modules/engines/software_generic/Makefile.in
+++ b/libraries/evas/src/modules/engines/software_generic/Makefile.in
@@ -236,8 +236,6 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
236PIXMAN_CFLAGS = @PIXMAN_CFLAGS@ 236PIXMAN_CFLAGS = @PIXMAN_CFLAGS@
237PIXMAN_LIBS = @PIXMAN_LIBS@ 237PIXMAN_LIBS = @PIXMAN_LIBS@
238PKG_CONFIG = @PKG_CONFIG@ 238PKG_CONFIG = @PKG_CONFIG@
239PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
240PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
241PNG_CFLAGS = @PNG_CFLAGS@ 239PNG_CFLAGS = @PNG_CFLAGS@
242PNG_LIBS = @PNG_LIBS@ 240PNG_LIBS = @PNG_LIBS@
243RANLIB = @RANLIB@ 241RANLIB = @RANLIB@
@@ -254,6 +252,8 @@ VALGRIND_CFLAGS = @VALGRIND_CFLAGS@
254VALGRIND_LIBS = @VALGRIND_LIBS@ 252VALGRIND_LIBS = @VALGRIND_LIBS@
255VERSION = @VERSION@ 253VERSION = @VERSION@
256VMAJ = @VMAJ@ 254VMAJ = @VMAJ@
255WAYLAND_EGL_CFLAGS = @WAYLAND_EGL_CFLAGS@
256WAYLAND_EGL_LIBS = @WAYLAND_EGL_LIBS@
257WIN32_CFLAGS = @WIN32_CFLAGS@ 257WIN32_CFLAGS = @WIN32_CFLAGS@
258WIN32_CPPFLAGS = @WIN32_CPPFLAGS@ 258WIN32_CPPFLAGS = @WIN32_CPPFLAGS@
259XCB_CFLAGS = @XCB_CFLAGS@ 259XCB_CFLAGS = @XCB_CFLAGS@
@@ -335,6 +335,10 @@ evas_engine_software_xcb_cflags = @evas_engine_software_xcb_cflags@
335evas_engine_software_xcb_libs = @evas_engine_software_xcb_libs@ 335evas_engine_software_xcb_libs = @evas_engine_software_xcb_libs@
336evas_engine_software_xlib_cflags = @evas_engine_software_xlib_cflags@ 336evas_engine_software_xlib_cflags = @evas_engine_software_xlib_cflags@
337evas_engine_software_xlib_libs = @evas_engine_software_xlib_libs@ 337evas_engine_software_xlib_libs = @evas_engine_software_xlib_libs@
338evas_engine_wayland_egl_cflags = @evas_engine_wayland_egl_cflags@
339evas_engine_wayland_egl_libs = @evas_engine_wayland_egl_libs@
340evas_engine_wayland_shm_cflags = @evas_engine_wayland_shm_cflags@
341evas_engine_wayland_shm_libs = @evas_engine_wayland_shm_libs@
338evas_image_loader_bmp_cflags = @evas_image_loader_bmp_cflags@ 342evas_image_loader_bmp_cflags = @evas_image_loader_bmp_cflags@
339evas_image_loader_bmp_libs = @evas_image_loader_bmp_libs@ 343evas_image_loader_bmp_libs = @evas_image_loader_bmp_libs@
340evas_image_loader_edb_cflags = @evas_image_loader_edb_cflags@ 344evas_image_loader_edb_cflags = @evas_image_loader_edb_cflags@
diff --git a/libraries/evas/src/modules/engines/software_generic/evas_engine.c b/libraries/evas/src/modules/engines/software_generic/evas_engine.c
index b2c53c5..48944dd 100644
--- a/libraries/evas/src/modules/engines/software_generic/evas_engine.c
+++ b/libraries/evas/src/modules/engines/software_generic/evas_engine.c
@@ -1,6 +1,275 @@
1#include "evas_common.h" /* Also includes international specific stuff */ 1#include "evas_common.h" /* Also includes international specific stuff */
2#include "evas_private.h" 2#include "evas_private.h"
3 3
4#ifdef HAVE_DLSYM
5# include <dlfcn.h> /* dlopen,dlclose,etc */
6
7# define EVAS_GL 1
8# define EVAS_GL_NO_GL_H_CHECK 1
9# include "Evas_GL.h"
10
11#else
12# warning software_generic will not be able to have Evas_GL API.
13#endif
14
15#ifdef EVAS_GL
16//----------------------------------//
17// OSMesa...
18
19#define OSMESA_MAJOR_VERSION 6
20#define OSMESA_MINOR_VERSION 5
21#define OSMESA_PATCH_VERSION 0
22
23/*
24 * Values for the format parameter of OSMesaCreateContext()
25 * New in version 2.0.
26 */
27#define OSMESA_COLOR_INDEX GL_COLOR_INDEX
28#define OSMESA_RGBA GL_RGBA
29#define OSMESA_BGRA 0x1
30#define OSMESA_ARGB 0x2
31#define OSMESA_RGB GL_RGB
32#define OSMESA_BGR 0x4
33#define OSMESA_RGB_565 0x5
34
35
36/*
37 * OSMesaPixelStore() parameters:
38 * New in version 2.0.
39 */
40#define OSMESA_ROW_LENGTH 0x10
41#define OSMESA_Y_UP 0x11
42
43
44/*
45 * Accepted by OSMesaGetIntegerv:
46 */
47#define OSMESA_WIDTH 0x20
48#define OSMESA_HEIGHT 0x21
49#define OSMESA_FORMAT 0x22
50#define OSMESA_TYPE 0x23
51#define OSMESA_MAX_WIDTH 0x24 /* new in 4.0 */
52#define OSMESA_MAX_HEIGHT 0x25 /* new in 4.0 */
53
54
55typedef void (*OSMESAproc)();
56typedef struct osmesa_context *OSMesaContext;
57#endif
58
59typedef struct _Render_Engine_GL_Surface Render_Engine_GL_Surface;
60typedef struct _Render_Engine_GL_Context Render_Engine_GL_Context;
61
62struct _Render_Engine_GL_Surface
63{
64 int initialized;
65 int w, h;
66
67#ifdef EVAS_GL
68 GLenum internal_fmt;
69#endif
70 int internal_cpp; // Component per pixel. ie. RGB = 3
71
72 int depth_bits;
73 int stencil_bits;
74
75 // Data
76 void *buffer;
77
78 Render_Engine_GL_Context *current_ctx;
79};
80
81#ifdef EVAS_GL
82struct _Render_Engine_GL_Context
83{
84 int initialized;
85
86 OSMesaContext context;
87
88 Render_Engine_GL_Context *share_ctx;
89
90 Render_Engine_GL_Surface *current_sfc;
91};
92
93//------------------------------------------------------//
94typedef void (*_eng_fn) (void );
95typedef _eng_fn (*glsym_func_eng_fn) ();
96typedef void (*glsym_func_void) ();
97typedef unsigned int (*glsym_func_uint) ();
98typedef int (*glsym_func_int) ();
99typedef unsigned char (*glsym_func_uchar) ();
100typedef unsigned char *(*glsym_func_uchar_ptr) ();
101typedef const unsigned char *(*glsym_func_const_uchar_ptr) ();
102typedef char const *(*glsym_func_char_const_ptr) ();
103typedef GLboolean (*glsym_func_bool) ();
104typedef OSMesaContext (*glsym_func_osm_ctx) ();
105//------------------------------------------------------//
106
107/* Function table for GL APIs */
108static Evas_GL_API gl_funcs;
109static void *gl_lib_handle;
110static int gl_lib_is_gles = 0;
111static Evas_GL_API gl_funcs;
112
113//------------------------------------------------------//
114// OSMesa APIS...
115static OSMesaContext (*_sym_OSMesaCreateContextExt) (GLenum format, GLint depthBits, GLint stencilBits, GLint accumBits, OSMesaContext sharelist) = NULL;
116static void (*_sym_OSMesaDestroyContext) (OSMesaContext ctx) = NULL;
117static GLboolean (*_sym_OSMesaMakeCurrent) (OSMesaContext ctx, void *buffer, GLenum type, GLsizei width, GLsizei height) = NULL;
118static void (*_sym_OSMesaPixelStore) (GLint pname, GLint value) = NULL;
119static OSMESAproc (*_sym_OSMesaGetProcAddress) (const char *funcName);
120
121
122//------------------------------------------------------//
123// GLES 2.0 APIs...
124static void (*_sym_glActiveTexture) (GLenum texture) = NULL;
125static void (*_sym_glAttachShader) (GLuint program, GLuint shader) = NULL;
126static void (*_sym_glBindAttribLocation) (GLuint program, GLuint index, const char* name) = NULL;
127static void (*_sym_glBindBuffer) (GLenum target, GLuint buffer) = NULL;
128static void (*_sym_glBindFramebuffer) (GLenum target, GLuint framebuffer) = NULL;
129static void (*_sym_glBindRenderbuffer) (GLenum target, GLuint renderbuffer) = NULL;
130static void (*_sym_glBindTexture) (GLenum target, GLuint texture) = NULL;
131static void (*_sym_glBlendColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) = NULL;
132static void (*_sym_glBlendEquation) (GLenum mode) = NULL;
133static void (*_sym_glBlendEquationSeparate) (GLenum modeRGB, GLenum modeAlpha) = NULL;
134static void (*_sym_glBlendFunc) (GLenum sfactor, GLenum dfactor) = NULL;
135static void (*_sym_glBlendFuncSeparate) (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) = NULL;
136static void (*_sym_glBufferData) (GLenum target, GLsizeiptr size, const void* data, GLenum usage) = NULL;
137static void (*_sym_glBufferSubData) (GLenum target, GLintptr offset, GLsizeiptr size, const void* data) = NULL;
138static GLenum (*_sym_glCheckFramebufferStatus) (GLenum target) = NULL;
139static void (*_sym_glClear) (GLbitfield mask) = NULL;
140static void (*_sym_glClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) = NULL;
141static void (*_sym_glClearDepthf) (GLclampf depth) = NULL;
142static void (*_sym_glClearStencil) (GLint s) = NULL;
143static void (*_sym_glColorMask) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) = NULL;
144static void (*_sym_glCompileShader) (GLuint shader) = NULL;
145static void (*_sym_glCompressedTexImage2D) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) = NULL;
146static void (*_sym_glCompressedTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) = NULL;
147static void (*_sym_glCopyTexImage2D) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) = NULL;
148static void (*_sym_glCopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
149static GLuint (*_sym_glCreateProgram) (void) = NULL;
150static GLuint (*_sym_glCreateShader) (GLenum type) = NULL;
151static void (*_sym_glCullFace) (GLenum mode) = NULL;
152static void (*_sym_glDeleteBuffers) (GLsizei n, const GLuint* buffers) = NULL;
153static void (*_sym_glDeleteFramebuffers) (GLsizei n, const GLuint* framebuffers) = NULL;
154static void (*_sym_glDeleteProgram) (GLuint program) = NULL;
155static void (*_sym_glDeleteRenderbuffers) (GLsizei n, const GLuint* renderbuffers) = NULL;
156static void (*_sym_glDeleteShader) (GLuint shader) = NULL;
157static void (*_sym_glDeleteTextures) (GLsizei n, const GLuint* textures) = NULL;
158static void (*_sym_glDepthFunc) (GLenum func) = NULL;
159static void (*_sym_glDepthMask) (GLboolean flag) = NULL;
160static void (*_sym_glDepthRangef) (GLclampf zNear, GLclampf zFar) = NULL;
161static void (*_sym_glDetachShader) (GLuint program, GLuint shader) = NULL;
162static void (*_sym_glDisable) (GLenum cap) = NULL;
163static void (*_sym_glDisableVertexAttribArray) (GLuint index) = NULL;
164static void (*_sym_glDrawArrays) (GLenum mode, GLint first, GLsizei count) = NULL;
165static void (*_sym_glDrawElements) (GLenum mode, GLsizei count, GLenum type, const void* indices) = NULL;
166static void (*_sym_glEnable) (GLenum cap) = NULL;
167static void (*_sym_glEnableVertexAttribArray) (GLuint index) = NULL;
168static void (*_sym_glFinish) (void) = NULL;
169static void (*_sym_glFlush) (void) = NULL;
170static void (*_sym_glFramebufferRenderbuffer) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) = NULL;
171static void (*_sym_glFramebufferTexture2D) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL;
172static void (*_sym_glFrontFace) (GLenum mode) = NULL;
173static void (*_sym_glGenBuffers) (GLsizei n, GLuint* buffers) = NULL;
174static void (*_sym_glGenerateMipmap) (GLenum target) = NULL;
175static void (*_sym_glGenFramebuffers) (GLsizei n, GLuint* framebuffers) = NULL;
176static void (*_sym_glGenRenderbuffers) (GLsizei n, GLuint* renderbuffers) = NULL;
177static void (*_sym_glGenTextures) (GLsizei n, GLuint* textures) = NULL;
178static void (*_sym_glGetActiveAttrib) (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) = NULL;
179static void (*_sym_glGetActiveUniform) (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) = NULL;
180static void (*_sym_glGetAttachedShaders) (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) = NULL;
181static int (*_sym_glGetAttribLocation) (GLuint program, const char* name) = NULL;
182static void (*_sym_glGetBooleanv) (GLenum pname, GLboolean* params) = NULL;
183static void (*_sym_glGetBufferParameteriv) (GLenum target, GLenum pname, GLint* params) = NULL;
184static GLenum (*_sym_glGetError) (void) = NULL;
185static void (*_sym_glGetFloatv) (GLenum pname, GLfloat* params) = NULL;
186static void (*_sym_glGetFramebufferAttachmentParameteriv) (GLenum target, GLenum attachment, GLenum pname, GLint* params) = NULL;
187static void (*_sym_glGetIntegerv) (GLenum pname, GLint* params) = NULL;
188static void (*_sym_glGetProgramiv) (GLuint program, GLenum pname, GLint* params) = NULL;
189static void (*_sym_glGetProgramInfoLog) (GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) = NULL;
190static void (*_sym_glGetRenderbufferParameteriv) (GLenum target, GLenum pname, GLint* params) = NULL;
191static void (*_sym_glGetShaderiv) (GLuint shader, GLenum pname, GLint* params) = NULL;
192static void (*_sym_glGetShaderInfoLog) (GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) = NULL;
193static void (*_sym_glGetShaderPrecisionFormat) (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) = NULL;
194static void (*_sym_glGetShaderSource) (GLuint shader, GLsizei bufsize, GLsizei* length, char* source) = NULL;
195static const GLubyte *(*_sym_glGetString) (GLenum name) = NULL;
196static void (*_sym_glGetTexParameterfv) (GLenum target, GLenum pname, GLfloat* params) = NULL;
197static void (*_sym_glGetTexParameteriv) (GLenum target, GLenum pname, GLint* params) = NULL;
198static void (*_sym_glGetUniformfv) (GLuint program, GLint location, GLfloat* params) = NULL;
199static void (*_sym_glGetUniformiv) (GLuint program, GLint location, GLint* params) = NULL;
200static int (*_sym_glGetUniformLocation) (GLuint program, const char* name) = NULL;
201static void (*_sym_glGetVertexAttribfv) (GLuint index, GLenum pname, GLfloat* params) = NULL;
202static void (*_sym_glGetVertexAttribiv) (GLuint index, GLenum pname, GLint* params) = NULL;
203static void (*_sym_glGetVertexAttribPointerv) (GLuint index, GLenum pname, void** pointer) = NULL;
204static void (*_sym_glHint) (GLenum target, GLenum mode) = NULL;
205static GLboolean (*_sym_glIsBuffer) (GLuint buffer) = NULL;
206static GLboolean (*_sym_glIsEnabled) (GLenum cap) = NULL;
207static GLboolean (*_sym_glIsFramebuffer) (GLuint framebuffer) = NULL;
208static GLboolean (*_sym_glIsProgram) (GLuint program) = NULL;
209static GLboolean (*_sym_glIsRenderbuffer) (GLuint renderbuffer) = NULL;
210static GLboolean (*_sym_glIsShader) (GLuint shader) = NULL;
211static GLboolean (*_sym_glIsTexture) (GLuint texture) = NULL;
212static void (*_sym_glLineWidth) (GLfloat width) = NULL;
213static void (*_sym_glLinkProgram) (GLuint program) = NULL;
214static void (*_sym_glPixelStorei) (GLenum pname, GLint param) = NULL;
215static void (*_sym_glPolygonOffset) (GLfloat factor, GLfloat units) = NULL;
216static void (*_sym_glReadPixels) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) = NULL;
217static void (*_sym_glReleaseShaderCompiler) (void) = NULL;
218static void (*_sym_glRenderbufferStorage) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height) = NULL;
219static void (*_sym_glSampleCoverage) (GLclampf value, GLboolean invert) = NULL;
220static void (*_sym_glScissor) (GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
221static void (*_sym_glShaderBinary) (GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) = NULL;
222static void (*_sym_glShaderSource) (GLuint shader, GLsizei count, const char** string, const GLint* length) = NULL;
223static void (*_sym_glStencilFunc) (GLenum func, GLint ref, GLuint mask) = NULL;
224static void (*_sym_glStencilFuncSeparate) (GLenum face, GLenum func, GLint ref, GLuint mask) = NULL;
225static void (*_sym_glStencilMask) (GLuint mask) = NULL;
226static void (*_sym_glStencilMaskSeparate) (GLenum face, GLuint mask) = NULL;
227static void (*_sym_glStencilOp) (GLenum fail, GLenum zfail, GLenum zpass) = NULL;
228static void (*_sym_glStencilOpSeparate) (GLenum face, GLenum fail, GLenum zfail, GLenum zpass) = NULL;
229static void (*_sym_glTexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) = NULL;
230static void (*_sym_glTexParameterf) (GLenum target, GLenum pname, GLfloat param) = NULL;
231static void (*_sym_glTexParameterfv) (GLenum target, GLenum pname, const GLfloat* params) = NULL;
232static void (*_sym_glTexParameteri) (GLenum target, GLenum pname, GLint param) = NULL;
233static void (*_sym_glTexParameteriv) (GLenum target, GLenum pname, const GLint* params) = NULL;
234static void (*_sym_glTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) = NULL;
235static void (*_sym_glUniform1f) (GLint location, GLfloat x) = NULL;
236static void (*_sym_glUniform1fv) (GLint location, GLsizei count, const GLfloat* v) = NULL;
237static void (*_sym_glUniform1i) (GLint location, GLint x) = NULL;
238static void (*_sym_glUniform1iv) (GLint location, GLsizei count, const GLint* v) = NULL;
239static void (*_sym_glUniform2f) (GLint location, GLfloat x, GLfloat y) = NULL;
240static void (*_sym_glUniform2fv) (GLint location, GLsizei count, const GLfloat* v) = NULL;
241static void (*_sym_glUniform2i) (GLint location, GLint x, GLint y) = NULL;
242static void (*_sym_glUniform2iv) (GLint location, GLsizei count, const GLint* v) = NULL;
243static void (*_sym_glUniform3f) (GLint location, GLfloat x, GLfloat y, GLfloat z) = NULL;
244static void (*_sym_glUniform3fv) (GLint location, GLsizei count, const GLfloat* v) = NULL;
245static void (*_sym_glUniform3i) (GLint location, GLint x, GLint y, GLint z) = NULL;
246static void (*_sym_glUniform3iv) (GLint location, GLsizei count, const GLint* v) = NULL;
247static void (*_sym_glUniform4f) (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL;
248static void (*_sym_glUniform4fv) (GLint location, GLsizei count, const GLfloat* v) = NULL;
249static void (*_sym_glUniform4i) (GLint location, GLint x, GLint y, GLint z, GLint w) = NULL;
250static void (*_sym_glUniform4iv) (GLint location, GLsizei count, const GLint* v) = NULL;
251static void (*_sym_glUniformMatrix2fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
252static void (*_sym_glUniformMatrix3fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
253static void (*_sym_glUniformMatrix4fv) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) = NULL;
254static void (*_sym_glUseProgram) (GLuint program) = NULL;
255static void (*_sym_glValidateProgram) (GLuint program) = NULL;
256static void (*_sym_glVertexAttrib1f) (GLuint indx, GLfloat x) = NULL;
257static void (*_sym_glVertexAttrib1fv) (GLuint indx, const GLfloat* values) = NULL;
258static void (*_sym_glVertexAttrib2f) (GLuint indx, GLfloat x, GLfloat y) = NULL;
259static void (*_sym_glVertexAttrib2fv) (GLuint indx, const GLfloat* values) = NULL;
260static void (*_sym_glVertexAttrib3f) (GLuint indx, GLfloat x, GLfloat y, GLfloat z) = NULL;
261static void (*_sym_glVertexAttrib3fv) (GLuint indx, const GLfloat* values) = NULL;
262static void (*_sym_glVertexAttrib4f) (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL;
263static void (*_sym_glVertexAttrib4fv) (GLuint indx, const GLfloat* values) = NULL;
264static void (*_sym_glVertexAttribPointer) (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) = NULL;
265static void (*_sym_glViewport) (GLint x, GLint y, GLsizei width, GLsizei height) = NULL;
266
267// GLES Extensions...
268/* static void (*_sym_glGetProgramBinary) (GLuint a, GLsizei b, GLsizei* c, GLenum* d, void* e) = NULL; */
269/* static void (*_sym_glProgramBinary) (GLuint a, GLenum b, const void* c, GLint d) = NULL; */
270/* static void (*_sym_glProgramParameteri) (GLuint a, GLuint b, GLint d) = NULL; */
271#endif
272
4/* 273/*
5 ***** 274 *****
6 ** 275 **
@@ -258,6 +527,15 @@ eng_image_colorspace_get(void *data __UNUSED__, void *image)
258 return im->space; 527 return im->space;
259} 528}
260 529
530static Eina_Bool
531eng_image_can_region_get(void *data __UNUSED__, void *image)
532{
533 Image_Entry *im;
534 if (!image) return EINA_FALSE;
535 im = image;
536 return ((Evas_Image_Load_Func*) im->info.loader)->do_region;
537}
538
261static void 539static void
262eng_image_mask_create(void *data __UNUSED__, void *image) 540eng_image_mask_create(void *data __UNUSED__, void *image)
263{ 541{
@@ -349,7 +627,37 @@ eng_image_colorspace_set(void *data __UNUSED__, void *image, int cspace)
349static void * 627static void *
350eng_image_native_set(void *data __UNUSED__, void *image, void *native __UNUSED__) 628eng_image_native_set(void *data __UNUSED__, void *image, void *native __UNUSED__)
351{ 629{
352 return image; 630 //return image;
631 Evas_Native_Surface *ns = native;
632 Image_Entry *im = image, *im2 = NULL;
633
634 if (!im)
635 {
636 if ((!ns) && (ns->data.x11.visual))
637 {
638 im = evas_cache_image_data(evas_common_image_cache_get(),
639 im->w, im->h,
640 ns->data.x11.visual, 1,
641 EVAS_COLORSPACE_ARGB8888);
642 return im;
643 }
644 else
645 return NULL;
646 }
647
648 if ((!ns) && (!im)) return im;
649
650 if (!ns) return im;
651
652 im2 = evas_cache_image_data(evas_common_image_cache_get(),
653 im->w, im->h,
654 ns->data.x11.visual, 1,
655 EVAS_COLORSPACE_ARGB8888);
656 evas_cache_image_drop(im);
657 im = im2;
658
659 return im;
660
353} 661}
354 662
355static void * 663static void *
@@ -1035,6 +1343,311 @@ eng_image_load_error_get(void *data __UNUSED__, void *image)
1035 return im->cache_entry.load_error; 1343 return im->cache_entry.load_error;
1036} 1344}
1037 1345
1346//------------ Evas GL engine code ---------------//
1347static void *
1348eng_gl_surface_create(void *data __UNUSED__, void *config, int w, int h)
1349{
1350#ifdef EVAS_GL
1351 Render_Engine_GL_Surface *sfc;
1352 Evas_GL_Config *cfg;
1353
1354 sfc = calloc(1, sizeof(Render_Engine_GL_Surface));
1355 if (!sfc) return NULL;
1356
1357 cfg = (Evas_GL_Config *)config;
1358
1359 sfc->initialized = 0;
1360 sfc->w = w;
1361 sfc->h = h;
1362
1363 // Color Format
1364 switch (cfg->color_format)
1365 {
1366
1367 case EVAS_GL_RGB_888:
1368 sfc->internal_fmt = OSMESA_RGB;
1369 sfc->internal_cpp = 3;
1370 break;
1371 case EVAS_GL_RGBA_8888:
1372 sfc->internal_fmt = OSMESA_BGRA;
1373 sfc->internal_cpp = 4;
1374 break;
1375 default:
1376 sfc->internal_fmt = OSMESA_RGBA;
1377 sfc->internal_cpp = 4;
1378 break;
1379 }
1380
1381 // Depth Bits
1382 switch (cfg->depth_bits)
1383 {
1384 case EVAS_GL_DEPTH_BIT_8:
1385 sfc->depth_bits = 8;
1386 break;
1387 case EVAS_GL_DEPTH_BIT_16:
1388 sfc->depth_bits = 16;
1389 break;
1390 case EVAS_GL_DEPTH_BIT_24:
1391 sfc->depth_bits = 24;
1392 break;
1393 case EVAS_GL_DEPTH_BIT_32:
1394 sfc->depth_bits = 32;
1395 break;
1396 case EVAS_GL_DEPTH_NONE:
1397 default:
1398 sfc->depth_bits = 0;
1399 break;
1400 }
1401
1402 // Stencil Bits
1403 switch (cfg->stencil_bits)
1404 {
1405 case EVAS_GL_STENCIL_BIT_1:
1406 sfc->stencil_bits = 1;
1407 break;
1408 case EVAS_GL_STENCIL_BIT_2:
1409 sfc->stencil_bits = 2;
1410 break;
1411 case EVAS_GL_STENCIL_BIT_4:
1412 sfc->stencil_bits = 4;
1413 break;
1414 case EVAS_GL_STENCIL_BIT_8:
1415 sfc->stencil_bits = 8;
1416 break;
1417 case EVAS_GL_STENCIL_BIT_16:
1418 sfc->stencil_bits = 16;
1419 break;
1420 case EVAS_GL_STENCIL_NONE:
1421 default:
1422 sfc->stencil_bits = 0;
1423 break;
1424 }
1425
1426 sfc->buffer = malloc(sizeof(unsigned char)*sfc->internal_cpp*w*h);
1427
1428 if (!sfc->buffer)
1429 {
1430 free(sfc);
1431 return NULL;
1432 }
1433
1434 return sfc;
1435#else
1436 (void) config;
1437 (void) w;
1438 (void) h;
1439 return NULL;
1440#endif
1441}
1442
1443static int
1444eng_gl_surface_destroy(void *data __UNUSED__, void *surface)
1445{
1446#ifdef EVAS_GL
1447 Render_Engine_GL_Surface *sfc;
1448
1449 sfc = (Render_Engine_GL_Surface*)surface;
1450
1451 if (!sfc) return 0;
1452
1453 if (sfc->buffer) free(sfc->buffer);
1454
1455 free(sfc);
1456
1457 surface = NULL;
1458
1459 return 1;
1460#else
1461 (void) surface;
1462 return 1;
1463#endif
1464}
1465
1466static void *
1467eng_gl_context_create(void *data __UNUSED__, void *share_context)
1468{
1469#ifdef EVAS_GL
1470 Render_Engine_GL_Context *ctx;
1471 Render_Engine_GL_Context *share_ctx;
1472
1473 ctx = calloc(1, sizeof(Render_Engine_GL_Context));
1474
1475 if (!ctx) return NULL;
1476
1477 share_ctx = (Render_Engine_GL_Context *)share_context;
1478
1479 ctx->share_ctx = share_ctx;
1480
1481 /*
1482 if (share_ctx)
1483 ctx->context = OSMesaCreateContextExt( OSMESA_RGBA, 8, 0, 0, share_ctx->context );
1484 else
1485 ctx->context = OSMesaCreateContextExt( OSMESA_RGBA, 8, 0, 0, NULL );
1486
1487
1488 if (!ctx->context)
1489 {
1490 ERR("Error creating OSMesa Context.");
1491 free(ctx);
1492 return NULL;
1493 }
1494 */
1495
1496 ctx->initialized = 0;
1497
1498 return ctx;
1499#else
1500 (void) share_context;
1501 return NULL;
1502#endif
1503}
1504
1505static int
1506eng_gl_context_destroy(void *data __UNUSED__, void *context)
1507{
1508#ifdef EVAS_GL
1509 Render_Engine_GL_Context *ctx;
1510
1511 ctx = (Render_Engine_GL_Context*)context;
1512
1513 if (!ctx) return 0;
1514
1515 _sym_OSMesaDestroyContext(ctx->context);
1516
1517 free(ctx);
1518 context = NULL;
1519
1520 return 1;
1521#else
1522 (void) context;
1523 return 0;
1524#endif
1525}
1526
1527static int
1528eng_gl_make_current(void *data __UNUSED__, void *surface, void *context)
1529{
1530#ifdef EVAS_GL
1531 Render_Engine_GL_Surface *sfc;
1532 Render_Engine_GL_Context *ctx;
1533 OSMesaContext share_ctx;
1534 GLboolean ret;
1535
1536 sfc = (Render_Engine_GL_Surface*)surface;
1537 ctx = (Render_Engine_GL_Context*)context;
1538
1539 // Unset surface/context
1540 if ((!sfc) || (!ctx))
1541 {
1542 if (ctx) ctx->current_sfc = NULL;
1543 if (sfc) sfc->current_ctx = NULL;
1544 return 1;
1545 }
1546
1547 // Initialize Context if it hasn't been.
1548 if (!ctx->initialized)
1549 {
1550 if (ctx->share_ctx)
1551 share_ctx = ctx->share_ctx->context;
1552 else
1553 share_ctx = NULL;
1554
1555 ctx->context = _sym_OSMesaCreateContextExt(sfc->internal_fmt,
1556 sfc->depth_bits,
1557 sfc->stencil_bits,
1558 0,
1559 share_ctx);
1560 if (!ctx->context)
1561 {
1562 ERR("Error initializing context.");
1563 return 0;
1564 }
1565
1566 ctx->initialized = 1;
1567 }
1568
1569
1570 // Call MakeCurrent
1571 ret = _sym_OSMesaMakeCurrent(ctx->context, sfc->buffer, GL_UNSIGNED_BYTE,
1572 sfc->w, sfc->h);
1573
1574 if (ret == GL_FALSE)
1575 {
1576 ERR("Error doing MakeCurrent.");
1577 return 0;
1578 }
1579
1580 _sym_OSMesaPixelStore(OSMESA_Y_UP, 0);
1581
1582 // Set the current surface/context
1583 ctx->current_sfc = sfc;
1584 sfc->current_ctx = ctx;
1585
1586 return 1;
1587#else
1588 (void) surface;
1589 (void) context;
1590 return 1;
1591#endif
1592}
1593
1594// FIXME!!! Implement later
1595static void *
1596eng_gl_string_query(void *data __UNUSED__, int name __UNUSED__)
1597{
1598 return NULL;
1599}
1600
1601static void *
1602eng_gl_proc_address_get(void *data __UNUSED__, const char *name)
1603{
1604#ifdef EVAS_GL
1605 if (_sym_OSMesaGetProcAddress) return _sym_OSMesaGetProcAddress(name);
1606 return dlsym(RTLD_DEFAULT, name);
1607#else
1608 (void) name;
1609 return NULL;
1610#endif
1611}
1612
1613static int
1614eng_gl_native_surface_get(void *data __UNUSED__, void *surface, void *native_surface)
1615{
1616#ifdef EVAS_GL
1617 Render_Engine_GL_Surface *sfc;
1618 Evas_Native_Surface *ns;
1619
1620 sfc = (Render_Engine_GL_Surface*)surface;
1621 ns = (Evas_Native_Surface*)native_surface;
1622
1623 if (!sfc) return 0;
1624
1625 ns->type = EVAS_NATIVE_SURFACE_OPENGL;
1626 ns->version = EVAS_NATIVE_SURFACE_VERSION;
1627 ns->data.x11.visual = sfc->buffer;
1628
1629 return 1;
1630#else
1631 (void) surface;
1632 (void) native_surface;
1633 return 1;
1634#endif
1635}
1636
1637
1638static void *
1639eng_gl_api_get(void *data __UNUSED__)
1640{
1641#ifdef EVAS_GL
1642 return &gl_funcs;
1643#else
1644 return NULL;
1645#endif
1646}
1647
1648//------------------------------------------------//
1649
1650
1038/* 1651/*
1039 ***** 1652 *****
1040 ** 1653 **
@@ -1112,6 +1725,7 @@ static Evas_Func func =
1112 eng_image_format_get, 1725 eng_image_format_get,
1113 eng_image_colorspace_set, 1726 eng_image_colorspace_set,
1114 eng_image_colorspace_get, 1727 eng_image_colorspace_get,
1728 eng_image_can_region_get,
1115 eng_image_mask_create, 1729 eng_image_mask_create,
1116 eng_image_native_set, 1730 eng_image_native_set,
1117 eng_image_native_get, 1731 eng_image_native_get,
@@ -1161,15 +1775,15 @@ static Evas_Func func =
1161 eng_image_filtered_save, 1775 eng_image_filtered_save,
1162 eng_image_filtered_free, 1776 eng_image_filtered_free,
1163#endif 1777#endif
1164 NULL, // FIXME: need software mesa for gl rendering <- gl_surface_create 1778 NULL, // need software mesa for gl rendering <- gl_surface_create
1165 NULL, // FIXME: need software mesa for gl rendering <- gl_surface_destroy 1779 NULL, // need software mesa for gl rendering <- gl_surface_destroy
1166 NULL, // FIXME: need software mesa for gl rendering <- gl_context_create 1780 NULL, // need software mesa for gl rendering <- gl_context_create
1167 NULL, // FIXME: need software mesa for gl rendering <- gl_context_destroy 1781 NULL, // need software mesa for gl rendering <- gl_context_destroy
1168 NULL, // FIXME: need software mesa for gl rendering <- gl_make_current 1782 NULL, // need software mesa for gl rendering <- gl_make_current
1169 NULL, // FIXME: need software mesa for gl rendering <- gl_string_query 1783 NULL, // need software mesa for gl rendering <- gl_string_query
1170 NULL, // FIXME: need software mesa for gl rendering <- gl_proc_address_get 1784 NULL, // need software mesa for gl rendering <- gl_proc_address_get
1171 NULL, // FIXME: need software mesa for gl rendering <- gl_native_surface_get 1785 NULL, // need software mesa for gl rendering <- gl_native_surface_get
1172 NULL, // FIXME: need software mesa for gl rendering <- gl_api_get 1786 NULL, // need software mesa for gl rendering <- gl_api_get
1173 eng_image_load_error_get, 1787 eng_image_load_error_get,
1174 eng_font_run_font_end_get, 1788 eng_font_run_font_end_get,
1175 eng_image_animated_get, 1789 eng_image_animated_get,
@@ -1182,6 +1796,981 @@ static Evas_Func func =
1182 /* FUTURE software generic calls go here */ 1796 /* FUTURE software generic calls go here */
1183}; 1797};
1184 1798
1799
1800//----------------------------------------------------------------//
1801// //
1802// Load Symbols //
1803// //
1804//----------------------------------------------------------------//
1805#ifdef EVAS_GL
1806static void
1807sym_missing(void)
1808{
1809 ERR("GL symbols missing!\n");
1810}
1811
1812static int
1813glue_sym_init(void)
1814{
1815 //------------------------------------------------//
1816 // Use eglGetProcAddress
1817#define FINDSYM(dst, sym, typ) \
1818 if (!dst) dst = (typeof(dst))dlsym(gl_lib_handle, sym); \
1819 if (!dst) \
1820 { \
1821 ERR("Symbol not found %s\n", sym); \
1822 return 0; \
1823 }
1824#define FALLBAK(dst, typ) if (!dst) dst = (typeof(dst))sym_missing;
1825
1826 //------------------------------------------------------//
1827 // OSMesa APIs...
1828 FINDSYM(_sym_OSMesaCreateContextExt, "OSMesaCreateContextExt", glsym_func_osm_ctx);
1829 FALLBAK(_sym_OSMesaCreateContextExt, glsym_func_void);
1830
1831 FINDSYM(_sym_OSMesaDestroyContext, "OSMesaDestroyContext", glsym_func_void);
1832 FALLBAK(_sym_OSMesaDestroyContext, glsym_func_void);
1833
1834 FINDSYM(_sym_OSMesaMakeCurrent, "OSMesaMakeCurrent", glsym_func_bool);
1835 FALLBAK(_sym_OSMesaMakeCurrent, glsym_func_void);
1836
1837 FINDSYM(_sym_OSMesaPixelStore, "OSMesaPixelStore", glsym_func_void);
1838 FALLBAK(_sym_OSMesaPixelStore, glsym_func_void);
1839
1840 FINDSYM(_sym_OSMesaGetProcAddress, "OSMesaGetProcAddress", glsym_func_eng_fn);
1841 FALLBAK(_sym_OSMesaGetProcAddress, glsym_func_void);
1842
1843#undef FINDSYM
1844#undef FALLBAK
1845
1846 return 1;
1847}
1848
1849static int
1850gl_sym_init(void)
1851{
1852 //------------------------------------------------//
1853#define FINDSYM(dst, sym, typ) \
1854 if (!dst) dst = (typeof(dst))dlsym(gl_lib_handle, sym); \
1855 if (!dst) DBG("Symbol not found %s\n", sym);
1856#define FALLBAK(dst, typ) if (!dst) dst = (typeof(dst))sym_missing;
1857
1858
1859 //------------------------------------------------------//
1860 // GLES 2.0 APIs...
1861 FINDSYM(_sym_glActiveTexture, "glActiveTexture", glsym_func_void);
1862 FALLBAK(_sym_glActiveTexture, glsym_func_void);
1863
1864 FINDSYM(_sym_glAttachShader, "glAttachShader", glsym_func_void);
1865 FALLBAK(_sym_glAttachShader, glsym_func_void);
1866
1867 FINDSYM(_sym_glBindAttribLocation, "glBindAttribLocation", glsym_func_void);
1868 FALLBAK(_sym_glBindAttribLocation, glsym_func_void);
1869
1870 FINDSYM(_sym_glBindBuffer, "glBindBuffer", glsym_func_void);
1871 FALLBAK(_sym_glBindBuffer, glsym_func_void);
1872
1873 FINDSYM(_sym_glBindFramebuffer, "glBindFramebuffer", glsym_func_void);
1874 FALLBAK(_sym_glBindFramebuffer, glsym_func_void);
1875
1876 FINDSYM(_sym_glBindRenderbuffer, "glBindRenderbuffer", glsym_func_void);
1877 FALLBAK(_sym_glBindRenderbuffer, glsym_func_void);
1878
1879 FINDSYM(_sym_glBindTexture, "glBindTexture", glsym_func_void);
1880 FALLBAK(_sym_glBindTexture, glsym_func_void);
1881
1882 FINDSYM(_sym_glBlendColor, "glBlendColor", glsym_func_void);
1883 FALLBAK(_sym_glBlendColor, glsym_func_void);
1884
1885 FINDSYM(_sym_glBlendEquation, "glBlendEquation", glsym_func_void);
1886 FALLBAK(_sym_glBlendEquation, glsym_func_void);
1887
1888 FINDSYM(_sym_glBlendEquationSeparate, "glBlendEquationSeparate", glsym_func_void);
1889 FALLBAK(_sym_glBlendEquationSeparate, glsym_func_void);
1890
1891 FINDSYM(_sym_glBlendFunc, "glBlendFunc", glsym_func_void);
1892 FALLBAK(_sym_glBlendFunc, glsym_func_void);
1893
1894 FINDSYM(_sym_glBlendFuncSeparate, "glBlendFuncSeparate", glsym_func_void);
1895 FALLBAK(_sym_glBlendFuncSeparate, glsym_func_void);
1896
1897 FINDSYM(_sym_glBufferData, "glBufferData", glsym_func_void);
1898 FALLBAK(_sym_glBufferData, glsym_func_void);
1899
1900 FINDSYM(_sym_glBufferSubData, "glBufferSubData", glsym_func_void);
1901 FALLBAK(_sym_glBufferSubData, glsym_func_void);
1902
1903 FINDSYM(_sym_glCheckFramebufferStatus, "glCheckFramebufferStatus", glsym_func_uint);
1904 FALLBAK(_sym_glCheckFramebufferStatus, glsym_func_uint);
1905
1906 FINDSYM(_sym_glClear, "glClear", glsym_func_void);
1907 FALLBAK(_sym_glClear, glsym_func_void);
1908
1909 FINDSYM(_sym_glClearColor, "glClearColor", glsym_func_void);
1910 FALLBAK(_sym_glClearColor, glsym_func_void);
1911
1912 FINDSYM(_sym_glClearDepthf, "glClearDepthf", glsym_func_void);
1913 FINDSYM(_sym_glClearDepthf, "glClearDepth", glsym_func_void);
1914 FALLBAK(_sym_glClearDepthf, glsym_func_void);
1915
1916 FINDSYM(_sym_glClearStencil, "glClearStencil", glsym_func_void);
1917 FALLBAK(_sym_glClearStencil, glsym_func_void);
1918
1919 FINDSYM(_sym_glColorMask, "glColorMask", glsym_func_void);
1920 FALLBAK(_sym_glColorMask, glsym_func_void);
1921
1922 FINDSYM(_sym_glCompileShader, "glCompileShader", glsym_func_void);
1923 FALLBAK(_sym_glCompileShader, glsym_func_void);
1924
1925 FINDSYM(_sym_glCompressedTexImage2D, "glCompressedTexImage2D", glsym_func_void);
1926 FALLBAK(_sym_glCompressedTexImage2D, glsym_func_void);
1927
1928 FINDSYM(_sym_glCompressedTexSubImage2D, "glCompressedTexSubImage2D", glsym_func_void);
1929 FALLBAK(_sym_glCompressedTexSubImage2D, glsym_func_void);
1930
1931 FINDSYM(_sym_glCopyTexImage2D, "glCopyTexImage2D", glsym_func_void);
1932 FALLBAK(_sym_glCopyTexImage2D, glsym_func_void);
1933
1934 FINDSYM(_sym_glCopyTexSubImage2D, "glCopyTexSubImage2D", glsym_func_void);
1935 FALLBAK(_sym_glCopyTexSubImage2D, glsym_func_void);
1936
1937 FINDSYM(_sym_glCreateProgram, "glCreateProgram", glsym_func_uint);
1938 FALLBAK(_sym_glCreateProgram, glsym_func_uint);
1939
1940 FINDSYM(_sym_glCreateShader, "glCreateShader", glsym_func_uint);
1941 FALLBAK(_sym_glCreateShader, glsym_func_uint);
1942
1943 FINDSYM(_sym_glCullFace, "glCullFace", glsym_func_void);
1944 FALLBAK(_sym_glCullFace, glsym_func_void);
1945
1946 FINDSYM(_sym_glDeleteBuffers, "glDeleteBuffers", glsym_func_void);
1947 FALLBAK(_sym_glDeleteBuffers, glsym_func_void);
1948
1949 FINDSYM(_sym_glDeleteFramebuffers, "glDeleteFramebuffers", glsym_func_void);
1950 FALLBAK(_sym_glDeleteFramebuffers, glsym_func_void);
1951
1952 FINDSYM(_sym_glDeleteProgram, "glDeleteProgram", glsym_func_void);
1953 FALLBAK(_sym_glDeleteProgram, glsym_func_void);
1954
1955 FINDSYM(_sym_glDeleteRenderbuffers, "glDeleteRenderbuffers", glsym_func_void);
1956 FALLBAK(_sym_glDeleteRenderbuffers, glsym_func_void);
1957
1958 FINDSYM(_sym_glDeleteShader, "glDeleteShader", glsym_func_void);
1959 FALLBAK(_sym_glDeleteShader, glsym_func_void);
1960
1961 FINDSYM(_sym_glDeleteTextures, "glDeleteTextures", glsym_func_void);
1962 FALLBAK(_sym_glDeleteTextures, glsym_func_void);
1963
1964 FINDSYM(_sym_glDepthFunc, "glDepthFunc", glsym_func_void);
1965 FALLBAK(_sym_glDepthFunc, glsym_func_void);
1966
1967 FINDSYM(_sym_glDepthMask, "glDepthMask", glsym_func_void);
1968 FALLBAK(_sym_glDepthMask, glsym_func_void);
1969
1970 FINDSYM(_sym_glDepthRangef, "glDepthRangef", glsym_func_void);
1971 FINDSYM(_sym_glDepthRangef, "glDepthRange", glsym_func_void);
1972 FALLBAK(_sym_glDepthRangef, glsym_func_void);
1973
1974 FINDSYM(_sym_glDetachShader, "glDetachShader", glsym_func_void);
1975 FALLBAK(_sym_glDetachShader, glsym_func_void);
1976
1977 FINDSYM(_sym_glDisable, "glDisable", glsym_func_void);
1978 FALLBAK(_sym_glDisable, glsym_func_void);
1979
1980 FINDSYM(_sym_glDisableVertexAttribArray, "glDisableVertexAttribArray", glsym_func_void);
1981 FALLBAK(_sym_glDisableVertexAttribArray, glsym_func_void);
1982
1983 FINDSYM(_sym_glDrawArrays, "glDrawArrays", glsym_func_void);
1984 FALLBAK(_sym_glDrawArrays, glsym_func_void);
1985
1986 FINDSYM(_sym_glDrawElements, "glDrawElements", glsym_func_void);
1987 FALLBAK(_sym_glDrawElements, glsym_func_void);
1988
1989 FINDSYM(_sym_glEnable, "glEnable", glsym_func_void);
1990 FALLBAK(_sym_glEnable, glsym_func_void);
1991
1992 FINDSYM(_sym_glEnableVertexAttribArray, "glEnableVertexAttribArray", glsym_func_void);
1993 FALLBAK(_sym_glEnableVertexAttribArray, glsym_func_void);
1994
1995 FINDSYM(_sym_glFinish, "glFinish", glsym_func_void);
1996 FALLBAK(_sym_glFinish, glsym_func_void);
1997
1998 FINDSYM(_sym_glFlush, "glFlush", glsym_func_void);
1999 FALLBAK(_sym_glFlush, glsym_func_void);
2000
2001 FINDSYM(_sym_glFramebufferRenderbuffer, "glFramebufferRenderbuffer", glsym_func_void);
2002 FALLBAK(_sym_glFramebufferRenderbuffer, glsym_func_void);
2003
2004 FINDSYM(_sym_glFramebufferTexture2D, "glFramebufferTexture2D", glsym_func_void);
2005 FALLBAK(_sym_glFramebufferTexture2D, glsym_func_void);
2006
2007 FINDSYM(_sym_glFrontFace, "glFrontFace", glsym_func_void);
2008 FALLBAK(_sym_glFrontFace, glsym_func_void);
2009
2010 FINDSYM(_sym_glGenBuffers, "glGenBuffers", glsym_func_void);
2011 FALLBAK(_sym_glGenBuffers, glsym_func_void);
2012
2013 FINDSYM(_sym_glGenerateMipmap, "glGenerateMipmap", glsym_func_void);
2014 FALLBAK(_sym_glGenerateMipmap, glsym_func_void);
2015
2016 FINDSYM(_sym_glGenFramebuffers, "glGenFramebuffers", glsym_func_void);
2017 FALLBAK(_sym_glGenFramebuffers, glsym_func_void);
2018
2019 FINDSYM(_sym_glGenRenderbuffers, "glGenRenderbuffers", glsym_func_void);
2020 FALLBAK(_sym_glGenRenderbuffers, glsym_func_void);
2021
2022 FINDSYM(_sym_glGenTextures, "glGenTextures", glsym_func_void);
2023 FALLBAK(_sym_glGenTextures, glsym_func_void);
2024
2025 FINDSYM(_sym_glGetActiveAttrib, "glGetActiveAttrib", glsym_func_void);
2026 FALLBAK(_sym_glGetActiveAttrib, glsym_func_void);
2027
2028 FINDSYM(_sym_glGetActiveUniform, "glGetActiveUniform", glsym_func_void);
2029 FALLBAK(_sym_glGetActiveUniform, glsym_func_void);
2030
2031 FINDSYM(_sym_glGetAttachedShaders, "glGetAttachedShaders", glsym_func_void);
2032 FALLBAK(_sym_glGetAttachedShaders, glsym_func_void);
2033
2034 FINDSYM(_sym_glGetAttribLocation, "glGetAttribLocation", glsym_func_int);
2035 FALLBAK(_sym_glGetAttribLocation, glsym_func_int);
2036
2037 FINDSYM(_sym_glGetBooleanv, "glGetBooleanv", glsym_func_void);
2038 FALLBAK(_sym_glGetBooleanv, glsym_func_void);
2039
2040 FINDSYM(_sym_glGetBufferParameteriv, "glGetBufferParameteriv", glsym_func_void);
2041 FALLBAK(_sym_glGetBufferParameteriv, glsym_func_void);
2042
2043 FINDSYM(_sym_glGetError, "glGetError", glsym_func_uint);
2044 FALLBAK(_sym_glGetError, glsym_func_uint);
2045
2046 FINDSYM(_sym_glGetFloatv, "glGetFloatv", glsym_func_void);
2047 FALLBAK(_sym_glGetFloatv, glsym_func_void);
2048
2049 FINDSYM(_sym_glGetFramebufferAttachmentParameteriv, "glGetFramebufferAttachmentParameteriv", glsym_func_void);
2050 FALLBAK(_sym_glGetFramebufferAttachmentParameteriv, glsym_func_void);
2051
2052 FINDSYM(_sym_glGetIntegerv, "glGetIntegerv", glsym_func_void);
2053 FALLBAK(_sym_glGetIntegerv, glsym_func_void);
2054
2055 FINDSYM(_sym_glGetProgramiv, "glGetProgramiv", glsym_func_void);
2056 FALLBAK(_sym_glGetProgramiv, glsym_func_void);
2057
2058 FINDSYM(_sym_glGetProgramInfoLog, "glGetProgramInfoLog", glsym_func_void);
2059 FALLBAK(_sym_glGetProgramInfoLog, glsym_func_void);
2060
2061 FINDSYM(_sym_glGetRenderbufferParameteriv, "glGetRenderbufferParameteriv", glsym_func_void);
2062 FALLBAK(_sym_glGetRenderbufferParameteriv, glsym_func_void);
2063
2064 FINDSYM(_sym_glGetShaderiv, "glGetShaderiv", glsym_func_void);
2065 FALLBAK(_sym_glGetShaderiv, glsym_func_void);
2066
2067 FINDSYM(_sym_glGetShaderInfoLog, "glGetShaderInfoLog", glsym_func_void);
2068 FALLBAK(_sym_glGetShaderInfoLog, glsym_func_void);
2069
2070 FINDSYM(_sym_glGetShaderPrecisionFormat, "glGetShaderPrecisionFormat", glsym_func_void);
2071 FALLBAK(_sym_glGetShaderPrecisionFormat, glsym_func_void);
2072
2073 FINDSYM(_sym_glGetShaderSource, "glGetShaderSource", glsym_func_void);
2074 FALLBAK(_sym_glGetShaderSource, glsym_func_void);
2075
2076 FINDSYM(_sym_glGetString, "glGetString", glsym_func_uchar_ptr);
2077 FALLBAK(_sym_glGetString, glsym_func_const_uchar_ptr);
2078
2079 FINDSYM(_sym_glGetTexParameterfv, "glGetTexParameterfv", glsym_func_void);
2080 FALLBAK(_sym_glGetTexParameterfv, glsym_func_void);
2081
2082 FINDSYM(_sym_glGetTexParameteriv, "glGetTexParameteriv", glsym_func_void);
2083 FALLBAK(_sym_glGetTexParameteriv, glsym_func_void);
2084
2085 FINDSYM(_sym_glGetUniformfv, "glGetUniformfv", glsym_func_void);
2086 FALLBAK(_sym_glGetUniformfv, glsym_func_void);
2087
2088 FINDSYM(_sym_glGetUniformiv, "glGetUniformiv", glsym_func_void);
2089 FALLBAK(_sym_glGetUniformiv, glsym_func_void);
2090
2091 FINDSYM(_sym_glGetUniformLocation, "glGetUniformLocation", glsym_func_int);
2092 FALLBAK(_sym_glGetUniformLocation, glsym_func_int);
2093
2094 FINDSYM(_sym_glGetVertexAttribfv, "glGetVertexAttribfv", glsym_func_void);
2095 FALLBAK(_sym_glGetVertexAttribfv, glsym_func_void);
2096
2097 FINDSYM(_sym_glGetVertexAttribiv, "glGetVertexAttribiv", glsym_func_void);
2098 FALLBAK(_sym_glGetVertexAttribiv, glsym_func_void);
2099
2100 FINDSYM(_sym_glGetVertexAttribPointerv, "glGetVertexAttribPointerv", glsym_func_void);
2101 FALLBAK(_sym_glGetVertexAttribPointerv, glsym_func_void);
2102
2103 FINDSYM(_sym_glHint, "glHint", glsym_func_void);
2104 FALLBAK(_sym_glHint, glsym_func_void);
2105
2106 FINDSYM(_sym_glIsBuffer, "glIsBuffer", glsym_func_uchar);
2107 FALLBAK(_sym_glIsBuffer, glsym_func_uchar);
2108
2109 FINDSYM(_sym_glIsEnabled, "glIsEnabled", glsym_func_uchar);
2110 FALLBAK(_sym_glIsEnabled, glsym_func_uchar);
2111
2112 FINDSYM(_sym_glIsFramebuffer, "glIsFramebuffer", glsym_func_uchar);
2113 FALLBAK(_sym_glIsFramebuffer, glsym_func_uchar);
2114
2115 FINDSYM(_sym_glIsProgram, "glIsProgram", glsym_func_uchar);
2116 FALLBAK(_sym_glIsProgram, glsym_func_uchar);
2117
2118 FINDSYM(_sym_glIsRenderbuffer, "glIsRenderbuffer", glsym_func_uchar);
2119 FALLBAK(_sym_glIsRenderbuffer, glsym_func_uchar);
2120
2121 FINDSYM(_sym_glIsShader, "glIsShader", glsym_func_uchar);
2122 FALLBAK(_sym_glIsShader, glsym_func_uchar);
2123
2124 FINDSYM(_sym_glIsTexture, "glIsTexture", glsym_func_uchar);
2125 FALLBAK(_sym_glIsTexture, glsym_func_uchar);
2126
2127 FINDSYM(_sym_glLineWidth, "glLineWidth", glsym_func_void);
2128 FALLBAK(_sym_glLineWidth, glsym_func_void);
2129
2130 FINDSYM(_sym_glLinkProgram, "glLinkProgram", glsym_func_void);
2131 FALLBAK(_sym_glLinkProgram, glsym_func_void);
2132
2133 FINDSYM(_sym_glPixelStorei, "glPixelStorei", glsym_func_void);
2134 FALLBAK(_sym_glPixelStorei, glsym_func_void);
2135
2136 FINDSYM(_sym_glPolygonOffset, "glPolygonOffset", glsym_func_void);
2137 FALLBAK(_sym_glPolygonOffset, glsym_func_void);
2138
2139 FINDSYM(_sym_glReadPixels, "glReadPixels", glsym_func_void);
2140 FALLBAK(_sym_glReadPixels, glsym_func_void);
2141
2142 FINDSYM(_sym_glReleaseShaderCompiler, "glReleaseShaderCompiler", glsym_func_void);
2143 FALLBAK(_sym_glReleaseShaderCompiler, glsym_func_void);
2144
2145 FINDSYM(_sym_glRenderbufferStorage, "glRenderbufferStorage", glsym_func_void);
2146 FALLBAK(_sym_glRenderbufferStorage, glsym_func_void);
2147
2148 FINDSYM(_sym_glSampleCoverage, "glSampleCoverage", glsym_func_void);
2149 FALLBAK(_sym_glSampleCoverage, glsym_func_void);
2150
2151 FINDSYM(_sym_glScissor, "glScissor", glsym_func_void);
2152 FALLBAK(_sym_glScissor, glsym_func_void);
2153
2154 FINDSYM(_sym_glShaderBinary, "glShaderBinary", glsym_func_void);
2155 FALLBAK(_sym_glShaderBinary, glsym_func_void);
2156
2157 FINDSYM(_sym_glShaderSource, "glShaderSource", glsym_func_void);
2158 FALLBAK(_sym_glShaderSource, glsym_func_void);
2159
2160 FINDSYM(_sym_glStencilFunc, "glStencilFunc", glsym_func_void);
2161 FALLBAK(_sym_glStencilFunc, glsym_func_void);
2162
2163 FINDSYM(_sym_glStencilFuncSeparate, "glStencilFuncSeparate", glsym_func_void);
2164 FALLBAK(_sym_glStencilFuncSeparate, glsym_func_void);
2165
2166 FINDSYM(_sym_glStencilMask, "glStencilMask", glsym_func_void);
2167 FALLBAK(_sym_glStencilMask, glsym_func_void);
2168
2169 FINDSYM(_sym_glStencilMaskSeparate, "glStencilMaskSeparate", glsym_func_void);
2170 FALLBAK(_sym_glStencilMaskSeparate, glsym_func_void);
2171
2172 FINDSYM(_sym_glStencilOp, "glStencilOp", glsym_func_void);
2173 FALLBAK(_sym_glStencilOp, glsym_func_void);
2174
2175 FINDSYM(_sym_glStencilOpSeparate, "glStencilOpSeparate", glsym_func_void);
2176 FALLBAK(_sym_glStencilOpSeparate, glsym_func_void);
2177
2178 FINDSYM(_sym_glTexImage2D, "glTexImage2D", glsym_func_void);
2179 FALLBAK(_sym_glTexImage2D, glsym_func_void);
2180
2181 FINDSYM(_sym_glTexParameterf, "glTexParameterf", glsym_func_void);
2182 FALLBAK(_sym_glTexParameterf, glsym_func_void);
2183
2184 FINDSYM(_sym_glTexParameterfv, "glTexParameterfv", glsym_func_void);
2185 FALLBAK(_sym_glTexParameterfv, glsym_func_void);
2186
2187 FINDSYM(_sym_glTexParameteri, "glTexParameteri", glsym_func_void);
2188 FALLBAK(_sym_glTexParameteri, glsym_func_void);
2189
2190 FINDSYM(_sym_glTexParameteriv, "glTexParameteriv", glsym_func_void);
2191 FALLBAK(_sym_glTexParameteriv, glsym_func_void);
2192
2193 FINDSYM(_sym_glTexSubImage2D, "glTexSubImage2D", glsym_func_void);
2194 FALLBAK(_sym_glTexSubImage2D, glsym_func_void);
2195
2196 FINDSYM(_sym_glUniform1f, "glUniform1f", glsym_func_void);
2197 FALLBAK(_sym_glUniform1f, glsym_func_void);
2198
2199 FINDSYM(_sym_glUniform1fv, "glUniform1fv", glsym_func_void);
2200 FALLBAK(_sym_glUniform1fv, glsym_func_void);
2201
2202 FINDSYM(_sym_glUniform1i, "glUniform1i", glsym_func_void);
2203 FALLBAK(_sym_glUniform1i, glsym_func_void);
2204
2205 FINDSYM(_sym_glUniform1iv, "glUniform1iv", glsym_func_void);
2206 FALLBAK(_sym_glUniform1iv, glsym_func_void);
2207
2208 FINDSYM(_sym_glUniform2f, "glUniform2f", glsym_func_void);
2209 FALLBAK(_sym_glUniform2f, glsym_func_void);
2210
2211 FINDSYM(_sym_glUniform2fv, "glUniform2fv", glsym_func_void);
2212 FALLBAK(_sym_glUniform2fv, glsym_func_void);
2213
2214 FINDSYM(_sym_glUniform2i, "glUniform2i", glsym_func_void);
2215 FALLBAK(_sym_glUniform2i, glsym_func_void);
2216
2217 FINDSYM(_sym_glUniform2iv, "glUniform2iv", glsym_func_void);
2218 FALLBAK(_sym_glUniform2iv, glsym_func_void);
2219
2220 FINDSYM(_sym_glUniform3f, "glUniform3f", glsym_func_void);
2221 FALLBAK(_sym_glUniform3f, glsym_func_void);
2222
2223 FINDSYM(_sym_glUniform3fv, "glUniform3fv", glsym_func_void);
2224 FALLBAK(_sym_glUniform3fv, glsym_func_void);
2225
2226 FINDSYM(_sym_glUniform3i, "glUniform3i", glsym_func_void);
2227 FALLBAK(_sym_glUniform3i, glsym_func_void);
2228
2229 FINDSYM(_sym_glUniform3iv, "glUniform3iv", glsym_func_void);
2230 FALLBAK(_sym_glUniform3iv, glsym_func_void);
2231
2232 FINDSYM(_sym_glUniform4f, "glUniform4f", glsym_func_void);
2233 FALLBAK(_sym_glUniform4f, glsym_func_void);
2234
2235 FINDSYM(_sym_glUniform4fv, "glUniform4fv", glsym_func_void);
2236 FALLBAK(_sym_glUniform4fv, glsym_func_void);
2237
2238 FINDSYM(_sym_glUniform4i, "glUniform4i", glsym_func_void);
2239 FALLBAK(_sym_glUniform4i, glsym_func_void);
2240
2241 FINDSYM(_sym_glUniform4iv, "glUniform4iv", glsym_func_void);
2242 FALLBAK(_sym_glUniform4iv, glsym_func_void);
2243
2244 FINDSYM(_sym_glUniformMatrix2fv, "glUniformMatrix2fv", glsym_func_void);
2245 FALLBAK(_sym_glUniformMatrix2fv, glsym_func_void);
2246
2247 FINDSYM(_sym_glUniformMatrix3fv, "glUniformMatrix3fv", glsym_func_void);
2248 FALLBAK(_sym_glUniformMatrix3fv, glsym_func_void);
2249
2250 FINDSYM(_sym_glUniformMatrix4fv, "glUniformMatrix4fv", glsym_func_void);
2251 FALLBAK(_sym_glUniformMatrix4fv, glsym_func_void);
2252
2253 FINDSYM(_sym_glUseProgram, "glUseProgram", glsym_func_void);
2254 FALLBAK(_sym_glUseProgram, glsym_func_void);
2255
2256 FINDSYM(_sym_glValidateProgram, "glValidateProgram", glsym_func_void);
2257 FALLBAK(_sym_glValidateProgram, glsym_func_void);
2258
2259 FINDSYM(_sym_glVertexAttrib1f, "glVertexAttrib1f", glsym_func_void);
2260 FALLBAK(_sym_glVertexAttrib1f, glsym_func_void);
2261
2262 FINDSYM(_sym_glVertexAttrib1fv, "glVertexAttrib1fv", glsym_func_void);
2263 FALLBAK(_sym_glVertexAttrib1fv, glsym_func_void);
2264
2265 FINDSYM(_sym_glVertexAttrib2f, "glVertexAttrib2f", glsym_func_void);
2266 FALLBAK(_sym_glVertexAttrib2f, glsym_func_void);
2267
2268 FINDSYM(_sym_glVertexAttrib2fv, "glVertexAttrib2fv", glsym_func_void);
2269 FALLBAK(_sym_glVertexAttrib2fv, glsym_func_void);
2270
2271 FINDSYM(_sym_glVertexAttrib3f, "glVertexAttrib3f", glsym_func_void);
2272 FALLBAK(_sym_glVertexAttrib3f, glsym_func_void);
2273
2274 FINDSYM(_sym_glVertexAttrib3fv, "glVertexAttrib3fv", glsym_func_void);
2275 FALLBAK(_sym_glVertexAttrib3fv, glsym_func_void);
2276
2277 FINDSYM(_sym_glVertexAttrib4f, "glVertexAttrib4f", glsym_func_void);
2278 FALLBAK(_sym_glVertexAttrib4f, glsym_func_void);
2279
2280 FINDSYM(_sym_glVertexAttrib4fv, "glVertexAttrib4fv", glsym_func_void);
2281 FALLBAK(_sym_glVertexAttrib4fv, glsym_func_void);
2282
2283 FINDSYM(_sym_glVertexAttribPointer, "glVertexAttribPointer", glsym_func_void);
2284 FALLBAK(_sym_glVertexAttribPointer, glsym_func_void);
2285
2286 FINDSYM(_sym_glViewport, "glViewport", glsym_func_void);
2287 FALLBAK(_sym_glViewport, glsym_func_void);
2288
2289#undef FINDSYM
2290#undef FALLBAK
2291
2292 // Checking to see if this function exists is a poor but reasonable way to
2293 // check if it's gles but it works for now
2294 if (_sym_glGetShaderPrecisionFormat != (typeof(_sym_glGetShaderPrecisionFormat))sym_missing )
2295 {
2296 DBG("GL Library is GLES.");
2297 gl_lib_is_gles = 1;
2298 }
2299
2300 return 1;
2301}
2302
2303//--------------------------------------------------------------//
2304// Wrapped GL APIs to handle desktop compatibility
2305
2306// Stripping precision code from GLES shader for desktop compatibility
2307// Code adopted from Meego GL code. Temporary Fix.
2308static const char *
2309opengl_strtok(const char *s, int *n, char **saveptr, char *prevbuf)
2310{
2311 char *start;
2312 char *ret;
2313 char *p;
2314 int retlen;
2315 static const char *delim = " \t\n\r/";
2316
2317 if (prevbuf) free(prevbuf);
2318
2319 if (s)
2320 *saveptr = (char *)s;
2321 else
2322 {
2323 if (!(*saveptr) || !(*n))
2324 return NULL;
2325 s = *saveptr;
2326 }
2327
2328 for (; *n && strchr(delim, *s); s++, (*n)--)
2329 {
2330 if (*s == '/' && *n > 1)
2331 {
2332 if (s[1] == '/')
2333 {
2334 do
2335 {
2336 s++, (*n)--;
2337 }
2338 while (*n > 1 && s[1] != '\n' && s[1] != '\r');
2339 }
2340 else if (s[1] == '*')
2341 {
2342 do
2343 {
2344 s++, (*n)--;
2345 }
2346 while (*n > 2 && (s[1] != '*' || s[2] != '/'));
2347 s++, (*n)--;
2348 }
2349 }
2350 }
2351
2352 start = (char *)s;
2353 for (; *n && *s && !strchr(delim, *s); s++, (*n)--);
2354 if (*n > 0) s++, (*n)--;
2355
2356 *saveptr = (char *)s;
2357
2358 retlen = s - start;
2359 ret = malloc(retlen + 1);
2360 p = ret;
2361
2362 while (retlen > 0)
2363 {
2364 if (*start == '/' && retlen > 1)
2365 {
2366 if (start[1] == '/')
2367 {
2368 do
2369 {
2370 start++, retlen--;
2371 }
2372 while (retlen > 1 && start[1] != '\n' && start[1] != '\r');
2373 start++, retlen--;
2374 continue;
2375 }
2376 else if (start[1] == '*')
2377 {
2378 do
2379 {
2380 start++, retlen--;
2381 }
2382 while (retlen > 2 && (start[1] != '*' || start[2] != '/'));
2383 start += 3, retlen -= 3;
2384 continue;
2385 }
2386 }
2387 *(p++) = *(start++), retlen--;
2388 }
2389
2390 *p = 0;
2391 return ret;
2392}
2393
2394static char *
2395patch_gles_shader(const char *source, int length, int *patched_len)
2396{
2397 char *saveptr = NULL;
2398 char *sp;
2399 char *p = NULL;
2400
2401 if (!length) length = strlen(source);
2402
2403 *patched_len = 0;
2404 int patched_size = length;
2405 char *patched = malloc(patched_size + 1);
2406
2407 if (!patched) return NULL;
2408
2409 p = (char *)opengl_strtok(source, &length, &saveptr, NULL);
2410 for (; p; p = (char *)opengl_strtok(0, &length, &saveptr, p))
2411 {
2412 if (!strncmp(p, "lowp", 4) || !strncmp(p, "mediump", 7) || !strncmp(p, "highp", 5))
2413 {
2414 continue;
2415 }
2416 else if (!strncmp(p, "precision", 9))
2417 {
2418 while ((p = (char *)opengl_strtok(0, &length, &saveptr, p)) && !strchr(p, ';'));
2419 }
2420 else
2421 {
2422 if (!strncmp(p, "gl_MaxVertexUniformVectors", 26))
2423 {
2424 p = "(gl_MaxVertexUniformComponents / 4)";
2425 }
2426 else if (!strncmp(p, "gl_MaxFragmentUniformVectors", 28))
2427 {
2428 p = "(gl_MaxFragmentUniformComponents / 4)";
2429 }
2430 else if (!strncmp(p, "gl_MaxVaryingVectors", 20))
2431 {
2432 p = "(gl_MaxVaryingFloats / 4)";
2433 }
2434
2435 int new_len = strlen(p);
2436 if (*patched_len + new_len > patched_size)
2437 {
2438 patched_size *= 2;
2439 patched = realloc(patched, patched_size + 1);
2440
2441 if (!patched)
2442 return NULL;
2443 }
2444
2445 memcpy(patched + *patched_len, p, new_len);
2446 *patched_len += new_len;
2447 }
2448 }
2449
2450 patched[*patched_len] = 0;
2451 /* check that we don't leave dummy preprocessor lines */
2452 for (sp = patched; *sp;)
2453 {
2454 for (; *sp == ' ' || *sp == '\t'; sp++);
2455 if (!strncmp(sp, "#define", 7))
2456 {
2457 for (p = sp + 7; *p == ' ' || *p == '\t'; p++);
2458 if (*p == '\n' || *p == '\r' || *p == '/')
2459 {
2460 memset(sp, 0x20, 7);
2461 }
2462 }
2463 for (; *sp && *sp != '\n' && *sp != '\r'; sp++);
2464 for (; *sp == '\n' || *sp == '\r'; sp++);
2465 }
2466 return patched;
2467}
2468
2469static void
2470evgl_glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length)
2471{
2472 int i = 0, len = 0;
2473
2474 char **s = malloc(count * sizeof(char*));
2475 GLint *l = malloc(count * sizeof(GLint));
2476
2477 memset(s, 0, count * sizeof(char*));
2478 memset(l, 0, count * sizeof(GLint));
2479
2480 for (i = 0; i < count; ++i)
2481 {
2482 if (length)
2483 {
2484 len = length[i];
2485 if (len < 0)
2486 len = string[i] ? strlen(string[i]) : 0;
2487 }
2488 else
2489 len = string[i] ? strlen(string[i]) : 0;
2490
2491 if (string[i])
2492 {
2493 s[i] = patch_gles_shader(string[i], len, &l[i]);
2494 if (!s[i])
2495 {
2496 while(i)
2497 free(s[--i]);
2498 free(l);
2499 free(s);
2500
2501 DBG("Patching Shader Failed.");
2502 return;
2503 }
2504 }
2505 else
2506 {
2507 s[i] = NULL;
2508 l[i] = 0;
2509 }
2510 }
2511
2512 _sym_glShaderSource(shader, count, (const char **)s, l);
2513
2514 while(i)
2515 free(s[--i]);
2516 free(l);
2517 free(s);
2518}
2519
2520
2521static void
2522evgl_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
2523{
2524 if (range)
2525 {
2526 range[0] = -126; // floor(log2(FLT_MIN))
2527 range[1] = 127; // floor(log2(FLT_MAX))
2528 }
2529 if (precision)
2530 {
2531 precision[0] = 24; // floor(-log2((1.0/16777218.0)));
2532 }
2533 return;
2534 shadertype = precisiontype = 0;
2535}
2536
2537static void
2538evgl_glReleaseShaderCompiler(void)
2539{
2540 DBG("Not supported in Desktop GL");
2541 return;
2542}
2543
2544static void
2545evgl_glShaderBinary(GLsizei n __UNUSED__, const GLuint* shaders __UNUSED__, GLenum binaryformat __UNUSED__, const void* binary __UNUSED__, GLsizei length __UNUSED__)
2546{
2547 // FIXME: need to dlsym/getprocaddress for this
2548 DBG("Not supported in Desktop GL");
2549 return;
2550 //n = binaryformat = length = 0;
2551 //shaders = binary = 0;
2552}
2553#endif
2554//--------------------------------------------------------------//
2555
2556
2557#ifdef EVAS_GL
2558static void
2559override_gl_apis(Evas_GL_API *api)
2560{
2561
2562 api->version = EVAS_GL_API_VERSION;
2563
2564#define ORD(f) EVAS_API_OVERRIDE(f, api, _sym_)
2565 // GLES 2.0
2566 ORD(glActiveTexture);
2567 ORD(glAttachShader);
2568 ORD(glBindAttribLocation);
2569 ORD(glBindBuffer);
2570 ORD(glBindTexture);
2571 ORD(glBlendColor);
2572 ORD(glBlendEquation);
2573 ORD(glBlendEquationSeparate);
2574 ORD(glBlendFunc);
2575 ORD(glBlendFuncSeparate);
2576 ORD(glBufferData);
2577 ORD(glBufferSubData);
2578 ORD(glCheckFramebufferStatus);
2579 ORD(glClear);
2580 ORD(glClearColor);
2581 ORD(glClearDepthf);
2582 ORD(glClearStencil);
2583 ORD(glColorMask);
2584 ORD(glCompileShader);
2585 ORD(glCompressedTexImage2D);
2586 ORD(glCompressedTexSubImage2D);
2587 ORD(glCopyTexImage2D);
2588 ORD(glCopyTexSubImage2D);
2589 ORD(glCreateProgram);
2590 ORD(glCreateShader);
2591 ORD(glCullFace);
2592 ORD(glDeleteBuffers);
2593 ORD(glDeleteFramebuffers);
2594 ORD(glDeleteProgram);
2595 ORD(glDeleteRenderbuffers);
2596 ORD(glDeleteShader);
2597 ORD(glDeleteTextures);
2598 ORD(glDepthFunc);
2599 ORD(glDepthMask);
2600 ORD(glDepthRangef);
2601 ORD(glDetachShader);
2602 ORD(glDisable);
2603 ORD(glDisableVertexAttribArray);
2604 ORD(glDrawArrays);
2605 ORD(glDrawElements);
2606 ORD(glEnable);
2607 ORD(glEnableVertexAttribArray);
2608 ORD(glFinish);
2609 ORD(glFlush);
2610 ORD(glFramebufferRenderbuffer);
2611 ORD(glFramebufferTexture2D);
2612 ORD(glFrontFace);
2613 ORD(glGenBuffers);
2614 ORD(glGenerateMipmap);
2615 ORD(glGenFramebuffers);
2616 ORD(glGenRenderbuffers);
2617 ORD(glGenTextures);
2618 ORD(glGetActiveAttrib);
2619 ORD(glGetActiveUniform);
2620 ORD(glGetAttachedShaders);
2621 ORD(glGetAttribLocation);
2622 ORD(glGetBooleanv);
2623 ORD(glGetBufferParameteriv);
2624 ORD(glGetError);
2625 ORD(glGetFloatv);
2626 ORD(glGetFramebufferAttachmentParameteriv);
2627 ORD(glGetIntegerv);
2628 ORD(glGetProgramiv);
2629 ORD(glGetProgramInfoLog);
2630 ORD(glGetRenderbufferParameteriv);
2631 ORD(glGetShaderiv);
2632 ORD(glGetShaderInfoLog);
2633 ORD(glGetShaderPrecisionFormat);
2634 ORD(glGetShaderSource);
2635 ORD(glGetString); // FIXME
2636 ORD(glGetTexParameterfv);
2637 ORD(glGetTexParameteriv);
2638 ORD(glGetUniformfv);
2639 ORD(glGetUniformiv);
2640 ORD(glGetUniformLocation);
2641 ORD(glGetVertexAttribfv);
2642 ORD(glGetVertexAttribiv);
2643 ORD(glGetVertexAttribPointerv);
2644 ORD(glHint);
2645 ORD(glIsBuffer);
2646 ORD(glIsEnabled);
2647 ORD(glIsFramebuffer);
2648 ORD(glIsProgram);
2649 ORD(glIsRenderbuffer);
2650 ORD(glIsShader);
2651 ORD(glIsTexture);
2652 ORD(glLineWidth);
2653 ORD(glLinkProgram);
2654 ORD(glPixelStorei);
2655 ORD(glPolygonOffset);
2656 ORD(glReadPixels);
2657 ORD(glReleaseShaderCompiler);
2658 ORD(glRenderbufferStorage);
2659 ORD(glSampleCoverage);
2660 ORD(glScissor);
2661 ORD(glShaderBinary);
2662 ORD(glShaderSource);
2663 ORD(glStencilFunc);
2664 ORD(glStencilFuncSeparate);
2665 ORD(glStencilMask);
2666 ORD(glStencilMaskSeparate);
2667 ORD(glStencilOp);
2668 ORD(glStencilOpSeparate);
2669 ORD(glTexImage2D);
2670 ORD(glTexParameterf);
2671 ORD(glTexParameterfv);
2672 ORD(glTexParameteri);
2673 ORD(glTexParameteriv);
2674 ORD(glTexSubImage2D);
2675 ORD(glUniform1f);
2676 ORD(glUniform1fv);
2677 ORD(glUniform1i);
2678 ORD(glUniform1iv);
2679 ORD(glUniform2f);
2680 ORD(glUniform2fv);
2681 ORD(glUniform2i);
2682 ORD(glUniform2iv);
2683 ORD(glUniform3f);
2684 ORD(glUniform3fv);
2685 ORD(glUniform3i);
2686 ORD(glUniform3iv);
2687 ORD(glUniform4f);
2688 ORD(glUniform4fv);
2689 ORD(glUniform4i);
2690 ORD(glUniform4iv);
2691 ORD(glUniformMatrix2fv);
2692 ORD(glUniformMatrix3fv);
2693 ORD(glUniformMatrix4fv);
2694 ORD(glUseProgram);
2695 ORD(glValidateProgram);
2696 ORD(glVertexAttrib1f);
2697 ORD(glVertexAttrib1fv);
2698 ORD(glVertexAttrib2f);
2699 ORD(glVertexAttrib2fv);
2700 ORD(glVertexAttrib3f);
2701 ORD(glVertexAttrib3fv);
2702 ORD(glVertexAttrib4f);
2703 ORD(glVertexAttrib4fv);
2704 ORD(glVertexAttribPointer);
2705 ORD(glViewport);
2706#undef ORD
2707
2708#define ORD(f) EVAS_API_OVERRIDE(f, &gl_funcs, evgl_)
2709 if (!gl_lib_is_gles)
2710 {
2711 // Override functions wrapped by Evas_GL
2712 // GLES2.0 API compat on top of desktop gl
2713 ORD(glGetShaderPrecisionFormat);
2714 ORD(glReleaseShaderCompiler);
2715 ORD(glShaderBinary);
2716 }
2717
2718 ORD(glShaderSource); // Do precision stripping in both cases
2719#undef ORD
2720}
2721#endif
2722
2723//-------------------------------------------//
2724static int
2725gl_lib_init(void)
2726{
2727#ifdef EVAS_GL
2728 // dlopen OSMesa
2729 gl_lib_handle = dlopen("libOSMesa.so.1", RTLD_NOW);
2730 if (!gl_lib_handle) gl_lib_handle = dlopen("libOSMesa.so", RTLD_NOW);
2731 if (!gl_lib_handle)
2732 {
2733 DBG("Unable to open libOSMesa: %s", dlerror());
2734 return 0;
2735 }
2736
2737 //------------------------------------------------//
2738 if (!glue_sym_init()) return 0;
2739 if (!gl_sym_init()) return 0;
2740
2741 override_gl_apis(&gl_funcs);
2742
2743 return 1;
2744#else
2745 return 0;
2746#endif
2747}
2748
2749
2750static void
2751init_gl(void)
2752{
2753 DBG("Initializing Software OpenGL APIs...\n");
2754
2755 if (!gl_lib_init())
2756 DBG("Unable to support EvasGL in this engine module. Install OSMesa to get it running");
2757 else
2758 {
2759#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
2760 ORD(gl_surface_create);
2761 ORD(gl_surface_destroy);
2762 ORD(gl_context_create);
2763 ORD(gl_context_destroy);
2764 ORD(gl_make_current);
2765 ORD(gl_string_query); // FIXME: Need to implement
2766 ORD(gl_proc_address_get); // FIXME: Need to implement
2767 ORD(gl_native_surface_get);
2768 ORD(gl_api_get);
2769#undef ORD
2770 }
2771}
2772
2773
1185/* 2774/*
1186 ***** 2775 *****
1187 ** 2776 **
@@ -1201,6 +2790,9 @@ module_open(Evas_Module *em)
1201 EINA_LOG_ERR("Can not create a module log domain."); 2790 EINA_LOG_ERR("Can not create a module log domain.");
1202 return 0; 2791 return 0;
1203 } 2792 }
2793
2794 init_gl();
2795
1204 em->functions = (void *)(&func); 2796 em->functions = (void *)(&func);
1205 cpunum = eina_cpu_count(); 2797 cpunum = eina_cpu_count();
1206 return 1; 2798 return 1;