Skip to content
Snippets Groups Projects

Fix core ruler plugin

Merged Martin Schultz requested to merge fixCoreRulerPlugin into master
6 files
+ 464
62
Compare changes
  • Side-by-side
  • Inline
Files
6
@@ -232,6 +232,11 @@ void
@@ -232,6 +232,11 @@ void
LineNode::
LineNode::
draw(GLState& _state , const DrawModes::DrawMode& _drawMode)
draw(GLState& _state , const DrawModes::DrawMode& _drawMode)
{
{
 
if(_state.compatibilityProfile())
 
drawCompat(_state, _drawMode);
 
else
 
{
 
/* //Node Based Drawing is not supported on Core profiles
if (_drawMode & DrawModes::WIREFRAME)
if (_drawMode & DrawModes::WIREFRAME)
{
{
ACG::GLState::disable(GL_LIGHTING);
ACG::GLState::disable(GL_LIGHTING);
@@ -343,6 +348,7 @@ draw(GLState& _state , const DrawModes::DrawMode& _drawMode)
@@ -343,6 +348,7 @@ draw(GLState& _state , const DrawModes::DrawMode& _drawMode)
}
}
//glEnd();
//glEnd();
 
}*/
}
}
}
}
@@ -364,13 +370,15 @@ leave(GLState& _state , const DrawModes::DrawMode& _drawMode)
@@ -364,13 +370,15 @@ leave(GLState& _state , const DrawModes::DrawMode& _drawMode)
void LineNode::pick(GLState& _state , PickTarget _target)
void LineNode::pick(GLState& _state , PickTarget _target)
{
{
 
if(_state.compatibilityProfile())
 
pickCompat(_state, _target);
 
else
 
{
if (n_points() == 0)
if (n_points() == 0)
return;
return;
// Bind the vertex array
// Bind the vertex array
ACG::GLState::bindBuffer(GL_ARRAY_BUFFER_ARB, 0);
ACG::GLState::bindBuffer(GL_ARRAY_BUFFER_ARB, 0);
ACG::GLState::vertexPointer( &(points_)[0] );
ACG::GLState::enableClientState(GL_VERTEX_ARRAY);
const size_t n_edges = n_points() - 1;
const size_t n_edges = n_points() - 1;
@@ -393,53 +401,14 @@ void LineNode::pick(GLState& _state , PickTarget _target)
@@ -393,53 +401,14 @@ void LineNode::pick(GLState& _state , PickTarget _target)
default:
default:
break;
break;
}
}
}
//Disable the vertex array
ACG::GLState::disableClientState(GL_VERTEX_ARRAY);
}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void LineNode::pick_edges(GLState& _state, unsigned int _offset)
void LineNode::pick_edges(GLState& _state, unsigned int _offset)
{
{
// Check if we have any edges to draw (% 0 causes division by zero on windows)
//TODO: implement edge picking for lines in CoreProfile
if (n_points() < 2)
return;
const float line_width_old = _state.line_width();
_state.set_line_width(picking_line_width());
_state.pick_set_name (0);
glDepthRange(0.0, 0.99);
if (line_mode_ == PolygonMode)
{
const size_t n_edges = n_points() - 1;
for (size_t i = 0; i < n_edges; ++i)
{
_state.pick_set_name(i + _offset);
glBegin(GL_LINES);
glArrayElement(static_cast<GLint>(i));
glArrayElement(static_cast<GLint>(i + 1));
glEnd();
}
}
else if (line_mode_ == LineSegmentsMode)
{
const size_t n_edges = n_points() / 2;
for (size_t i = 0; i < n_edges; ++i)
{
_state.pick_set_name(i + _offset);
glBegin(GL_LINES);
glArrayElement(static_cast<GLint>(2*i));
glArrayElement(static_cast<GLint>(2*i + 1));
glEnd();
}
}
glDepthRange(0.0, 1.0);
_state.set_line_width(line_width_old);
}
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
Loading