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

3
#include "system.h"
4

Pierre Kraemer's avatar
Pierre Kraemer committed
5
MapHandlerGen::MapHandlerGen(const QString& name, Window* window, CGoGN::GenericMap* map) :
6
	m_name(name),
Pierre Kraemer's avatar
Pierre Kraemer committed
7 8
	m_window(window),
	m_map(map)
9 10 11
{
	m_render = new CGoGN::Algo::Render::GL2::MapRender();
}
12

13
MapHandlerGen::~MapHandlerGen()
14
{
15 16
	foreach(CGoGN::Utils::VBO* vbo, h_vbo)
		delete vbo;
17 18
}

19 20 21 22 23
void MapHandlerGen::draw(CGoGN::Utils::GLSLShader* shader, int primitive)
{
	m_render->draw(shader, primitive);
}

24
CGoGN::Utils::VBO* MapHandlerGen::getVBO(const std::string& name)
25
{
26
	if (h_vbo.contains(name))
27 28
		return h_vbo[name];
	else
29
	{
30 31 32
		CGoGN::Utils::VBO* vbo = new CGoGN::Utils::VBO();
		h_vbo.insert(name, vbo);
		return vbo;
33 34 35
	}
}

36
void MapHandlerGen::deleteVBO(const std::string& name)
37
{
38
	if (h_vbo.contains(name))
39
	{
40 41 42
		CGoGN::Utils::VBO* vbo = h_vbo[name];
		h_vbo.remove(name);
		delete vbo;
43 44 45
	}
}

46
/*********************************************************
47
 * MANAGE LINKED VIEWS
48 49
 *********************************************************/

Pierre Kraemer's avatar
Pierre Kraemer committed
50
void MapHandlerGen::linkView(View* view)
51 52 53 54 55
{
	if(view && !l_views.contains(view))
		l_views.push_back(view);
}

56
void MapHandlerGen::unlinkView(View* view)
57
{
Pierre Kraemer's avatar
Pierre Kraemer committed
58
	l_views.removeOne(view);
59
}