Commit 34776b1e authored by Jan Möbius's avatar Jan Möbius

Get rid of the display lists in picking

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12705 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 165231bc
......@@ -77,18 +77,14 @@ MeshNodeT(Mesh& _mesh,
enableNormals_(true),
enableColors_(true),
enabled_arrays_(0),
updateVertexPickingList_(true),
updateVertexPicking_(true),
vertexPickingBaseIndex_(0),
vertexPickingList_(0),
updateEdgePickingList_(true),
updateEdgePicking_(true),
edgePickingBaseIndex_(0),
edgePickingList_(0),
updateFacePickingList_(true),
updateFacePicking_(true),
facePickingBaseIndex_(0),
facePickingList_(0),
updateAnyPickingList_(true),
updateAnyPicking_(true),
anyPickingBaseIndex_(0),
anyPickingList_(0),
perFaceTextureIndexAvailable_(false),
perFaceTextureCoordsAvailable_(false),
textureMap_(0)
......@@ -101,11 +97,6 @@ MeshNodeT(Mesh& _mesh,
drawMesh_ = new DrawMeshT<Mesh>(mesh_);
vertexPickingList_ = glGenLists(1);
edgePickingList_ = glGenLists(1);
facePickingList_ = glGenLists(1);
anyPickingList_ = glGenLists(3);
}
template<class Mesh>
......@@ -113,19 +104,6 @@ MeshNodeT<Mesh>::
~MeshNodeT()
{
// Delete all allocated buffers
if (vertexPickingList_)
glDeleteLists (vertexPickingList_, 1);
if (edgePickingList_)
glDeleteLists (edgePickingList_, 1);
if (facePickingList_)
glDeleteLists (facePickingList_, 1);
if (anyPickingList_)
glDeleteLists (anyPickingList_, 3);
delete drawMesh_;
}
......@@ -776,21 +754,13 @@ pick_vertices(GLState& _state, bool _front)
}
if (vertexPickingList_ && !updateVertexPickingList_ && _state.pick_current_index () == vertexPickingBaseIndex_) {
glCallList (vertexPickingList_);
ACG::GLState::depthFunc(prev_depth);
return;
}
if (vertexPickingList_) {
glNewList (vertexPickingList_, GL_COMPILE);
updateVertexPickingList_ = false;
if ( updateVertexPicking_ || _state.pick_current_index () != vertexPickingBaseIndex_) {
drawMesh_->updatePickingVertices(_state);
vertexPickingBaseIndex_ = _state.pick_current_index ();
updateVertexPicking_ = false;
}
if (_state.color_picking () && drawMesh_) {
drawMesh_->updatePickingVertices(_state);
// For this version we load the colors directly not from vbo
ACG::GLState::bindBuffer(GL_ARRAY_BUFFER_ARB, 0);
......@@ -814,11 +784,7 @@ pick_vertices(GLState& _state, bool _front)
std::cerr << "Fallback not available pick_vertices!" << std::endl;
ACG::GLState::depthFunc(prev_depth);
if (vertexPickingList_) {
glEndList ();
glCallList (vertexPickingList_);
}
}
template<class Mesh>
......@@ -861,22 +827,15 @@ pick_edges(GLState& _state, bool _front)
enable_arrays(0);
}
if (edgePickingList_ && !updateEdgePickingList_ && _state.pick_current_index () == edgePickingBaseIndex_) {
glCallList (edgePickingList_);
ACG::GLState::depthFunc(prev_depth);
return;
}
if (edgePickingList_) {
glNewList (edgePickingList_, GL_COMPILE);
updateEdgePickingList_ = false;
if ( updateEdgePicking_ || _state.pick_current_index () != edgePickingBaseIndex_) {
drawMesh_->updatePickingEdges(_state);
edgePickingBaseIndex_ = _state.pick_current_index ();
updateEdgePicking_ = false;
}
if (_state.color_picking () ) {
if ( mesh_.n_edges() != 0 && drawMesh_) {
drawMesh_->updatePickingEdges(_state);
// For this version we load the colors directly not from vbo
ACG::GLState::bindBuffer(GL_ARRAY_BUFFER_ARB, 0);
......@@ -903,11 +862,7 @@ pick_edges(GLState& _state, bool _front)
}
ACG::GLState::depthFunc(prev_depth);
if (edgePickingList_) {
glEndList ();
glCallList (edgePickingList_);
}
}
template<class Mesh>
......@@ -936,21 +891,15 @@ pick_faces(GLState& _state)
}
}
if (facePickingList_ && !updateFacePickingList_ && _state.pick_current_index () == facePickingBaseIndex_) {
glCallList (facePickingList_);
return;
if ( updateFacePicking_ || _state.pick_current_index () != facePickingBaseIndex_) {
drawMesh_->updatePickingFaces(_state);
facePickingBaseIndex_ = _state.pick_current_index ();
updateFacePicking_ = false;
}
if (facePickingList_) {
glNewList (facePickingList_, GL_COMPILE);
updateFacePickingList_ = false;
facePickingBaseIndex_ = _state.pick_current_index();
}
if (_state.color_picking ()) {
if ( mesh_.n_faces() != 0 ) {
drawMesh_->updatePickingFaces(_state);
// For this version we load the colors directly not from vbo
ACG::GLState::bindBuffer(GL_ARRAY_BUFFER_ARB, 0);
......@@ -975,10 +924,6 @@ pick_faces(GLState& _state)
} else
std::cerr << "No fallback pick_faces!" << std::endl;
if (facePickingList_) {
glEndList ();
glCallList (facePickingList_);
}
}
template<class Mesh>
......@@ -1006,24 +951,15 @@ pick_any(GLState& _state)
return;
}
if (anyPickingList_ && !updateAnyPickingList_ && _state.pick_current_index () == anyPickingBaseIndex_)
{
glCallList (anyPickingList_);
glCallList (anyPickingList_+1);
glCallList (anyPickingList_+2);
return;
}
if (anyPickingList_) {
glNewList (anyPickingList_, GL_COMPILE);
updateAnyPickingList_ = false;
if ( updateAnyPicking_ || _state.pick_current_index () != anyPickingBaseIndex_) {
drawMesh_->updatePickingAny(_state);
anyPickingBaseIndex_ = _state.pick_current_index ();
updateAnyPicking_ = false;
}
if (_state.color_picking()) {
drawMesh_->updatePickingAny(_state);
// For this version we load the colors directly, not from vbo
ACG::GLState::bindBuffer(GL_ARRAY_BUFFER_ARB, 0);
......@@ -1043,12 +979,6 @@ pick_any(GLState& _state)
}
if (anyPickingList_)
{
glEndList ();
glNewList (anyPickingList_+1, GL_COMPILE);
}
ACG::GLState::depthFunc(GL_LEQUAL);
// If we do not have any edges, we generate an empty list here.
......@@ -1060,18 +990,6 @@ pick_any(GLState& _state)
glDrawArrays(GL_LINES, 0, mesh_.n_edges() * 2);
}
if (anyPickingList_)
{
//restore depth buffer comparison function for this display list
ACG::GLState::depthFunc(prev_depth);
glEndList ();
glNewList (anyPickingList_+2, GL_COMPILE);
ACG::GLState::depthFunc(GL_LEQUAL);
}
// For this version we load the colors directly not from vbo
ACG::GLState::bindBuffer(GL_ARRAY_BUFFER_ARB, 0);
ACG::GLState::colorPointer(drawMesh_->pickVertexColorBuffer());
......@@ -1090,14 +1008,6 @@ pick_any(GLState& _state)
//restore depth buffer comparison function for the active display list
ACG::GLState::depthFunc(prev_depth);
if (anyPickingList_)
{
glEndList ();
glCallList (anyPickingList_);
glCallList (anyPickingList_+1);
glCallList (anyPickingList_+2);
}
glCheckErrors();
}
......@@ -1111,10 +1021,10 @@ update_geometry() {
updateAnyList_ = true;
*/
updateVertexPickingList_ = true;
updateEdgePickingList_ = true;
updateFacePickingList_ = true;
updateAnyPickingList_ = true;
updateVertexPicking_ = true;
updateEdgePicking_ = true;
updateFacePicking_ = true;
updateAnyPicking_ = true;
// Set per edge arrays to invalid as they have to be regenerated
drawMesh_->invalidatePerEdgeBuffers();
......
......@@ -329,15 +329,12 @@ private:
*/
void pick_vertices(GLState& _state, bool _front = false);
/// Flag indicating if the vertex picking display list has to be updates
bool updateVertexPickingList_;
/// Flag indicating if the vertex picking has to be updated
bool updateVertexPicking_;
/// Index of the first vertex in vertexpicking
unsigned int vertexPickingBaseIndex_;
/// Dispplay list for rendering vertex picking
GLuint vertexPickingList_;
/** @} */
......@@ -353,14 +350,12 @@ private:
*/
void pick_edges(GLState& _state, bool _front = false);
/// Flag indicating if the edge picking display list has to be updates
bool updateEdgePickingList_;
/// Flag indicating if the edge picking has to be updated
bool updateEdgePicking_;
/// Index of the first edge in edgepicking
unsigned int edgePickingBaseIndex_;
/// Dispplay list for rendering edge picking
GLuint edgePickingList_;
/** @} */
......@@ -376,14 +371,11 @@ private:
*/
void pick_faces(GLState& _state);
/// Flag indicating if the edge picking display list has to be updates
bool updateFacePickingList_;
/// Flag indicating if the edge picking has to be updated
bool updateFacePicking_;
/// Index of the first face in facepicking
unsigned int facePickingBaseIndex_;
/// Dispplay list for rendering edge picking
GLuint facePickingList_;
/** @} */
......@@ -399,15 +391,12 @@ private:
*/
void pick_any(GLState& _state);
/// Flag indicating if the any picking display list has to be updates
bool updateAnyPickingList_;
/// Flag indicating if the any picking has to be updated
bool updateAnyPicking_;
/// Index of the first face in anypicking
unsigned int anyPickingBaseIndex_;
/// Dispplay list for rendering general picking
GLuint anyPickingList_;
/** @} */
......
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