Commit 461e5daf authored by Sylvain Thery's avatar Sylvain Thery

add callSubList possibility in Drawe

parent 5f83b5b9
......@@ -90,8 +90,9 @@ public:
/**
* as glBegin, but need a newList call before
* @param mode: POINTS, LINES, LINE_LOOP, TRIANGLES, QUADS, POLYGON, etc..
* @return index of subdrawing possible call
*/
void begin(GLenum mode);
int begin(GLenum mode);
/**
* as glEnd
......@@ -131,6 +132,16 @@ public:
*/
void callList(float opacity = 1.0f);
/**
* call a sub-list (index return by begin (0,1,...)
*/
void callSubList(int index, float opacity = 1.0f);
/**
* call a set of sub-lists
*/
void callSubLists(std::vector<int> indices, float opacity);
/**
* use as glLineWidth
*/
......
......@@ -74,12 +74,14 @@ void Drawer::pointSize(float ps)
m_currentSize = ps;
}
void Drawer::begin(GLenum mode)
int Drawer::begin(GLenum mode)
{
int res = m_begins.size();
if (mode == GL_POINTS)
m_begins.push_back(PrimParam(m_dataPos.size(), mode, m_currentSize));
else
m_begins.push_back(PrimParam(m_dataPos.size(), mode, m_currentWidth));
return res;
}
void Drawer::end()
......@@ -186,6 +188,47 @@ void Drawer::callList(float opacity)
}
void Drawer::callSubList(int index, float opacity)
{
if (index >= int(m_begins.size()))
return;
m_shader->setOpacity(opacity);
m_shader->enableVertexAttribs();
PrimParam* pp = & (m_begins[index]);
if (pp->mode == GL_POINTS)
glPointSize(pp->width);
if ((pp->mode == GL_LINES) || (pp->mode == GL_LINE_LOOP))
glLineWidth(pp->width);
glDrawArrays(pp->mode, pp->begin, pp->nb);
m_shader->disableVertexAttribs();
}
void Drawer::callSubLists(std::vector<int> indices, float opacity)
{
m_shader->setOpacity(opacity);
m_shader->enableVertexAttribs();
for (std::vector<int>::iterator it = indices.begin(); it != indices.end(); ++it)
if (*it < int(m_begins.size()))
{
PrimParam* pp = & (m_begins[*it]);
if (pp->mode == GL_POINTS)
glPointSize(pp->width);
if ((pp->mode == GL_LINES) || (pp->mode == GL_LINE_LOOP))
glLineWidth(pp->width);
glDrawArrays(pp->mode, pp->begin, pp->nb);
}
m_shader->disableVertexAttribs();
}
void Drawer::toSVG(Utils::SVG::SVGOut& svg)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment