From c36fa266231814810e45b5bd473f9dd17c92b874 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Sat, 13 Aug 2016 11:47:09 +0000 Subject: [PATCH] one more try to fix the font texture bugs with recent MacOS versions --- Fltk/openglWindow.cpp | 4 +++- Geo/GModel.h | 4 ++-- Geo/GModelVertexArrays.cpp | 5 +++-- Graphics/drawContext.cpp | 2 -- Graphics/drawMesh.cpp | 11 ++++++++++- Graphics/drawPost.cpp | 12 +++++++++--- Post/PView.h | 2 +- Post/PViewVertexArrays.cpp | 16 ++++++++++------ 8 files changed, 38 insertions(+), 18 deletions(-) diff --git a/Fltk/openglWindow.cpp b/Fltk/openglWindow.cpp index baf3730f8d..2d90a691cb 100644 --- a/Fltk/openglWindow.cpp +++ b/Fltk/openglWindow.cpp @@ -153,7 +153,9 @@ void openglWindow::draw() Msg::Debug("openglWindow::draw()"); - if(!context_valid()) _ctx->invalidateQuadricsAndDisplayLists(); + if(!context_valid()){ + _ctx->invalidateQuadricsAndDisplayLists(); + } _ctx->viewport[0] = 0; _ctx->viewport[1] = 0; diff --git a/Geo/GModel.h b/Geo/GModel.h index a9d3c9fb8b..6e1de7891f 100644 --- a/Geo/GModel.h +++ b/Geo/GModel.h @@ -429,7 +429,7 @@ class GModel void createTopologyFromFaces(std::vector<discreteFace*> &pFaces, int ignoreHoles=0); void makeDiscreteRegionsSimplyConnected(); void makeDiscreteFacesSimplyConnected(); - + // align periodic boundaries void alignPeriodicBoundaries(); @@ -489,7 +489,7 @@ class GModel void createPartitionBoundaries(int createGhostCells, int createAllDims = 0); // fill the vertex arrays, given the current option and data - void fillVertexArrays(); + bool fillVertexArrays(); // reclassify a mesh i.e. use an angle threshold to tag edges faces and regions void classifyFaces(std::set<GFace*> &_faces); diff --git a/Geo/GModelVertexArrays.cpp b/Geo/GModelVertexArrays.cpp index 952105a994..9c4c1763a5 100644 --- a/Geo/GModelVertexArrays.cpp +++ b/Geo/GModelVertexArrays.cpp @@ -413,9 +413,9 @@ class initMeshGRegion { } }; -void GModel::fillVertexArrays() +bool GModel::fillVertexArrays() { - if(!getVisibility() || !CTX::instance()->mesh.changed) return; + if(!getVisibility() || !CTX::instance()->mesh.changed) return false; Msg::Debug("Mesh has changed: reinitializing vertex arrays"); @@ -434,4 +434,5 @@ void GModel::fillVertexArrays() if(status >= 3 && CTX::instance()->mesh.changed & ENT_VOLUME) std::for_each(firstRegion(), lastRegion(), initMeshGRegion()); + return true; } diff --git a/Graphics/drawContext.cpp b/Graphics/drawContext.cpp index 19386228b3..0827f40e35 100644 --- a/Graphics/drawContext.cpp +++ b/Graphics/drawContext.cpp @@ -285,8 +285,6 @@ void drawContext::draw3d() CTX::instance()->mesh.volumesNum) numStrings = std::max(numStrings, GModel::current()->getNumMeshElements()); numStrings *= 2; - // FIXME: restting to 1 each time to workaround bug on recent MacOS versions - gl_texture_pile_height(1); if(gl_texture_pile_height() < numStrings) gl_texture_pile_height(numStrings); #endif diff --git a/Graphics/drawMesh.cpp b/Graphics/drawMesh.cpp index 7544c357bd..76a9ea56e3 100644 --- a/Graphics/drawMesh.cpp +++ b/Graphics/drawMesh.cpp @@ -27,6 +27,11 @@ #include "PView.h" #include "PViewData.h" +#if defined(HAVE_FLTK) +#include <FL/Fl.H> +#include <FL/gl.h> +#endif + // from GModelVertexArrays extern unsigned int getColorByEntity(GEntity *e); extern bool isElementVisible(MElement *ele); @@ -685,7 +690,11 @@ void drawContext::drawMesh() for(unsigned int i = 0; i < GModel::list.size(); i++){ GModel *m = GModel::list[i]; - m->fillVertexArrays(); + bool changed = m->fillVertexArrays(); +#if defined(HAVE_FLTK) && defined(__APPLE__) + // FIXME: resetting texture pile fixes bug with recent MacOS versions + if(changed) gl_texture_pile_height(gl_texture_pile_height()); +#endif if(m->getVisibility() && isVisible(m)){ int status = m->getMeshStatus(); if(status >= 0) diff --git a/Graphics/drawPost.cpp b/Graphics/drawPost.cpp index cdcea4a6a6..b35bffe084 100644 --- a/Graphics/drawPost.cpp +++ b/Graphics/drawPost.cpp @@ -577,7 +577,13 @@ void drawContext::drawPost() if(!CTX::instance()->post.draw) return; - for(unsigned int i = 0; i < PView::list.size(); i++) - PView::list[i]->fillVertexArrays(); - std::for_each(PView::list.begin(), PView::list.end(), drawPView(this)); + for(unsigned int i = 0; i < PView::list.size(); i++){ + bool changed = PView::list[i]->fillVertexArrays(); +#if defined(HAVE_FLTK) && defined(__APPLE__) + // FIXME: resetting texture pile fixes bug with recent MacOS versions + if(changed) gl_texture_pile_height(gl_texture_pile_height()); +#endif + } + + std::for_each(PView::list.begin(), PView::list.end(), drawPView(this)); } diff --git a/Post/PView.h b/Post/PView.h index 478f77c4e6..78922d7ef6 100644 --- a/Post/PView.h +++ b/Post/PView.h @@ -135,7 +135,7 @@ class PView{ VertexArray *va_points, *va_lines, *va_triangles, *va_vectors, *va_ellipses; // fill the vertex arrays, given the current option and data - void fillVertexArrays(); + bool fillVertexArrays(); // fill a vertex array using a raw stream of bytes static void fillVertexArray(onelab::localNetworkClient *remote, int length, diff --git a/Post/PViewVertexArrays.cpp b/Post/PViewVertexArrays.cpp index 013694845c..157e4b86d5 100644 --- a/Post/PViewVertexArrays.cpp +++ b/Post/PViewVertexArrays.cpp @@ -1388,14 +1388,16 @@ class initPView { return heuristic + 1000; } public: - void operator () (PView *p) + bool operator () (PView *p) { // use adaptive data if available PViewData *data = p->getData(true); PViewOptions *opt = p->getOptions(); - if(data->getDirty() || !data->getNumTimeSteps() || !p->getChanged()) return; - if(!opt->visible || opt->type != PViewOptions::Plot3D) return; + if(data->getDirty() || !data->getNumTimeSteps() || !p->getChanged()) + return false; + if(!opt->visible || opt->type != PViewOptions::Plot3D) + return false; p->deleteVertexArrays(); @@ -1405,7 +1407,7 @@ class initPView { PrintOptions(0, GMSH_FULLRC, 0, 0, fileName.c_str()); std::string options = ConvertFileToString(fileName); data->fillRemoteVertexArrays(options); - return; + return false; } if(opt->useGenRaise) opt->createGeneralRaise(); @@ -1432,6 +1434,7 @@ class initPView { p->va_ellipses = new VertexArray(4, _estimateNumEllipses(p)); if(p->normals) delete p->normals; + p->normals = new smooth_normals(opt->angleSmoothNormals); if(opt->smoothNormals) addElementsInArrays(p, true); @@ -1451,13 +1454,14 @@ class initPView { p->va_vectors->getMemoryInMb() + p->va_ellipses->getMemoryInMb()); p->setChanged(false); + return true; } }; -void PView::fillVertexArrays() +bool PView::fillVertexArrays() { initPView init; - init(this); + return init(this); } void PView::fillVertexArray(onelab::localNetworkClient *remote, int length, -- GitLab