From: José Fonseca Date: Fri, 9 Dec 2011 17:03:01 +0000 (+0000) Subject: Cleanup texture environment state dumping. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=6cba345d8d0aedcb61344ee008305fdcdc08be3d;p=apitrace Cleanup texture environment state dumping. --- diff --git a/glstate.py b/glstate.py index 7ab2dd1..e542a39 100644 --- a/glstate.py +++ b/glstate.py @@ -90,12 +90,19 @@ class StateGetter(Visitor): self.inflector = GetInflector(radical, inflections) self.suffix = suffix - def __call__(self, *args): - pname = args[-1] - + def iter(self): for function, type, count, name in parameters: + inflection = self.inflector.radical + self.suffix + if inflection not in function.split(','): + continue if type is X: continue + yield type, count, name + + def __call__(self, *args): + pname = args[-1] + + for type, count, name in self.iter(): if name == pname: if count != 1: type = Array(type, str(count)) @@ -288,7 +295,6 @@ class StateDumper: self.dump_material_params() self.dump_light_params() self.dump_vertex_attribs() - self.dump_texenv_params() self.dump_program_params() self.dump_texture_parameters() self.dump_framebuffer_parameters() @@ -325,15 +331,22 @@ class StateDumper: print ' }' print + def texenv_param_target(self, name): + if name == 'GL_TEXTURE_LOD_BIAS': + return 'GL_TEXTURE_FILTER_CONTROL' + elif name == 'GL_COORD_REPLACE': + return 'GL_POINT_SPRITE' + else: + return 'GL_TEXTURE_ENV' + def dump_texenv_params(self): for target in ['GL_TEXTURE_ENV', 'GL_TEXTURE_FILTER_CONTROL', 'GL_POINT_SPRITE']: - if target != 'GL_TEXTURE_FILTER_CONTROL': - print ' if (glIsEnabled(%s)) {' % target - else: - print ' {' + print ' {' print ' json.beginMember("%s");' % target print ' json.beginObject();' - self.dump_atoms(glGetTexEnv, target) + for _, _, name in glGetTexEnv.iter(): + if self.texenv_param_target(name) == target: + self.dump_atom(glGetTexEnv, target, name) print ' json.endObject();' print ' }' @@ -401,6 +414,9 @@ class StateDumper: print ' json.endMember(); // %s' % target print ' }' print + print ' if (unit < max_texture_coords) {' + self.dump_texenv_params() + print ' }' print ' json.endObject();' print ' json.endMember(); // GL_TEXTUREi' print ' }' @@ -447,17 +463,18 @@ class StateDumper: print ' }' def dump_atoms(self, getter, *args): - for function, type, count, name in parameters: - inflection = getter.inflector.radical + getter.suffix - if inflection not in function.split(','): - continue - if type is X: - continue + for _, _, name in getter.iter(): + self.dump_atom(getter, *(args + (name,))) + + def dump_atom(self, getter, *args): + name = args[-1] print ' // %s' % name print ' {' - type, value = getter(*(args + (name,))) + #print ' assert(glGetError() == GL_NO_ERROR);' + type, value = getter(*args) print ' if (glGetError() != GL_NO_ERROR) {' #print ' std::cerr << "warning: %s(%s) failed\\n";' % (inflection, name) + print ' while (glGetError() != GL_NO_ERROR) {}' print ' } else {' print ' json.beginMember("%s");' % name JsonWriter().visit(type, value) diff --git a/specs/glparams.py b/specs/glparams.py index eaff783..1641f2a 100644 --- a/specs/glparams.py +++ b/specs/glparams.py @@ -462,7 +462,7 @@ parameters = [ ("", X, 1, "GL_DECAL"), # 0x2101 ("glGetTexEnv", E, 1, "GL_TEXTURE_ENV_MODE"), # 0x2200 ("glGetTexEnv", F, 4, "GL_TEXTURE_ENV_COLOR"), # 0x2201 - ("_glGet", X, 1, "GL_TEXTURE_ENV"), # 0x2300 + ("", X, 1, "GL_TEXTURE_ENV"), # 0x2300 ("", X, 1, "GL_EYE_LINEAR"), # 0x2400 ("", X, 1, "GL_OBJECT_LINEAR"), # 0x2401 ("", X, 1, "GL_SPHERE_MAP"), # 0x2402 @@ -1191,7 +1191,7 @@ parameters = [ ("glGet", F, 1, "GL_MAX_TEXTURE_LOD_BIAS"), # 0x84FD ("glGetTexParameter", F, 1, "GL_TEXTURE_MAX_ANISOTROPY_EXT"), # 0x84FE ("glGet", F, 1, "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT"), # 0x84FF - ("glGetTexEnv", E, 1, "GL_TEXTURE_FILTER_CONTROL"), # 0x8500 + ("", X, 1, "GL_TEXTURE_FILTER_CONTROL"), # 0x8500 ("glGetTexParameter,glGetTexEnv", F, 1, "GL_TEXTURE_LOD_BIAS"), # 0x8501 ("", X, 1, "GL_MODELVIEW1_STACK_DEPTH_EXT"), # 0x8502 ("", X, 1, "GL_COMBINE4_NV"), # 0x8503 @@ -1844,7 +1844,7 @@ parameters = [ ("", X, 1, "GL_HILO8_NV"), # 0x885E ("", X, 1, "GL_SIGNED_HILO8_NV"), # 0x885F ("", X, 1, "GL_FORCE_BLUE_TO_ONE_NV"), # 0x8860 - ("_glGet", B, 1, "GL_POINT_SPRITE"), # 0x8861 + ("glGet", B, 1, "GL_POINT_SPRITE"), # 0x8861 ("glGetTexEnv", B, 1, "GL_COORD_REPLACE"), # 0x8862 ("glGet", E, 1, "GL_POINT_SPRITE_R_MODE_NV"), # 0x8863 ("glGetQuery", I, 1, "GL_QUERY_COUNTER_BITS"), # 0x8864