Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: aa47bfac181290ebf444d81670492aaea75cf2d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
   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, bool filter = true);

	/// bind a texture for OpenGL usage
	/** Returns 0 on failure, and the texture index on success
	 */
	static size_t bind(std::string name, bool filter = true);

	/// bind a texture for OpenGL usage
	static size_t bind(size_t texture, bool filter = true);

	/// find the texture index for a given name
	static size_t find(std::string name);

	/// unload a texture
	static void unload(size_t id);

	/// unload a texture
	static void unload(std::string name);

	/// list loaded textures
	static void list();

private:
	static void clear();
	static void set_filter(bool filter);

	typedef std::map<std::string, size_t>::iterator iterator;

	static std::map<std::string, size_t> registry;
	static GLuint textures[MAXTEXTURES];
};

}

#endif // __INCLUDED_RENDER_TEXTURES_H__