From 883476dd7f035bfca1f02bc1284c21c5015cb0fd Mon Sep 17 00:00:00 2001 From: danij Date: Sun, 23 Dec 2012 11:44:27 +0000 Subject: [PATCH] Refactor|Texture: Dumped Texture's now redundant C wrapper API --- doomsday/engine/include/gl/gl_texmanager.h | 16 +- doomsday/engine/include/render/r_draw.h | 8 +- doomsday/engine/include/resource/r_data.h | 7 +- doomsday/engine/include/resource/texture.h | 345 ++++++++---------- doomsday/engine/src/gl/dgl_common.cpp | 2 +- doomsday/engine/src/render/r_draw.cpp | 20 +- doomsday/engine/src/render/rend_model.cpp | 4 +- doomsday/engine/src/resource/material.cpp | 12 +- .../engine/src/resource/materialsnapshot.cpp | 4 +- .../engine/src/resource/materialvariant.cpp | 6 +- doomsday/engine/src/resource/models.cpp | 10 +- doomsday/engine/src/resource/r_data.cpp | 10 +- doomsday/engine/src/resource/texture.cpp | 110 ------ 13 files changed, 204 insertions(+), 350 deletions(-) diff --git a/doomsday/engine/include/gl/gl_texmanager.h b/doomsday/engine/include/gl/gl_texmanager.h index f0f147313e..7e093936d8 100644 --- a/doomsday/engine/include/gl/gl_texmanager.h +++ b/doomsday/engine/include/gl/gl_texmanager.h @@ -129,7 +129,7 @@ void GL_ReleaseTexturesByScheme(char const *schemeName); * Release all textures associated with the specified @a texture. * @param texture Logical Texture. Can be @c NULL, in which case this is a null-op. */ -void GL_ReleaseGLTexturesByTexture(Texture *texture); +void GL_ReleaseGLTexturesByTexture(struct texture_s *texture); /** * Release all textures associated with the specified variant @a texture. @@ -142,7 +142,7 @@ void GL_ReleaseVariantTexture(struct texturevariant_s *texture); * @param texture Logical Texture to process. Can be @c NULL, in which case this is a null-op. * @param spec Specification to match. Comparision mode is exact and not fuzzy. */ -void GL_ReleaseVariantTexturesBySpec(Texture *tex, texturevariantspecification_t *spec); +void GL_ReleaseVariantTexturesBySpec(struct texture_s *tex, texturevariantspecification_t *spec); /// Release all textures associated with the identified colorpalette @a paletteId. void GL_ReleaseTexturesByColorPalette(colorpaletteid_t paletteId); @@ -262,14 +262,14 @@ typedef enum { * * @return GL-name of the prepared texture if successful else @c 0 */ -DGLuint GL_PrepareTexture2(Texture *tex, texturevariantspecification_t *spec, preparetextureresult_t *returnOutcome); -DGLuint GL_PrepareTexture(Texture *tex, texturevariantspecification_t *spec/*, returnOutcome = 0 */); +DGLuint GL_PrepareTexture2(struct texture_s *tex, texturevariantspecification_t *spec, preparetextureresult_t *returnOutcome); +DGLuint GL_PrepareTexture(struct texture_s *tex, texturevariantspecification_t *spec/*, returnOutcome = 0 */); /** * Same as GL_PrepareTexture(2) except for visibility of TextureVariant. */ -struct texturevariant_s *GL_PrepareTextureVariant2(Texture *tex, texturevariantspecification_t *spec, preparetextureresult_t *returnOutcome); -struct texturevariant_s *GL_PrepareTextureVariant(Texture *tex, texturevariantspecification_t *spec/*, returnOutcome = 0 */); +struct texturevariant_s *GL_PrepareTextureVariant2(struct texture_s *tex, texturevariantspecification_t *spec, preparetextureresult_t *returnOutcome); +struct texturevariant_s *GL_PrepareTextureVariant(struct texture_s *tex, texturevariantspecification_t *spec/*, returnOutcome = 0 */); /** * Bind this texture to the currently active texture unit. @@ -310,8 +310,8 @@ DGLuint GL_PrepareLightmap(Uri const *path); DGLuint GL_PrepareLSTexture(lightingtexid_t which); DGLuint GL_PrepareRawTexture(rawtex_t *rawTex); -struct texturevariant_s *GL_PreparePatchTexture2(Texture *tex, int wrapS, int wrapT); -struct texturevariant_s *GL_PreparePatchTexture(Texture *tex); +struct texturevariant_s *GL_PreparePatchTexture2(struct texture_s *tex, int wrapS, int wrapT); +struct texturevariant_s *GL_PreparePatchTexture(struct texture_s *tex); /** * Attempt to locate and prepare a flare texture. diff --git a/doomsday/engine/include/render/r_draw.h b/doomsday/engine/include/render/r_draw.h index 0f233efbf1..ea19e04ec9 100644 --- a/doomsday/engine/include/render/r_draw.h +++ b/doomsday/engine/include/render/r_draw.h @@ -39,11 +39,11 @@ void R_SetBorderGfx(Uri const *const *paths); */ void R_DrawViewBorder(void); -void R_DrawPatch(Texture *texture, int x, int y); -void R_DrawPatch2(Texture *texture, int x, int y, int w, int h); -void R_DrawPatch3(Texture *texture, int x, int y, int w, int h, boolean useOffsets); +void R_DrawPatch(struct texture_s *texture, int x, int y); +void R_DrawPatch2(struct texture_s *texture, int x, int y, int w, int h); +void R_DrawPatch3(struct texture_s *texture, int x, int y, int w, int h, boolean useOffsets); -void R_DrawPatchTiled(Texture *texture, int x, int y, int w, int h, int wrapS, int wrapT); +void R_DrawPatchTiled(struct texture_s *texture, int x, int y, int w, int h, int wrapS, int wrapT); #ifdef __cplusplus } // extern "C" diff --git a/doomsday/engine/include/resource/r_data.h b/doomsday/engine/include/resource/r_data.h index a65761a2e5..80cd80a746 100644 --- a/doomsday/engine/include/resource/r_data.h +++ b/doomsday/engine/include/resource/r_data.h @@ -26,9 +26,8 @@ #include "dd_def.h" #include "thinker.h" #include "def_data.h" -#include "textures.h" +#include "resource/textures.h" -struct texture_s; struct font_s; /** @@ -87,8 +86,8 @@ AutoStr *R_ComposePatchPath(patchid_t id); #endif #ifdef __cplusplus -struct texture_s *R_DefineTexture(de::String schemeName, de::Uri const &resourceUri, QSize const &dimensions); -struct texture_s *R_DefineTexture(de::String schemeName, de::Uri const &resourceUri); +de::Texture *R_DefineTexture(de::String schemeName, de::Uri const &resourceUri, QSize const &dimensions); +de::Texture *R_DefineTexture(de::String schemeName, de::Uri const &resourceUri); #endif #endif /// LIBDENG_REFRESH_DATA_H diff --git a/doomsday/engine/include/resource/texture.h b/doomsday/engine/include/resource/texture.h index 7fe3ee9543..fab5a16e66 100644 --- a/doomsday/engine/include/resource/texture.h +++ b/doomsday/engine/include/resource/texture.h @@ -58,208 +58,169 @@ typedef enum { namespace de { -class TextureManifest; + class TextureManifest; -/** - * Logical texture object. - * @ingroup resource - */ -class Texture -{ -public: /** - * Classification/processing flags + * Logical texture object. + * @ingroup resource */ - enum Flag + class Texture { - /// Texture is not to be drawn. - NoDraw = 0x1, - - /// Texture is "custom" (i.e., not an original game resource). - Custom = 0x2, - - /// Apply the monochrome filter to the processed image. - Monochrome = 0x4, - - /// Apply the upscaleAndSharpen filter to the processed image. - UpscaleAndSharpen = 0x8 + public: + /** + * Classification/processing flags + */ + enum Flag + { + /// Texture is not to be drawn. + NoDraw = 0x1, + + /// Texture is "custom" (i.e., not an original game resource). + Custom = 0x2, + + /// Apply the monochrome filter to the processed image. + Monochrome = 0x4, + + /// Apply the upscaleAndSharpen filter to the processed image. + UpscaleAndSharpen = 0x8 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + typedef std::list Variants; + + public: + /** + * @param manifest Manifest derived to yield the texture. + * @param userData User data to associate with the resultant texture. + */ + Texture(TextureManifest &manifest, void *userData = 0); + + ~Texture(); + + /// @return Provides access to the classification/processing flags. + Flags const &flags() const; + + /// @return Provides access to the classification/processing flags. + Flags &flags(); + + /** + * Returns the TextureManifest derived to yield the texture. + */ + TextureManifest &manifest() const; + + /** + * Retrieve the value of the associated user data pointer. + * @return Associated data pointer value. + */ + void *userDataPointer() const; + + /** + * Set the user data pointer value. Ownership of the data is not given to + * this instance. + * + * @note If already set the old value will be replaced (so if it points + * to some dynamically constructed data/resource it is the caller's + * responsibility to release it beforehand). + * + * @param userData User data pointer value. + */ + void setUserDataPointer(void *userData); + + /** + * Add a new prepared variant to the list of resources for this Texture. + * Texture takes ownership of the variant. + * + * @param variant Variant instance to add to the resource list. + */ + TextureVariant &addVariant(TextureVariant &variant); + + /// @return Number of variants for the texture. + uint variantCount() const; + + /// Destroy all analyses for the texture. + void clearAnalyses(); + + /// Destroy all prepared variants for the texture. + void clearVariants(); + + /** + * Retrieve the value of an identified @a analysis data pointer. + * @return Associated data pointer value. + **/ + void *analysisDataPointer(texture_analysisid_t analysis) const; + + /** + * Set the value of an identified @a analysis data pointer. Ownership of + * the data is not given to this instance. + * + * @note If already set the old value will be replaced (so if it points + * to some dynamically constructed data/resource it is the caller's + * responsibility to release it beforehand). + * + * @param analysis Identifier of the data being attached. + * @param data Data to be attached. + */ + void setAnalysisDataPointer(texture_analysisid_t analysis, void *data); + + /** + * Returns the world width of the texture in map coordinate space units. + */ + int width() const; + + /** + * Returns the world height of the texture in map coordinate space units. + */ + int height() const; + + /** + * Returns the world dimensions [width, height] of the texture in map + * coordinate space units. + */ + QSize const &dimensions() const; + + /** + * Change the world width of the texture. + * @param newWidth New width in map coordinate space units. + */ + void setWidth(int newWidth); + + /** + * Change the world height of the texture. + * @param newHeight New height in map coordinate space units. + */ + void setHeight(int newHeight); + + /** + * Change the world dimensions of the texture. + * @param newDimensions New dimensions [width, height] in map coordinate space units. + */ + void setDimensions(QSize const &newDimensions); + + /** + * Returns the world origin offset of texture in map coordinate space units. + */ + QPoint const &origin() const; + + /** + * Change the world origin offset of the texture. + * @param newOrigin New origin in map coordinate space units. + */ + void setOrigin(QPoint const &newOrigin); + + /** + * Provides access to the list of variant textures for efficent traversals. + */ + Variants const &variantList() const; + + private: + struct Instance; + Instance *d; }; - Q_DECLARE_FLAGS(Flags, Flag) - - typedef std::list Variants; - -public: - /** - * @param manifest Manifest derived to yield the texture. - * @param userData User data to associate with the resultant texture. - */ - Texture(TextureManifest &manifest, void *userData = 0); - - ~Texture(); - - /// @return Provides access to the classification/processing flags. - Flags const &flags() const; - - /// @return Provides access to the classification/processing flags. - Flags &flags(); - - /** - * Returns the TextureManifest derived to yield the texture. - */ - TextureManifest &manifest() const; - - /** - * Retrieve the value of the associated user data pointer. - * @return Associated data pointer value. - */ - void *userDataPointer() const; - - /** - * Set the user data pointer value. Ownership of the data is not given to - * this instance. - * - * @note If already set the old value will be replaced (so if it points - * to some dynamically constructed data/resource it is the caller's - * responsibility to release it beforehand). - * - * @param userData User data pointer value. - */ - void setUserDataPointer(void *userData); - - /** - * Add a new prepared variant to the list of resources for this Texture. - * Texture takes ownership of the variant. - * - * @param variant Variant instance to add to the resource list. - */ - TextureVariant &addVariant(TextureVariant &variant); - - /// @return Number of variants for the texture. - uint variantCount() const; - - /// Destroy all analyses for the texture. - void clearAnalyses(); - - /// Destroy all prepared variants for the texture. - void clearVariants(); - - /** - * Retrieve the value of an identified @a analysis data pointer. - * @return Associated data pointer value. - **/ - void *analysisDataPointer(texture_analysisid_t analysis) const; - - /** - * Set the value of an identified @a analysis data pointer. Ownership of - * the data is not given to this instance. - * - * @note If already set the old value will be replaced (so if it points - * to some dynamically constructed data/resource it is the caller's - * responsibility to release it beforehand). - * - * @param analysis Identifier of the data being attached. - * @param data Data to be attached. - */ - void setAnalysisDataPointer(texture_analysisid_t analysis, void *data); - - /** - * Returns the world width of the texture in map coordinate space units. - */ - int width() const; - - /** - * Returns the world height of the texture in map coordinate space units. - */ - int height() const; - - /** - * Returns the world dimensions [width, height] of the texture in map - * coordinate space units. - */ - QSize const &dimensions() const; - - /** - * Change the world width of the texture. - * @param newWidth New width in map coordinate space units. - */ - void setWidth(int newWidth); - - /** - * Change the world height of the texture. - * @param newHeight New height in map coordinate space units. - */ - void setHeight(int newHeight); - - /** - * Change the world dimensions of the texture. - * @param newDimensions New dimensions [width, height] in map coordinate space units. - */ - void setDimensions(QSize const &newDimensions); - - /** - * Returns the world origin offset of texture in map coordinate space units. - */ - QPoint const &origin() const; - - /** - * Change the world origin offset of the texture. - * @param newOrigin New origin in map coordinate space units. - */ - void setOrigin(QPoint const &newOrigin); - - /** - * Provides access to the list of variant textures for efficent traversals. - */ - Variants const &variantList() const; - -private: - struct Instance; - Instance *d; -}; } // namespace de -extern "C" { #endif // __cplusplus -/** - * C wrapper API: - */ - struct texture_s; // The texture instance (opaque). -typedef struct texture_s Texture; - -void* Texture_UserDataPointer(Texture const *tex); -void Texture_SetUserDataPointer(Texture *tex, void *userData); - -void Texture_ClearVariants(Texture *tex); -uint Texture_VariantCount(Texture const *tex); -struct texturevariant_s *Texture_AddVariant(Texture *tex, struct texturevariant_s *variant); - -void* Texture_AnalysisDataPointer(Texture const *tex, texture_analysisid_t analysis); -void Texture_SetAnalysisDataPointer(Texture *tex, texture_analysisid_t analysis, void *data); - -int Texture_Width(Texture const *tex); -int Texture_Height(Texture const *tex); -void Texture_SetWidth(Texture *tex, int width); -void Texture_SetHeight(Texture *tex, int height); - -/** - * Iterate over all derived TextureVariants, making a callback for each. - * Iteration ends once all variants have been visited, or immediately upon - * a callback returning non-zero. - * - * @param tex Texture instance. - * @param callback Callback to make for each processed variant. - * @param parameters Passed to the callback. - * - * @return @c 0 iff iteration completed wholly. - */ -int Texture_IterateVariants(Texture *tex, - int (*callback)(struct texturevariant_s *instance, void *parameters), void *parameters); - -#ifdef __cplusplus -} // extern "C" -#endif #endif /// LIBDENG_RESOURCE_TEXTURE_H diff --git a/doomsday/engine/src/gl/dgl_common.cpp b/doomsday/engine/src/gl/dgl_common.cpp index eac6b7479a..fa7dcc60e1 100644 --- a/doomsday/engine/src/gl/dgl_common.cpp +++ b/doomsday/engine/src/gl/dgl_common.cpp @@ -723,7 +723,7 @@ void DGL_SetPatch(patchid_t id, DGLint wrapS, DGLint wrapT) { try { - Texture *tex = reinterpret_cast(App_Textures()->scheme("Patches").findByUniqueId(id).texture()); + struct texture_s *tex = reinterpret_cast(App_Textures()->scheme("Patches").findByUniqueId(id).texture()); if(!tex) return; GL_BindTexture(GL_PreparePatchTexture2(tex, DGL_ToGLWrapCap(wrapS), DGL_ToGLWrapCap(wrapT))); diff --git a/doomsday/engine/src/render/r_draw.cpp b/doomsday/engine/src/render/r_draw.cpp index 876ea860d8..6ea2449ab8 100644 --- a/doomsday/engine/src/render/r_draw.cpp +++ b/doomsday/engine/src/render/r_draw.cpp @@ -127,7 +127,7 @@ void R_ShutdownViewWindow(void) inited = false; } -void R_DrawPatch3(Texture *_tex, int x, int y, int w, int h, boolean useOffsets) +void R_DrawPatch3(struct texture_s *_tex, int x, int y, int w, int h, boolean useOffsets) { if(!_tex) return; de::Texture &tex = reinterpret_cast(*_tex); @@ -151,22 +151,26 @@ void R_DrawPatch3(Texture *_tex, int x, int y, int w, int h, boolean useOffsets) GL_DrawRectf2Color(x, y, w, h, 1, 1, 1, 1); } -void R_DrawPatch2(Texture *tex, int x, int y, int w, int h) +void R_DrawPatch2(struct texture_s *tex, int x, int y, int w, int h) { R_DrawPatch3(tex, x, y, w, h, true); } -void R_DrawPatch(Texture *tex, int x, int y) +void R_DrawPatch(struct texture_s *_tex, int x, int y) { - R_DrawPatch2(tex, x, y, Texture_Width(tex), Texture_Height(tex)); + if(!_tex) return; + de::Texture &tex = reinterpret_cast(*_tex); + + R_DrawPatch2(_tex, x, y, tex.width(), tex.height()); } -void R_DrawPatchTiled(Texture *tex, int x, int y, int w, int h, int wrapS, int wrapT) +void R_DrawPatchTiled(struct texture_s *_tex, int x, int y, int w, int h, int wrapS, int wrapT) { - if(!tex) return; + if(!_tex) return; + de::Texture &tex = reinterpret_cast(*_tex); - GL_BindTexture(GL_PreparePatchTexture2(tex, wrapS, wrapT)); - GL_DrawRectf2Tiled(x, y, w, h, Texture_Width(tex), Texture_Height(tex)); + GL_BindTexture(GL_PreparePatchTexture2(_tex, wrapS, wrapT)); + GL_DrawRectf2Tiled(x, y, w, h, tex.width(), tex.height()); } materialvariantspecification_t const *Ui_MaterialSpec() diff --git a/doomsday/engine/src/render/rend_model.cpp b/doomsday/engine/src/render/rend_model.cpp index f28d1c41d5..b56b1ee239 100644 --- a/doomsday/engine/src/render/rend_model.cpp +++ b/doomsday/engine/src/render/rend_model.cpp @@ -1064,7 +1064,7 @@ static void Mod_RenderSubModel(uint number, rendmodelparams_t const *parm) // Ensure we've prepared the shiny skin. if(shininess > 0) { - Texture *tex = mf->sub[number].shinySkin; + struct texture_s *tex = mf->sub[number].shinySkin; if(tex) { shinyTexture = reinterpret_cast(GL_PrepareTextureVariant(tex, Rend_ModelShinyTextureSpec())); @@ -1153,7 +1153,7 @@ static void Mod_RenderSubModel(uint number, rendmodelparams_t const *parm) } else { - Texture *tex = mdl->skins[useSkin].texture; + struct texture_s *tex = mdl->skins[useSkin].texture; skinTexture = 0; if(tex) diff --git a/doomsday/engine/src/resource/material.cpp b/doomsday/engine/src/resource/material.cpp index fdcc1230c2..d68e397589 100644 --- a/doomsday/engine/src/resource/material.cpp +++ b/doomsday/engine/src/resource/material.cpp @@ -276,13 +276,13 @@ void Material_SetEnvironmentClass(material_t* mat, material_env_class_t envClass mat->_envClass = envClass; } -Texture* Material_DetailTexture(material_t* mat) +struct texture_s *Material_DetailTexture(material_t *mat) { DENG2_ASSERT(mat); return mat->_detailTex; } -void Material_SetDetailTexture(material_t* mat, Texture* tex) +void Material_SetDetailTexture(material_t *mat, struct texture_s *tex) { DENG2_ASSERT(mat); mat->_detailTex = tex; @@ -312,13 +312,13 @@ void Material_SetDetailScale(material_t* mat, float scale) mat->_detailScale = MINMAX_OF(0, scale, 1); } -Texture* Material_ShinyTexture(material_t* mat) +struct texture_s *Material_ShinyTexture(material_t *mat) { DENG2_ASSERT(mat); return mat->_shinyTex; } -void Material_SetShinyTexture(material_t* mat, Texture* tex) +void Material_SetShinyTexture(material_t *mat, struct texture_s *tex) { DENG2_ASSERT(mat); mat->_shinyTex = tex; @@ -362,13 +362,13 @@ void Material_SetShinyStrength(material_t* mat, float strength) mat->_shinyStrength = MINMAX_OF(0, strength, 1); } -Texture* Material_ShinyMaskTexture(material_t* mat) +struct texture_s *Material_ShinyMaskTexture(material_t *mat) { DENG2_ASSERT(mat); return mat->_shinyMaskTex; } -void Material_SetShinyMaskTexture(material_t* mat, Texture* tex) +void Material_SetShinyMaskTexture(material_t* mat, struct texture_s *tex) { DENG2_ASSERT(mat); mat->_shinyMaskTex = tex; diff --git a/doomsday/engine/src/resource/materialsnapshot.cpp b/doomsday/engine/src/resource/materialsnapshot.cpp index 2dbc48b0f7..ce1bf9c326 100644 --- a/doomsday/engine/src/resource/materialsnapshot.cpp +++ b/doomsday/engine/src/resource/materialsnapshot.cpp @@ -179,8 +179,8 @@ void MaterialSnapshot::update() // Are we inheriting the logical dimensions from the texture? if(0 == Material_Width(mat) && 0 == Material_Height(mat)) { - Size2Raw texSize(Texture_Width(ml->texture), - Texture_Height(ml->texture)); + Texture &tex = reinterpret_cast(*ml->texture); + Size2Raw texSize(tex.width(), tex.height()); Material_SetSize(mat, &texSize); } } diff --git a/doomsday/engine/src/resource/materialvariant.cpp b/doomsday/engine/src/resource/materialvariant.cpp index e8d5a1a979..266f41744f 100644 --- a/doomsday/engine/src/resource/materialvariant.cpp +++ b/doomsday/engine/src/resource/materialvariant.cpp @@ -113,11 +113,11 @@ void MaterialVariant::ticker(timespan_t /*time*/) inter = 1.0f - (layer->tics - frameTimePos) / (float) lsDef->tics; } - /* Texture const *glTex; + /* Texture const *tex; de::Uri *texUri = reinterpret_cast(lsDef->texture); - if(texUri && (glTex = Textures::resolveUri(*texUri))) + if(texUri && (tex = Textures::resolveUri(*texUri))) { - layer->tex = Texture_Id(glTex); + layer->tex = tex->id(); setTranslationPoint(inter); } else diff --git a/doomsday/engine/src/resource/models.cpp b/doomsday/engine/src/resource/models.cpp index 17487e6a3e..5e104fec7c 100644 --- a/doomsday/engine/src/resource/models.cpp +++ b/doomsday/engine/src/resource/models.cpp @@ -503,12 +503,12 @@ static short defineSkinAndAddToModelIndex(model_t &mdl, Path const &skinPath) { int const newSkin = mdl.info.numSkins; - if(texture_s *tex = R_DefineTexture("ModelSkins", de::Uri(skinPath))) + if(Texture *tex = R_DefineTexture("ModelSkins", de::Uri(skinPath))) { // A duplicate? (return existing skin number) for(int i = 0; i < mdl.info.numSkins; ++i) { - if(mdl.skins[i].texture == tex) return i; + if(mdl.skins[i].texture == reinterpret_cast(tex)) return i; } // Add this new skin. @@ -518,7 +518,7 @@ static short defineSkinAndAddToModelIndex(model_t &mdl, Path const &skinPath) QByteArray pathUtf8 = skinPath.toString().toUtf8(); qstrncpy(mdl.skins[newSkin].name, pathUtf8.constData(), 256); - mdl.skins[newSkin].texture = tex; + mdl.skins[newSkin].texture = reinterpret_cast(tex); } return newSkin; @@ -537,7 +537,7 @@ static void defineAllSkins(model_t &mdl) { de::Uri foundResourceUri(Path(findSkinPath(mdl.skins[i].name, modelFilePath))); - mdl.skins[i].texture = R_DefineTexture("ModelSkins", foundResourceUri); + mdl.skins[i].texture = reinterpret_cast(R_DefineTexture("ModelSkins", foundResourceUri)); // We have found one more skin for this model. numFoundSkins += 1; @@ -1159,7 +1159,7 @@ static void setupModel(ded_model_t& def) { de::Uri foundResourceUri(Path(findSkinPath(skinFilePath, modelFilePath))); - sub->shinySkin = R_DefineTexture("ModelReflectionSkins", foundResourceUri); + sub->shinySkin = reinterpret_cast(R_DefineTexture("ModelReflectionSkins", foundResourceUri)); } catch(FS1::NotFoundError const &) { diff --git a/doomsday/engine/src/resource/r_data.cpp b/doomsday/engine/src/resource/r_data.cpp index a815dbfe7d..bce6a8a60a 100644 --- a/doomsday/engine/src/resource/r_data.cpp +++ b/doomsday/engine/src/resource/r_data.cpp @@ -843,8 +843,8 @@ void R_InitSpriteTextures() LOG_INFO(String("R_InitSpriteTextures: Done in %1 seconds.").arg(begunAt.since(), 0, 'g', 2)); } -texture_s *R_DefineTexture(de::String schemeName, de::Uri const &resourceUri, - QSize const &dimensions) +Texture *R_DefineTexture(de::String schemeName, de::Uri const &resourceUri, + QSize const &dimensions) { LOG_AS("R_DefineTexture"); @@ -855,7 +855,7 @@ texture_s *R_DefineTexture(de::String schemeName, de::Uri const &resourceUri, try { de::Texture *tex = scheme.findByResourceUri(resourceUri).texture(); - if(tex) return reinterpret_cast(tex); + if(tex) return tex; } catch(Textures::Scheme::NotFoundError const &) {} // Ignore this error. @@ -874,10 +874,10 @@ texture_s *R_DefineTexture(de::String schemeName, de::Uri const &resourceUri, if(!manifest) return 0; // Invalid URI? /// @todo Defer until necessary (manifest texture is first referenced). - return reinterpret_cast( deriveTexture(*manifest) ); + return deriveTexture(*manifest); } -texture_s *R_DefineTexture(de::String schemeName, de::Uri const &resourceUri) +de::Texture *R_DefineTexture(de::String schemeName, de::Uri const &resourceUri) { return R_DefineTexture(schemeName, resourceUri, QSize()); } diff --git a/doomsday/engine/src/resource/texture.cpp b/doomsday/engine/src/resource/texture.cpp index 0605de5e0e..acf78eb3be 100644 --- a/doomsday/engine/src/resource/texture.cpp +++ b/doomsday/engine/src/resource/texture.cpp @@ -30,8 +30,6 @@ #include #include -#include -#include namespace de { @@ -227,111 +225,3 @@ Texture::Flags &Texture::flags() } } // namespace de - -/** - * C Wrapper API: - */ - -#define TOINTERNAL(inst) \ - (inst) != 0? reinterpret_cast(inst) : NULL - -#define TOINTERNAL_CONST(inst) \ - (inst) != 0? reinterpret_cast(inst) : NULL - -#define SELF(inst) \ - DENG2_ASSERT(inst); \ - de::Texture *self = TOINTERNAL(inst) - -#define SELF_CONST(inst) \ - DENG2_ASSERT(inst); \ - de::Texture const *self = TOINTERNAL_CONST(inst) - -void *Texture_UserDataPointer(Texture const *tex) -{ - SELF_CONST(tex); - return self->userDataPointer(); -} - -void Texture_SetUserDataPointer(Texture *tex, void *newUserData) -{ - SELF(tex); - self->setUserDataPointer(newUserData); -} - -void Texture_ClearVariants(Texture *tex) -{ - SELF(tex); - self->clearVariants(); -} - -uint Texture_VariantCount(Texture const *tex) -{ - SELF_CONST(tex); - return self->variantCount(); -} - -struct texturevariant_s *Texture_AddVariant(Texture *tex, struct texturevariant_s *variant) -{ - SELF(tex); - if(!variant) - { - LOG_AS("Texture_AddVariant"); - LOG_WARNING("Invalid variant argument, ignoring."); - return variant; - } - self->addVariant(*reinterpret_cast(variant)); - return variant; -} - -void *Texture_AnalysisDataPointer(Texture const *tex, texture_analysisid_t analysisId) -{ - SELF_CONST(tex); - return self->analysisDataPointer(analysisId); -} - -void Texture_SetAnalysisDataPointer(Texture *tex, texture_analysisid_t analysis, void *data) -{ - SELF(tex); - self->setAnalysisDataPointer(analysis, data); -} - -int Texture_Width(Texture const *tex) -{ - SELF_CONST(tex); - return self->width(); -} - -void Texture_SetWidth(Texture *tex, int newWidth) -{ - SELF(tex); - self->setWidth(newWidth); -} - -int Texture_Height(Texture const *tex) -{ - SELF_CONST(tex); - return self->height(); -} - -void Texture_SetHeight(Texture *tex, int newHeight) -{ - SELF(tex); - self->setHeight(newHeight); -} - -int Texture_IterateVariants(Texture *tex, - int (*callback)(struct texturevariant_s *variant, void *parameters), void *parameters) -{ - SELF(tex); - int result = 0; - if(callback) - { - DENG2_FOR_EACH_CONST(de::Texture::Variants, i, self->variantList()) - { - de::TextureVariant *variant = const_cast(*i); - result = callback(reinterpret_cast(variant), parameters); - if(result) break; - } - } - return result; -}