mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Multi-canvas rendering (love.graphics.setCanvas with multiple canvases) now allows canvases with different formats, if the system supports it. Added 'multicanvasformats' to the table returned by love.graphics.getSupported.
--HG-- branch : minor
This commit is contained in:
@@ -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<Graphics::DrawMode, Graphics::DRAW_MAX_ENUM>::Entry Graphics::drawModeEntries[] =
|
||||
{
|
||||
{ "line", Graphics::DRAW_LINE },
|
||||
{ "fill", Graphics::DRAW_FILL },
|
||||
{ "line", DRAW_LINE },
|
||||
{ "fill", DRAW_FILL },
|
||||
};
|
||||
|
||||
StringMap<Graphics::DrawMode, Graphics::DRAW_MAX_ENUM> Graphics::drawModes(Graphics::drawModeEntries, sizeof(Graphics::drawModeEntries));
|
||||
|
||||
StringMap<Graphics::BlendMode, Graphics::BLEND_MAX_ENUM>::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::BlendMode, Graphics::BLEND_MAX_ENUM> Graphics::blendModes(Graphics::blendModeEntries, sizeof(Graphics::blendModeEntries));
|
||||
|
||||
StringMap<Graphics::LineStyle, Graphics::LINE_MAX_ENUM>::Entry Graphics::lineStyleEntries[] =
|
||||
{
|
||||
{ "smooth", Graphics::LINE_SMOOTH },
|
||||
{ "rough", Graphics::LINE_ROUGH }
|
||||
{ "smooth", LINE_SMOOTH },
|
||||
{ "rough", LINE_ROUGH }
|
||||
};
|
||||
|
||||
StringMap<Graphics::LineStyle, Graphics::LINE_MAX_ENUM> Graphics::lineStyles(Graphics::lineStyleEntries, sizeof(Graphics::lineStyleEntries));
|
||||
|
||||
StringMap<Graphics::LineJoin, Graphics::LINE_JOIN_MAX_ENUM>::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::LineJoin, Graphics::LINE_JOIN_MAX_ENUM> Graphics::lineJoins(Graphics::lineJoinEntries, sizeof(Graphics::lineJoinEntries));
|
||||
|
||||
StringMap<Graphics::Support, Graphics::SUPPORT_MAX_ENUM>::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::SUPPORT_MAX_ENUM> Graphics::support(Graphics::supportEntries, sizeof(Graphics::supportEntries));
|
||||
|
||||
StringMap<Graphics::SystemLimit, Graphics::LIMIT_MAX_ENUM>::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::SystemLimit, Graphics::LIMIT_MAX_ENUM> Graphics::systemLimits(Graphics::systemLimitEntries, sizeof(Graphics::systemLimitEntries));
|
||||
|
||||
StringMap<Graphics::StackType, Graphics::STACK_MAX_ENUM>::Entry Graphics::stackTypeEntries[] =
|
||||
{
|
||||
{"all", Graphics::STACK_ALL},
|
||||
{"transform", Graphics::STACK_TRANSFORM},
|
||||
{ "all", STACK_ALL },
|
||||
{ "transform", STACK_TRANSFORM },
|
||||
};
|
||||
|
||||
StringMap<Graphics::StackType, Graphics::STACK_MAX_ENUM> Graphics::stackTypes(Graphics::stackTypeEntries, sizeof(Graphics::stackTypeEntries));
|
||||
|
||||
StringMap<Graphics::StatType, Graphics::STAT_MAX_ENUM>::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::StatType, Graphics::STAT_MAX_ENUM> Graphics::statTypes(Graphics::statTypeEntries, sizeof(Graphics::statTypeEntries));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -416,19 +416,21 @@ void Canvas::startGrab(const std::vector<Canvas *> &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};
|
||||
|
||||
|
||||
@@ -119,6 +119,7 @@ public:
|
||||
|
||||
static bool isSupported();
|
||||
static bool isMultiCanvasSupported();
|
||||
static bool isMultiFormatMultiCanvasSupported();
|
||||
static bool isFormatSupported(Format format);
|
||||
|
||||
static Canvas *current;
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user