Skip to content

Commit

Permalink
Texture|Resources: Ensure any prepared GL texture is released on Text…
Browse files Browse the repository at this point in the history
…ure::Variant deletion
  • Loading branch information
danij-deng committed Dec 6, 2013
1 parent b15406e commit 920c760
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
6 changes: 3 additions & 3 deletions doomsday/client/src/resource/resourcesystem.cpp
Expand Up @@ -759,20 +759,20 @@ DENG2_PIMPL(ResourceSystem)
bool cacheGroups = true)
{
// Already in the queue?
bool isQueued = false;
bool alreadyQueued = false;
foreach(CacheTask *baseTask, cacheQueue)
{
if(MaterialCacheTask *task = dynamic_cast<MaterialCacheTask *>(baseTask))
{
if(&material == task->material && &contextSpec == task->spec)
{
isQueued = true;
alreadyQueued = true;
break;
}
}
}

if(!isQueued)
if(!alreadyQueued)
{
cacheQueue.append(new MaterialCacheTask(material, contextSpec));
}
Expand Down
5 changes: 0 additions & 5 deletions doomsday/client/src/resource/texture.cpp
Expand Up @@ -91,11 +91,6 @@ Texture::~Texture()
{
DENG2_FOR_AUDIENCE(Deletion, i) i->textureBeingDeleted(*this);

#ifdef __CLIENT__
/// @todo ResourceSystem should observe Deletion.
App_ResourceSystem().releaseGLTexturesFor(*this);
#endif

if(!manifest().schemeName().compareWithoutCase("Textures"))
{
CompositeTexture *pcTex = reinterpret_cast<CompositeTexture *>(userDataPointer());
Expand Down
39 changes: 20 additions & 19 deletions doomsday/client/src/resource/texturevariant.cpp
Expand Up @@ -263,34 +263,35 @@ String TextureVariantSpec::asText() const

DENG2_PIMPL(Texture::Variant)
{
/// Superior Texture of which this is a derivative.
Texture &texture;
Texture &texture; /// The base for which "this" is a context derivative.
TextureVariantSpec const &spec; /// Usage context specification.
Flags flags;

/// Specification used to derive this variant.
TextureVariantSpec const &spec;

/// Variant flags.
Texture::Variant::Flags flags;

/// Source of this texture.
res::Source texSource;
res::Source texSource; ///< Logical source of the image.

/// Name of the associated GL texture object.
/// @todo Use GLTexture
uint glTexName;

/// Prepared coordinates for the bottom right of the texture minus border.
float s, t;

Instance(Public *i, Texture &generalCase,
TextureVariantSpec const &spec) : Base(i),
texture(generalCase),
spec(spec),
flags(0),
texSource(res::None),
glTexName(0),
s(0),
t(0)
Instance(Public *i, Texture &generalCase, TextureVariantSpec const &spec)
: Base(i)
, texture(generalCase)
, spec(spec)
, flags(0)
, texSource(res::None)
, glTexName(0)
, s(0)
, t(0)
{}

~Instance()
{
// Release any GL texture we may have prepared.
self.release();
}
};

Texture::Variant::Variant(Texture &generalCase, TextureVariantSpec const &spec)
Expand Down

0 comments on commit 920c760

Please sign in to comment.