From 842ec7a4d7cac166c3088894bb879b005a2d143e Mon Sep 17 00:00:00 2001 From: lubomyr Date: Sat, 28 Feb 2015 20:10:00 +0000 Subject: [PATCH] glshim library updated. added changes from https://github.com/ptitSeb/glshim/commit/a3dd877115defb4a2fb38914f9fdd58ae2e09146 --- project/jni/glshim/src/gl/gl.c | 63 +++++++++++++++++++++++------ project/jni/glshim/src/gl/state.h | 4 +- project/jni/glshim/src/gl/texture.c | 14 ++++--- 3 files changed, 63 insertions(+), 18 deletions(-) diff --git a/project/jni/glshim/src/gl/gl.c b/project/jni/glshim/src/gl/gl.c index 87894f906..0ef9ebc0a 100755 --- a/project/jni/glshim/src/gl/gl.c +++ b/project/jni/glshim/src/gl/gl.c @@ -333,13 +333,13 @@ void glGetFloatv(GLenum pname, GLfloat *params) { *params=MAX_STACK_TEXTURE; break; case GL_MODELVIEW_STACK_DEPTH: - *params=(state.modelview_matrix)?1:(state.modelview_matrix->top+1); + *params=(state.modelview_matrix)?(state.modelview_matrix->top+1):1; break; case GL_PROJECTION_STACK_DEPTH: - *params=(state.projection_matrix)?1:(state.projection_matrix->top+1); + *params=(state.projection_matrix)?(state.projection_matrix->top+1):1; break; case GL_TEXTURE_STACK_DEPTH: - *params=(state.texture_matrix)?1:(state.texture_matrix[state.texture.active]->top+1); + *params=(state.texture_matrix)?(state.texture_matrix[state.texture.active]->top+1):1; break; case GL_MAX_LIST_NESTING: *params=64; // fake, no limit in fact @@ -380,7 +380,7 @@ static void proxy_glEnable(GLenum cap, bool enable, void (*next)(GLenum)) { // 2. enable GL_TEXTURE_2D // 3. disable GL_TEXTURE_1D // 4. render. GL_TEXTURE_2D would be disabled. - cap = map_tex_target(cap); + // cap = map_tex_target(cap); // Alpha Hack if (alphahack && (cap==GL_ALPHA_TEST) && enable) @@ -407,6 +407,11 @@ static void proxy_glEnable(GLenum cap, bool enable, void (*next)(GLenum)) { proxy_enable(GL_NORMAL_ARRAY, normal_array); proxy_enable(GL_COLOR_ARRAY, color_array); proxy_enable(GL_TEXTURE_COORD_ARRAY, tex_coord_array[state.texture.client]); + + // Texture 1D and 3D + enable(GL_TEXTURE_1D, texture_1d[state.texture.active]); + enable(GL_TEXTURE_3D, texture_3d[state.texture.active]); + default: errorGL(); next(cap); break; } #undef proxy_enable @@ -471,6 +476,10 @@ GLboolean glIsEnabled(GLenum cap) { return state.enable.color_sum; case GL_SECONDARY_COLOR_ARRAY: return state.enable.secondary_array; + case GL_TEXTURE_1D: + return state.enable.texture_1d[state.texture.active]; + case GL_TEXTURE_3D: + return state.enable.texture_1d[state.texture.active]; default: errorGL(); return gles_glIsEnabled(cap); @@ -565,6 +574,8 @@ void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indic LOAD_GLES(glVertexPointer); LOAD_GLES(glColorPointer); LOAD_GLES(glTexCoordPointer); + LOAD_GLES(glEnable); + LOAD_GLES(glDisable); GLuint len = 0; for (int i=0; i=GL_TRIANGLES) { int n, s; @@ -661,6 +677,14 @@ void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indic free(final_colors); // glColorPointer(old_color.size, old_color.type, old_color.stride, old_color.pointer); } + for (int aa=0; aadata; @@ -686,6 +710,8 @@ void glDrawArrays(GLenum mode, GLint first, GLsizei count) { LOAD_GLES(glVertexPointer); LOAD_GLES(glColorPointer); LOAD_GLES(glTexCoordPointer); + LOAD_GLES(glEnable); + LOAD_GLES(glDisable); renderlist_t *list, *active = state.list.active; if (active && (state.list.compiling || state.gl_batch)) { @@ -753,15 +779,20 @@ void glDrawArrays(GLenum mode, GLint first, GLsizei count) { gles_glNormalPointer(state.pointers.normal.type, state.pointers.normal.stride, state.pointers.normal.pointer); if (state.enable.vertex_array) gles_glVertexPointer(state.pointers.vertex.size, state.pointers.vertex.type, state.pointers.vertex.stride, state.pointers.vertex.pointer); - //GLuint old_tex = state.texture.client; - for (int aa=0; aa=GL_TRIANGLES) { int n, s; @@ -800,6 +831,14 @@ void glDrawArrays(GLenum mode, GLint first, GLsizei count) { if (final_colors) { free(final_colors); } + for (int aa=0; aadata; diff --git a/project/jni/glshim/src/gl/state.h b/project/jni/glshim/src/gl/state.h index 9360891c3..3cf7a689f 100755 --- a/project/jni/glshim/src/gl/state.h +++ b/project/jni/glshim/src/gl/state.h @@ -19,7 +19,9 @@ typedef struct { texgen_s[MAX_TEX], texgen_t[MAX_TEX], texgen_r[MAX_TEX], - texture_2d[MAX_TEX]; + texture_2d[MAX_TEX], + texture_3d[MAX_TEX], + texture_1d[MAX_TEX]; } enable_state_t; diff --git a/project/jni/glshim/src/gl/texture.c b/project/jni/glshim/src/gl/texture.c index ee6ab8687..4d83164ae 100755 --- a/project/jni/glshim/src/gl/texture.c +++ b/project/jni/glshim/src/gl/texture.c @@ -311,7 +311,8 @@ void glTexImage2D(GLenum target, GLint level, GLint internalformat, } } if (bound && (texshrink==2 || texshrink==3)) { - if (((width > ((texshrink==2)?512:256)) && (height > 8)) || ((height > ((texshrink==2)?512:256)) && (width > 8))) { + if (((width%2==0) && (height%2==0)) && + ((width > ((texshrink==2)?512:256)) && (height > 8)) || ((height > ((texshrink==2)?512:256)) && (width > 8))) { GLvoid *out = pixels; pixel_halfscale(pixels, &out, width, height, format, type); if (out != pixels && pixels!=datab) @@ -323,7 +324,8 @@ void glTexImage2D(GLenum target, GLint level, GLint internalformat, } } if (bound && (texshrink==4)) { - if (((width > 256) && (height > 8)) || ((height > 256) && (width > 8))) { + if (((width%4==0) && (height%4==0)) && + ((width > 256) && (height > 8)) || ((height > 256) && (width > 8))) { if ((width>=1024) || (height>=1024)) { GLvoid *out = pixels; pixel_quarterscale(pixels, &out, width, height, format, type); @@ -346,7 +348,8 @@ void glTexImage2D(GLenum target, GLint level, GLint internalformat, } } if (bound && (texshrink==5)) { - while (((width > 256) && (height > 8)) || ((height > 256) && (width > 8))) { + while (((width%2==0) && (height%2==0)) && + ((width > 256) && (height > 8)) || ((height > 256) && (width > 8))) { GLvoid *out = pixels; pixel_halfscale(pixels, &out, width, height, format, type); if (out != pixels && pixels!=datab) @@ -358,8 +361,9 @@ void glTexImage2D(GLenum target, GLint level, GLint internalformat, } } if (bound && (texshrink==6)) { - if (((width > 128) && (height > 8)) || ((height > 128) && (width > 8))) { - if ((width>=512) || (height>=512)) { + if (((width%2==0) && (height%2==0)) && + ((width > 128) && (height > 8)) || ((height > 128) && (width > 8))) { + if (((width%2==0) && (height%2==0)) && (width>=512) || (height>=512)) { while (((width > 256) && (height > 8)) || ((height > 256) && (width > 8))) { GLvoid *out = pixels; pixel_halfscale(pixels, &out, width, height, format, type);