CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class 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 "csextern.h"
00028  
00029 #include "csutil/parray.h"
00030 #include "igraphic/image.h"
00031 
00032 struct iTextureHandle;
00033 struct iTextureManager;
00034 
00040 class CS_CSWS_EXPORT csWSTexture
00041 {
00042   // Reference count
00043   int RefCount;
00044   // texture image
00045   csRef<iImage> Image;
00046   // Will be this texture used for 3D and/or for 2D operations?
00047   int Flags;
00048   // Red,Green and Blue components of key color
00049   uint8 tr, tg, tb;
00050   // texture has key color?
00051   bool HasKey;
00052   // Has transparent color changed?
00053   bool KeyChanged;
00054   // texture handle for the 3D/2D driver
00055   csRef<iTextureHandle> Handle;
00056   // texture name
00057   char *Name;
00058   // VFS file name
00059   char *FileName;
00060 
00061 public:
00063   csWSTexture (const char *iName, iImage *Image, int iFlags);
00065   ~csWSTexture ();
00067   void SetKeyColor (int iR, int iG, int iB);
00069   void SetKeyColor (bool iEnable);
00071   void GetKeyColor (int &oR, int &oG, int &oB) const
00072   { oR = tr; oG = tg; oB = tb; }
00074   bool HasKeyColor () const
00075   { return HasKey; }
00077   void Register (iTextureManager *iTexMan);
00079   void Unregister ();
00081   void Refresh ();
00083   void SetName (const char *iName);
00085   const char *GetName () const
00086   { return Name; }
00088   iTextureHandle *GetHandle ()
00089   { return Handle; }
00091   void IncRef ()
00092   { RefCount++; }
00094   void DecRef ()
00095   { RefCount--; }
00097   int GetRefCount () const
00098   { return RefCount; }
00100   const char *GetFileName () const
00101   { return FileName; }
00103   void SetFileName (const char *iFileName);
00105   void FixKeyColor ();
00107   void DontFixKeyColor ()
00108   { KeyChanged = false; }
00110   int GetWidth ();
00112   int GetHeight ();
00113 };
00114 
00116 class CS_CSWS_EXPORT csWSTexVector : public csPDelArray<csWSTexture>
00117 {
00118 public:
00120   csWSTexVector ();
00122   static int CompareKey (csWSTexture* const&, char const* const& Key);
00124   csWSTexture *FindTexture (const char *name) const
00125   {
00126     size_t idx = FindKey (csArrayCmp<csWSTexture*,char const*>(name, CompareKey));
00127     return idx != csArrayItemNotFound ? Get (idx) : (csWSTexture*)0;
00128   }
00129 };
00130 
00131 #endif // __CS_CSWSTEX_H__

Generated for Crystal Space by doxygen 1.3.9.1