mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Moved anisotropic filtering to Image:setFilter(min, mag, anisotropy), added anisotropic filtering support to canvases and fonts
This commit is contained in:
@@ -19,8 +19,10 @@
|
||||
**/
|
||||
|
||||
#include "Canvas.h"
|
||||
#include "Image.h"
|
||||
#include "Graphics.h"
|
||||
#include "common/Matrix.h"
|
||||
#include "common/config.h"
|
||||
|
||||
#include <cstring> // For memcpy
|
||||
|
||||
@@ -315,6 +317,7 @@ Canvas::Canvas(int width, int height, TextureType texture_type)
|
||||
vertices[3].t = 0;
|
||||
|
||||
settings.filter = Image::getDefaultFilter();
|
||||
settings.anisotropy = Image::getDefaultAnisotropy();
|
||||
|
||||
getStrategy();
|
||||
|
||||
@@ -494,6 +497,24 @@ Image::Wrap Canvas::getWrap() const
|
||||
return getTextureWrap();
|
||||
}
|
||||
|
||||
void Canvas::setAnisotropy(float anisotropy)
|
||||
{
|
||||
if (Image::hasAnisotropicFilteringSupport())
|
||||
{
|
||||
settings.anisotropy = std::min(std::max(anisotropy, 1.0f), Image::getMaxAnisotropy());
|
||||
|
||||
bindTexture(img);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, settings.anisotropy);
|
||||
}
|
||||
else
|
||||
settings.anisotropy = 1.0f;
|
||||
}
|
||||
|
||||
float Canvas::getAnisotropy() const
|
||||
{
|
||||
return settings.anisotropy;
|
||||
}
|
||||
|
||||
bool Canvas::loadVolatile()
|
||||
{
|
||||
status = strategy->createFBO(fbo, depth_stencil, img, width, height, texture_type);
|
||||
@@ -502,6 +523,7 @@ bool Canvas::loadVolatile()
|
||||
|
||||
setFilter(settings.filter);
|
||||
setWrap(settings.wrap);
|
||||
setAnisotropy(settings.anisotropy);
|
||||
Color c;
|
||||
c.r = c.g = c.b = c.a = 0;
|
||||
clear(c);
|
||||
|
||||
Reference in New Issue
Block a user