CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

cswstex.h

00001 /*
00002     Crystal Space Windowing System: Windowing System Texture class
00003     Copyright (C) 1998,1999 by Andrew Zabolotny <bit@eltech.ru>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef __CS_CSWSTEX_H__
00021 #define __CS_CSWSTEX_H__
00022 
00027 #include "csgfx/csimage.h"
00028 #include "csutil/parray.h"
00029 
00030 struct iTextureHandle;
00031 struct iTextureManager;
00032 
00038 class csWSTexture
00039 {
00040   // Reference count
00041   int RefCount;
00042   // texture image
00043   csRef<iImage> Image;
00044   // Will be this texture used for 3D and/or for 2D operations?
00045   int Flags;
00046   // Red,Green and Blue components of key color
00047   uint8 tr, tg, tb;
00048   // texture has key color?
00049   bool HasKey;
00050   // Has transparent color changed?
00051   bool KeyChanged;
00052   // texture handle for the 3D/2D driver
00053   csRef<iTextureHandle> Handle;
00054   // texture name
00055   char *Name;
00056   // VFS file name
00057   char *FileName;
00058 
00059 public:
00061   csWSTexture (const char *iName, iImage *Image, int iFlags);
00063   ~csWSTexture ();
00065   void SetKeyColor (int iR, int iG, int iB);
00067   void SetKeyColor (bool iEnable);
00069   void GetKeyColor (int &oR, int &oG, int &oB)
00070   { oR = tr; oG = tg; oB = tb; }
00072   bool HasKeyColor ()
00073   { return HasKey; }
00075   void Register (iTextureManager *iTexMan);
00077   void Unregister ();
00079   void Refresh ();
00081   void SetName (const char *iName);
00083   const char *GetName () const
00084   { return Name; }
00086   iTextureHandle *GetHandle ()
00087   { return Handle; }
00089   void IncRef ()
00090   { RefCount++; }
00092   void DecRef ()
00093   { RefCount--; }
00095   int GetRefCount () const
00096   { return RefCount; }
00098   const char *GetFileName () const
00099   { return FileName; }
00101   void SetFileName (const char *iFileName);
00103   void FixKeyColor ();
00105   void DontFixKeyColor ()
00106   { KeyChanged = false; }
00108   int GetWidth ();
00110   int GetHeight ();
00111 };
00112 
00114 class csWSTexVector : public csPDelArray<csWSTexture>
00115 {
00116 public:
00118   csWSTexVector ();
00120   static int CompareKey (csWSTexture* const& Item, void* Key);
00122   csWSTexture *FindTexture (const char *name)
00123   {
00124     int idx = FindKey ((void*)name, CompareKey);
00125     return idx >= 0 ? Get (idx) : (csWSTexture*)0;
00126   }
00127 };
00128 
00131 #endif // __CS_CSWSTEX_H__

Generated for Crystal Space by doxygen 1.2.14