Commit 60e9b3eb authored by Martin Schultz's avatar Martin Schultz

synchronized the pickImplementation in DrawMeshT and MeshNode2T

also removed some obsolete checks for compatibility profiles, which
prevented the proper use of the optimized picking variant when compat
profiles with version 3.2 or newer were present
parent 8859b39c
......@@ -96,7 +96,9 @@ DrawMeshT<Mesh>::DrawMeshT(Mesh& _mesh)
updatePerHalfedgeBuffers_(1)
{
pickVertexMethod_ = 1;
//today (4.5.2018) the picking shader which uses a textureBuffer, also uses gl_PrimitiveID
// since it is only supported since glslversion 150 we can just check for openGLVersion 3.2
pickVertexMethod_ = openGLVersionTest(3,2) ? 1 : 0;
pickVertexShader_ = 0;
pickFaceShader_ = 0;
......@@ -1621,18 +1623,12 @@ void DrawMeshT<Mesh>::updatePickingVertices_opt(ACG::GLState& _state)
rebuild();
}
if(ACG::compatibilityProfile())
pickVertexMethod_ = 1; // no texture buffers supported during compilation
if (numVerts_)
{
// upload vbo id->openmesh id lookup-table to texture buffer
if (pickVertexMethod_ == 0)
{
if(!ACG::compatibilityProfile())
{
std::vector<int> forwardMap(numVerts_, 0);
for (int i = 0; i < (int)numVerts_; ++i)
......@@ -1642,7 +1638,6 @@ void DrawMeshT<Mesh>::updatePickingVertices_opt(ACG::GLState& _state)
forwardMap[vboIdx] = i;
}
pickVertexMapTBO_.setBufferData(sizeof(int) * numVerts_, &forwardMap[0], GL_R32I, GL_STATIC_DRAW);
}
}
else
......@@ -1727,8 +1722,7 @@ void ACG::DrawMeshT<Mesh>::drawPickingVertices_opt( const GLMatrixf& _mvp, size_
if (pickVertexMethod_ == 0)
{
pickVertexShader_->setUniform("vboToInputMap", 0);
if(!ACG::compatibilityProfile())
pickVertexMap_opt()->bind(GL_TEXTURE0);
pickVertexMap_opt()->bind(GL_TEXTURE0);
}
pickVertexShader_->setUniform("mWVP", _mvp);
......@@ -2150,8 +2144,7 @@ void ACG::DrawMeshT<Mesh>::drawPickingFaces_opt( const GLMatrixf& _mvp, size_t _
pickFaceShader_->setUniform("pickFaceOffset", static_cast<GLint>(_pickOffset));
pickFaceShader_->setUniform("triToFaceMap", 0);
if(!ACG::compatibilityProfile())
pickFaceTriangleMap_opt()->bind(GL_TEXTURE0);
pickFaceTriangleMap_opt()->bind(GL_TEXTURE0);
pickFaceShader_->setUniform("mWVP", _mvp);
......
......@@ -1215,9 +1215,10 @@ pick_vertices(GLState& _state, bool _front)
// 1 -> render mesh with picking shader (optimized, add. mem alloc: none for point-clouds, otherwise 4 bytes per openmesh vertex on gpu)
int pickImplementationMethod = 0;
// use optimized picking if supported
// use optimized picking if supported (the function actually checks whether the shader was linked and bound)
// which shader should be used only depends on the available OpenGL version
if (drawMesh_->supportsPickingVertices_opt())
pickImplementationMethod = 1;
pickImplementationMethod = openGLVersionTest(3,2) ? 1 : 0;
if (_state.color_picking () ) {
......@@ -1320,7 +1321,7 @@ pick_edges(GLState& _state, bool _front)
// use optimized picking if supported
if (drawMesh_->supportsPickingEdges_opt())
pickImplementationMethod = 1;
pickImplementationMethod = openGLVersionTest(3,2) ? 1 : 0;
if ( updateEdgePicking_ || _state.pick_current_index () != edgePickingBaseIndex_) {
if (pickImplementationMethod == 0)
......@@ -1398,7 +1399,7 @@ pick_faces(GLState& _state)
// use optimized picking if supported
if (drawMesh_->supportsPickingFaces_opt())
pickImplementationMethod = 1;
pickImplementationMethod = openGLVersionTest(3,2) ? 1 : 0;
// pickImplementationMethod = 0;
......@@ -1501,12 +1502,9 @@ pick_any(GLState& _state)
// 1 -> render mesh with picking shader (optimized, add. mem alloc: none [ shared memory with optimized vertex,edge,face picking ])
int pickImplementationMethod = 0;
if(!_state.compatibilityProfile())
pickImplementationMethod = 1;
// use optimized picking if supported
if (drawMesh_->supportsPickingAny_opt())
pickImplementationMethod = 1;
pickImplementationMethod = openGLVersionTest(3,2) ? 1 : 0;
if ( updateAnyPicking_ || _state.pick_current_index () != anyPickingBaseIndex_) {
......
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