Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages
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 "csutil/parray.h" 00028 #include "ivideo/txtmgr.h" 00029 #include "ivideo/material.h" 00030 #include "iengine/material.h" 00031 #include "ivideo/texture.h" 00032 #include "ivideo/shader/shader.h" 00033 #include "iengine/texture.h" 00034 #include "ivideo/graph2d.h" 00035 #include "csgfx/rgbpixel.h" 00036 #include "csutil/weakrefarr.h" 00037 00038 class csTexture; 00039 class csTextureManager; 00040 struct iImage; 00041 struct iConfigFile; 00042 struct iGraphics2D; 00043 struct iObjectRegistry; 00044 00059 class CS_CRYSTALSPACE_EXPORT csTextureHandle : public iTextureHandle 00060 { 00061 protected: 00063 csRef<iImage> image; 00065 csRef<csTextureManager> texman; 00066 00068 int flags; 00069 00071 csTexture *tex [4]; 00072 00074 void *cachedata; 00075 00077 bool transp; 00079 csRGBpixel transp_color; 00080 00081 csStringID texClass; 00082 public: 00084 csTextureHandle (csTextureManager* texman, iImage *Image, int Flags); 00086 virtual ~csTextureHandle (); 00087 00089 int GetFlags () const { return flags; } 00090 00092 void FreeImage (); 00093 00095 virtual void CreateMipmaps (); 00096 00100 virtual void PrepareInt () { } 00101 00103 csTexture *get_texture (int mipmap) 00104 { 00105 PrepareInt (); 00106 return (mipmap >= 0) && (mipmap < 4) ? tex [mipmap] : 0; 00107 } 00108 00113 void AdjustSizePo2 (); 00114 00116 csRGBpixel *get_transparent () 00117 { return &transp_color; } 00118 00120 virtual csTexture* NewTexture (iImage *Image, bool ismipmap = false) = 0; 00121 00122 virtual void Blit (int /*x*/, int /*y*/, int /*width*/, int /*height*/, 00123 unsigned char const* /*data*/, TextureBlitDataFormat) { } 00124 00126 SCF_DECLARE_IBASE; 00127 00129 virtual void SetKeyColor (bool Enable); 00130 00132 virtual void SetKeyColor (uint8 red, uint8 green, uint8 blue); 00133 00138 virtual bool GetKeyColor () const; 00139 00141 virtual void GetKeyColor (uint8 &r, uint8 &g, uint8 &b) const; 00142 00148 virtual bool GetRendererDimensions (int &mw, int &mh); 00149 virtual void GetOriginalDimensions (int& w, int& h) 00150 { 00151 GetRendererDimensions (w, h); 00152 } 00153 00155 virtual void *GetCacheData () 00156 { return cachedata; } 00158 virtual void SetCacheData (void *d) 00159 { cachedata = d; } 00160 00162 virtual void *GetPrivateObject () 00163 { return (csTextureHandle *)this; } 00164 00170 virtual bool GetAlphaMap () 00171 { return false; } 00172 00179 static void CalculateNextBestPo2Size (const int orgDim, int& newDim); 00180 00181 virtual csAlphaMode::AlphaType GetAlphaType () const 00182 { return csAlphaMode::alphaNone; } 00183 virtual void SetAlphaType (csAlphaMode::AlphaType /*alphaType*/) 00184 { } 00185 00186 virtual void Precache () {} 00187 00188 virtual void SetTextureClass (const char* className); 00189 virtual const char* GetTextureClass (); 00190 }; 00191 00207 class CS_CRYSTALSPACE_EXPORT csTexture 00208 { 00209 protected: 00211 csTextureHandle *parent; 00213 int w, h; 00215 int shf_w, shf_h; 00217 int and_w, and_h; 00218 00220 void compute_masks (); 00221 00222 public: 00224 csTexture (csTextureHandle *Parent); 00226 virtual ~csTexture (); 00227 00229 int get_width () { return w; } 00231 int get_height () { return h; } 00233 int get_w_shift () { return shf_w; } 00235 int get_h_shift () { return shf_h; } 00237 int get_w_mask () { return and_w; } 00239 int get_h_mask () { return and_h; } 00241 int get_size () { return w * h; } 00243 csTextureHandle *get_parent () { return parent; } 00244 }; 00245 00251 class CS_CRYSTALSPACE_EXPORT csTextureManager : public iTextureManager 00252 { 00253 protected: 00254 00255 //typedef csArray<csTextureHandle*> csTexVector; 00256 typedef csWeakRefArray<csTextureHandle> csTexVector; 00257 00259 csTexVector textures; 00260 00262 iObjectRegistry *object_reg; 00263 00265 virtual void read_config (iConfigFile *config); 00266 public: 00268 csPixelFormat pfmt; 00269 00270 csStringID nameDiffuseTexture; 00271 00272 csStringSet texClassIDs; 00273 00274 SCF_DECLARE_IBASE; 00275 00277 csTextureManager (iObjectRegistry* object_reg, iGraphics2D *iG2D); 00279 virtual ~csTextureManager (); 00280 00282 virtual void Clear () 00283 { 00284 textures.DeleteAll (); 00285 } 00286 00294 virtual int GetTextureFormat (); 00295 }; 00296 00297 #endif // __CS_TXTMGR_H__
Generated for Crystal Space by doxygen 1.4.4