disable mip-mapping for canvas texture

This commit is contained in:
MihailRis 2025-03-17 03:46:40 +03:00
parent 5b49c72d12
commit 3a203bd4b0
6 changed files with 14 additions and 7 deletions

View File

@ -165,7 +165,7 @@ assetload::postfunc assetload::font(
textures.emplace_back(nullptr);
} else {
auto texture = Texture::from(page.get());
texture->setMipMapping(false);
texture->setMipMapping(false, true);
textures.emplace_back(std::move(texture));
}
}

View File

@ -71,14 +71,20 @@ void GLTexture::setNearestFilter() {
glBindTexture(GL_TEXTURE_2D, 0);
}
void GLTexture::setMipMapping(bool flag) {
void GLTexture::setMipMapping(bool flag, bool pixelated) {
bind();
if (flag) {
glTexParameteri(
GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST
GL_TEXTURE_2D,
GL_TEXTURE_MIN_FILTER,
pixelated ? GL_NEAREST : GL_LINEAR_MIPMAP_NEAREST
);
} else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(
GL_TEXTURE_2D,
GL_TEXTURE_MIN_FILTER,
pixelated ? GL_NEAREST : GL_LINEAR
);
}
glBindTexture(GL_TEXTURE_2D, 0);
}

View File

@ -18,7 +18,7 @@ public:
virtual void reload(const ImageData& image) override;
virtual void setMipMapping(bool flag) override;
virtual void setMipMapping(bool flag, bool pixelated) override;
virtual std::unique_ptr<ImageData> readData() override;
virtual uint getId() const override;

View File

@ -34,7 +34,7 @@ public:
virtual uint getId() const = 0;
virtual void setMipMapping(bool flag) = 0;
virtual void setMipMapping(bool flag, bool pixelated) = 0;
static std::unique_ptr<Texture> from(const ImageData* image);
};

View File

@ -114,7 +114,7 @@ void PrecipitationRenderer::render(
batch->begin();
auto& texture = assets.require<Texture>(weather.fall.texture);
texture.setMipMapping(false);
texture.setMipMapping(false, true);
batch->setTexture(&texture, {});
const struct {

View File

@ -17,6 +17,7 @@ LuaCanvas::LuaCanvas(
void LuaCanvas::createTexture() {
mTexture = Texture::from(mData.get());
mTexture->setMipMapping(false, true);
}
union RGBA {