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)
40 Image* loadImage(const char* name) const
42 return m_func(m_environment, name);
46 inline bool operator==(const LoadImageCallback& self, const LoadImageCallback& other)
48 return self.m_environment == other.m_environment && self.m_func == other.m_func;
50 inline bool operator<(const LoadImageCallback& self, const LoadImageCallback& other)
52 return self.m_environment < other.m_environment ||
53 (!(other.m_environment < self.m_environment) && self.m_func < other.m_func);
56 class TexturesCacheObserver
59 virtual void unrealise() = 0;
60 virtual void realise() = 0;
66 INTEGER_CONSTANT(Version, 1);
67 STRING_CONSTANT(Name, "textures");
68 virtual LoadImageCallback defaultLoader() const = 0;
69 virtual Image* loadImage(const char* name) = 0;
70 virtual qtexture_t* capture(const char* name) = 0;
71 virtual qtexture_t* capture(const LoadImageCallback& load, const char* name) = 0;
72 virtual void release(qtexture_t* texture) = 0;
73 virtual void attach(TexturesCacheObserver& observer) = 0;
74 virtual void detach(TexturesCacheObserver& observer) = 0;
77 #include "modulesystem.h"
79 template<typename Type>
81 typedef GlobalModule<TexturesCache> GlobalTexturesModule;
83 template<typename Type>
84 class GlobalModuleRef;
85 typedef GlobalModuleRef<TexturesCache> GlobalTexturesModuleRef;
87 inline TexturesCache& GlobalTexturesCache()
89 return GlobalTexturesModule::getTable();