Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

proctex.h

00001 /*
00002     Copyright (C) 2000-2001 by Jorrit Tyberghein
00003     Copyright (C) 2000 by Samuel Humphreys
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 __PROCTEX_H__
00021 #define __PROCTEX_H__
00022 
00023 #include <stdarg.h>
00024 #include "csutil/csobject.h"
00025 #include "qint.h"
00026 
00027 struct iTextureWrapper;
00028 struct iMaterialWrapper;
00029 struct iEngine;
00030 
00031 struct iObjectRegistry;
00032 struct iGraphics2D;
00033 struct iGraphics3D;
00034 struct iTextureManager;
00035 struct iTextureWrapper;
00036 
00037 class csProcTexture : public csObject
00038 {
00039   friend struct ProcCallback;
00040 
00041 protected:
00042   // Will be set to true as soon as pt is initialized.
00043   bool ptReady;
00044 
00045   // Flags uses for the texture.
00046   int texFlags;
00047 
00048   // Texture wrapper.
00049   iTextureWrapper* tex;
00050   // Dimensions of texture.
00051   int mat_w, mat_h;
00052   // Procedural G3D and G2D.
00053   iGraphics3D* ptG3D;
00054   iGraphics2D* ptG2D;
00055   iTextureManager* ptTxtMgr;
00056   iObjectRegistry* object_reg;
00057   bool anim_prepared;
00058 
00059   bool key_color;
00060   int key_red, key_green, key_blue;
00061 
00062   // If true (default) then proc texture will register a callback
00063   // so that the texture is automatically updated (Animate is called)
00064   // whenever it is used.
00065   bool use_cb;
00066   // The current time the previous time the callback was called.
00067   // This is used to detect if the callback is called multiple times
00068   // in one frame.
00069   csTicks last_cur_time;
00070 
00071 private:
00072   static void ProcCallback (iTextureWrapper* txt, void* data);
00073 
00074 public:
00075   csProcTexture ();
00076   virtual ~csProcTexture ();
00077 
00085   void DisableAutoUpdate () { use_cb = false; }
00086 
00101   virtual bool Initialize (iObjectRegistry* object_reg);
00102 
00112   iMaterialWrapper* Initialize (iObjectRegistry* object_reg, iEngine* engine,
00113         iTextureManager* txtmgr, const char* name);
00114 
00119   virtual bool PrepareAnim ();
00120 
00122   void SetKeyColor (int red, int green, int blue)
00123   {
00124     key_color = true;
00125     key_red = red;
00126     key_green = green;
00127     key_blue = blue;
00128   }
00129 
00134   virtual void Animate (csTicks current_time) = 0;
00135 
00137   iTextureWrapper* GetTextureWrapper () { return tex; }
00138 
00140   virtual void GetDimension (int &w, int &h)
00141   { w = mat_w; h = mat_h; }
00142 
00143   static int GetRandom (int max)
00144   {
00145     return int ((float(max)*rand()/(RAND_MAX+1.0)));
00146   }
00147 };
00148 
00149 
00150 #endif // __PROCTEX_H__
00151 

Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000