Skip to content

Commit

Permalink
Remove Texture::Delete.
Browse files Browse the repository at this point in the history
This is just a reimplementation of a virtual destructor.
  • Loading branch information
DanAlbert committed May 15, 2024
1 parent ba3fd32 commit b5534eb
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 31 deletions.
27 changes: 0 additions & 27 deletions teapots/textured-teapot/src/main/cpp/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,6 @@ Texture* Texture::Create(std::vector<std::string>& texFiles,
return new TextureCubemap(texFiles, assetManager);
}

void Texture::Delete(Texture* obj) {
if (obj == nullptr) {
ASSERT(false, "NULL pointer to Texture::Delete() function");
return;
}

GLuint type = obj->GetTexType();
if (type == GL_TEXTURE_2D) {
Texture2d* d2Instance = dynamic_cast<Texture2d*>(obj);
if (d2Instance) {
delete d2Instance;
} else {
ASSERT(false, "Unknown obj type to %s", __FUNCTION__);
}
} else if (type == GL_TEXTURE_CUBE_MAP) {
TextureCubemap* cubemapInstance = dynamic_cast<TextureCubemap*>(obj);
if (cubemapInstance) {
delete cubemapInstance;
} else {
ASSERT(false, "Unknown obj type to %s", __FUNCTION__);
}
} else {
LOGE("Supported Texture Types: %s", supportedTextureTypes.c_str());
ASSERT(false, "Unknow texture type %x to delete", type);
}
}

/**
* TextureCubemap implementations
*/
Expand Down
4 changes: 1 addition & 3 deletions teapots/textured-teapot/src/main/cpp/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@
* - texture unit 0, sampler unit 0
*/
class Texture {
protected:
public:
Texture();
virtual ~Texture();

public:
/**
* Create a texture object
* @param texFiles holds image file names under APK/assets.
Expand All @@ -51,7 +50,6 @@ class Texture {
*/
static Texture* Create(std::vector<std::string>& texFiles,
AAssetManager* assetManager);
static void Delete(Texture* obj);

virtual bool GetActiveSamplerInfo(std::vector<std::string>& names,
std::vector<GLint>& units) = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void TexturedTeapotRender::Unload() {
texVbo_ = GL_INVALID_VALUE;
}
if (texObj_) {
Texture::Delete(texObj_);
delete texObj_;
texObj_ = nullptr;
}
}

0 comments on commit b5534eb

Please sign in to comment.