CrystalSpace

Public API Reference

csplugincommon/render3d/txtmgr.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 1998 by Jorrit Tyberghein
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_TXTMGR_H__
00020 #define __CS_TXTMGR_H__
00021 
00026 #include "csextern.h"
00027 #include "csgfx/rgbpixel.h"
00028 #include "csutil/parray.h"
00029 #include "csutil/scf_implementation.h"
00030 #include "csutil/weakrefarr.h"
00031 #include "iengine/material.h"
00032 #include "iengine/texture.h"
00033 #include "ivideo/graph2d.h"
00034 #include "ivideo/material.h"
00035 #include "ivideo/shader/shader.h"
00036 #include "ivideo/texture.h"
00037 #include "ivideo/txtmgr.h"
00038 
00039 class csTexture;
00040 class csTextureManager;
00041 struct iImage;
00042 struct iConfigFile;
00043 struct iGraphics2D;
00044 struct iObjectRegistry;
00045 
00060 class CS_CRYSTALSPACE_EXPORT csTextureHandle : 
00061   public scfImplementation1<csTextureHandle, iTextureHandle>
00062 {
00063 protected:
00065   csRef<csTextureManager> texman;
00066 
00068   int flags;
00069 
00071   bool transp;
00073   csRGBpixel transp_color;
00074 
00075   csStringID texClass;
00076   csAlphaMode::AlphaType alphaType;
00077 public:
00079   csTextureHandle (csTextureManager* texman, int Flags);
00081   virtual ~csTextureHandle ();
00082 
00087   void AdjustSizePo2 (int width, int height, int depth,
00088     int& newwidth, int& newheight, int& newdepth);
00089 
00091 
00092   int GetFlags () const { return flags; }
00093 
00095   virtual void SetKeyColor (bool Enable);
00096 
00098   virtual void SetKeyColor (uint8 red, uint8 green, uint8 blue);
00099 
00104   virtual bool GetKeyColor () const;
00105 
00107   virtual void GetKeyColor (uint8 &r, uint8 &g, uint8 &b) const;
00108 
00110   virtual void *GetPrivateObject ()
00111   { return (csTextureHandle *)this; }
00112 
00118   virtual bool GetAlphaMap () 
00119   { return false; }
00120 
00127   static void CalculateNextBestPo2Size (int flags, const int orgDim, 
00128     int& newDim);
00129 
00130   virtual csAlphaMode::AlphaType GetAlphaType () const
00131   { return alphaType; }
00132   virtual void SetAlphaType (csAlphaMode::AlphaType alphaType)
00133   { this->alphaType = alphaType; }
00134 
00135   virtual void SetTextureClass (const char* className);
00136   virtual const char* GetTextureClass ();
00137 };
00138 
00144 class CS_CRYSTALSPACE_EXPORT csTextureManager : 
00145   public scfImplementation1<csTextureManager, iTextureManager>
00146 {
00147 protected:
00148 
00149   //typedef csArray<csTextureHandle*> csTexVector;
00150   typedef csWeakRefArray<csTextureHandle> csTexVector;
00151 
00153   csTexVector textures;
00154 
00156   iObjectRegistry *object_reg;
00157 
00159   virtual void read_config (iConfigFile *config);
00160 public:
00162   csPixelFormat pfmt;
00163 
00164   csStringID nameDiffuseTexture;
00165 
00166   csStringSet texClassIDs;
00167 
00169   csTextureManager (iObjectRegistry* object_reg, iGraphics2D *iG2D);
00171   virtual ~csTextureManager ();
00172 
00174   virtual void Clear ()
00175   {
00176     textures.DeleteAll ();
00177   }
00178 };
00179 
00180 #endif // __CS_TXTMGR_H__

Generated for Crystal Space by doxygen 1.4.7