mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
fixed canvas:clear() when multi-canvas rendering is active, changed some names and wording
--HG-- branch : MRTs
This commit is contained in:
@@ -158,7 +158,7 @@ StringMap<Graphics::Support, Graphics::SUPPORT_MAX_ENUM>::Entry Graphics::suppor
|
||||
{
|
||||
{ "canvas", Graphics::SUPPORT_CANVAS },
|
||||
{ "hdrcanvas", Graphics::SUPPORT_HDR_CANVAS },
|
||||
{ "mrtcanvas", Graphics::SUPPORT_MRT_CANVAS },
|
||||
{ "multicanvas", Graphics::SUPPORT_MULTI_CANVAS },
|
||||
{ "shader", Graphics::SUPPORT_SHADER },
|
||||
{ "npot", Graphics::SUPPORT_NPOT },
|
||||
{ "subtractive", Graphics::SUPPORT_SUBTRACTIVE },
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
{
|
||||
SUPPORT_CANVAS = 1,
|
||||
SUPPORT_HDR_CANVAS,
|
||||
SUPPORT_MRT_CANVAS,
|
||||
SUPPORT_MULTI_CANVAS,
|
||||
SUPPORT_SHADER,
|
||||
SUPPORT_NPOT,
|
||||
SUPPORT_SUBTRACTIVE,
|
||||
|
||||
@@ -423,7 +423,7 @@ bool Canvas::isHDRSupported()
|
||||
return GLEE_VERSION_3_0 || GLEE_ARB_texture_float;
|
||||
}
|
||||
|
||||
bool Canvas::isMRTSupported()
|
||||
bool Canvas::isMultiCanvasSupported()
|
||||
{
|
||||
if (!(isSupported() && (GLEE_VERSION_2_0 || GLEE_ARB_draw_buffers || GLEE_ATI_draw_buffers)))
|
||||
return false;
|
||||
@@ -434,7 +434,7 @@ bool Canvas::isMRTSupported()
|
||||
glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers);
|
||||
}
|
||||
|
||||
// system must support at least 4 simultanious render targets
|
||||
// system must support at least 4 simultanious active canvases
|
||||
return maxFBOColorAttachments >= 4 && maxDrawBuffers >= 4;
|
||||
}
|
||||
|
||||
@@ -478,11 +478,11 @@ void Canvas::startGrab(const std::vector<Canvas *> &canvases)
|
||||
{
|
||||
if (canvases.size() > 0)
|
||||
{
|
||||
if (!isMRTSupported())
|
||||
throw love::Exception("Multiple render targets are not supported on this system.");
|
||||
if (!isMultiCanvasSupported())
|
||||
throw love::Exception("Multi-canvas rendering is not supported on this system.");
|
||||
|
||||
if (canvases.size() + 1 > maxDrawBuffers || canvases.size() + 1 > maxFBOColorAttachments)
|
||||
throw love::Exception("This system can't support %d simultanious render targets.", canvases.size() + 1);
|
||||
if (canvases.size()+1 > maxDrawBuffers || canvases.size()+1 > maxFBOColorAttachments)
|
||||
throw love::Exception("This system can't simultaniously render to %d canvases.", canvases.size()+1);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < canvases.size(); i++)
|
||||
@@ -500,7 +500,7 @@ void Canvas::startGrab(const std::vector<Canvas *> &canvases)
|
||||
if (canvases.size() == 0 && attachedCanvases.size() == 0)
|
||||
return;
|
||||
|
||||
// attach the canvas textures to this FBO and set up multiple render targets
|
||||
// attach the canvas textures to the active FBO and set up multiple render targets
|
||||
strategy->setAttachments(canvases);
|
||||
|
||||
// retain newly attached canvases
|
||||
@@ -521,7 +521,7 @@ void Canvas::startGrab()
|
||||
if (attachedCanvases.size() == 0)
|
||||
return;
|
||||
|
||||
// make sure the FBO is only using a single render target
|
||||
// make sure the FBO is only using a single canvas
|
||||
strategy->setAttachments();
|
||||
|
||||
// release any previously attached canvases
|
||||
@@ -548,16 +548,31 @@ void Canvas::stopGrab()
|
||||
void Canvas::clear(const Color &c)
|
||||
{
|
||||
GLuint previous = 0;
|
||||
if (current != NULL)
|
||||
previous = current->fbo;
|
||||
|
||||
strategy->bindFBO(fbo);
|
||||
glPushAttrib(GL_COLOR_BUFFER_BIT);
|
||||
if (current != this)
|
||||
{
|
||||
if (current != NULL)
|
||||
previous = current->fbo;
|
||||
|
||||
strategy->bindFBO(fbo);
|
||||
glPushAttrib(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
// Make sure only this canvas is cleared when multi-canvas rendering is set
|
||||
if (attachedCanvases.size() > 0)
|
||||
strategy->setAttachments();
|
||||
|
||||
glClearColor((float)c.r/255.0f, (float)c.g/255.0f, (float)c.b/255.0f, (float)c.a/255.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
||||
glPopAttrib();
|
||||
|
||||
strategy->bindFBO(previous);
|
||||
if (attachedCanvases.size() > 0)
|
||||
strategy->setAttachments(attachedCanvases);
|
||||
|
||||
if (current != this)
|
||||
{
|
||||
glPopAttrib();
|
||||
strategy->bindFBO(previous);
|
||||
}
|
||||
}
|
||||
|
||||
void Canvas::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
|
||||
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
|
||||
static bool isSupported();
|
||||
static bool isHDRSupported();
|
||||
static bool isMRTSupported();
|
||||
static bool isMultiCanvasSupported();
|
||||
static bool getConstant(const char *in, TextureType &out);
|
||||
static bool getConstant(TextureType in, const char *&out);
|
||||
|
||||
|
||||
@@ -1083,8 +1083,8 @@ int w_isSupported(lua_State *L)
|
||||
if (!Canvas::isHDRSupported())
|
||||
supported = false;
|
||||
break;
|
||||
case Graphics::SUPPORT_MRT_CANVAS:
|
||||
if (!Canvas::isMRTSupported())
|
||||
case Graphics::SUPPORT_MULTI_CANVAS:
|
||||
if (!Canvas::isMultiCanvasSupported())
|
||||
supported = false;
|
||||
break;
|
||||
case Graphics::SUPPORT_SHADER:
|
||||
|
||||
Reference in New Issue
Block a user