/* 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 "model/material.h" #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 the environment cubemap static void load_cubemap(const std::string & name); /// Load a texture /** Returns 0 on failure, and the texture index on success */ static size_t load(const std::string & name, const bool filter = true); static size_t load(const char *name, const bool filter = true); /// bind a texture for OpenGL usage /** Returns 0 on failure, and the texture index on success */ static size_t bind(const std::string &name, const bool filter = true); static size_t bind(const char *name, const bool filter = true); /// bind a texture for OpenGL usage static size_t bind(const size_t texture, const bool filter = true); /// find the texture index for a given name static size_t find(const std::string &name); /// unload a texture static void unload(const size_t id); /// unload a texture static void unload(const std::string &name); /// list loaded textures static void list(); /// material image loader hook static void image_loader(model::Layer *layer); private: static void clear(); typedef std::map::iterator iterator; static math::Vector2f texture_size[MAXTEXTURES]; static std::map registry; static GLuint textures[MAXTEXTURES]; static GLuint textures_cubemap_id; }; } #endif // __INCLUDED_RENDER_TEXTURES_H__