Commit 2e0db28f authored by Martin Schultz's avatar Martin Schultz

use new picking sahder which uses color attributes to render to screen.

implements picking for core profiles
parent fcbb07d7
......@@ -1253,21 +1253,13 @@ void VolumeMeshNodeT<VolumeMeshT>::pickVertices(GLState& _state) {
vertexPickBufferManager_.disableNormals();
vertexPickBufferManager_.enablePickColors();
int pickVertexMethod_ = 0;
static GLSL::Program* pickVertexShader_;
static ACG::ShaderGenDesc desc;
desc.vertexColors = true;
desc.vertexTemplateFile = "Picking/vertexPassColors.glsl";
desc.fragmentTemplateFile = "Picking/passColors_fs.glsl";
// load from cache
if (pickVertexMethod_ == 0)
{
desc.vertexTemplateFile = "Picking/pick_vertices_vs.glsl";
desc.fragmentTemplateFile = "Picking/pick_vertices_fs.glsl";
}
else
{
desc.vertexTemplateFile = "Picking/vertex.glsl";
desc.fragmentTemplateFile = "Picking/pick_vertices_fs2.glsl";
}
// load from cache
pickVertexShader_ = ShaderCache::getInstance()->getProgram(&desc,nullptr);
// check link status
......@@ -1275,10 +1267,9 @@ void VolumeMeshNodeT<VolumeMeshT>::pickVertices(GLState& _state) {
return;
GLState::bindBuffer(GL_ARRAY_BUFFER, vertexPickBufferManager_.getPickBuffer(_state, 0));
pickVertexShader_->use();
vertexPickBufferManager_.getVertexDeclaration()->activateShaderPipeline(pickVertexShader_);
vertexPickBufferManager_.getVertexDeclaration()->activateShaderPipeline(pickVertexShader_);
pickVertexShader_->setUniform("pickVertexOffset", static_cast<GLint>(_state.pick_current_index()));//vertexPickBufferManager_.getColorOffset()) );
pickVertexShader_->setUniform("pickVertexOffset", static_cast<int>(_state.pick_current_index()));
pickVertexShader_->setUniform("mWVP", _state.projection() * _state.modelview());
float oldPointSize = _state.point_size();
......@@ -1307,26 +1298,36 @@ void VolumeMeshNodeT<VolumeMeshT>::pickEdges(GLState& _state, unsigned int _offs
edgePickBufferManager_.enablePickColors();
edgePickBufferManager_.disableNormals();
static GLSL::Program* pickVertexShader_;
static ACG::ShaderGenDesc desc;
desc.vertexColors = true;
desc.vertexTemplateFile = "Picking/vertexPassColors.glsl";
desc.fragmentTemplateFile = "Picking/passColors_fs.glsl";
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));
// load from cache
pickVertexShader_ = ShaderCache::getInstance()->getProgram(&desc,nullptr);
//GLState::enableClientState(GL_COLOR_ARRAY);
//GLState::colorPointer(4, GL_UNSIGNED_BYTE, edgePickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(edgePickBufferManager_.getColorOffset()));
// check link status
if(!( pickVertexShader_ && pickVertexShader_->isLinked()))
return;
GLState::bindBuffer(GL_ARRAY_BUFFER, edgePickBufferManager_.getPickBuffer(_state, _offset));
//GLState::shadeModel(GL_SMOOTH);
//GLState::disable(GL_LIGHTING);
pickVertexShader_->use();
edgePickBufferManager_.getVertexDeclaration()->activateShaderPipeline(pickVertexShader_);
pickVertexShader_->setUniform("pickVertexOffset", static_cast<int>(_state.pick_current_index()));
pickVertexShader_->setUniform("mWVP", _state.projection() * _state.modelview());
float oldLineWidth = _state.line_width();
_state.set_line_width(4.0*_state.line_width());
glDrawArrays(GL_LINES, 0, edgePickBufferManager_.getNumOfVertices());
edgePickBufferManager_.getVertexDeclaration()->deactivateShaderPipeline(pickVertexShader_);
pickVertexShader_->disable();
_state.set_line_width(oldLineWidth);
//GLState::disableClientState(GL_COLOR_ARRAY);
GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
}
......@@ -1346,21 +1347,31 @@ void VolumeMeshNodeT<VolumeMeshT>::pickFaces(GLState& _state, unsigned int _offs
facePickBufferManager_.disableNormals();
facePickBufferManager_.enablePickColors();
static GLSL::Program* pickVertexShader_;
static ACG::ShaderGenDesc desc;
desc.vertexColors = true;
desc.vertexTemplateFile = "Picking/vertexPassColors.glsl";
desc.fragmentTemplateFile = "Picking/passColors_fs.glsl";
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));
// load from cache
pickVertexShader_ = ShaderCache::getInstance()->getProgram(&desc,nullptr);
//GLState::enableClientState(GL_COLOR_ARRAY);
//GLState::colorPointer(4, GL_UNSIGNED_BYTE, facePickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(facePickBufferManager_.getColorOffset()));
// check link status
if(!( pickVertexShader_ && pickVertexShader_->isLinked()))
return;
GLState::bindBuffer(GL_ARRAY_BUFFER, facePickBufferManager_.getPickBuffer(_state, _offset));
pickVertexShader_->use();
facePickBufferManager_.getVertexDeclaration()->activateShaderPipeline(pickVertexShader_);
//GLState::shadeModel(GL_SMOOTH);
//GLState::disable(GL_LIGHTING);
pickVertexShader_->setUniform("pickVertexOffset", static_cast<int>(_state.pick_current_index()));
pickVertexShader_->setUniform("mWVP", _state.projection() * _state.modelview());
glDrawArrays(GL_TRIANGLES, 0, facePickBufferManager_.getNumOfVertices());
//GLState::disableClientState(GL_COLOR_ARRAY);
facePickBufferManager_.getVertexDeclaration()->deactivateShaderPipeline(pickVertexShader_);
pickVertexShader_->disable();
GLState::bindBuffer(GL_ARRAY_BUFFER, 0);
}
......@@ -1373,21 +1384,33 @@ void VolumeMeshNodeT<VolumeMeshT>::pickCells(GLState& _state, unsigned int _offs
cellPickBufferManager_.enablePickColors();
cellPickBufferManager_.disableNormals();
cellPickBufferManager_.enableCellPrimitives();
static GLSL::Program* pickVertexShader_;
static ACG::ShaderGenDesc desc;
desc.vertexColors = true;
desc.vertexTemplateFile = "Picking/vertexPassColors.glsl";
desc.fragmentTemplateFile = "Picking/passColors_fs.glsl";
GLState::bindBuffer(GL_ARRAY_BUFFER, cellPickBufferManager_.getPickBuffer(_state, _offset));
// load from cache
pickVertexShader_ = ShaderCache::getInstance()->getProgram(&desc,nullptr);
//GLState::enableClientState(GL_VERTEX_ARRAY);
//GLState::vertexPointer(3, GL_FLOAT, cellPickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(0));
// check link status
if(!( pickVertexShader_ && pickVertexShader_->isLinked()))
return;
GLState::bindBuffer(GL_ARRAY_BUFFER, cellPickBufferManager_.getPickBuffer(_state, _offset));
pickVertexShader_->use();
cellPickBufferManager_.getVertexDeclaration()->activateShaderPipeline(pickVertexShader_);
//GLState::enableClientState(GL_COLOR_ARRAY);
//GLState::colorPointer(4, GL_UNSIGNED_BYTE, cellPickBufferManager_.getStride(), reinterpret_cast<GLvoid*>(cellPickBufferManager_.getColorOffset()));
pickVertexShader_->setUniform("pickVertexOffset", static_cast<int>(_state.pick_current_index()));
pickVertexShader_->setUniform("mWVP", _state.projection() * _state.modelview());
//GLState::shadeModel(GL_SMOOTH);
//GLState::disable(GL_LIGHTING);
glDrawArrays(GL_TRIANGLES, 0, cellPickBufferManager_.getNumOfVertices());
//GLState::disableClientState(GL_COLOR_ARRAY);
cellPickBufferManager_.getVertexDeclaration()->deactivateShaderPipeline(pickVertexShader_);
pickVertexShader_->disable();
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