glshim library updated. added changes from a3dd877115

This commit is contained in:
lubomyr
2015-02-28 20:10:00 +00:00
parent 06cee38198
commit 842ec7a4d7
3 changed files with 63 additions and 18 deletions

View File

@@ -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<count; i++)
if (len<sindices[i]) len = sindices[i]; // get the len of the arrays
@@ -613,15 +624,20 @@ void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indic
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<MAX_TEX; aa++)
GLuint old_tex = state.texture.client;
for (int aa=0; aa<MAX_TEX; aa++) {
if (!state.enable.texture_2d[aa] && (state.enable.texture_1d[aa] || state.enable.texture_3d[aa])) {
glClientActiveTexture(aa+GL_TEXTURE0);
gles_glEnable(GL_TEXTURE_2D);
}
if (state.enable.tex_coord_array[aa]) {
tex_setup_texcoord(aa, len);
/*glClientActiveTexture(aa+GL_TEXTURE0);
gles_glTexCoordPointer(state.pointers.tex_coord[aa].size, state.pointers.tex_coord[aa].type, state.pointers.tex_coord[aa].stride, state.pointers.tex_coord[aa].pointer);*/
}
/*if (state.texture.client!=old_tex)
glClientActiveTexture(old_tex+GL_TEXTURE0);*/
}
if (state.texture.client!=old_tex)
glClientActiveTexture(old_tex+GL_TEXTURE0);
if (state.polygon_mode == GL_LINE && mode_init>=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; aa<MAX_TEX; aa++) {
if (!state.enable.texture_2d[aa] && (state.enable.texture_1d[aa] || state.enable.texture_3d[aa])) {
glClientActiveTexture(aa+GL_TEXTURE0);
gles_glDisable(GL_TEXTURE_2D);
}
}
if (state.texture.client!=old_tex)
glClientActiveTexture(old_tex+GL_TEXTURE0);
}
#define shift_pointer(a, b) \
if (state.enable.b && state.pointers.a.buffer) state.pointers.a.pointer -= (uintptr_t)state.pointers.a.buffer->data;
@@ -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<MAX_TEX; aa++)
GLuint old_tex = state.texture.client;
for (int aa=0; aa<MAX_TEX; aa++) {
if (!state.enable.texture_2d[aa] && (state.enable.texture_1d[aa] || state.enable.texture_3d[aa])) {
glClientActiveTexture(aa+GL_TEXTURE0);
gles_glEnable(GL_TEXTURE_2D);
}
if (state.enable.tex_coord_array[aa]) {
tex_setup_texcoord(aa, count+first);
/*glClientActiveTexture(aa+GL_TEXTURE0);
gles_glTexCoordPointer(state.pointers.tex_coord[aa].size, state.pointers.tex_coord[aa].type, state.pointers.tex_coord[aa].stride, state.pointers.tex_coord[aa].pointer);*/
}
/*if (state.texture.client!=old_tex)
glClientActiveTexture(old_tex+GL_TEXTURE0);*/
}
if (state.texture.client!=old_tex)
glClientActiveTexture(old_tex+GL_TEXTURE0);
if (state.polygon_mode == GL_LINE && mode_init>=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; aa<MAX_TEX; aa++) {
if (!state.enable.texture_2d[aa] && (state.enable.texture_1d[aa] || state.enable.texture_3d[aa])) {
glClientActiveTexture(aa+GL_TEXTURE0);
gles_glDisable(GL_TEXTURE_2D);
}
}
if (state.texture.client!=old_tex)
glClientActiveTexture(old_tex+GL_TEXTURE0);
#define shift_pointer(a, b) \
if (state.enable.b && state.pointers.a.buffer) state.pointers.a.pointer = state.pointers.a.pointer - (uintptr_t)state.pointers.a.buffer->data;

View File

@@ -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;

View File

@@ -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);