mapHandler.cpp 1.18 KB
Newer Older
1
#include "mapHandler.h"
2

3
#include "system.h"
4

Pierre Kraemer's avatar
Pierre Kraemer committed
5 6 7 8 9 10 11
namespace CGoGN
{

namespace SCHNApps
{

MapHandlerGen::MapHandlerGen(const QString& name, Window* window, GenericMap* map) :
12
	m_name(name),
Pierre Kraemer's avatar
Pierre Kraemer committed
13 14
	m_window(window),
	m_map(map)
15
{
Pierre Kraemer's avatar
Pierre Kraemer committed
16
	m_render = new Algo::Render::GL2::MapRender();
17
}
18

19
MapHandlerGen::~MapHandlerGen()
20
{
21 22
	foreach(CGoGN::Utils::VBO* vbo, h_vbo)
		delete vbo;
23 24
}

Pierre Kraemer's avatar
Pierre Kraemer committed
25
void MapHandlerGen::draw(Utils::GLSLShader* shader, int primitive)
26 27 28 29
{
	m_render->draw(shader, primitive);
}

Pierre Kraemer's avatar
Pierre Kraemer committed
30
Utils::VBO* MapHandlerGen::getVBO(const std::string& name)
31
{
32
	if (h_vbo.contains(name))
33 34
		return h_vbo[name];
	else
35
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
36
		Utils::VBO* vbo = new Utils::VBO();
37 38
		h_vbo.insert(name, vbo);
		return vbo;
39 40 41
	}
}

42
void MapHandlerGen::deleteVBO(const std::string& name)
43
{
44
	if (h_vbo.contains(name))
45
	{
Pierre Kraemer's avatar
Pierre Kraemer committed
46
		Utils::VBO* vbo = h_vbo[name];
47 48
		h_vbo.remove(name);
		delete vbo;
49 50 51
	}
}

52
/*********************************************************
53
 * MANAGE LINKED VIEWS
54 55
 *********************************************************/

Pierre Kraemer's avatar
Pierre Kraemer committed
56
void MapHandlerGen::linkView(View* view)
57 58 59 60 61
{
	if(view && !l_views.contains(view))
		l_views.push_back(view);
}

62
void MapHandlerGen::unlinkView(View* view)
63
{
Pierre Kraemer's avatar
Pierre Kraemer committed
64
	l_views.removeOne(view);
65
}
Pierre Kraemer's avatar
Pierre Kraemer committed
66 67 68 69

} // namespace SCHNApps

} // namespace CGoGN