No subject


Thu Mar 29 20:50:10 PDT 2007


(God, it's been that long?!)

> Anyways here is my next attempt.  I have to change it around and get rid 
> of the "loadTexture" function because that can not return scope classes, 
> which makes sense I suppose.
>
> btw, thanks for the help!  This is certainly and educational experience.
>
>
>
> module texture;
>
> import std.stdio;
>
> scope class TextureHandle
> {
>     private Texture mTexture;
>     private char[]  mName;
>
>     this(char[] aName)
>     { mName = aName;
>
>         if (auto t = (aName in textureList))
>         {
>             mTexture = *t;
>         }
>         else
>         {
>             mTexture = new Texture();
>             textureList[aName] = mTexture;
>         }
>
>         mTexture.mRef++;
>
>     }
>
>     ~this()
>     {
>         mTexture.mRef--;
>         if (mTexture.mRef == 0)
>         {
>             mTexture.freeGPUtexture();
>             textureList.remove(mName);
>             delete mTexture;
>         }
>     }
> }
>
> private
> {
>     Texture[char[]] textureList;
>
>     class Texture
>     {
>         private uint mRef = 0;
>         this()
>         {
>         }
>
>         ~this()
>         {
>         }
>         void freeGPUtexture()
>         {
>         }
>     }
> }

Looks good to me. 




More information about the Digitalmars-d-learn mailing list