TexturePainter.h

Go to the documentation of this file.
00001 // Copyright (C) 2005 Dave Griffiths
00002 //
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00016 
00017 #ifndef N_TEXTURE
00018 #define N_TEXTURE
00019 
00020 #include <iostream>
00021 #include <string>
00022 #include <map>
00023 #include "PNGLoader.h"
00024 #include "PData.h"
00025 
00026 using namespace std;
00027 
00028 namespace Fluxus
00029 {
00030 
00033 class TextureDesc
00034 {
00035 public:
00036     TextureDesc() : Format(NONE) {}
00037     int Width;
00038     int Height;
00039     PixelFormat Format;
00040 };
00041 
00050 class TexturePainter
00051 {
00052 public:
00054     static TexturePainter* Get()
00055     {
00056         if (m_Singleton==NULL) m_Singleton=new TexturePainter;
00057         return m_Singleton;
00058     }
00059     
00060     static void Shutdown()
00061     {
00062         if (m_Singleton!=NULL) delete m_Singleton;
00063     }
00064     
00066     void Initialise();
00067     
00069     void ClearCache();
00070         
00074     
00077     unsigned int LoadTexture(const string &Filename, bool ignorecache=false);
00078     
00080     bool LoadPData(const string &Filename, unsigned int &w, unsigned int &h, TypedPData<dColour> &pixels);
00081     
00083     unsigned int MakeTexture(unsigned int w, unsigned int h, PData *data);
00085     
00090     
00093     bool SetCurrent(unsigned int *ids);
00094     
00096     void DisableAll();
00098     
00099 private:
00100     TexturePainter();
00101     ~TexturePainter();
00102     static TexturePainter *m_Singleton;
00103 
00104     map<string,int> m_LoadedMap;
00105     map<unsigned int,TextureDesc*> m_TextureMap;
00106 };
00107 
00108 }
00109 
00110 #endif

Generated on Tue Sep 4 23:22:18 2007 for The Fluxus Renderer (libfluxus) by  doxygen 1.5.1