diff --git a/project/jni/glshim/src/gl/buffers.c b/project/jni/glshim/src/gl/buffers.c index 6ba0bdea1..2eb0c7e67 100755 --- a/project/jni/glshim/src/gl/buffers.c +++ b/project/jni/glshim/src/gl/buffers.c @@ -361,7 +361,17 @@ void glBindVertexArray(GLuint array) { // check if needs to copy the data to current vao if ((state.bindedvao!=NULL) && (state.bindedvao->array!=array)) { - memcpy(&state.bindedvao->pointers, &state.pointers, sizeof(state.pointers)); + memcpy(&state.bindedvao->pointers, &state.pointers, sizeof(pointer_states_t)); + state.bindedvao->vertex = state.buffers.vertex; + state.bindedvao->elements = state.buffers.elements; + state.bindedvao->pack = state.buffers.pack; + state.bindedvao->unpack = state.buffers.unpack; + state.bindedvao->secondary_array = state.enable.secondary_array; + state.bindedvao->color_array = state.enable.color_array; + state.bindedvao->normal_array = state.enable.normal_array; + state.bindedvao->vertex_array = state.enable.vertex_array; + memcpy(state.bindedvao->tex_coord_array, state.enable.tex_coord_array, MAX_TEX*sizeof(GLboolean)); + } // if array = 0 => unbind buffer! if (array == 0) { @@ -374,14 +384,24 @@ void glBindVertexArray(GLuint array) { if (k == kh_end(list)){ k = kh_put(glvao, list, array, &ret); glvao = kh_value(list, k) = malloc(sizeof(glvao_t)); - glvao->array = array; // new vao is binded to nothing - memset(&glvao->pointers, 0, sizeof(glvao->pointers)); + memset(glvao, 0, sizeof(glvao_t)); + // just put is number + glvao->array = array; } else { glvao = kh_value(list, k); } state.bindedvao = glvao; - memcpy(&state.pointers, &glvao->pointers, sizeof(state.pointers)); + memcpy(&state.pointers, &glvao->pointers, sizeof(pointer_states_t)); + state.buffers.vertex = glvao->vertex; + state.buffers.elements = glvao->elements; + state.buffers.pack = glvao->pack; + state.buffers.unpack = glvao->unpack; + state.enable.secondary_array = glvao->secondary_array; + state.enable.color_array = glvao->color_array; + state.enable.normal_array = glvao->normal_array; + state.enable.vertex_array = glvao->vertex_array; + memcpy(state.enable.tex_coord_array, glvao->tex_coord_array, MAX_TEX*sizeof(GLboolean)); } noerrorShim(); } diff --git a/project/jni/glshim/src/gl/buffers.h b/project/jni/glshim/src/gl/buffers.h index ce0b621b6..1e3021391 100755 --- a/project/jni/glshim/src/gl/buffers.h +++ b/project/jni/glshim/src/gl/buffers.h @@ -55,11 +55,22 @@ typedef struct { pointer_state_t vertex, color, normal, tex_coord[MAX_TEX], secondary; } pointer_states_t; - // VAO **************** typedef struct { GLuint array; + // pointer state pointer_states_t pointers; + // buffer state + glbuffer_t *vertex; + glbuffer_t *elements; + glbuffer_t *pack; + glbuffer_t *unpack; + // client state + GLboolean secondary_array, + color_array, + normal_array, + vertex_array, + tex_coord_array[MAX_TEX]; } glvao_t; KHASH_MAP_INIT_INT(glvao, glvao_t*) diff --git a/project/jni/glshim/src/gl/texture.c b/project/jni/glshim/src/gl/texture.c index bf94f2697..f7fa07208 100755 --- a/project/jni/glshim/src/gl/texture.c +++ b/project/jni/glshim/src/gl/texture.c @@ -765,11 +765,11 @@ void glTexImage1D(GLenum target, GLint level, GLint internalFormat, glTexImage2D(GL_TEXTURE_2D, level, internalFormat, width, 1, border, format, type, data); } -void glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint yoffset, +void glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *data) { - glTexSubImage2D(GL_TEXTURE_2D, level, xoffset, yoffset, + glTexSubImage2D(GL_TEXTURE_2D, level, xoffset, 0, width, 1, format, type, data); } void glCopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, diff --git a/project/jni/glshim/src/gl/texture.h b/project/jni/glshim/src/gl/texture.h index aa3158407..a0e6178a2 100755 --- a/project/jni/glshim/src/gl/texture.h +++ b/project/jni/glshim/src/gl/texture.h @@ -19,7 +19,7 @@ void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *data); -void glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint yoffset, +void glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *data);