diff --git a/src/modules/graphics/Font.cpp b/src/modules/graphics/Font.cpp index 97f82572a..3d71b84fd 100644 --- a/src/modules/graphics/Font.cpp +++ b/src/modules/graphics/Font.cpp @@ -154,7 +154,7 @@ void Font::createTexture() settings.format = pixelFormat; settings.width = size.width; settings.height = size.height; - texture = gfx->newImage(settings, nullptr); + texture = gfx->newTexture(settings, nullptr); texture->setSamplerState(samplerState); { diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index c76c0afc3..9620a579e 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -821,12 +821,13 @@ Texture *Graphics::getTemporaryTexture(PixelFormat format, int w, int h, int sam if (texture == nullptr) { Texture::Settings settings; + settings.renderTarget = true; settings.format = format; settings.width = w; settings.height = h; settings.msaa = samples; - texture = newCanvas(settings); + texture = newTexture(settings); temporaryTextures.emplace_back(texture); } diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index f7bf99529..09a34bf00 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -426,7 +426,7 @@ public: // Implements Module. virtual ModuleType getModuleType() const { return M_GRAPHICS; } - virtual Texture *newImage(const Texture::Settings &settings, const Texture::Slices *data) = 0; + virtual Texture *newTexture(const Texture::Settings &settings, const Texture::Slices *data = nullptr) = 0; Quad *newQuad(Quad::Viewport v, double sw, double sh); Font *newFont(love::font::Rasterizer *data); @@ -436,8 +436,6 @@ public: SpriteBatch *newSpriteBatch(Texture *texture, int size, vertex::Usage usage); ParticleSystem *newParticleSystem(Texture *texture, int size); - virtual Texture *newCanvas(const Texture::Settings &settings) = 0; - ShaderStage *newShaderStage(ShaderStage::StageType stage, const std::string &source); Shader *newShader(const std::string &vertex, const std::string &pixel); diff --git a/src/modules/graphics/Video.cpp b/src/modules/graphics/Video.cpp index 92d387cd3..8854e64c7 100644 --- a/src/modules/graphics/Video.cpp +++ b/src/modules/graphics/Video.cpp @@ -86,7 +86,7 @@ Video::Video(Graphics *gfx, love::video::VideoStream *stream, float dpiscale) settings.width = widths[i]; settings.height = heights[i]; settings.format = PIXELFORMAT_R8_UNORM; - Texture *tex = gfx->newImage(settings, nullptr); + Texture *tex = gfx->newTexture(settings, nullptr); tex->setSamplerState(samplerState); diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 4cc54eb22..ef7c46622 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -130,14 +130,12 @@ love::graphics::StreamBuffer *Graphics::newStreamBuffer(BufferType type, size_t return CreateStreamBuffer(type, size); } -love::graphics::Texture *Graphics::newImage(const Texture::Settings &settings, const Texture::Slices *data) +love::graphics::Texture *Graphics::newTexture(const Texture::Settings &settings, const Texture::Slices *data) { - return new Image(settings, data); -} - -love::graphics::Texture *Graphics::newCanvas(const Texture::Settings &settings) -{ - return new Canvas(settings); + if (settings.renderTarget) + return new Canvas(settings); + else + return new Image(settings, data); } love::graphics::ShaderStage *Graphics::newShaderStageInternal(ShaderStage::StageType stage, const std::string &cachekey, const std::string &source, bool gles) diff --git a/src/modules/graphics/opengl/Graphics.h b/src/modules/graphics/opengl/Graphics.h index 1375feca9..b2ba4d186 100644 --- a/src/modules/graphics/opengl/Graphics.h +++ b/src/modules/graphics/opengl/Graphics.h @@ -60,8 +60,7 @@ public: // Implements Module. const char *getName() const override; - love::graphics::Texture *newImage(const Texture::Settings &settings, const Texture::Slices *data) override; - love::graphics::Texture *newCanvas(const Texture::Settings &settings) override; + love::graphics::Texture *newTexture(const Texture::Settings &settings, const Texture::Slices *data = nullptr) override; love::graphics::Buffer *newBuffer(size_t size, const void *data, BufferType type, vertex::Usage usage, uint32 mapflags) override; void setViewportSize(int width, int height, int pixelwidth, int pixelheight) override; diff --git a/src/modules/graphics/wrap_Graphics.cpp b/src/modules/graphics/wrap_Graphics.cpp index 2989d5f0f..dac60e959 100644 --- a/src/modules/graphics/wrap_Graphics.cpp +++ b/src/modules/graphics/wrap_Graphics.cpp @@ -761,7 +761,7 @@ static int w__pushNewImage(lua_State *L, Texture::Slices &slices, const Texture: { StrongRef i; luax_catchexcept(L, - [&]() { i.set(instance()->newImage(settings, &slices), Acquire::NORETAIN); }, + [&]() { i.set(instance()->newTexture(settings, &slices), Acquire::NORETAIN); }, [&](bool) { slices.clear(); } ); @@ -1248,7 +1248,7 @@ int w_newCanvas(lua_State *L) } Texture *texture = nullptr; - luax_catchexcept(L, [&](){ texture = instance()->newCanvas(settings); }); + luax_catchexcept(L, [&](){ texture = instance()->newTexture(settings); }); luax_pushtype(L, texture); texture->release();