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 },
{ "pixeleffect", Graphics::SUPPORT_PIXELEFFECT },
{ "npot", Graphics::SUPPORT_NPOT },
{ "subtractive", Graphics::SUPPORT_SUBTRACTIVE },
};
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_PIXELEFFECT,
SUPPORT_NPOT,
SUPPORT_SUBTRACTIVE,
SUPPORT_MAX_ENUM
};
+18 -4
View File
@@ -511,10 +511,24 @@ namespace opengl
{
glAlphaFunc(GL_GEQUAL, 0);
if (mode == BLEND_SUBTRACTIVE)
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
else
glBlendEquation(GL_FUNC_ADD);
if (GLEE_VERSION_1_4 || GLEE_ARB_imaging) {
if (mode == BLEND_SUBTRACTIVE) {
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
} 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)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -19,6 +19,7 @@
**/
#include "wrap_Graphics.h"
#include "GLee.h"
#include <graphics/DrawQable.h>
#include <image/ImageData.h>
#include <font/Rasterizer.h>
@@ -793,6 +794,9 @@ namespace opengl
if (!Image::hasNpot())
supported = false;
break;
case Graphics::SUPPORT_SUBTRACTIVE:
supported = (GLEE_VERSION_1_4 || GLEE_ARB_imaging) || (GLEE_EXT_blend_minmax && GLEE_EXT_blend_subtract);
break;
default:
supported = false;
}