From c035b3e9e3a38784e1cff7555c1232e888581b5b Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 28 Jan 2018 16:10:18 +0000 Subject: [PATCH] Better fix for Canvas-in-PUI compositing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This seems to work everywhere, let’s try it. --- src/GUI/CanvasWidget.cxx | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/GUI/CanvasWidget.cxx b/src/GUI/CanvasWidget.cxx index b72da56c0..33f1af076 100644 --- a/src/GUI/CanvasWidget.cxx +++ b/src/GUI/CanvasWidget.cxx @@ -16,9 +16,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -#ifdef HAVE_CONFIG_H -# include -#endif +#include #include "CanvasWidget.hxx" @@ -26,9 +24,6 @@ #include
// fgGetKeyModifiers() #include -#include -#include - #include #include @@ -201,13 +196,11 @@ void CanvasWidget::draw(int dx, int dy) { glEnable(GL_TEXTURE_2D); - glEnable(GL_BLEND); + // prevent alpha values in the Canvas texture ending up in the PUI + // compositing FBO. While that would ideally be a feature, it didn't + // use to work, so Canvas users don't do a default opaque fill. + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); -#if OSG_VERSION_LESS_THAN(3,4,0) -#else - osg::GLExtensions* extensions = osg::GLExtensions::Get(0, true); - extensions->glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ZERO, GL_ONE); -#endif glBindTexture(GL_TEXTURE_2D, _canvas_mgr->getCanvasTexId(_canvas)); glBegin( GL_QUADS ); glColor4f(1,1,1, 1.0f); @@ -216,6 +209,7 @@ void CanvasWidget::draw(int dx, int dy) glTexCoord2f(1,1); glVertex2f(dx + abox.max[0], dy + abox.max[1]); glTexCoord2f(0,1); glVertex2f(dx + abox.min[0], dy + abox.max[1]); glEnd(); + glDisable(GL_TEXTURE_2D); - glDisable(GL_BLEND); + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); }