source: GTP/trunk/Lib/Vis/Preprocessing/src/ResourceManager.cpp @ 1001

Revision 1001, 1.9 KB checked in by mattausch, 18 years ago (diff)

added mesh instance support
improved support for occlusion queries + other extensions

RevLine 
[1001]1#include "ResourceManager.h"
2#include "Mesh.h"
3
4namespace GtpVisibilityPreprocessor {
5
6ResourceManager *ResourceManager::sResourceManager = NULL;
7
8
9ResourceManager *ResourceManager::GetSingleton()
10{Debug << "here1" << endl;
11        if (!sResourceManager)
12        {
13                Debug << "here888" << endl;
14                sResourceManager = new ResourceManager();
15        }
16
17  Debug << "here999" << endl;
18        return sResourceManager;
19}
20
21
22ResourceManager::ResourceManager()
23{
24}
25
26ResourceManager::~ResourceManager()
27{
28        cout << "here839 " << mMeshes.size() << endl;
29
30        MeshMap::iterator mit, mit_end = mMeshes.end();
31        for (mit = mMeshes.begin(); mit != mMeshes.end(); ++ mit)
32        {
33                cout << "mesh: " << (*mit).first << " " << (*mit).second << endl;
34                DEL_PTR((*mit).second);
35        }
36}
37
38void ResourceManager::DelSingleton()
39{
40        cout << "here11" << endl;
41        DEL_PTR(sResourceManager);
42}
43
44/*Mesh *ResourceManager::CreateMesh(const string meshName)
45{
46        Mesh *mesh = new Mesh();
47        mMeshes[meshName] = mesh;
48       
49        return mesh;
50}*/
51
52
53Mesh *ResourceManager::GetOrCreateMesh(const string meshName)
54{Debug << "here2" << endl;
55        Mesh *mesh = NULL;
56
57        if (!(mesh = FindMesh(meshName.c_str())))
58        {
59                mesh = new Mesh();
60                mMeshes[meshName.c_str()] = mesh;
61        }
62
63        return mesh;
64}
65
66
67/*
68bool ResourceManager::InsertMesh(Mesh *mesh, const string meshName)
69{
70        Mesh *mesh = NULL;
71
72        if (FindMesh(meshName.c_str()))
73                return false;
74
75        mMeshes[meshName.c_str()] = mesh;
76       
77        return mesh;
78}
79*/
80
81Mesh *ResourceManager::FindMesh(const string &name) const
82{Debug << "here3" << endl;
83        MeshMap::const_iterator mit = mMeshes.find(name.c_str());
84
85        if (mit != mMeshes.end())
86        {
87                return (*mit).second;
88        }
89
90        return NULL;
91}
92
93
94bool ResourceManager::DestroyMesh(const string &meshName)
95{
96        if (!FindMesh(meshName))
97        {
98                Mesh *mesh = mMeshes[meshName.c_str()];
99
100                mMeshes.erase(meshName.c_str());
101                DEL_PTR(mesh);
102
103                return true;
104        }
105
106        return false;
107}
108
109}
Note: See TracBrowser for help on using the repository browser.