/
FBOManager.h
62 lines (58 loc) · 1.2 KB
/
FBOManager.h
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
#ifndef FBOMANAGER_H
#define FBOMANAGER_H
#include "FrameBufferObject.h"
#include <map>
typedef std::map<std::string, FrameBufferObject*>::iterator FBOIterator;
typedef std::pair<std::string, FrameBufferObject*> FBOEntry;
class FBOManager
{
public:
FrameBufferObject* operator[] (std::string name) { return FBOs[name]; }
static FBOManager* GetSingletonPtr()
{
if (!instance)
instance = new FBOManager();
return instance;
}
static FBOManager& GetSingleton()
{
return *(GetSingletonPtr());
}
void AddFBO(FrameBufferObject* fbo)
{
FBOs.insert(FBOEntry(fbo->GetName(), fbo));
}
bool Contains(std::string name)
{
return (FBOs.count(name) > 0);
}
void Clear()
{
FBOIterator it = FBOs.begin();
while (it != FBOs.end())
{
delete it->second;
++it;
}
FBOs.clear();
}
FBOTexture* GetTexture(unsigned int index)
{
FBOTexture* current;
FBOIterator it = FBOs.begin();
while (index >= 0)
{
if (it == FBOs.end())
break;
if (it->second->GetNumTextures() > index)
return it->second->GetTexture(index);
index -= it->second->GetNumTextures();
++it;
}
return 0;
}
private:
std::map<std::string, FrameBufferObject*> FBOs;
static FBOManager* instance;
};
#endif