From 5812c494a59d0bb6614bc4c332073e5c6773887d Mon Sep 17 00:00:00 2001 From: Maxime Curioni Date: Sun, 28 Sep 2008 18:18:30 +0000 Subject: [PATCH] soc-2008-mxcurioni: imposed the glBlendEquation test accross all platforms (providing greater robustness), introduced the FRS_glBlendEquation that uses glBlendEquation/glBlendEquationEXT based on the system's capabilities. --- .../intern/app_blender/AppCanvas.cpp | 32 ++++++++----------- .../intern/rendering/GLStrokeRenderer.cpp | 8 ++--- .../intern/rendering/GLStrokeRenderer.h | 11 +------ 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/source/blender/freestyle/intern/app_blender/AppCanvas.cpp b/source/blender/freestyle/intern/app_blender/AppCanvas.cpp index dd4075eccd0..12a7004cd86 100755 --- a/source/blender/freestyle/intern/app_blender/AppCanvas.cpp +++ b/source/blender/freestyle/intern/app_blender/AppCanvas.cpp @@ -19,16 +19,7 @@ // /////////////////////////////////////////////////////////////////////////////// - -#ifdef WIN32 -# include -# include -#endif -#ifdef __MACH__ -# include -#else -# include -#endif +#include "../rendering/GLBlendEquation.h" #include "AppGLWidget.h" #include "../image/Image.h" @@ -103,7 +94,7 @@ void AppCanvas::preDraw() void AppCanvas::init() { -#ifdef WIN32 + static bool firsttime = true; if (firsttime) { @@ -112,15 +103,18 @@ void AppCanvas::init() { cerr << "Error: problem occurred while initializing GLEW" << endl; } - cout << "GLEW initialized" << endl; + cout << "GLEW initialized: "; - if(!glBlendEquation) { + if(glBlendEquation) { + cout << "using glBlendEquation" << endl; + } else if(glBlendEquationEXT) { + cout << "using glBlendEquationEXT" << endl; + } else { _basic = true; - cout << "glBlendEquation unavailable on this hardware -> switching to strokes basic rendering mode" << endl; + cout << "glBlendEquation or glBlendEquationEXT unavailable on this hardware -> switching to strokes basic rendering mode" << endl; } firsttime=false; } -#endif _Renderer = new GLStrokeRenderer; if(!StrokeRenderer::loadTextures()) @@ -258,12 +252,12 @@ void AppCanvas::Render(const StrokeRenderer *iRenderer) glDisable(GL_DEPTH_TEST); - glBlendEquation(GL_ADD); + FRS_glBlendEquation(GL_ADD); glBlendFunc(GL_DST_COLOR, GL_ZERO); glPushAttrib(GL_COLOR_BUFFER_BIT); - glBlendEquation(GL_FUNC_SUBTRACT); + FRS_glBlendEquation(GL_FUNC_SUBTRACT); glBlendFunc(GL_ONE, GL_ONE); glDisable(GL_TEXTURE_2D); @@ -280,7 +274,7 @@ void AppCanvas::Render(const StrokeRenderer *iRenderer) glPopAttrib(); glDisable(GL_DEPTH_TEST); - glBlendEquation(GL_ADD); + FRS_glBlendEquation(GL_ADD); glBlendFunc(GL_SRC_ALPHA, GL_ONE); glEnable(GL_TEXTURE_2D); @@ -288,7 +282,7 @@ void AppCanvas::Render(const StrokeRenderer *iRenderer) Canvas::Render(iRenderer); // glPushAttrib(GL_COLOR_BUFFER_BIT); - glBlendEquation(GL_FUNC_SUBTRACT); + FRS_glBlendEquation(GL_FUNC_SUBTRACT); glBlendFunc(GL_ONE, GL_ONE); glDisable(GL_TEXTURE_2D); diff --git a/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp b/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp index e0189da7075..0213b5450ab 100755 --- a/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/rendering/GLStrokeRenderer.cpp @@ -36,8 +36,6 @@ extern "C" { #include "../system/StringUtils.h" -//#define glBlendEquation(x) - GLStrokeRenderer::GLStrokeRenderer() :StrokeRenderer() { @@ -95,16 +93,16 @@ void GLStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const if(strokeType==Stroke::DRY_MEDIUM) { - glBlendEquation(GL_MAX); + FRS_glBlendEquation(GL_MAX); } else if(strokeType==Stroke::OPAQUE_MEDIUM) { - glBlendEquation(GL_ADD); + FRS_glBlendEquation(GL_ADD); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } else { - glBlendEquation(GL_ADD); + FRS_glBlendEquation(GL_ADD); glBlendFunc(GL_SRC_ALPHA, GL_ONE); } glEnable(GL_TEXTURE_2D); diff --git a/source/blender/freestyle/intern/rendering/GLStrokeRenderer.h b/source/blender/freestyle/intern/rendering/GLStrokeRenderer.h index d7435ae5e47..345a4273350 100755 --- a/source/blender/freestyle/intern/rendering/GLStrokeRenderer.h +++ b/source/blender/freestyle/intern/rendering/GLStrokeRenderer.h @@ -34,16 +34,7 @@ # include "../stroke/StrokeRenderer.h" # include "../stroke/StrokeRep.h" - -#ifdef WIN32 -# include -# include -#endif -#ifdef __MACH__ -# include -#else -# include -#endif +#include "GLBlendEquation.h" /**********************************/ /* */