glshim updated, added latest changes by ptitSeb

This commit is contained in:
lubomyr
2015-10-31 13:48:44 +02:00
parent 88977dc7bb
commit a2d6acad8c
4 changed files with 39 additions and 8 deletions

View File

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

View File

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

View File

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

View File

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