diff --git a/src/modules/event/sdl/Event.cpp b/src/modules/event/sdl/Event.cpp index 8f4b891df..59b779863 100644 --- a/src/modules/event/sdl/Event.cpp +++ b/src/modules/event/sdl/Event.cpp @@ -161,11 +161,11 @@ void Event::exceptionIfInRenderPass(const char *name) { // Some core OS graphics functionality (e.g. swap buffers on some platforms) // happens inside SDL_PumpEvents - which is called by SDL_PollEvent and - // friends. It's probably a bad idea to call those functions while a Canvas + // friends. It's probably a bad idea to call those functions while a RT // is active. auto gfx = Module::getInstance(Module::M_GRAPHICS); - if (gfx != nullptr && gfx->isCanvasActive()) - throw love::Exception("%s cannot be called while a Canvas is active in love.graphics.", name); + if (gfx != nullptr && gfx->isRenderTargetActive()) + throw love::Exception("%s cannot be called while a render target is active in love.graphics.", name); } Message *Event::convert(const SDL_Event &e) diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index 9620a579e..f2fc3b11f 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -397,7 +397,7 @@ void Graphics::restoreState(const DisplayState &s) setFont(s.font.get()); setShader(s.shader.get()); - setCanvas(s.renderTargets); + setRenderTargets(s.renderTargets); setColorMask(s.colorMask); setWireframe(s.wireframe); @@ -450,27 +450,27 @@ void Graphics::restoreStateChecked(const DisplayState &s) const auto &sRTs = s.renderTargets; const auto &curRTs = cur.renderTargets; - bool canvaseschanged = sRTs.colors.size() != curRTs.colors.size(); - if (!canvaseschanged) + bool rtschanged = sRTs.colors.size() != curRTs.colors.size(); + if (!rtschanged) { for (size_t i = 0; i < sRTs.colors.size() && i < curRTs.colors.size(); i++) { if (sRTs.colors[i] != curRTs.colors[i]) { - canvaseschanged = true; + rtschanged = true; break; } } - if (!canvaseschanged && sRTs.depthStencil != curRTs.depthStencil) - canvaseschanged = true; + if (!rtschanged && sRTs.depthStencil != curRTs.depthStencil) + rtschanged = true; if (sRTs.temporaryRTFlags != curRTs.temporaryRTFlags) - canvaseschanged = true; + rtschanged = true; } - if (canvaseschanged) - setCanvas(s.renderTargets); + if (rtschanged) + setRenderTargets(s.renderTargets); if (s.colorMask != cur.colorMask) setColorMask(s.colorMask); @@ -543,19 +543,19 @@ love::graphics::Shader *Graphics::getShader() const return states.back().shader.get(); } -void Graphics::setCanvas(RenderTarget rt, uint32 temporaryRTFlags) +void Graphics::setRenderTarget(RenderTarget rt, uint32 temporaryRTFlags) { if (rt.texture == nullptr) - return setCanvas(); + return setRenderTarget(); RenderTargets rts; rts.colors.push_back(rt); rts.temporaryRTFlags = temporaryRTFlags; - setCanvas(rts); + setRenderTargets(rts); } -void Graphics::setCanvas(const RenderTargetsStrongRef &rts) +void Graphics::setRenderTargets(const RenderTargetsStrongRef &rts) { RenderTargets targets; targets.colors.reserve(rts.colors.size()); @@ -566,27 +566,27 @@ void Graphics::setCanvas(const RenderTargetsStrongRef &rts) targets.depthStencil = RenderTarget(rts.depthStencil.texture, rts.depthStencil.slice, rts.depthStencil.mipmap); targets.temporaryRTFlags = rts.temporaryRTFlags; - return setCanvas(targets); + return setRenderTargets(targets); } -void Graphics::setCanvas(const RenderTargets &rts) +void Graphics::setRenderTargets(const RenderTargets &rts) { DisplayState &state = states.back(); - int ncanvases = (int) rts.colors.size(); + int rtcount = (int) rts.colors.size(); RenderTarget firsttarget = rts.getFirstTarget(); Texture *firsttex = firsttarget.texture; if (firsttex == nullptr) - return setCanvas(); + return setRenderTarget(); const auto &prevRTs = state.renderTargets; - if (ncanvases == (int) prevRTs.colors.size()) + if (rtcount == (int) prevRTs.colors.size()) { bool modified = false; - for (int i = 0; i < ncanvases; i++) + for (int i = 0; i < rtcount; i++) { if (rts.colors[i] != prevRTs.colors[i]) { @@ -605,8 +605,8 @@ void Graphics::setCanvas(const RenderTargets &rts) return; } - if (ncanvases > capabilities.limits[LIMIT_MULTI_CANVAS]) - throw love::Exception("This system can't simultaneously render to %d canvases.", ncanvases); + if (rtcount > capabilities.limits[LIMIT_MULTI_CANVAS]) + throw love::Exception("This system can't simultaneously render to %d textures.", rtcount); bool multiformatsupported = capabilities.features[FEATURE_MULTI_CANVAS_FORMATS]; @@ -615,10 +615,10 @@ void Graphics::setCanvas(const RenderTargets &rts) firstcolorformat = rts.colors[0].texture->getPixelFormat(); if (!firsttex->isRenderTarget()) - throw love::Exception("Texture must be created as a render target to be used in setCanvas."); + throw love::Exception("Texture must be created as a render target to be used in setRenderTargets."); if (isPixelFormatDepthStencil(firstcolorformat)) - throw love::Exception("Depth/stencil format Canvases must be used with the 'depthstencil' field of the table passed into setCanvas."); + throw love::Exception("Depth/stencil format textures must be used with the 'depthstencil' field of the table passed into setRenderTargets."); if (firsttarget.mipmap < 0 || firsttarget.mipmap >= firsttex->getMipmapCount()) throw love::Exception("Invalid mipmap level %d.", firsttarget.mipmap + 1); @@ -626,12 +626,12 @@ void Graphics::setCanvas(const RenderTargets &rts) if (!firsttex->isValidSlice(firsttarget.slice)) throw love::Exception("Invalid slice index: %d.", firsttarget.slice + 1); - bool hasSRGBcanvas = firstcolorformat == PIXELFORMAT_sRGBA8_UNORM; + bool hasSRGBtexture = firstcolorformat == PIXELFORMAT_sRGBA8_UNORM; int pixelw = firsttex->getPixelWidth(firsttarget.mipmap); int pixelh = firsttex->getPixelHeight(firsttarget.mipmap); int reqmsaa = firsttex->getRequestedMSAA(); - for (int i = 1; i < ncanvases; i++) + for (int i = 1; i < rtcount; i++) { Texture *c = rts.colors[i].texture; PixelFormat format = c->getPixelFormat(); @@ -639,7 +639,7 @@ void Graphics::setCanvas(const RenderTargets &rts) int slice = rts.colors[i].slice; if (!c->isRenderTarget()) - throw love::Exception("Texture must be created as a render target to be used in setCanvas."); + throw love::Exception("Texture must be created as a render target to be used in setRenderTargets."); if (mip < 0 || mip >= c->getMipmapCount()) throw love::Exception("Invalid mipmap level %d.", mip + 1); @@ -648,19 +648,19 @@ void Graphics::setCanvas(const RenderTargets &rts) throw love::Exception("Invalid slice index: %d.", slice + 1); if (c->getPixelWidth(mip) != pixelw || c->getPixelHeight(mip) != pixelh) - throw love::Exception("All canvases must have the same pixel dimensions."); + throw love::Exception("All textures must have the same pixel dimensions."); if (!multiformatsupported && format != firstcolorformat) - throw love::Exception("This system doesn't support multi-canvas rendering with different canvas formats."); + throw love::Exception("This system doesn't support multi-render-target rendering with different texture formats."); if (c->getRequestedMSAA() != reqmsaa) - throw love::Exception("All Canvases must have the same MSAA value."); + throw love::Exception("All textures must have the same MSAA value."); if (isPixelFormatDepthStencil(format)) - throw love::Exception("Depth/stencil format Canvases must be used with the 'depthstencil' field of the table passed into setCanvas."); + throw love::Exception("Depth/stencil format textures must be used with the 'depthstencil' field of the table passed into setRenderTargets."); if (format == PIXELFORMAT_sRGBA8_UNORM) - hasSRGBcanvas = true; + hasSRGBtexture = true; } if (rts.depthStencil.texture != nullptr) @@ -670,10 +670,10 @@ void Graphics::setCanvas(const RenderTargets &rts) int slice = rts.depthStencil.slice; if (!c->isRenderTarget()) - throw love::Exception("Texture must be created as a render target to be used in setCanvas."); + throw love::Exception("Texture must be created as a render target to be used in setRenderTargets."); if (!isPixelFormatDepthStencil(c->getPixelFormat())) - throw love::Exception("Only depth/stencil format Texture can be used with the 'depthstencil' field of the table passed into setCanvas."); + throw love::Exception("Only depth/stencil format textures can be used with the 'depthstencil' field of the table passed into setRenderTargets."); if (c->getPixelWidth(mip) != pixelw || c->getPixelHeight(mip) != pixelh) throw love::Exception("All Textures must have the same pixel dimensions."); @@ -708,17 +708,17 @@ void Graphics::setCanvas(const RenderTargets &rts) else if (wantsstencil) dsformat = PIXELFORMAT_STENCIL8; - // We want setCanvasInternal to have a pointer to the temporary RT, but - // we don't want to directly store it in the main graphics state. + // We want setRenderTargetsInternal to have a pointer to the temporary RT, + // but we don't want to directly store it in the main graphics state. RenderTargets realRTs = rts; realRTs.depthStencil.texture = getTemporaryTexture(dsformat, pixelw, pixelh, reqmsaa); realRTs.depthStencil.slice = 0; - setCanvasInternal(realRTs, w, h, pixelw, pixelh, hasSRGBcanvas); + setRenderTargetsInternal(realRTs, w, h, pixelw, pixelh, hasSRGBtexture); } else - setCanvasInternal(rts, w, h, pixelw, pixelh, hasSRGBcanvas); + setRenderTargetsInternal(rts, w, h, pixelw, pixelh, hasSRGBtexture); RenderTargetsStrongRef refs; refs.colors.reserve(rts.colors.size()); @@ -734,7 +734,7 @@ void Graphics::setCanvas(const RenderTargets &rts) renderTargetSwitchCount++; } -void Graphics::setCanvas() +void Graphics::setRenderTarget() { DisplayState &state = states.back(); @@ -742,13 +742,13 @@ void Graphics::setCanvas() return; flushStreamDraws(); - setCanvasInternal(RenderTargets(), width, height, pixelWidth, pixelHeight, isGammaCorrect()); + setRenderTargetsInternal(RenderTargets(), width, height, pixelWidth, pixelHeight, isGammaCorrect()); state.renderTargets = RenderTargetsStrongRef(); renderTargetSwitchCount++; } -Graphics::RenderTargets Graphics::getCanvas() const +Graphics::RenderTargets Graphics::getRenderTargets() const { const auto &curRTs = states.back().renderTargets; @@ -764,7 +764,7 @@ Graphics::RenderTargets Graphics::getCanvas() const return rts; } -bool Graphics::isCanvasActive() const +bool Graphics::isRenderTargetActive() const { const auto &rts = states.back().renderTargets; return !rts.colors.empty() || rts.depthStencil.texture != nullptr; diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index 09a34bf00..0b97a69ec 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -538,13 +538,13 @@ public: Shader *getShader() const; - void setCanvas(RenderTarget rt, uint32 temporaryRTFlags); - void setCanvas(const RenderTargets &rts); - void setCanvas(const RenderTargetsStrongRef &rts); - void setCanvas(); + void setRenderTarget(RenderTarget rt, uint32 temporaryRTFlags); + void setRenderTargets(const RenderTargets &rts); + void setRenderTargets(const RenderTargetsStrongRef &rts); + void setRenderTarget(); - RenderTargets getCanvas() const; - bool isCanvasActive() const; + RenderTargets getRenderTargets() const; + bool isRenderTargetActive() const; bool isRenderTargetActive(Texture *texture) const; bool isRenderTargetActive(Texture *texture, int slice) const; @@ -949,7 +949,7 @@ protected: virtual Shader *newShaderInternal(ShaderStage *vertex, ShaderStage *pixel) = 0; virtual StreamBuffer *newStreamBuffer(BufferType type, size_t size) = 0; - virtual void setCanvasInternal(const RenderTargets &rts, int w, int h, int pixelw, int pixelh, bool hasSRGBcanvas) = 0; + virtual void setRenderTargetsInternal(const RenderTargets &rts, int w, int h, int pixelw, int pixelh, bool hasSRGBtexture) = 0; virtual void initCapabilities() = 0; virtual void getAPIStats(int &shaderswitches) const = 0; diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 9f2bf702c..b0b9f25e6 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -157,7 +157,7 @@ void Graphics::setViewportSize(int width, int height, int pixelwidth, int pixelh this->pixelWidth = pixelwidth; this->pixelHeight = pixelheight; - if (!isCanvasActive()) + if (!isRenderTargetActive()) { // Set the viewport to top-left corner. gl.setViewport({0, 0, pixelwidth, pixelheight}); @@ -499,11 +499,11 @@ void Graphics::setDebug(bool enable) ::printf("OpenGL debug output enabled (LOVE_GRAPHICS_DEBUG=1)\n"); } -void Graphics::setCanvasInternal(const RenderTargets &rts, int w, int h, int pixelw, int pixelh, bool hasSRGBcanvas) +void Graphics::setRenderTargetsInternal(const RenderTargets &rts, int w, int h, int pixelw, int pixelh, bool hasSRGBtexture) { const DisplayState &state = states.back(); - OpenGL::TempDebugGroup debuggroup("setCanvas"); + OpenGL::TempDebugGroup debuggroup("setRenderTargets"); flushStreamDraws(); endPass(); @@ -515,8 +515,8 @@ void Graphics::setCanvasInternal(const RenderTargets &rts, int w, int h, int pix { gl.bindFramebuffer(OpenGL::FRAMEBUFFER_ALL, gl.getDefaultFBO()); - // The projection matrix is flipped compared to rendering to a canvas, due - // to OpenGL considering (0,0) bottom-left instead of top-left. + // The projection matrix is flipped compared to rendering to a texture, + // due to OpenGL considering (0,0) bottom-left instead of top-left. projectionMatrix = Matrix4::ortho(0.0, (float) w, (float) h, 0.0, -10.0f, 10.0f); } else @@ -525,7 +525,7 @@ void Graphics::setCanvasInternal(const RenderTargets &rts, int w, int h, int pix projectionMatrix = Matrix4::ortho(0.0, (float) w, 0.0, (float) h, -10.0f, 10.0f); - // Flip front face winding when rendering to a canvas, since our + // Flip front face winding when rendering to a texture, since our // projection matrix is flipped. vertexwinding = vertexwinding == vertex::WINDING_CW ? vertex::WINDING_CCW : vertex::WINDING_CW; } @@ -539,11 +539,11 @@ void Graphics::setCanvasInternal(const RenderTargets &rts, int w, int h, int pix if (state.scissor) setScissor(state.scissorRect); - // Make sure the correct sRGB setting is used when drawing to the canvases. + // Make sure the correct sRGB setting is used when drawing to the textures. if (GLAD_VERSION_1_0 || GLAD_EXT_sRGB_write_control) { - if (hasSRGBcanvas != gl.isStateEnabled(OpenGL::ENABLE_FRAMEBUFFER_SRGB)) - gl.setEnableState(OpenGL::ENABLE_FRAMEBUFFER_SRGB, hasSRGBcanvas); + if (hasSRGBtexture != gl.isStateEnabled(OpenGL::ENABLE_FRAMEBUFFER_SRGB)) + gl.setEnableState(OpenGL::ENABLE_FRAMEBUFFER_SRGB, hasSRGBtexture); } } @@ -669,10 +669,10 @@ void Graphics::clear(const std::vector &colors, OptionalInt sten if (colors.size() == 0 && !stencil.hasValue && !depth.hasValue) return; - int ncolorcanvases = (int) states.back().renderTargets.colors.size(); + int ncolorRTs = (int) states.back().renderTargets.colors.size(); int ncolors = (int) colors.size(); - if (ncolors <= 1 && ncolorcanvases <= 1) + if (ncolors <= 1 && ncolorRTs <= 1) { clear(ncolors > 0 ? colors[0] : OptionalColorf(), stencil, depth); return; @@ -681,7 +681,7 @@ void Graphics::clear(const std::vector &colors, OptionalInt sten flushStreamDraws(); bool drawbuffersmodified = false; - ncolors = std::min(ncolors, ncolorcanvases); + ncolors = std::min(ncolors, ncolorRTs); for (int i = 0; i < ncolors; i++) { @@ -712,10 +712,10 @@ void Graphics::clear(const std::vector &colors, OptionalInt sten { GLenum bufs[MAX_COLOR_RENDER_TARGETS]; - for (int i = 0; i < ncolorcanvases; i++) + for (int i = 0; i < ncolorRTs; i++) bufs[i] = GL_COLOR_ATTACHMENT0 + i; - glDrawBuffers(ncolorcanvases, bufs); + glDrawBuffers(ncolorRTs, bufs); } GLbitfield flags = 0; @@ -773,7 +773,7 @@ void Graphics::discard(OpenGL::FramebufferTarget target, const std::vector attachments.reserve(colorbuffers.size()); // glDiscardFramebuffer uses different attachment enums for the default FBO. - if (!isCanvasActive() && gl.getDefaultFBO() == 0) + if (!isRenderTargetActive() && gl.getDefaultFBO() == 0) { if (colorbuffers.size() > 0 && colorbuffers[0]) attachments.push_back(GL_COLOR); @@ -859,7 +859,7 @@ void Graphics::bindCachedFBO(const RenderTargets &targets) int ncolortargets = 0; GLenum drawbuffers[MAX_COLOR_RENDER_TARGETS]; - auto attachCanvas = [&](const RenderTarget &rt) + auto attachRT = [&](const RenderTarget &rt) { bool renderbuffer = msaa > 1 || !rt.texture->isReadable(); bool srgb = false; @@ -894,10 +894,10 @@ void Graphics::bindCachedFBO(const RenderTargets &targets) }; for (const auto &rt : targets.colors) - attachCanvas(rt); + attachRT(rt); if (hasDS) - attachCanvas(targets.depthStencil); + attachRT(targets.depthStencil); if (ncolortargets > 1) glDrawBuffers(ncolortargets, drawbuffers); @@ -930,8 +930,8 @@ void Graphics::present(void *screenshotCallbackData) if (!isActive()) return; - if (isCanvasActive()) - throw love::Exception("present cannot be called while a Canvas is active."); + if (isRenderTargetActive()) + throw love::Exception("present cannot be called while a render target is active."); deprecations.draw(this); @@ -1084,7 +1084,7 @@ void Graphics::setScissor(const Rect &rect) glrect.h = (int) (rect.h * dpiscale); // OpenGL's reversed y-coordinate is compensated for in OpenGL::setScissor. - gl.setScissor(glrect, isCanvasActive()); + gl.setScissor(glrect, isRenderTargetActive()); state.scissor = true; state.scissorRect = rect; @@ -1106,10 +1106,10 @@ void Graphics::drawToStencilBuffer(StencilAction action, int value) const auto &rts = states.back().renderTargets; love::graphics::Texture *dstexture = rts.depthStencil.texture.get(); - if (!isCanvasActive() && !windowHasStencil) + if (!isRenderTargetActive() && !windowHasStencil) throw love::Exception("The window must have stenciling enabled to draw to the main screen's stencil buffer."); - else if (isCanvasActive() && (rts.temporaryRTFlags & TEMPORARY_RT_STENCIL) == 0 && (dstexture == nullptr || !isPixelFormatStencil(dstexture->getPixelFormat()))) - throw love::Exception("Drawing to the stencil buffer with a Canvas active requires either stencil=true or a custom stencil-type Canvas to be used, in setCanvas."); + else if (isRenderTargetActive() && (rts.temporaryRTFlags & TEMPORARY_RT_STENCIL) == 0 && (dstexture == nullptr || !isPixelFormatStencil(dstexture->getPixelFormat()))) + throw love::Exception("Drawing to the stencil buffer with a render target active requires either stencil=true or a custom stencil-type texture to be used, in setRenderTarget."); flushStreamDraws(); @@ -1237,7 +1237,7 @@ void Graphics::setFrontFaceWinding(vertex::Winding winding) state.winding = winding; - if (isCanvasActive()) + if (isRenderTargetActive()) winding = winding == vertex::WINDING_CW ? vertex::WINDING_CCW : vertex::WINDING_CW; glFrontFace(winding == vertex::WINDING_CW ? GL_CW : GL_CCW); diff --git a/src/modules/graphics/opengl/Graphics.h b/src/modules/graphics/opengl/Graphics.h index b6df9b629..e6b59c71a 100644 --- a/src/modules/graphics/opengl/Graphics.h +++ b/src/modules/graphics/opengl/Graphics.h @@ -135,7 +135,7 @@ private: love::graphics::ShaderStage *newShaderStageInternal(ShaderStage::StageType stage, const std::string &cachekey, const std::string &source, bool gles) override; love::graphics::Shader *newShaderInternal(love::graphics::ShaderStage *vertex, love::graphics::ShaderStage *pixel) override; love::graphics::StreamBuffer *newStreamBuffer(BufferType type, size_t size) override; - void setCanvasInternal(const RenderTargets &rts, int w, int h, int pixelw, int pixelh, bool hasSRGBcanvas) override; + void setRenderTargetsInternal(const RenderTargets &rts, int w, int h, int pixelw, int pixelh, bool hasSRGBtexture) override; void initCapabilities() override; void getAPIStats(int &shaderswitches) const override; diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index 2b4c15454..b010202d4 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -804,13 +804,13 @@ Rect OpenGL::getViewport() const return state.viewport; } -void OpenGL::setScissor(const Rect &v, bool canvasActive) +void OpenGL::setScissor(const Rect &v, bool rtActive) { - if (canvasActive) + if (rtActive) glScissor(v.x, v.y, v.w, v.h); else { - // With no Canvas active, we need to compensate for glScissor starting + // With no RT active, we need to compensate for glScissor starting // from the lower left of the viewport instead of the top left. glScissor(v.x, state.viewport.h - (v.y + v.h), v.w, v.h); } @@ -1996,7 +1996,7 @@ const char *OpenGL::framebufferStatusString(GLenum status) case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: return "Error in graphics driver (incomplete read buffer)"; case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: - return "Canvas with the specified MSAA count cannot be rendered to on this system."; + return "Texture with the specified MSAA count cannot be rendered to on this system."; case GL_FRAMEBUFFER_UNSUPPORTED: return "Renderable textures are unsupported"; default: diff --git a/src/modules/graphics/opengl/OpenGL.h b/src/modules/graphics/opengl/OpenGL.h index 9e7b26f55..ba17b8431 100644 --- a/src/modules/graphics/opengl/OpenGL.h +++ b/src/modules/graphics/opengl/OpenGL.h @@ -261,7 +261,7 @@ public: * Sets the scissor box to the specified rectangle. * The y-coordinate starts at the top and is flipped internally. **/ - void setScissor(const Rect &v, bool canvasActive); + void setScissor(const Rect &v, bool rtActive); /** * Sets the global point size. diff --git a/src/modules/graphics/opengl/Shader.cpp b/src/modules/graphics/opengl/Shader.cpp index 519cba618..e57f918f3 100644 --- a/src/modules/graphics/opengl/Shader.cpp +++ b/src/modules/graphics/opengl/Shader.cpp @@ -734,8 +734,8 @@ void Shader::updateBuiltinUniforms(love::graphics::Graphics *gfx, int viewportW, // The shader does pixcoord.y = gl_FragCoord.y * params.z + params.w. // This lets us flip pixcoord.y when needed, to be consistent (drawing - // with no Canvas active makes the pixel coordinates y-flipped.) - if (gfx->isCanvasActive()) + // with no RT active makes the pixel coordinates y-flipped.) + if (gfx->isRenderTargetActive()) { // No flipping: pixcoord.y = gl_FragCoord.y * 1.0 + 0.0. data.screenSizeParams.z = 1.0f; diff --git a/src/modules/graphics/opengl/Texture.cpp b/src/modules/graphics/opengl/Texture.cpp index a9675ff67..ec6da42a8 100644 --- a/src/modules/graphics/opengl/Texture.cpp +++ b/src/modules/graphics/opengl/Texture.cpp @@ -402,7 +402,7 @@ void Texture::unloadVolatile() if (isRenderTarget() && (fbo != 0 || renderbuffer != 0 || texture != 0)) { // This is a bit ugly, but we need some way to destroy the cached FBO - // when this Canvas' texture is destroyed. + // when this texture's texture is destroyed. auto gfx = Module::getInstance(Module::M_GRAPHICS); if (gfx != nullptr) gfx->cleanupRenderTexture(this); diff --git a/src/modules/graphics/wrap_Graphics.cpp b/src/modules/graphics/wrap_Graphics.cpp index dac60e959..647a7242d 100644 --- a/src/modules/graphics/wrap_Graphics.cpp +++ b/src/modules/graphics/wrap_Graphics.cpp @@ -169,7 +169,7 @@ int w_discard(lua_State *L) else { bool discardcolor = luax_optboolean(L, 1, true); - size_t numbuffers = std::max((size_t) 1, instance()->getCanvas().colors.size()); + size_t numbuffers = std::max((size_t) 1, instance()->getRenderTargets().colors.size()); colorbuffers = std::vector(numbuffers, discardcolor); } @@ -271,7 +271,7 @@ int w_setCanvas(lua_State *L) // called with none -> reset to default buffer if (lua_isnoneornil(L, 1)) { - instance()->setCanvas(); + instance()->setRenderTarget(); return 0; } @@ -295,7 +295,7 @@ int w_setCanvas(lua_State *L) targets.colors.emplace_back(luax_checktexture(L, -1), 0); if (targets.colors.back().texture->getTextureType() != TEXTURE_2D) - return luaL_error(L, "Non-2D canvases must use the table-of-tables variant of setCanvas."); + return luaL_error(L, "Non-2D textures must use the table-of-tables variant of setRenderTargets."); } lua_pop(L, 1); @@ -341,7 +341,7 @@ int w_setCanvas(lua_State *L) } if (i > 1 && type != TEXTURE_2D) - return luaL_error(L, "This variant of setCanvas only supports 2D texture types."); + return luaL_error(L, "This variant of setRenderTargets only supports 2D texture types."); targets.colors.push_back(target); } @@ -349,9 +349,9 @@ int w_setCanvas(lua_State *L) luax_catchexcept(L, [&]() { if (targets.getFirstTarget().texture != nullptr) - instance()->setCanvas(targets); + instance()->setRenderTargets(targets); else - instance()->setCanvas(); + instance()->setRenderTarget(); }); return 0; @@ -383,7 +383,7 @@ static void pushRenderTarget(lua_State *L, const Graphics::RenderTarget &rt) int w_getCanvas(lua_State *L) { - Graphics::RenderTargets targets = instance()->getCanvas(); + Graphics::RenderTargets targets = instance()->getRenderTargets(); int ntargets = (int) targets.colors.size(); if (ntargets == 0) diff --git a/src/modules/graphics/wrap_Texture.cpp b/src/modules/graphics/wrap_Texture.cpp index a27b55c54..28e1d6b5f 100644 --- a/src/modules/graphics/wrap_Texture.cpp +++ b/src/modules/graphics/wrap_Texture.cpp @@ -418,7 +418,7 @@ int w_Texture_renderTo(lua_State *L) if (graphics) { // Save the current render targets so we can restore them when we're done. - Graphics::RenderTargets oldtargets = graphics->getCanvas(); + Graphics::RenderTargets oldtargets = graphics->getRenderTargets(); for (auto c : oldtargets.colors) c.texture->retain(); @@ -427,7 +427,7 @@ int w_Texture_renderTo(lua_State *L) oldtargets.depthStencil.texture->retain(); luax_catchexcept(L, - [&]() { graphics->setCanvas(rt, 0); }, + [&]() { graphics->setRenderTarget(rt, 0); }, [&](bool err) { if (err) @@ -441,7 +441,7 @@ int w_Texture_renderTo(lua_State *L) lua_settop(L, 2); // make sure the function is on top of the stack int status = lua_pcall(L, 0, 0, 0); - graphics->setCanvas(oldtargets); + graphics->setRenderTargets(oldtargets); for (auto c : oldtargets.colors) c.texture->release(); diff --git a/src/modules/window/sdl/Window.cpp b/src/modules/window/sdl/Window.cpp index 43d8ec238..1f77ff641 100644 --- a/src/modules/window/sdl/Window.cpp +++ b/src/modules/window/sdl/Window.cpp @@ -432,8 +432,8 @@ bool Window::setWindow(int width, int height, WindowSettings *settings) if (!graphics.get()) graphics.set(Module::getInstance(Module::M_GRAPHICS)); - if (graphics.get() && graphics->isCanvasActive()) - throw love::Exception("love.window.setMode cannot be called while a Canvas is active in love.graphics."); + if (graphics.get() && graphics->isRenderTargetActive()) + throw love::Exception("love.window.setMode cannot be called while a render target is active in love.graphics."); WindowSettings f; @@ -664,8 +664,8 @@ void Window::close(bool allowExceptions) { if (graphics.get()) { - if (allowExceptions && graphics->isCanvasActive()) - throw love::Exception("love.window.close cannot be called while a Canvas is active in love.graphics."); + if (allowExceptions && graphics->isRenderTargetActive()) + throw love::Exception("love.window.close cannot be called while a render target is active in love.graphics."); graphics->unSetMode(); } @@ -694,8 +694,8 @@ bool Window::setFullscreen(bool fullscreen, Window::FullscreenType fstype) if (!window) return false; - if (graphics.get() && graphics->isCanvasActive()) - throw love::Exception("love.window.setFullscreen cannot be called while a Canvas is active in love.graphics."); + if (graphics.get() && graphics->isRenderTargetActive()) + throw love::Exception("love.window.setFullscreen cannot be called while a render target is active in love.graphics."); WindowSettings newsettings = settings; newsettings.fullscreen = fullscreen;