mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Replace internal C++ newImage and newCanvas methods with newTexture
This commit is contained in:
@@ -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);
|
||||
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -761,7 +761,7 @@ static int w__pushNewImage(lua_State *L, Texture::Slices &slices, const Texture:
|
||||
{
|
||||
StrongRef<Texture> 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();
|
||||
|
||||
Reference in New Issue
Block a user