Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-05-03 21:17:45 +0000
committerStijn Buys <ingar@osirion.org>2008-05-03 21:17:45 +0000
commit6155d32aa9e5fc2e5548fcc863a64d442cf5770a (patch)
tree0f1b08c0485797b9f0c48dd5905b70072c0e5741 /src/render/textures.h
parent82293065b52f5a4e5c4ccde5eade4ebae18014ca (diff)
texture manager
Diffstat (limited to 'src/render/textures.h')
-rw-r--r--src/render/textures.h54
1 files changed, 54 insertions, 0 deletions
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 <string>
+#include <map>
+
+#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<std::string, size_t>::iterator iterator;
+
+ static std::map<std::string, size_t> registry;
+ static size_t index;
+ static GLuint textures[MAXTEXTURES];
+};
+
+}
+
+#endif // __INCLUDED_RENDER_TEXTURES_H__