From 6155d32aa9e5fc2e5548fcc863a64d442cf5770a Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 3 May 2008 21:17:45 +0000 Subject: texture manager --- src/render/textures.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/render/textures.h (limited to 'src/render/textures.h') diff --git a/src/render/textures.h b/src/render/textures.h new file mode 100644 index 0000000..ad38451 --- /dev/null +++ b/src/render/textures.h @@ -0,0 +1,54 @@ +/* + render/textures.h + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#ifndef __INCLUDED_RENDER_TEXTURES_H__ +#define __INCLUDED_RENDER_TEXTURES_H__ + +#include +#include + +#include "render/gl.h" + +namespace render { + +const size_t MAXTEXTURES = 256; + +/// Texture managment +class Textures +{ +public: + /// Initialize the textures registry + static void init(); + + /// Shutdown the textures registry + static void shutdown(); + + /// Load a texture + /** Returns 0 on failure, and the texture index on success + */ + static size_t load(std::string name); + + /// bind a texture for OpenGL usage + /** Returns 0 on failure, and the texture index on success + */ + static size_t bind(std::string name); + + /// bind a texture for OpenGL usage + static size_t bind(size_t texture); + +private: + static void clear(); + + typedef std::map::iterator iterator; + + static std::map registry; + static size_t index; + static GLuint textures[MAXTEXTURES]; +}; + +} + +#endif // __INCLUDED_RENDER_TEXTURES_H__ -- cgit v1.2.3