diff --git a/doomsday/engine/include/gl/gl_texmanager.h b/doomsday/engine/include/gl/gl_texmanager.h index 9f718bee71..67e455edba 100644 --- a/doomsday/engine/include/gl/gl_texmanager.h +++ b/doomsday/engine/include/gl/gl_texmanager.h @@ -201,14 +201,6 @@ GLint GL_MinFilterForVariantSpec(variantspecification_t const *spec); GLint GL_MagFilterForVariantSpec(variantspecification_t const *spec); int GL_LogicalAnisoLevelForVariantSpec(variantspecification_t const *spec); -/** - * Compare the given TextureVariantSpecifications and determine whether they can - * be considered equal (dependent on current engine state and the available features - * of the GL implementation). - */ -int GL_CompareTextureVariantSpecifications(texturevariantspecification_t const *a, - texturevariantspecification_t const *b); - /** * Prepare a TextureVariantSpecification according to usage context. If incomplete * context information is supplied, suitable defaults are chosen in their place. diff --git a/doomsday/engine/include/resource/materialvariantspec.h b/doomsday/engine/include/resource/materialvariantspec.h index 4980a539dd..704a188a58 100644 --- a/doomsday/engine/include/resource/materialvariantspec.h +++ b/doomsday/engine/include/resource/materialvariantspec.h @@ -21,8 +21,7 @@ #define LIBDENG_RESOURCE_MATERIALVARIANTSPEC_H #include "def_data.h" - -struct texturevariantspecification_s; +#include "resource/texture.h" // TextureVariantSpec /// Identifiers for material usage contexts. typedef enum { @@ -58,7 +57,7 @@ struct MaterialVariantSpec materialcontext_t context; /// Specification for the primary texture. - struct texturevariantspecification_s *primarySpec; + texturevariantspecification_t *primarySpec; public: /** diff --git a/doomsday/engine/include/resource/texturevariantspec.h b/doomsday/engine/include/resource/texturevariantspec.h index 1116e6215b..5a8c55ea65 100644 --- a/doomsday/engine/include/resource/texturevariantspec.h +++ b/doomsday/engine/include/resource/texturevariantspec.h @@ -158,4 +158,12 @@ typedef struct texturevariantspecification_s { } data; // type-specific data. } texturevariantspecification_t; +/** + * Compare the given TextureVariantSpecifications and determine whether they can + * be considered equal (dependent on current engine state and the available features + * of the GL implementation). + */ +int TextureVariantSpec_Compare(texturevariantspecification_t const *a, + texturevariantspecification_t const *b); + #endif /* LIBDENG_RESOURCE_TEXTUREVARIANTSPEC_H */ diff --git a/doomsday/engine/src/gl/gl_texmanager.cpp b/doomsday/engine/src/gl/gl_texmanager.cpp index a1ef29ea78..6a0cb60c43 100644 --- a/doomsday/engine/src/gl/gl_texmanager.cpp +++ b/doomsday/engine/src/gl/gl_texmanager.cpp @@ -309,47 +309,6 @@ static texturevariantspecification_t *copyDetailVariantSpecification( return spec; } -#endif // __CLIENT__ - -/** - * @todo Magnification, Anisotropic filter level and GL texture wrap modes - * will be handled through dynamic changes to GL's texture environment state. - * Consequently they should be ignored here. - */ -static int compareVariantSpecifications(variantspecification_t const *a, - variantspecification_t const *b) -{ - /// @todo We can be a bit cleverer here... - if(a->context != b->context) return 0; - if(a->flags != b->flags) return 0; - if(a->wrapS != b->wrapS || a->wrapT != b->wrapT) return 0; - //if(a->magFilter != b->magFilter) return 0; - //if(a->anisoFilter != b->anisoFilter) return 0; - if(a->mipmapped != b->mipmapped) return 0; - if(a->noStretch != b->noStretch) return 0; - if(a->gammaCorrection != b->gammaCorrection) return 0; - if(a->toAlpha != b->toAlpha) return 0; - if(a->border != b->border) return 0; - if(a->flags & TSF_HAS_COLORPALETTE_XLAT) - { - colorpalettetranslationspecification_t const *cptA = a->translated; - colorpalettetranslationspecification_t const *cptB = b->translated; - DENG_ASSERT(cptA && cptB); - if(cptA->tClass != cptB->tClass) return 0; - if(cptA->tMap != cptB->tMap) return 0; - } - return 1; // Equal. -} - -static int compareDetailVariantSpecifications(detailvariantspecification_t const *a, - detailvariantspecification_t const *b) -{ - if(a->contrast != b->contrast) return 0; - return 1; // Equal. -} - -#ifdef __CLIENT__ - static colorpalettetranslationspecification_t *applyColorPaletteTranslationSpecification( colorpalettetranslationspecification_t *spec, int tClass, int tMap) { @@ -467,7 +426,7 @@ static texturevariantspecification_t *findVariantSpecification( // Do we already have a concrete version of the template specification? for(; node; node = node->next) { - if(GL_CompareTextureVariantSpecifications(node->spec, &tpl)) + if(TextureVariantSpec_Compare(node->spec, &tpl)) return node->spec; } @@ -1130,25 +1089,6 @@ void GL_InitTextureManager() initedOk = true; } -#endif // __CLIENT__ - -int GL_CompareTextureVariantSpecifications(texturevariantspecification_t const *a, - texturevariantspecification_t const *b) -{ - DENG_ASSERT(a && b); - if(a == b) return 1; - if(a->type != b->type) return 0; - switch(a->type) - { - case TST_GENERAL: return compareVariantSpecifications(TS_GENERAL(*a), TS_GENERAL(*b)); - case TST_DETAIL: return compareDetailVariantSpecifications(TS_DETAIL(*a), TS_DETAIL(*b)); - } - Con_Error("GL_CompareTextureVariantSpecifications: Invalid type %i.", (int) a->type); - exit(1); // Unreachable. -} - -#ifdef __CLIENT__ - void GL_ResetTextureManager() { if(!initedOk) return; diff --git a/doomsday/engine/src/resource/materialvariant.cpp b/doomsday/engine/src/resource/materialvariant.cpp index 588514b9e3..12412272eb 100644 --- a/doomsday/engine/src/resource/materialvariant.cpp +++ b/doomsday/engine/src/resource/materialvariant.cpp @@ -27,7 +27,6 @@ #endif #include "map/r_world.h" // R_UpdateMapSurfacesOnMaterialChange -#include "gl/gl_texmanager.h" // GL_CompareTextureVariantSpecifications #include "render/r_main.h" // frameTimePos #include "resource/materialvariantspec.h" @@ -38,7 +37,7 @@ bool MaterialVariantSpec::compare(MaterialVariantSpec const &other) const { if(this == &other) return 1; if(context != other.context) return 0; - return 1 == GL_CompareTextureVariantSpecifications(primarySpec, other.primarySpec); + return 1 == TextureVariantSpec_Compare(primarySpec, other.primarySpec); } struct Material::Variant::Instance diff --git a/doomsday/engine/src/resource/texture.cpp b/doomsday/engine/src/resource/texture.cpp index 6ee15645b4..cd243c136c 100644 --- a/doomsday/engine/src/resource/texture.cpp +++ b/doomsday/engine/src/resource/texture.cpp @@ -205,7 +205,7 @@ Texture::Variant *Texture::chooseVariant(ChooseVariantMethod method, break; case FuzzyMatchSpec: - if(GL_CompareTextureVariantSpecifications(&cand, &spec)) + if(TextureVariantSpec_Compare(&cand, &spec)) { // This will do fine. return *i; diff --git a/doomsday/engine/src/resource/texturevariant.cpp b/doomsday/engine/src/resource/texturevariant.cpp index a5d52cf214..f1288677a0 100644 --- a/doomsday/engine/src/resource/texturevariant.cpp +++ b/doomsday/engine/src/resource/texturevariant.cpp @@ -19,6 +19,57 @@ #include "resource/texture.h" +/** + * @todo Magnification, Anisotropic filter level and GL texture wrap modes + * will be handled through dynamic changes to GL's texture environment state. + * Consequently they should be ignored here. + */ +static int compareVariantSpecifications(variantspecification_t const *a, + variantspecification_t const *b) +{ + /// @todo We can be a bit cleverer here... + if(a->context != b->context) return 0; + if(a->flags != b->flags) return 0; + if(a->wrapS != b->wrapS || a->wrapT != b->wrapT) return 0; + //if(a->magFilter != b->magFilter) return 0; + //if(a->anisoFilter != b->anisoFilter) return 0; + if(a->mipmapped != b->mipmapped) return 0; + if(a->noStretch != b->noStretch) return 0; + if(a->gammaCorrection != b->gammaCorrection) return 0; + if(a->toAlpha != b->toAlpha) return 0; + if(a->border != b->border) return 0; + if(a->flags & TSF_HAS_COLORPALETTE_XLAT) + { + colorpalettetranslationspecification_t const *cptA = a->translated; + colorpalettetranslationspecification_t const *cptB = b->translated; + DENG_ASSERT(cptA && cptB); + if(cptA->tClass != cptB->tClass) return 0; + if(cptA->tMap != cptB->tMap) return 0; + } + return 1; // Equal. +} + +static int compareDetailVariantSpecifications(detailvariantspecification_t const *a, + detailvariantspecification_t const *b) +{ + if(a->contrast != b->contrast) return 0; + return 1; // Equal. +} + +int TextureVariantSpec_Compare(texturevariantspecification_t const *a, + texturevariantspecification_t const *b) +{ + DENG_ASSERT(a && b); + if(a == b) return 1; + if(a->type != b->type) return 0; + switch(a->type) + { + case TST_GENERAL: return compareVariantSpecifications(TS_GENERAL(*a), TS_GENERAL(*b)); + case TST_DETAIL: return compareDetailVariantSpecifications(TS_DETAIL(*a), TS_DETAIL(*b)); + } + throw de::Error("TextureVariantSpec_Compare", QString("Invalid type %1").arg(a->type)); +} + namespace de { struct Texture::Variant::Instance