Add support for falling back to glBlendEquationEXT if necessary.

This should help keep LÖVE from crashing on old cards with crappy drivers.
This commit is contained in:
Bill Meltsner
2012-03-03 19:25:42 -05:00
parent 830283ff17
commit 57b4d2c5b9
4 changed files with 24 additions and 4 deletions
+1
View File
@@ -156,6 +156,7 @@ namespace graphics
{ "canvas", Graphics::SUPPORT_CANVAS }, { "canvas", Graphics::SUPPORT_CANVAS },
{ "pixeleffect", Graphics::SUPPORT_PIXELEFFECT }, { "pixeleffect", Graphics::SUPPORT_PIXELEFFECT },
{ "npot", Graphics::SUPPORT_NPOT }, { "npot", Graphics::SUPPORT_NPOT },
{ "subtractive", Graphics::SUPPORT_SUBTRACTIVE },
}; };
StringMap<Graphics::Support, Graphics::SUPPORT_MAX_ENUM> Graphics::support(Graphics::supportEntries, sizeof(Graphics::supportEntries)); StringMap<Graphics::Support, Graphics::SUPPORT_MAX_ENUM> Graphics::support(Graphics::supportEntries, sizeof(Graphics::supportEntries));
+1
View File
@@ -85,6 +85,7 @@ namespace graphics
SUPPORT_CANVAS = 1, SUPPORT_CANVAS = 1,
SUPPORT_PIXELEFFECT, SUPPORT_PIXELEFFECT,
SUPPORT_NPOT, SUPPORT_NPOT,
SUPPORT_SUBTRACTIVE,
SUPPORT_MAX_ENUM SUPPORT_MAX_ENUM
}; };
+18 -4
View File
@@ -511,10 +511,24 @@ namespace opengl
{ {
glAlphaFunc(GL_GEQUAL, 0); glAlphaFunc(GL_GEQUAL, 0);
if (mode == BLEND_SUBTRACTIVE) if (GLEE_VERSION_1_4 || GLEE_ARB_imaging) {
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT); if (mode == BLEND_SUBTRACTIVE) {
else glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
glBlendEquation(GL_FUNC_ADD); } else {
glBlendEquation(GL_FUNC_ADD);
}
} else if (GLEE_EXT_blend_minmax && GLEE_EXT_blend_subtract) {
if (mode == BLEND_SUBTRACTIVE) {
glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT_EXT);
} else {
glBlendEquationEXT(GL_FUNC_ADD_EXT);
}
} else {
if (mode == BLEND_SUBTRACTIVE) {
std::cerr << "This graphics card does not support the subtract blend mode!" << std::endl;
}
// GL_FUNC_ADD is the default even without access to glBlendEquation, so that'll still work.
}
if (mode == BLEND_ALPHA) if (mode == BLEND_ALPHA)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -19,6 +19,7 @@
**/ **/
#include "wrap_Graphics.h" #include "wrap_Graphics.h"
#include "GLee.h"
#include <graphics/DrawQable.h> #include <graphics/DrawQable.h>
#include <image/ImageData.h> #include <image/ImageData.h>
#include <font/Rasterizer.h> #include <font/Rasterizer.h>
@@ -793,6 +794,9 @@ namespace opengl
if (!Image::hasNpot()) if (!Image::hasNpot())
supported = false; supported = false;
break; break;
case Graphics::SUPPORT_SUBTRACTIVE:
supported = (GLEE_VERSION_1_4 || GLEE_ARB_imaging) || (GLEE_EXT_blend_minmax && GLEE_EXT_blend_subtract);
break;
default: default:
supported = false; supported = false;
} }