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

3
#include "system.h"
4

5
MapHandlerGen::MapHandlerGen(const QString& name, Window* window) :
6
	m_name(name),
7
	m_window(window)
8 9 10
{
	m_render = new CGoGN::Algo::Render::GL2::MapRender();
}
11

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

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

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

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

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

49
bool MapHandlerGen::linkView(View* view)
50 51 52 53 54 55 56 57 58 59 60
{
	if(view && !l_views.contains(view))
	{
		l_views.push_back(view);
		view->updateGL();
		return true;
	}
	else
		return false;
}

61
void MapHandlerGen::unlinkView(View* view)
62 63 64 65
{
	if(l_views.removeOne(view))
		view->updateGL();
}