From 7a954e3dc088ff401b1c962694cc4a4137cc08fb Mon Sep 17 00:00:00 2001 From: lubomyr Date: Sun, 13 Nov 2016 15:43:07 +0200 Subject: [PATCH] gl4es updated, added latest changes by ptitSeb --- project/jni/gl4es/README.md | 3 + project/jni/gl4es/src/gl/array.c | 37 +++- project/jni/gl4es/src/gl/array.h | 1 + project/jni/gl4es/src/gl/framebuffers.c | 14 +- project/jni/gl4es/src/gl/getter.c | 1 + project/jni/gl4es/src/gl/gl.c | 26 ++- project/jni/gl4es/src/gl/texture.c | 2 +- project/jni/gl4es/src/glx/glx.c | 260 ++++++++++++++++-------- project/jni/gl4es/src/glx/glx.h | 79 ++++--- project/jni/gl4es/src/glx/lookup.c | 80 ++++---- 10 files changed, 321 insertions(+), 182 deletions(-) diff --git a/project/jni/gl4es/README.md b/project/jni/gl4es/README.md index 5256f4bab..fd17f187c 100755 --- a/project/jni/gl4es/README.md +++ b/project/jni/gl4es/README.md @@ -216,6 +216,9 @@ Initial Hardware test Version history ---- +##### Current version + * Return some values in glXQueryServerString, coherent with glXGetClientString + ##### 0.9.2 * All matrix are tracked now * Texture Matrix are 100% handled by gl4es. GLES Hardware keep an Identity matrix (TexCoord are transformed if needed). This allows a better handling of NPOT texture on hadware that doesn't support Full NPOT (fixed movies beiing horizontaly shifted in openmw with LIBGL_NPOT=1 for example) diff --git a/project/jni/gl4es/src/gl/array.c b/project/jni/gl4es/src/gl/array.c index 5d0a36aa0..c72469632 100755 --- a/project/jni/gl4es/src/gl/array.c +++ b/project/jni/gl4es/src/gl/array.c @@ -10,7 +10,7 @@ GLvoid *copy_gl_array(const GLvoid *src, if (! stride) stride = width * gl_sizeof(from); - const char *unknown_str = "libGL: copy_gl_array -> unknown type: %x\n"; + const char *unknown_str = "LIBGL: copy_gl_array -> unknown type: %x\n"; GLvoid *dst = malloc((count-skip) * to_width * gl_sizeof(to)); GLsizei from_size = gl_sizeof(from) * width; if (to_width < width) { @@ -73,7 +73,7 @@ GLvoid *copy_gl_array_texcoord(const GLvoid *src, if (! stride) stride = width * gl_sizeof(from); - const char *unknown_str = "libGL: copy_gl_array -> unknown type: %x\n"; + const char *unknown_str = "LIBGL: copy_gl_array -> unknown type: %x\n"; GLvoid *dst = (dest)?dest:malloc((count-skip) * to_width * gl_sizeof(to)); GLsizei from_size = gl_sizeof(from) * width; GLsizei to_elem = gl_sizeof(to); @@ -140,7 +140,7 @@ GLvoid *copy_gl_array_quickconvert(const GLvoid *src, if (! stride) stride = 4 * gl_sizeof(from); - const char *unknown_str = "libGL: copy_gl_array_quickconvert -> unknown type: %x\n"; + const char *unknown_str = "LIBGL: copy_gl_array_quickconvert -> unknown type: %x\n"; GLvoid *dst = malloc((count-skip) * 4 * gl_sizeof(GL_FLOAT)); uintptr_t in = (uintptr_t)src; @@ -176,7 +176,7 @@ GLvoid *copy_gl_array_convert(const GLvoid *src, if (! stride) stride = width * gl_sizeof(from); - const char *unknown_str = "libGL: copy_gl_array_convert -> unknown type: %x\n"; + const char *unknown_str = "LIBGL: copy_gl_array_convert -> unknown type: %x\n"; GLvoid *dst = malloc((count-skip) * to_width * gl_sizeof(to)); GLsizei from_size = gl_sizeof(from) * width; if (to_width < width) { @@ -286,7 +286,7 @@ GLfloat *gl_pointer_index(pointer_state_t *p, GLint index) { buf[i] = 0; }, default: - printf("libGL: unknown pointer type: 0x%x\n", p->type); + printf("LIBGL: unknown pointer type: 0x%x\n", p->type); ) return buf; } @@ -336,3 +336,30 @@ void normalize_indices(GLushort *indices, GLsizei *max, GLsizei *min, GLsizei co indices[i] -= *min; } } + +GLvoid *copy_gl_pointer_color_bgra(pointer_state_t *ptr, GLsizei width, GLsizei skip, GLsizei count) { + // this one only convert from BGRA (unsigned byte) to RGBA FLOAT + GLubyte* src = (GLubyte*)ptr->pointer; + int stride = ptr->stride; + + if (! src || !(count-skip)) + return NULL; + + if (! stride) + stride = 4; + + void* out = malloc(4*sizeof(GLfloat)*(count-skip)); + GLfloat* dst = out; + src += skip*(stride); + + for (int i=skip; ivert = copy_gl_pointer_tex(&glstate->vao->pointers.vertex, 4, skip, count); } if (glstate->vao->color_array) { - list->color = copy_gl_pointer_color(&glstate->vao->pointers.color, 4, skip, count); + if(glstate->vao->pointers.color.size==GL_BGRA) + list->color = copy_gl_pointer_color_bgra(&glstate->vao->pointers.color, 4, skip, count); + else + list->color = copy_gl_pointer_color(&glstate->vao->pointers.color, 4, skip, count); } if (glstate->vao->secondary_array/* && glstate->enable.color_array*/) { - list->secondary = copy_gl_pointer(&glstate->vao->pointers.secondary, 4, skip, count); // alpha chanel is always 0 for secondary... + if(glstate->vao->pointers.secondary.size==GL_BGRA) + list->secondary = copy_gl_pointer_color_bgra(&glstate->vao->pointers.secondary, 4, skip, count); + else + list->secondary = copy_gl_pointer(&glstate->vao->pointers.secondary, 4, skip, count); // alpha chanel is always 0 for secondary... } if (glstate->vao->normal_array) { list->normal = copy_gl_pointer_raw(&glstate->vao->pointers.normal, 3, skip, count); @@ -656,11 +662,19 @@ void glDrawArrays(GLenum mode, GLint first, GLsizei count) AliasExport("gl4es_gl t.size = s; t.type = type; t.stride = stride; t.pointer = pointer + (uintptr_t)((glstate->vao->vertex)?glstate->vao->vertex->data:0) void gl4es_glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { + if(size<1 || size>4) { + errorShim(GL_INVALID_VALUE); + return; + } noerrorShim(); clone_gl_pointer(glstate->vao->pointers.vertex, size); } void gl4es_glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { + if (!((size>0 && size<=4) || (size==GL_BGRA && type==GL_UNSIGNED_BYTE))) { + errorShim(GL_INVALID_VALUE); + return; + } noerrorShim(); clone_gl_pointer(glstate->vao->pointers.color, size); } @@ -670,13 +684,19 @@ void gl4es_glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer) { } void gl4es_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { + if(size<1 || size>4) { + errorShim(GL_INVALID_VALUE); + return; + } noerrorShim(); clone_gl_pointer(glstate->vao->pointers.tex_coord[glstate->texture.client], size); } void gl4es_glSecondaryColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { - if (size!=3) + if (!(size==3 || (size==GL_BGRA && type==GL_UNSIGNED_BYTE))) { + errorShim(GL_INVALID_VALUE); return; // Size must be 3... + } clone_gl_pointer(glstate->vao->pointers.secondary, size); noerrorShim(); } diff --git a/project/jni/gl4es/src/gl/texture.c b/project/jni/gl4es/src/gl/texture.c index 60b02eb8c..1bd12a1fb 100755 --- a/project/jni/gl4es/src/gl/texture.c +++ b/project/jni/gl4es/src/gl/texture.c @@ -102,7 +102,7 @@ void tex_setup_texcoord(GLuint len) { if (!glstate->texture_matrix[texunit]->identity) tex_coord_matrix(tex[texunit], len, getTexMat(texunit)); // NPOT adjust - if ((bound->width!=bound->nwidth) || (bound->height!=bound->nheight)) + if (bound && ((bound->width!=bound->nwidth) || (bound->height!=bound->nheight))) tex_coord_npot(tex[texunit], len, bound->width, bound->height, bound->nwidth, bound->nheight); // All done, setup the texcoord array now gles_glTexCoordPointer(4, GL_FLOAT, 0, tex[texunit]); diff --git a/project/jni/gl4es/src/glx/glx.c b/project/jni/gl4es/src/glx/glx.c index 2e91810aa..9a1e95eea 100755 --- a/project/jni/gl4es/src/glx/glx.c +++ b/project/jni/gl4es/src/glx/glx.c @@ -25,7 +25,18 @@ #include "khash.h" #include "hardext.h" -#define EXPORT __attribute__((visibility("default"))) +//#define EXPORT __attribute__((visibility("default"))) +#ifndef AliasExport +#define AliasExport(name) __attribute__((alias(name))) __attribute__((visibility("default"))) +#endif + + +//#define DEBUG +#ifdef DEBUG +#define DBG(a) a +#else +#define DBG(a) +#endif #ifndef EGL_GL_COLORSPACE_KHR #define EGL_GL_COLORSPACE_KHR 0x309D @@ -200,7 +211,7 @@ static int get_config_default(Display *display, int attribute, int *value) { *value = GLX_RGBA_TYPE; break; case GLX_VISUAL_ID: - *value = glXChooseVisual(display, 0, NULL)->visualid; + *value = gl4es_glXChooseVisual(display, 0, NULL)->visualid; //*value = 1; break; case GLX_FBCONFIG_ID: @@ -378,22 +389,27 @@ void glx_init() { } #ifndef ANDROID -EXPORT GLXContext glXCreateContext(Display *display, +GLXContext gl4es_glXCreateContext(Display *display, XVisualInfo *visual, GLXContext shareList, Bool isDirect) { - //printf("glXCreateContext(%p, %p, %p, %i)\n", display, visual, shareList, isDirect); + DBG(printf("glXCreateContext(%p, %p, %p, %i)\n", display, visual, shareList, isDirect);) EGLint configAttribs[] = { #ifdef PANDORA EGL_RED_SIZE, 5, EGL_GREEN_SIZE, 6, EGL_BLUE_SIZE, 5, +#else + EGL_RED_SIZE, (visual==0)?0:(visual->depth==16)?5:8, + EGL_GREEN_SIZE, (visual==0)?0:(visual->depth==16)?6:8, + EGL_BLUE_SIZE, (visual==0)?0:(visual->depth==16)?5:8, + EGL_ALPHA_SIZE, (visual==0)?0:(visual->depth!=32)?0:8, #endif EGL_DEPTH_SIZE, 16, #ifdef USE_ES2 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, #else - EGL_BUFFER_SIZE, 16, + EGL_BUFFER_SIZE, (visual==0)?16:visual->depth, EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_PBUFFER_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT, #endif @@ -476,7 +492,10 @@ EXPORT GLXContext glXCreateContext(Display *display, #ifdef PANDORA fake->rbits = 5; fake->gbits=6; fake->bbits=5; fake->abits=0; #else - fake->rbits = 8; fake->gbits=8; fake->bbits=8; fake->abits=8; + fake->rbits = (visual==0)?8:(visual->depth==16)?5:8, + fake->gbits= (visual==0)?8:(visual->depth==16)?6:8, + fake->bbits= (visual==0)?8:(visual->depth==16)?5:8, + fake->abits= (visual==0)?8:(visual->depth!=32)?0:8, #endif fake->samples = 0; fake->samplebuffers = 0; @@ -575,10 +594,10 @@ GLXContext createPBufferContext(Display *display, GLXContext shareList, GLXFBCon return fake; } -EXPORT GLXContext glXCreateContextAttribsARB(Display *display, GLXFBConfig config, +GLXContext gl4es_glXCreateContextAttribsARB(Display *display, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list) { - //printf("glXCreateContextAttribsARB(%p, %p, %p, %d) ", display, config, share_context, direct);if(config)printf("config is RGBA:%d%d%d%d, depth=%d, stencil=%d, drawable=%d\n", config->redBits, config->greenBits, config->blueBits, config->alphaBits, config->depthBits, config->stencilBits, config->drawableType); else printf("\n"); + DBG(printf("glXCreateContextAttribsARB(%p, %p, %p, %d) ", display, config, share_context, direct);if(config)printf("config is RGBA:%d%d%d%d, depth=%d, stencil=%d, drawable=%d\n", config->redBits, config->greenBits, config->blueBits, config->alphaBits, config->depthBits, config->stencilBits, config->drawableType); else printf("\n");) if(config && config->drawableType==GLX_PBUFFER_BIT) { return createPBufferContext(display, share_context, config); } else { @@ -691,8 +710,8 @@ EXPORT GLXContext glXCreateContextAttribsARB(Display *display, GLXFBConfig confi } } -EXPORT void glXDestroyContext(Display *display, GLXContext ctx) { - //printf("glXDestroyContext(%p, %p)\n", display, ctx); +void gl4es_glXDestroyContext(Display *display, GLXContext ctx) { + DBG(printf("glXDestroyContext(%p, %p)\n", display, ctx);) if (globals4es.usefb && ctx->contextType==0) { if (fbcontext_count==0) return; // Should not happens! @@ -735,7 +754,8 @@ EXPORT void glXDestroyContext(Display *display, GLXContext ctx) { return; } -EXPORT Display *glXGetCurrentDisplay() { +Display *gl4es_glXGetCurrentDisplay() { + DBG(printf("glXGetCurrentDisplay()\n");) if (!globals4es.usefb) return XOpenDisplay(NULL); else @@ -745,10 +765,10 @@ EXPORT Display *glXGetCurrentDisplay() { return XOpenDisplay(NULL); } -EXPORT XVisualInfo *glXChooseVisual(Display *display, +XVisualInfo *gl4es_glXChooseVisual(Display *display, int screen, int *attributes) { - + DBG(printf("glXChooseVisual(%p, %d, %p)\n", display, screen, attributes);) // apparently can't trust the Display I'm passed? /* if (g_display == NULL) { @@ -775,10 +795,10 @@ EGL_NO_SURFACE, or if draw or read are set to EGL_NO_SURFACE and context is not set to EGL_NO_CONTEXT. */ -EXPORT Bool glXMakeCurrent(Display *display, +Bool gl4es_glXMakeCurrent(Display *display, GLXDrawable drawable, GLXContext context) { - //printf("glXMakeCurrent(%p, %p, %p) 'isPBuffer(drawable)=%d\n", display, drawable, context, isPBuffer(drawable)); + DBG(printf("glXMakeCurrent(%p, %p, %p) 'isPBuffer(drawable)=%d\n", display, drawable, context, isPBuffer(drawable));) LOAD_EGL(eglMakeCurrent); LOAD_EGL(eglDestroySurface); LOAD_EGL(eglCreateWindowSurface); @@ -792,6 +812,11 @@ EXPORT Bool glXMakeCurrent(Display *display, EGLContext eglContext = EGL_NO_CONTEXT; EGLSurface eglSurf = 0; EGLConfig eglConfig = 0; + if(context && glxContext==context && context->drawable==drawable) { + //same context, all is done bye + DBG(printf("Same context and drawable, doing nothing\n");) + return true; + } if(context) { eglContext = context->eglContext; if(context->drawable==drawable && context->eglSurface) @@ -906,13 +931,13 @@ EXPORT Bool glXMakeCurrent(Display *display, return true; } -EXPORT Bool glXMakeContextCurrent(Display *display, int drawable, +Bool gl4es_glXMakeContextCurrent(Display *display, int drawable, int readable, GLXContext context) { - //printf("glXMakeContextCurrent(%p, %X, %X, %p)\n", display, drawable, readable, context); - return glXMakeCurrent(display, drawable, context); + DBG(printf("glXMakeContextCurrent(%p, %X, %X, %p)\n", display, drawable, readable, context);) + return gl4es_glXMakeCurrent(display, drawable, context); } -EXPORT void glXSwapBuffers(Display *display, +void gl4es_glXSwapBuffers(Display *display, int drawable) { static int frames = 0; @@ -1000,29 +1025,40 @@ EXPORT void glXSwapBuffers(Display *display, } } -EXPORT int glXGetConfig(Display *display, +int gl4es_glXGetConfig(Display *display, XVisualInfo *visual, int attribute, int *value) { return get_config_default(display, attribute, value); } -EXPORT const char *glXQueryExtensionsString(Display *display, int screen) { +const char *gl4es_glXQueryExtensionsString(Display *display, int screen) { + DBG(printf("glXQueryExtensionString(%p, %d)\n", display, screen);) const char *extensions = { "GLX_ARB_create_context " "GLX_ARB_create_context_profile " "GLX_ARB_get_proc_address " "GLX_ARB_multisample " + "GLX_SGI_swap_control " + "GLX_MESA_swap_control " + "GLX_EXT_swap_control " // "GLX_EXT_create_context_es2_profile " }; return extensions; } -EXPORT const char *glXQueryServerString(Display *display, int screen, int name) { - return ""; +const char *gl4es_glXQueryServerString(Display *display, int screen, int name) { + DBG(printf("glXQueryServerString(%p, %d, %d)\n", display, screen, name);) + switch (name) { + case GLX_VENDOR: return "ptitSeb"; + case GLX_VERSION: return "1.4 GL4ES"; + case GLX_EXTENSIONS: return gl4es_glXQueryExtensionsString(display, 0); + } + return 0; } -EXPORT Bool glXQueryExtension(Display *display, int *errorBase, int *eventBase) { +Bool gl4es_glXQueryExtension(Display *display, int *errorBase, int *eventBase) { + DBG(printf("glXQuesryExtension(%p, %p, %p)\n", display, errorBase, eventBase);) if (errorBase) *errorBase = 0; @@ -1032,24 +1068,26 @@ EXPORT Bool glXQueryExtension(Display *display, int *errorBase, int *eventBase) return true; } -EXPORT Bool glXQueryVersion(Display *display, int *major, int *minor) { +Bool gl4es_glXQueryVersion(Display *display, int *major, int *minor) { + DBG(printf("glXQueryVersion(%p, %p, %p)\n", display, major, minor);) // TODO: figure out which version we want to pretend to implement *major = 1; *minor = 4; return true; } -EXPORT const char *glXGetClientString(Display *display, int name) { - // TODO: return actual data here +const char *gl4es_glXGetClientString(Display *display, int name) { + DBG(printf("glXGetClientString(%p, %d)\n", display, name);) switch (name) { case GLX_VENDOR: return "ptitSeb"; - case GLX_VERSION: return "1.4 OpenPandora"; - case GLX_EXTENSIONS: break; + case GLX_VERSION: return "1.4 GL4ES"; + case GLX_EXTENSIONS: return gl4es_glXQueryExtensionsString(display, 0); } - return ""; + return 0; } -EXPORT int glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value ){ +int gl4es_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value ) { + DBG(printf("glXQueryContext(%p, %p, %d, %p)\n", dpy, ctx, attribute, value);) *value=0; if (ctx) switch (attribute) { case GLX_FBCONFIG_ID: *value=ctx->xid; break; @@ -1059,14 +1097,9 @@ EXPORT int glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *va return 0; } -/* -EXPORT void glXQueryDrawable( Display *dpy, int draw, int attribute, - unsigned int *value ) { - *value=0; -} -*/ // stubs for glfw (GLX 1.3) -EXPORT GLXContext glXGetCurrentContext() { +GLXContext gl4es_glXGetCurrentContext() { + DBG(printf("glXGetCurrentContext()\n");) // hack to make some games start if (globals4es.usefb) return glxContext ? glxContext : fbContext; @@ -1074,9 +1107,9 @@ EXPORT GLXContext glXGetCurrentContext() { return glxContext; } -EXPORT GLXFBConfig *glXChooseFBConfig(Display *display, int screen, +GLXFBConfig *gl4es_glXChooseFBConfig(Display *display, int screen, const int *attrib_list, int *count) { - //printf("glXChooseFBConfig(%p, %d, %p, %p)\n", display, screen, attrib_list, count); + DBG(printf("glXChooseFBConfig(%p, %d, %p, %p)\n", display, screen, attrib_list, count);) // this is not really good. A static table of all config should be build, and then a filter done according to attribs... static struct __GLXFBConfigRec currentConfig[8]; static int idx = 0; @@ -1137,13 +1170,9 @@ EXPORT GLXFBConfig *glXChooseFBConfig(Display *display, int screen, return configs; } -EXPORT GLXFBConfig *glXChooseFBConfigSGIX(Display *display, int screen, - const int *attrib_list, int *count) { - return glXChooseFBConfig(display, screen, attrib_list, count); -} -EXPORT GLXFBConfig *glXGetFBConfigs(Display *display, int screen, int *count) { - //printf("glXGetFBConfigs(%p, %d, %p)\n", display, screen, count); +GLXFBConfig *gl4es_glXGetFBConfigs(Display *display, int screen, int *count) { + DBG(printf("glXGetFBConfigs(%p, %d, %p)\n", display, screen, count);) *count = 1; // this is to only do 1 malloc instead of 1 for the array and one for the element... GLXFBConfig *configs = (GLXFBConfig *)malloc(sizeof(GLXFBConfig) + sizeof(struct __GLXFBConfigRec)); @@ -1155,8 +1184,8 @@ EXPORT GLXFBConfig *glXGetFBConfigs(Display *display, int screen, int *count) { return configs; } -EXPORT int glXGetFBConfigAttrib(Display *display, GLXFBConfig config, int attribute, int *value) { - //printf("glXGetFBConfigAttrib(%p, %p, 0x%04X, %p)\n", display, config, attribute, value); +int gl4es_glXGetFBConfigAttrib(Display *display, GLXFBConfig config, int attribute, int *value) { + DBG(printf("glXGetFBConfigAttrib(%p, %p, 0x%04X, %p)\n", display, config, attribute, value);) if(!config) return get_config_default(display, attribute, value); @@ -1194,7 +1223,7 @@ EXPORT int glXGetFBConfigAttrib(Display *display, GLXFBConfig config, int attrib *value = GLX_RGBA_TYPE; break; case GLX_VISUAL_ID: - *value = glXChooseVisual(display, 0, NULL)->visualid; //config->associatedVisualId; + *value = gl4es_glXChooseVisual(display, 0, NULL)->visualid; //config->associatedVisualId; //*value = 1; break; case GLX_FBCONFIG_ID: @@ -1222,8 +1251,8 @@ EXPORT int glXGetFBConfigAttrib(Display *display, GLXFBConfig config, int attrib return Success; } -EXPORT XVisualInfo *glXGetVisualFromFBConfig(Display *display, GLXFBConfig config) { - //printf("glXGetVisualFromFBConfig(%p, %p)\n", display, config); +XVisualInfo *gl4es_glXGetVisualFromFBConfig(Display *display, GLXFBConfig config) { + DBG(printf("glXGetVisualFromFBConfig(%p, %p)\n", display, config);) /*if (g_display == NULL) { g_display = XOpenDisplay(NULL); }*/ @@ -1234,21 +1263,22 @@ EXPORT XVisualInfo *glXGetVisualFromFBConfig(Display *display, GLXFBConfig confi return visual; } -EXPORT GLXContext glXCreateNewContext(Display *display, GLXFBConfig config, +GLXContext gl4es_glXCreateNewContext(Display *display, GLXFBConfig config, int render_type, GLXContext share_list, Bool is_direct) { - //printf("glXCreateNewContext(%p, %p, %d, %p, %i), drawableType=0x%02X\n", display, config, render_type, share_list, is_direct, (config)?config->drawableType:0); + DBG(printf("glXCreateNewContext(%p, %p, %d, %p, %i), drawableType=0x%02X\n", display, config, render_type, share_list, is_direct, (config)?config->drawableType:0);) if(render_type!=GLX_RGBA_TYPE) return 0; if(config && config->drawableType==GLX_PBUFFER_BIT) { return createPBufferContext(display, share_list, config); } else - return glXCreateContextAttribsARB(display, config, share_list, is_direct, NULL); + return gl4es_glXCreateContextAttribsARB(display, config, share_list, is_direct, NULL); //return glXCreateContext(display, 0, share_list, is_direct); } #endif //ANDROID -EXPORT void glXSwapIntervalMESA(int interval) { -//LOGD("glXSwapInterval(%i)\n", interval); + +void gl4es_glXSwapInterval(int interval) { + DBG(printf("glXSwapInterval(%i)\n", interval);) #ifdef USE_FBIO if (! globals4es.vsync) LOGD("LIBGL: Enable LIBGL_VSYNC=1 if you want to use vsync.\n"); @@ -1259,35 +1289,44 @@ EXPORT void glXSwapIntervalMESA(int interval) { #endif } -EXPORT void glXSwapIntervalSGI(int interval) { - glXSwapIntervalMESA(interval); -} - #ifndef ANDROID -EXPORT void glXSwapIntervalEXT(Display *display, int drawable, int interval) { - glXSwapIntervalMESA(interval); +void gl4es_glXSwapIntervalEXT(Display *display, int drawable, int interval) { + gl4es_glXSwapInterval(interval); } // misc stubs -EXPORT void glXCopyContext(Display *display, GLXContext src, GLXContext dst, GLuint mask) { +void gl4es_glXCopyContext(Display *display, GLXContext src, GLXContext dst, GLuint mask) { + DBG(printf("glXCopyContext(%p, %p, %p, %04X)\n", display, src, dst, mask);) // mask is ignored for now, but should include glPushAttrib / glPopAttrib memcpy(dst, src, sizeof(struct __GLXContextRec)); } -EXPORT Window glXCreateWindow(Display *display, GLXFBConfig config, Window win, int *attrib_list) {return win;} // should return GLXWindow -EXPORT void glXDestroyWindow(Display *display, void *win) {} // really wants a GLXWindow -EXPORT GLXDrawable glXGetCurrentDrawable() { +Window gl4es_glXCreateWindow(Display *display, GLXFBConfig config, Window win, int *attrib_list) { + // should return GLXWindo + DBG(printf("glXCreateWindow(%p, %p, %d, %p)\n", display, config, win, attrib_list);) + return win; +} +void gl4es_glXDestroyWindow(Display *display, void *win) { + // really wants a GLXWindow + DBG(printf("glXDestroyWindow(%p, %p)\n", display, win);) + +} + +GLXDrawable gl4es_glXGetCurrentDrawable() { + DBG(printf("glXGetCurrentDrawable()\n");) if (glxContext) return glxContext->drawable; else return 0; } // this should actually return GLXDrawable. -EXPORT Bool glXIsDirect(Display * display, GLXContext ctx) { +Bool gl4es_glXIsDirect(Display * display, GLXContext ctx) { + DBG(printf("glXIsDirect(%p, %p)\n", display, ctx);) return true; } -EXPORT void glXUseXFont(Font font, int first, int count, int listBase) { +void gl4es_glXUseXFont(Font font, int first, int count, int listBase) { + DBG(printf("glXUseXFont(%p, %d, %d, %d)\n", font, first, count, listBase);) /* Mostly from MesaGL-9.0.1 * */ @@ -1414,12 +1453,14 @@ EXPORT void glXUseXFont(Font font, int first, int count, int listBase) { // All done } #endif //ANDROID -EXPORT void glXWaitGL() {} -EXPORT void glXWaitX() {} -EXPORT void glXReleaseBuffersMESA() {} +void gl4es_glXWaitGL() {} +void gl4es_glXWaitX() {} +void gl4es_glXReleaseBuffersMESA() {} + #ifndef ANDROID /* TODO proper implementation */ -EXPORT int glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value) { +int gl4es_glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value) { + DBG(printf("glXQueryDrawable(%p, %p, %d, %p)\n", dpy, draw, attribute, value);) int pbuf=isPBuffer(draw); *value = 0; switch(attribute) { @@ -1467,8 +1508,8 @@ void delPBuffer(int j) // should pack, but I think it's useless for common use } -EXPORT void glXDestroyPbuffer(Display * dpy, GLXPbuffer pbuf) { -// printf("glxDestroyPBuffer(%p, %p)\n", dpy, pbuf); +void gl4es_glXDestroyPbuffer(Display * dpy, GLXPbuffer pbuf) { + DBG(printf("glxDestroyPBuffer(%p, %p)\n", dpy, pbuf);) LOAD_EGL(eglDestroySurface); int j=0; while(jdrawableType&GLX_PIXMAP_BIT!=GLX_PIXMAP_BIT) return 0; - return glXCreateGLXPixmap(dpy, NULL, pixmap); + return gl4es_glXCreateGLXPixmap(dpy, NULL, pixmap); } -EXPORT void glXDestroyGLXPixmap(Display *display, void *pixmap) { -//LOGD("glXDestroyGLXPixmap(%p, %p)\n", display, pixmap); +void gl4es_glXDestroyGLXPixmap(Display *display, void *pixmap) { + DBG(printf("glXDestroyGLXPixmap(%p, %p)\n", display, pixmap);) LOAD_EGL(eglDestroySurface); int j=0; while(j