diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index badfb8b93..7a4f9f738 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -34,7 +34,7 @@ bool Graphics::getConstant(const char *in, DrawMode &out) return drawModes.find(in, out); } -bool Graphics::getConstant(DrawMode in, const char *&out) +bool Graphics::getConstant(DrawMode in, const char *&out) { return drawModes.find(in, out); } @@ -44,7 +44,7 @@ bool Graphics::getConstant(const char *in, BlendMode &out) return blendModes.find(in, out); } -bool Graphics::getConstant(BlendMode in, const char *&out) +bool Graphics::getConstant(BlendMode in, const char *&out) { return blendModes.find(in, out); } @@ -54,7 +54,7 @@ bool Graphics::getConstant(const char *in, LineStyle &out) return lineStyles.find(in, out); } -bool Graphics::getConstant(LineStyle in, const char *&out) +bool Graphics::getConstant(LineStyle in, const char *&out) { return lineStyles.find(in, out); } @@ -64,7 +64,7 @@ bool Graphics::getConstant(const char *in, LineJoin &out) return lineJoins.find(in, out); } -bool Graphics::getConstant(LineJoin in, const char *&out) +bool Graphics::getConstant(LineJoin in, const char *&out) { return lineJoins.find(in, out); } @@ -74,7 +74,7 @@ bool Graphics::getConstant(const char *in, Support &out) return support.find(in, out); } -bool Graphics::getConstant(Support in, const char *&out) +bool Graphics::getConstant(Support in, const char *&out) { return support.find(in, out); } @@ -111,76 +111,77 @@ bool Graphics::getConstant(StatType in, const char *&out) StringMap::Entry Graphics::drawModeEntries[] = { - { "line", Graphics::DRAW_LINE }, - { "fill", Graphics::DRAW_FILL }, + { "line", DRAW_LINE }, + { "fill", DRAW_FILL }, }; StringMap Graphics::drawModes(Graphics::drawModeEntries, sizeof(Graphics::drawModeEntries)); StringMap::Entry Graphics::blendModeEntries[] = { - { "alpha", Graphics::BLEND_ALPHA }, - { "add", Graphics::BLEND_ADD }, - { "subtract", Graphics::BLEND_SUBTRACT }, - { "multiply", Graphics::BLEND_MULTIPLY }, - { "premultiplied", Graphics::BLEND_PREMULTIPLIED }, - { "screen", Graphics::BLEND_SCREEN }, - { "replace", Graphics::BLEND_REPLACE }, + { "alpha", BLEND_ALPHA }, + { "add", BLEND_ADD }, + { "subtract", BLEND_SUBTRACT }, + { "multiply", BLEND_MULTIPLY }, + { "premultiplied", BLEND_PREMULTIPLIED }, + { "screen", BLEND_SCREEN }, + { "replace", BLEND_REPLACE }, }; StringMap Graphics::blendModes(Graphics::blendModeEntries, sizeof(Graphics::blendModeEntries)); StringMap::Entry Graphics::lineStyleEntries[] = { - { "smooth", Graphics::LINE_SMOOTH }, - { "rough", Graphics::LINE_ROUGH } + { "smooth", LINE_SMOOTH }, + { "rough", LINE_ROUGH } }; StringMap Graphics::lineStyles(Graphics::lineStyleEntries, sizeof(Graphics::lineStyleEntries)); StringMap::Entry Graphics::lineJoinEntries[] = { - { "none", Graphics::LINE_JOIN_NONE }, - { "miter", Graphics::LINE_JOIN_MITER }, - { "bevel", Graphics::LINE_JOIN_BEVEL } + { "none", LINE_JOIN_NONE }, + { "miter", LINE_JOIN_MITER }, + { "bevel", LINE_JOIN_BEVEL } }; StringMap Graphics::lineJoins(Graphics::lineJoinEntries, sizeof(Graphics::lineJoinEntries)); StringMap::Entry Graphics::supportEntries[] = { - { "multicanvas", Graphics::SUPPORT_MULTI_CANVAS }, - { "srgb", Graphics::SUPPORT_SRGB }, + { "multicanvas", SUPPORT_MULTI_CANVAS }, + { "multicanvasformats", SUPPORT_MULTI_CANVAS_FORMATS }, + { "srgb", SUPPORT_SRGB }, }; StringMap Graphics::support(Graphics::supportEntries, sizeof(Graphics::supportEntries)); StringMap::Entry Graphics::systemLimitEntries[] = { - {"pointsize", Graphics::LIMIT_POINT_SIZE}, - {"texturesize", Graphics::LIMIT_TEXTURE_SIZE}, - {"multicanvas", Graphics::LIMIT_MULTI_CANVAS}, - {"canvasmsaa", Graphics::LIMIT_CANVAS_MSAA}, + { "pointsize", LIMIT_POINT_SIZE }, + { "texturesize", LIMIT_TEXTURE_SIZE }, + { "multicanvas", LIMIT_MULTI_CANVAS }, + { "canvasmsaa", LIMIT_CANVAS_MSAA }, }; StringMap Graphics::systemLimits(Graphics::systemLimitEntries, sizeof(Graphics::systemLimitEntries)); StringMap::Entry Graphics::stackTypeEntries[] = { - {"all", Graphics::STACK_ALL}, - {"transform", Graphics::STACK_TRANSFORM}, + { "all", STACK_ALL }, + { "transform", STACK_TRANSFORM }, }; StringMap Graphics::stackTypes(Graphics::stackTypeEntries, sizeof(Graphics::stackTypeEntries)); StringMap::Entry Graphics::statTypeEntries[] = { - {"drawcalls", Graphics::STAT_DRAW_CALLS}, - {"canvasswitches", Graphics::STAT_CANVAS_SWITCHES}, - {"canvases", Graphics::STAT_CANVASES}, - {"images", Graphics::STAT_IMAGES}, - {"fonts", Graphics::STAT_FONTS}, - {"texturememory", Graphics::STAT_TEXTURE_MEMORY}, + { "drawcalls", STAT_DRAW_CALLS }, + { "canvasswitches", STAT_CANVAS_SWITCHES }, + { "canvases", STAT_CANVASES }, + { "images", STAT_IMAGES }, + { "fonts", STAT_FONTS }, + { "texturememory", STAT_TEXTURE_MEMORY }, }; StringMap Graphics::statTypes(Graphics::statTypeEntries, sizeof(Graphics::statTypeEntries)); diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index 50429f256..7777d06f8 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -74,6 +74,7 @@ public: enum Support { SUPPORT_MULTI_CANVAS, + SUPPORT_MULTI_CANVAS_FORMATS, SUPPORT_SRGB, SUPPORT_MAX_ENUM }; @@ -183,19 +184,19 @@ public: virtual bool isActive() const = 0; static bool getConstant(const char *in, DrawMode &out); - static bool getConstant(DrawMode in, const char *&out); + static bool getConstant(DrawMode in, const char *&out); static bool getConstant(const char *in, BlendMode &out); - static bool getConstant(BlendMode in, const char *&out); + static bool getConstant(BlendMode in, const char *&out); static bool getConstant(const char *in, LineStyle &out); - static bool getConstant(LineStyle in, const char *&out); + static bool getConstant(LineStyle in, const char *&out); static bool getConstant(const char *in, LineJoin &out); - static bool getConstant(LineJoin in, const char *&out); + static bool getConstant(LineJoin in, const char *&out); static bool getConstant(const char *in, Support &out); - static bool getConstant(Support in, const char *&out); + static bool getConstant(Support in, const char *&out); static bool getConstant(const char *in, SystemLimit &out); static bool getConstant(SystemLimit in, const char *&out); diff --git a/src/modules/graphics/opengl/Canvas.cpp b/src/modules/graphics/opengl/Canvas.cpp index 15afed7a7..89775eefd 100644 --- a/src/modules/graphics/opengl/Canvas.cpp +++ b/src/modules/graphics/opengl/Canvas.cpp @@ -416,19 +416,21 @@ void Canvas::startGrab(const std::vector &canvases) throw love::Exception("Multi-canvas rendering is not supported on this system."); if ((int) canvases.size() + 1 > gl.getMaxRenderTargets()) - throw love::Exception("This system can't simultaniously render to %d canvases.", canvases.size()+1); + throw love::Exception("This system can't simultaneously render to %d canvases.", canvases.size()+1); if (actual_samples != 0) throw love::Exception("Multi-canvas rendering is not supported with MSAA."); } + bool multiformatsupported = isMultiFormatMultiCanvasSupported(); + for (size_t i = 0; i < canvases.size(); i++) { if (canvases[i]->getWidth() != width || canvases[i]->getHeight() != height) - throw love::Exception("All canvas arguments must have the same dimensions."); + throw love::Exception("All canvases must have the same dimensions."); - if (canvases[i]->getTextureFormat() != format) - throw love::Exception("All canvas arguments must have the same texture format."); + if (canvases[i]->getTextureFormat() != format && !multiformatsupported) + throw love::Exception("This system doesn't support multi-canvas rendering with different canvas formats."); if (canvases[i]->getMSAA() != 0) throw love::Exception("Multi-canvas rendering is not supported with MSAA."); @@ -785,6 +787,11 @@ bool Canvas::isMultiCanvasSupported() return gl.getMaxRenderTargets() >= 4; } +bool Canvas::isMultiFormatMultiCanvasSupported() +{ + return isMultiCanvasSupported() && (GLAD_ES_VERSION_3_0 || GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object); +} + bool Canvas::supportedFormats[] = {false}; bool Canvas::checkedFormats[] = {false}; diff --git a/src/modules/graphics/opengl/Canvas.h b/src/modules/graphics/opengl/Canvas.h index 5a039f82c..90ac53eb1 100644 --- a/src/modules/graphics/opengl/Canvas.h +++ b/src/modules/graphics/opengl/Canvas.h @@ -119,6 +119,7 @@ public: static bool isSupported(); static bool isMultiCanvasSupported(); + static bool isMultiFormatMultiCanvasSupported(); static bool isFormatSupported(Format format); static Canvas *current; diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index a1925c74e..8d6073cc9 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -1336,6 +1336,8 @@ bool Graphics::isSupported(Support feature) const { case SUPPORT_MULTI_CANVAS: return Canvas::isMultiCanvasSupported(); + case SUPPORT_MULTI_CANVAS_FORMATS: + return Canvas::isMultiFormatMultiCanvasSupported(); case SUPPORT_SRGB: // sRGB support for the screen is guaranteed if it's supported as a // Canvas format.