Commit d67e9bab authored by Martin Schultz's avatar Martin Schultz
Browse files

* commented out compatibility calls in the volumeMeshNode picking

implementation for core profiles.
* Implemented first variant for picking volumeḾeshvertices in core
profiles.
parent 52c09c83
......@@ -61,6 +61,8 @@
#include <ACG/GL/RenderObject.hh>
#include <ACG/GL/VertexDeclaration.hh>
#include <ACG/GL/IRenderer.hh>
#include <ACG/ShaderUtils/GLSLShader.hh>
#include <ACG/GL/ShaderCache.hh>
#include <OpenVolumeMesh/Mesh/HexahedralMesh.hh>
......@@ -1110,23 +1112,18 @@ void VolumeMeshNodeT<VolumeMeshT>::getRenderObjects(IRenderer* _renderer, GLStat
template<class VolumeMeshT>
void VolumeMeshNodeT<VolumeMeshT>::pick(GLState& _state, PickTarget _target) {
// save state
bool clientStateEnabledVertexArray = GLState::isClientStateEnabled(GL_VERTEX_ARRAY);
bool clientStateEnabledColorArray = GLState::isClientStateEnabled(GL_COLOR_ARRAY);
bool clientStateEnabledNormalArray = GLState::isClientStateEnabled(GL_NORMAL_ARRAY);
bool clientStateEnabledTexCoordArray = GLState::isClientStateEnabled(GL_TEXTURE_COORD_ARRAY);
if(_state.compatibilityProfile())
pickCompat(_state, _target);
else
{
GLState::depthRange(0.01, 1.0);
if (lastCellDrawMode_)
{
//draw cells so the user cannot pick invisible stuff
GLState::bindBuffer(GL_ARRAY_BUFFER, cellsBufferManager_.getBuffer());
GLState::enableClientState(GL_VERTEX_ARRAY);
GLState::vertexPointer(3, GL_FLOAT, cellsBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
GLState::disableClientState(GL_NORMAL_ARRAY);
GLState::disableClientState(GL_COLOR_ARRAY);
GLState::vertexPointer(3, GL_FLOAT, cellsBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
Vec4f bc = _state.specular_color();
_state.set_color(Vec4f(0.0,0.0,0.0,0.0));
......@@ -1142,12 +1139,8 @@ void VolumeMeshNodeT<VolumeMeshT>::pick(GLState& _state, PickTarget _target) {
//draw faces so the user cannot pick invisible stuff
GLState::bindBuffer(GL_ARRAY_BUFFER, facesBufferManager_.getBuffer());
GLState::enableClientState(GL_VERTEX_ARRAY);
GLState::vertexPointer(3, GL_FLOAT, facesBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
GLState::disableClientState(GL_NORMAL_ARRAY);
GLState::disableClientState(GL_COLOR_ARRAY);
Vec4f bc = _state.specular_color();
_state.set_color(Vec4f(0.0,0.0,0.0,0.0));
......@@ -1214,28 +1207,7 @@ void VolumeMeshNodeT<VolumeMeshT>::pick(GLState& _state, PickTarget _target) {
_state.set_depthFunc(oldDepthFunc);
lastPickTarget_ = _target;
// restore state
if (clientStateEnabledVertexArray)
GLState::enableClientState(GL_VERTEX_ARRAY);
else
GLState::disableClientState(GL_VERTEX_ARRAY);
if (clientStateEnabledColorArray)
GLState::enableClientState(GL_COLOR_ARRAY);
else
GLState::disableClientState(GL_COLOR_ARRAY);
if (clientStateEnabledNormalArray)
GLState::enableClientState(GL_NORMAL_ARRAY);
else
GLState::disableClientState(GL_NORMAL_ARRAY);
if (clientStateEnabledTexCoordArray)
GLState::enableClientState(GL_TEXTURE_COORD_ARRAY);
else
GLState::disableClientState(GL_TEXTURE_COORD_ARRAY);
}
}
template<class VolumeMeshT>
......@@ -1274,27 +1246,35 @@ void VolumeMeshNodeT<VolumeMeshT>::pickVertices(GLState& _state) {
vertexPickBufferManager_.disableNormals();
vertexPickBufferManager_.enablePickColors();
int pickVertexMethod_ = 0;
static GLSL::Program* pickVertexShader_;
// load from cache
if (pickVertexMethod_ == 0)
pickVertexShader_ = ShaderCache::getInstance()->getProgram("Picking/pick_vertices_vs.glsl", "Picking/pick_vertices_fs.glsl", 0, false);
else
pickVertexShader_ = ShaderCache::getInstance()->getProgram("Picking/vertex.glsl", "Picking/pick_vertices_fs2.glsl", 0, false);
// check link status
if(!( pickVertexShader_ && pickVertexShader_->isLinked()))
return;
GLState::bindBuffer(GL_ARRAY_BUFFER, vertexPickBufferManager_.getPickBuffer(_state, 0));
pickVertexShader_->use();
vertexPickBufferManager_.getVertexDeclaration()->activateShaderPipeline(pickVertexShader_);
GLState::enableClientState(GL_VERTEX_ARRAY);
GLState::vertexPointer(3, GL_FLOAT, vertexPickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
GLState::enableClientState(GL_COLOR_ARRAY);
GLState::colorPointer(4, GL_UNSIGNED_BYTE, vertexPickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(vertexPickBufferManager_.getColorOffset()));
GLState::shadeModel(GL_SMOOTH);
GLState::disable(GL_LIGHTING);
pickVertexShader_->setUniform("pickVertexOffset", static_cast<GLint>(_state.pick_current_index()));//vertexPickBufferManager_.getColorOffset()) );
pickVertexShader_->setUniform("mWVP", _state.projection() * _state.modelview());
float oldPointSize = _state.point_size();
_state.set_point_size(1.5*_state.point_size());
glDrawArrays(GL_POINTS, 0, vertexPickBufferManager_.getNumOfVertices());
vertexPickBufferManager_.getVertexDeclaration()->deactivateShaderPipeline(pickVertexShader_);
pickVertexShader_->disable();
_state.set_point_size(oldPointSize);
GLState::disableClientState(GL_COLOR_ARRAY);
GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
}
......@@ -1315,14 +1295,14 @@ void VolumeMeshNodeT<VolumeMeshT>::pickEdges(GLState& _state, unsigned int _offs
GLState::bindBuffer(GL_ARRAY_BUFFER, edgePickBufferManager_.getPickBuffer(_state, _offset));
GLState::enableClientState(GL_VERTEX_ARRAY);
GLState::vertexPointer(3, GL_FLOAT, edgePickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
//GLState::enableClientState(GL_VERTEX_ARRAY);
//GLState::vertexPointer(3, GL_FLOAT, edgePickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
GLState::enableClientState(GL_COLOR_ARRAY);
GLState::colorPointer(4, GL_UNSIGNED_BYTE, edgePickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(edgePickBufferManager_.getColorOffset()));
//GLState::enableClientState(GL_COLOR_ARRAY);
//GLState::colorPointer(4, GL_UNSIGNED_BYTE, edgePickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(edgePickBufferManager_.getColorOffset()));
GLState::shadeModel(GL_SMOOTH);
GLState::disable(GL_LIGHTING);
//GLState::shadeModel(GL_SMOOTH);
//GLState::disable(GL_LIGHTING);
float oldLineWidth = _state.line_width();
_state.set_line_width(4.0*_state.line_width());
......@@ -1331,7 +1311,7 @@ void VolumeMeshNodeT<VolumeMeshT>::pickEdges(GLState& _state, unsigned int _offs
_state.set_line_width(oldLineWidth);
GLState::disableClientState(GL_COLOR_ARRAY);
//GLState::disableClientState(GL_COLOR_ARRAY);
GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
}
......@@ -1354,18 +1334,18 @@ void VolumeMeshNodeT<VolumeMeshT>::pickFaces(GLState& _state, unsigned int _offs
GLState::bindBuffer(GL_ARRAY_BUFFER, facePickBufferManager_.getPickBuffer(_state, _offset));
GLState::enableClientState(GL_VERTEX_ARRAY);
GLState::vertexPointer(3, GL_FLOAT, facePickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
//GLState::enableClientState(GL_VERTEX_ARRAY);
//GLState::vertexPointer(3, GL_FLOAT, facePickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
GLState::enableClientState(GL_COLOR_ARRAY);
GLState::colorPointer(4, GL_UNSIGNED_BYTE, facePickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(facePickBufferManager_.getColorOffset()));
//GLState::enableClientState(GL_COLOR_ARRAY);
//GLState::colorPointer(4, GL_UNSIGNED_BYTE, facePickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(facePickBufferManager_.getColorOffset()));
GLState::shadeModel(GL_SMOOTH);
GLState::disable(GL_LIGHTING);
//GLState::shadeModel(GL_SMOOTH);
//GLState::disable(GL_LIGHTING);
glDrawArrays(GL_TRIANGLES, 0, facePickBufferManager_.getNumOfVertices());
GLState::disableClientState(GL_COLOR_ARRAY);
//GLState::disableClientState(GL_COLOR_ARRAY);
GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
}
......@@ -1381,18 +1361,18 @@ void VolumeMeshNodeT<VolumeMeshT>::pickCells(GLState& _state, unsigned int _offs
GLState::bindBuffer(GL_ARRAY_BUFFER, cellPickBufferManager_.getPickBuffer(_state, _offset));
GLState::enableClientState(GL_VERTEX_ARRAY);
GLState::vertexPointer(3, GL_FLOAT, cellPickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
//GLState::enableClientState(GL_VERTEX_ARRAY);
//GLState::vertexPointer(3, GL_FLOAT, cellPickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
GLState::enableClientState(GL_COLOR_ARRAY);
GLState::colorPointer(4, GL_UNSIGNED_BYTE, cellPickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(cellPickBufferManager_.getColorOffset()));
//GLState::enableClientState(GL_COLOR_ARRAY);
//GLState::colorPointer(4, GL_UNSIGNED_BYTE, cellPickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(cellPickBufferManager_.getColorOffset()));
GLState::shadeModel(GL_SMOOTH);
GLState::disable(GL_LIGHTING);
//GLState::shadeModel(GL_SMOOTH);
//GLState::disable(GL_LIGHTING);
glDrawArrays(GL_TRIANGLES, 0, cellPickBufferManager_.getNumOfVertices());
GLState::disableClientState(GL_COLOR_ARRAY);
//GLState::disableClientState(GL_COLOR_ARRAY);
GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
}
......
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