X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=flavors%2Fgl%2Fsource%2Fglstate.cpp;fp=flavors%2Fgl%2Fsource%2Fglstate.cpp;h=750d70315835a45395512512ce04ff2a2963cf3d;hb=d72ef6d75a11f6cc05ab8ec039520719e1044741;hp=7f67596f099aa6581f2ef58c353d5cc40fb276ae;hpb=cbf00fed7d2ab4d3a6593a1f230d17f21bc61818;p=gldbg.git diff --git a/flavors/gl/source/glstate.cpp b/flavors/gl/source/glstate.cpp index 7f67596..750d703 100644 --- a/flavors/gl/source/glstate.cpp +++ b/flavors/gl/source/glstate.cpp @@ -63,21 +63,22 @@ Vector4::Vector4(): GlState::GlState(): decoder(gldecoder_new(this, NULL)), + texcoord(1), active_tex(0), client_active_tex(0), + texunits(1), array_buffer(0), element_buffer(0), uniform_buffer(0), - uniform_bind_points(64) + texcoord_arrays(1) { vertex_array.kind = GL_VERTEX_ARRAY; normal_array.kind = GL_NORMAL_ARRAY; color_array.kind = GL_COLOR_ARRAY; - for(unsigned i=0; i<8; ++i) - { - texcoord_arrays[i].kind = GL_TEXTURE_COORD_ARRAY; - texcoord_arrays[i].index = i; - } + texcoord_arrays[0].kind = GL_TEXTURE_COORD_ARRAY; + texcoord_arrays[0].index = 0; + + decoder->glGetIntegerv = glGetIntegerv; decoder->glEnableClientState = glEnableClientState; decoder->glDisableClientState = glDisableClientState; @@ -169,6 +170,30 @@ int GlState::decode(const char *data, unsigned len) return gldecoder_decode(decoder, data, len); } +void GlState::glGetIntegerv(void *user_data, GLenum pname, int *param) +{ + GlState *self = reinterpret_cast(user_data); + if(pname==GL_MAX_TEXTURE_UNITS) + { + self->texcoord.resize(*param); + self->texunits.resize(*param); + self->texcoord_arrays.resize(*param); + for(unsigned i=0; itexcoord_arrays.size(); ++i) + { + self->texcoord_arrays[i].kind = GL_TEXTURE_COORD_ARRAY; + self->texcoord_arrays[i].index = i; + } + } + else if(pname==GL_MAX_VERTEX_ATTRIBS) + { + self->attrib_arrays.resize(*param); + for(unsigned i=0; iattrib_arrays.size(); ++i) + self->attrib_arrays[i].index = i; + } + else if(pname==GL_MAX_UNIFORM_BUFFER_BINDINGS) + self->uniform_bind_points.resize(*param); +} + // Boolean state bool &GlState::get_boolean_state(GLenum state) @@ -252,18 +277,6 @@ void GlState::glMultiTexCoord4f(void *user_data, unsigned index, float s, float // Vertex arrays -ArrayState &GlState::get_attrib_array(unsigned index) -{ - map::iterator i = attrib_arrays.find(index); - if(i!=attrib_arrays.end()) - return i->second; - - ArrayState &array = attrib_arrays[index]; - array.index = index; - - return array; -} - void GlState::glVertexPointer(void *user_data, int size, GLenum type, int stride, const void *data) { GlState *self = reinterpret_cast(user_data); @@ -306,7 +319,7 @@ void GlState::glDisableVertexAttribArray(void *user_data, unsigned index) void GlState::glVertexAttribPointer(void *user_data, unsigned index, int size, GLenum type, unsigned char norm, int stride, const void *data) { GlState *self = reinterpret_cast(user_data); - self->get_attrib_array(index).set(size, type, norm, stride, self->array_buffer, reinterpret_cast(data)); + self->attrib_arrays[index].set(size, type, norm, stride, self->array_buffer, reinterpret_cast(data)); } const ArrayState &GlState::get_array(GLenum array) const @@ -330,12 +343,7 @@ const ArrayState &GlState::get_texture_coord_array(unsigned index) const const ArrayState &GlState::get_attrib_array(unsigned index) const { - map::const_iterator i = attrib_arrays.find(index); - if(i!=attrib_arrays.end()) - return i->second; - - // XXX Return a dummy? - throw runtime_error("Unknown attribute array"); + return attrib_arrays[index]; } // Array draw commands