2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #if !defined( INCLUDED_ITEXTURES_H )
23 #define INCLUDED_ITEXTURES_H
26 #include "generic/constant.h"
30 class LoadImageCallback
32 typedef Image* ( *LoadFunc )( void* environment, const char* name );
37 LoadImageCallback( void* environment, LoadFunc func ) : m_environment( environment ), m_func( func ){
39 Image* loadImage( const char* name ) const {
40 return m_func( m_environment, name );
44 inline bool operator==( const LoadImageCallback& self, const LoadImageCallback& other ){
45 return self.m_environment == other.m_environment && self.m_func == other.m_func;
47 inline bool operator<( const LoadImageCallback& self, const LoadImageCallback& other ){
48 return self.m_environment < other.m_environment ||
49 ( !( other.m_environment < self.m_environment ) && self.m_func < other.m_func );
52 class TexturesCacheObserver
55 virtual void unrealise() = 0;
56 virtual void realise() = 0;
62 INTEGER_CONSTANT( Version, 1 );
63 STRING_CONSTANT( Name, "textures" );
64 virtual LoadImageCallback defaultLoader() const = 0;
65 virtual Image* loadImage( const char* name ) = 0;
66 virtual qtexture_t* capture( const char* name ) = 0;
67 virtual qtexture_t* capture( const LoadImageCallback& load, const char* name ) = 0;
68 virtual void release( qtexture_t* texture ) = 0;
69 virtual void attach( TexturesCacheObserver& observer ) = 0;
70 virtual void detach( TexturesCacheObserver& observer ) = 0;
73 #include "modulesystem.h"
75 template<typename Type>
77 typedef GlobalModule<TexturesCache> GlobalTexturesModule;
79 template<typename Type>
80 class GlobalModuleRef;
81 typedef GlobalModuleRef<TexturesCache> GlobalTexturesModuleRef;
83 inline TexturesCache& GlobalTexturesCache(){
84 return GlobalTexturesModule::getTable();