mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Moved anisotropic filtering to Image:setFilter(min, mag, anisotropy), added anisotropic filtering support to canvases and fonts
This commit is contained in:
@@ -26,6 +26,7 @@ namespace graphics
|
||||
{
|
||||
|
||||
Image::Filter Image::defaultFilter;
|
||||
float Image::defaultAnisotropy = 1.0f;
|
||||
|
||||
Image::Filter::Filter()
|
||||
: min(FILTER_LINEAR)
|
||||
@@ -54,6 +55,16 @@ const Image::Filter &Image::getDefaultFilter()
|
||||
return defaultFilter;
|
||||
}
|
||||
|
||||
void Image::setDefaultAnisotropy(float anisotropy)
|
||||
{
|
||||
defaultAnisotropy = anisotropy;
|
||||
}
|
||||
|
||||
float Image::getDefaultAnisotropy()
|
||||
{
|
||||
return defaultAnisotropy;
|
||||
}
|
||||
|
||||
bool Image::getConstant(const char *in, FilterMode &out)
|
||||
{
|
||||
return filterModes.find(in, out);
|
||||
|
||||
@@ -71,6 +71,10 @@ public:
|
||||
static void setDefaultFilter(const Filter &f);
|
||||
static const Filter &getDefaultFilter();
|
||||
|
||||
// The default amount of anisotropic filtering.
|
||||
static void setDefaultAnisotropy(float anisotropy);
|
||||
static float getDefaultAnisotropy();
|
||||
|
||||
static bool getConstant(const char *in, FilterMode &out);
|
||||
static bool getConstant(FilterMode in, const char *&out);
|
||||
static bool getConstant(const char *in, WrapMode &out);
|
||||
@@ -78,9 +82,12 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
// The default image filter
|
||||
// The default image filter.
|
||||
static Filter defaultFilter;
|
||||
|
||||
// The default amount of anisotropic filtering.
|
||||
static float defaultAnisotropy;
|
||||
|
||||
static StringMap<FilterMode, FILTER_MAX_ENUM>::Entry filterModeEntries[];
|
||||
static StringMap<FilterMode, FILTER_MAX_ENUM> filterModes;
|
||||
static StringMap<WrapMode, WRAP_MAX_ENUM>::Entry wrapModeEntries[];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -72,6 +72,9 @@ public:
|
||||
void setWrap(const Image::Wrap &w);
|
||||
Image::Wrap getWrap() const;
|
||||
|
||||
void setAnisotropy(float anisotropy);
|
||||
float getAnisotropy() const;
|
||||
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
|
||||
@@ -119,6 +122,7 @@ private:
|
||||
{
|
||||
Image::Filter filter;
|
||||
Image::Wrap wrap;
|
||||
float anisotropy;
|
||||
} settings;
|
||||
|
||||
void drawv(const Matrix &t, const vertex *v) const;
|
||||
|
||||
@@ -47,6 +47,7 @@ Font::Font(love::font::Rasterizer *r, const Image::Filter &filter)
|
||||
, height(r->getHeight())
|
||||
, lineHeight(1)
|
||||
, mSpacing(1)
|
||||
, anisotropy(Image::getDefaultAnisotropy())
|
||||
, filter(filter)
|
||||
{
|
||||
// try to find the best texture size match for the font size
|
||||
@@ -166,6 +167,7 @@ void Font::createTexture()
|
||||
&emptyData[0]);
|
||||
|
||||
setFilter(filter);
|
||||
setAnisotropy(anisotropy);
|
||||
}
|
||||
|
||||
Font::Glyph *Font::addGlyph(unsigned int glyph)
|
||||
@@ -513,6 +515,28 @@ const Image::Filter &Font::getFilter()
|
||||
return filter;
|
||||
}
|
||||
|
||||
void Font::setAnisotropy(float anisotropy)
|
||||
{
|
||||
if (Image::hasAnisotropicFilteringSupport())
|
||||
{
|
||||
this->anisotropy = std::min(std::max(anisotropy, 1.0f), Image::getMaxAnisotropy());
|
||||
|
||||
std::vector<GLuint>::const_iterator it;
|
||||
for (it = textures.begin(); it != textures.end(); ++it)
|
||||
{
|
||||
bindTexture(*it);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, this->anisotropy);
|
||||
}
|
||||
}
|
||||
else
|
||||
this->anisotropy = 1.0f;
|
||||
}
|
||||
|
||||
float Font::getAnisotropy() const
|
||||
{
|
||||
return anisotropy;
|
||||
}
|
||||
|
||||
bool Font::loadVolatile()
|
||||
{
|
||||
createTexture();
|
||||
|
||||
@@ -129,6 +129,9 @@ public:
|
||||
void setFilter(const Image::Filter &f);
|
||||
const Image::Filter &getFilter();
|
||||
|
||||
void setAnisotropy(float anisotropy);
|
||||
float getAnisotropy() const;
|
||||
|
||||
// Implements Volatile.
|
||||
bool loadVolatile();
|
||||
void unloadVolatile();
|
||||
@@ -183,6 +186,8 @@ private:
|
||||
float lineHeight;
|
||||
float mSpacing; // modifies the spacing by multiplying it with this value
|
||||
|
||||
float anisotropy;
|
||||
|
||||
int texture_size_index;
|
||||
int texture_width;
|
||||
int texture_height;
|
||||
|
||||
@@ -639,16 +639,26 @@ const Image::Filter &Graphics::getDefaultImageFilter() const
|
||||
return Image::getDefaultFilter();
|
||||
}
|
||||
|
||||
void Graphics::setDefaultMipmapFilter(Image::FilterMode filter, float sharpness, float anisotropy)
|
||||
void Graphics::setDefaultAnisotropy(float anisotropy)
|
||||
{
|
||||
Image::setDefaultMipmapFilter(filter);
|
||||
Image::setDefaultMipmapSharpness(sharpness, anisotropy);
|
||||
Image::setDefaultAnisotropy(anisotropy);
|
||||
}
|
||||
|
||||
void Graphics::getDefaultMipmapFilter(Image::FilterMode *filter, float *sharpness, float *anisotropy) const
|
||||
float Graphics::getDefaultAnisotropy() const
|
||||
{
|
||||
return Image::getDefaultAnisotropy();
|
||||
}
|
||||
|
||||
void Graphics::setDefaultMipmapFilter(Image::FilterMode filter, float sharpness)
|
||||
{
|
||||
Image::setDefaultMipmapFilter(filter);
|
||||
Image::setDefaultMipmapSharpness(sharpness);
|
||||
}
|
||||
|
||||
void Graphics::getDefaultMipmapFilter(Image::FilterMode *filter, float *sharpness) const
|
||||
{
|
||||
*filter = Image::getDefaultMipmapFilter();
|
||||
Image::getDefaultMipmapSharpness(sharpness, anisotropy);
|
||||
*sharpness = Image::getDefaultMipmapSharpness();
|
||||
}
|
||||
|
||||
void Graphics::setLineWidth(float width)
|
||||
|
||||
@@ -320,10 +320,16 @@ public:
|
||||
const Image::Filter &getDefaultImageFilter() const;
|
||||
|
||||
/**
|
||||
* Default Image mipmap filtermode, sharpness, and anisotropy values.
|
||||
* Default texture anisotropic filtering level.
|
||||
**/
|
||||
void setDefaultMipmapFilter(Image::FilterMode filter, float sharpness, float anisotropy);
|
||||
void getDefaultMipmapFilter(Image::FilterMode *filter, float *sharpness, float *anisotropy) const;
|
||||
void setDefaultAnisotropy(float anisotropy);
|
||||
float getDefaultAnisotropy() const;
|
||||
|
||||
/**
|
||||
* Default Image mipmap filtermode and sharpness values.
|
||||
**/
|
||||
void setDefaultMipmapFilter(Image::FilterMode filter, float sharpness);
|
||||
void getDefaultMipmapFilter(Image::FilterMode *filter, float *sharpness) const;
|
||||
|
||||
/**
|
||||
* Sets the line width.
|
||||
|
||||
@@ -34,19 +34,18 @@ namespace opengl
|
||||
{
|
||||
|
||||
float Image::maxMipmapSharpness = 0.0f;
|
||||
float Image::maxMipmapAnisotropy = 0.0f;
|
||||
float Image::maxAnisotropy = 1.0f;
|
||||
|
||||
Image::FilterMode Image::defaultMipmapFilter = Image::FILTER_NONE;
|
||||
float Image::defaultMipmapSharpness = 0.0f;
|
||||
float Image::defaultMipmapAnisotropy = 0.0f;
|
||||
|
||||
Image::Image(love::image::ImageData *data)
|
||||
: width((float)(data->getWidth()))
|
||||
, height((float)(data->getHeight()))
|
||||
, texture(0)
|
||||
, mipmapSharpness(defaultMipmapSharpness)
|
||||
, mipmapAnisotropy(defaultMipmapAnisotropy)
|
||||
, mipmapsCreated(false)
|
||||
, anisotropy(getDefaultAnisotropy())
|
||||
{
|
||||
data->retain();
|
||||
this->data = data;
|
||||
@@ -231,7 +230,7 @@ const Image::Wrap &Image::getWrap() const
|
||||
return wrap;
|
||||
}
|
||||
|
||||
void Image::setMipmapSharpness(float sharpness, float anisotropy)
|
||||
void Image::setMipmapSharpness(float sharpness)
|
||||
{
|
||||
if (hasMipmapSharpnessSupport())
|
||||
{
|
||||
@@ -243,22 +242,29 @@ void Image::setMipmapSharpness(float sharpness, float anisotropy)
|
||||
}
|
||||
else
|
||||
mipmapSharpness = 0.0f;
|
||||
|
||||
if (hasMipmapAnisotropySupport())
|
||||
{
|
||||
mipmapAnisotropy = std::min(std::max(anisotropy, 0.0f), maxMipmapAnisotropy);
|
||||
|
||||
bind();
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, mipmapAnisotropy);
|
||||
}
|
||||
else
|
||||
mipmapAnisotropy = 0.0f;
|
||||
}
|
||||
|
||||
void Image::getMipmapSharpness(float *sharpness, float *anisotropy) const
|
||||
float Image::getMipmapSharpness() const
|
||||
{
|
||||
*sharpness = mipmapSharpness;
|
||||
*anisotropy = mipmapAnisotropy;
|
||||
return mipmapSharpness;
|
||||
}
|
||||
|
||||
void Image::setAnisotropy(float anisotropy)
|
||||
{
|
||||
if (hasAnisotropicFilteringSupport())
|
||||
{
|
||||
this->anisotropy = std::min(std::max(anisotropy, 1.0f), getMaxAnisotropy());
|
||||
|
||||
bind();
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, this->anisotropy);
|
||||
}
|
||||
else
|
||||
this->anisotropy = 1.0f;
|
||||
}
|
||||
|
||||
float Image::getAnisotropy() const
|
||||
{
|
||||
return anisotropy;
|
||||
}
|
||||
|
||||
void Image::bind() const
|
||||
@@ -284,9 +290,6 @@ bool Image::loadVolatile()
|
||||
if (hasMipmapSharpnessSupport() && maxMipmapSharpness == 0.0f)
|
||||
glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS, &maxMipmapSharpness);
|
||||
|
||||
if (hasMipmapAnisotropySupport() && maxMipmapAnisotropy == 0.0f)
|
||||
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxMipmapAnisotropy);
|
||||
|
||||
if (hasNpot())
|
||||
return loadVolatileNPOT();
|
||||
else
|
||||
@@ -338,7 +341,9 @@ bool Image::loadVolatilePOT()
|
||||
|
||||
mipmapsCreated = false;
|
||||
checkMipmapsCreated();
|
||||
setMipmapSharpness(mipmapSharpness, mipmapAnisotropy);
|
||||
|
||||
setMipmapSharpness(mipmapSharpness);
|
||||
setAnisotropy(anisotropy);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -368,7 +373,9 @@ bool Image::loadVolatileNPOT()
|
||||
|
||||
mipmapsCreated = false;
|
||||
checkMipmapsCreated();
|
||||
setMipmapSharpness(mipmapSharpness, mipmapAnisotropy);
|
||||
|
||||
setMipmapSharpness(mipmapSharpness);
|
||||
setAnisotropy(anisotropy);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -402,16 +409,14 @@ void Image::drawv(const Matrix &t, const vertex *v) const
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void Image::setDefaultMipmapSharpness(float sharpness, float anisotropy)
|
||||
void Image::setDefaultMipmapSharpness(float sharpness)
|
||||
{
|
||||
defaultMipmapSharpness = sharpness;
|
||||
defaultMipmapAnisotropy = anisotropy;
|
||||
}
|
||||
|
||||
void Image::getDefaultMipmapSharpness(float *sharpness, float *anisotropy)
|
||||
float Image::getDefaultMipmapSharpness()
|
||||
{
|
||||
*sharpness = defaultMipmapSharpness;
|
||||
*anisotropy = defaultMipmapAnisotropy;
|
||||
return defaultMipmapSharpness;
|
||||
}
|
||||
|
||||
void Image::setDefaultMipmapFilter(Image::FilterMode f)
|
||||
@@ -424,11 +429,24 @@ Image::FilterMode Image::getDefaultMipmapFilter()
|
||||
return defaultMipmapFilter;
|
||||
}
|
||||
|
||||
float Image::getMaxAnisotropy()
|
||||
{
|
||||
if (hasAnisotropicFilteringSupport() && maxAnisotropy == 1.0f)
|
||||
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy);
|
||||
|
||||
return maxAnisotropy;
|
||||
}
|
||||
|
||||
bool Image::hasNpot()
|
||||
{
|
||||
return GLEE_VERSION_2_0 || GLEE_ARB_texture_non_power_of_two;
|
||||
}
|
||||
|
||||
bool Image::hasAnisotropicFilteringSupport()
|
||||
{
|
||||
return GLEE_EXT_texture_filter_anisotropic;
|
||||
}
|
||||
|
||||
bool Image::hasMipmapSupport()
|
||||
{
|
||||
return GLEE_VERSION_1_4 || GLEE_SGIS_generate_mipmap;
|
||||
@@ -439,11 +457,6 @@ bool Image::hasMipmapSharpnessSupport()
|
||||
return GLEE_VERSION_1_4 || GLEE_EXT_texture_lod_bias;
|
||||
}
|
||||
|
||||
bool Image::hasMipmapAnisotropySupport()
|
||||
{
|
||||
return GLEE_EXT_texture_filter_anisotropic;
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
@@ -104,8 +104,11 @@ public:
|
||||
|
||||
const Image::Wrap &getWrap() const;
|
||||
|
||||
void setMipmapSharpness(float sharpness, float anisotropy);
|
||||
void getMipmapSharpness(float *sharpness, float *anisotropy) const;
|
||||
void setAnisotropy(float anisotropy);
|
||||
float getAnisotropy() const;
|
||||
|
||||
void setMipmapSharpness(float sharpness);
|
||||
float getMipmapSharpness() const;
|
||||
|
||||
void bind() const;
|
||||
|
||||
@@ -116,15 +119,17 @@ public:
|
||||
bool loadVolatile();
|
||||
void unloadVolatile();
|
||||
|
||||
static void setDefaultMipmapSharpness(float sharpness, float anisotropy);
|
||||
static void getDefaultMipmapSharpness(float *sharpness, float *anisotropy);
|
||||
static void setDefaultMipmapSharpness(float sharpness);
|
||||
static float getDefaultMipmapSharpness();
|
||||
static void setDefaultMipmapFilter(FilterMode f);
|
||||
static FilterMode getDefaultMipmapFilter();
|
||||
|
||||
static float getMaxAnisotropy();
|
||||
|
||||
static bool hasNpot();
|
||||
static bool hasAnisotropicFilteringSupport();
|
||||
static bool hasMipmapSupport();
|
||||
static bool hasMipmapSharpnessSupport();
|
||||
static bool hasMipmapAnisotropySupport();
|
||||
|
||||
private:
|
||||
|
||||
@@ -150,12 +155,12 @@ private:
|
||||
// Mipmap texture LOD bias (sharpness) value.
|
||||
float mipmapSharpness;
|
||||
|
||||
// Mipmap texture anisotropic filtering value.
|
||||
float mipmapAnisotropy;
|
||||
|
||||
// True if mipmaps have been created for this Image.
|
||||
bool mipmapsCreated;
|
||||
|
||||
// Anisotropic filtering value.
|
||||
float anisotropy;
|
||||
|
||||
// The image's filter mode
|
||||
Image::Filter filter;
|
||||
|
||||
@@ -168,11 +173,10 @@ private:
|
||||
void checkMipmapsCreated();
|
||||
|
||||
static float maxMipmapSharpness;
|
||||
static float maxMipmapAnisotropy;
|
||||
static float maxAnisotropy;
|
||||
|
||||
static FilterMode defaultMipmapFilter;
|
||||
static float defaultMipmapSharpness;
|
||||
static float defaultMipmapAnisotropy;
|
||||
|
||||
}; // Image
|
||||
|
||||
|
||||
@@ -101,6 +101,9 @@ int w_Canvas_setFilter(lua_State *L)
|
||||
|
||||
canvas->setFilter(f);
|
||||
|
||||
float anisotropy = (float) luaL_optnumber(L, 4, 1.0);
|
||||
canvas->setAnisotropy(anisotropy);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -118,7 +121,9 @@ int w_Canvas_getFilter(lua_State *L)
|
||||
lua_pushstring(L, minstr);
|
||||
lua_pushstring(L, magstr);
|
||||
|
||||
return 2;
|
||||
lua_pushnumber(L, canvas->getAnisotropy());
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
int w_Canvas_setWrap(lua_State *L)
|
||||
|
||||
@@ -112,6 +112,9 @@ int w_Font_setFilter(lua_State *L)
|
||||
return luaL_error(L, "%s", e.what());
|
||||
}
|
||||
|
||||
float anisotropy = (float) luaL_optnumber(L, 4, 1.0);
|
||||
t->setAnisotropy(anisotropy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -125,7 +128,8 @@ int w_Font_getFilter(lua_State *L)
|
||||
Image::getConstant(f.mag, magstr);
|
||||
lua_pushstring(L, minstr);
|
||||
lua_pushstring(L, magstr);
|
||||
return 2;
|
||||
lua_pushnumber(L, t->getAnisotropy());
|
||||
return 3;
|
||||
}
|
||||
|
||||
int w_Font_getAscent(lua_State *L)
|
||||
|
||||
@@ -738,6 +738,9 @@ int w_setDefaultImageFilter(lua_State *L)
|
||||
|
||||
instance->setDefaultImageFilter(f);
|
||||
|
||||
float anisotropy = (float) luaL_optnumber(L, 3, 1.0);
|
||||
instance->setDefaultAnisotropy(anisotropy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -764,12 +767,13 @@ int w_getDefaultImageFilter(lua_State *L)
|
||||
const char *minstr;
|
||||
const char *magstr;
|
||||
if (!Image::getConstant(f.min, minstr))
|
||||
return luaL_error(L, "Unknown filter mode for argument #1");
|
||||
return luaL_error(L, "Unknown minification filter mode");
|
||||
if (!Image::getConstant(f.mag, magstr))
|
||||
return luaL_error(L, "Unknown filter mode for argument #2");
|
||||
return luaL_error(L, "Unknown magnification filter mode");
|
||||
lua_pushstring(L, minstr);
|
||||
lua_pushstring(L, magstr);
|
||||
return 2;
|
||||
lua_pushnumber(L, instance->getDefaultAnisotropy());
|
||||
return 3;
|
||||
}
|
||||
|
||||
int w_setDefaultMipmapFilter(lua_State *L)
|
||||
@@ -783,9 +787,8 @@ int w_setDefaultMipmapFilter(lua_State *L)
|
||||
}
|
||||
|
||||
float sharpness = luaL_optnumber(L, 2, 0);
|
||||
float anisotropy = luaL_optnumber(L, 3, 0);
|
||||
|
||||
instance->setDefaultMipmapFilter(filter, sharpness, anisotropy);
|
||||
instance->setDefaultMipmapFilter(filter, sharpness);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -793,9 +796,9 @@ int w_setDefaultMipmapFilter(lua_State *L)
|
||||
int w_getDefaultMipmapFilter(lua_State *L)
|
||||
{
|
||||
Image::FilterMode filter;
|
||||
float sharpness, anisotropy;
|
||||
float sharpness;
|
||||
|
||||
instance->getDefaultMipmapFilter(&filter, &sharpness, &anisotropy);
|
||||
instance->getDefaultMipmapFilter(&filter, &sharpness);
|
||||
|
||||
const char *str;
|
||||
if (Image::getConstant(filter, str))
|
||||
@@ -804,9 +807,8 @@ int w_getDefaultMipmapFilter(lua_State *L)
|
||||
lua_pushnil(L);
|
||||
|
||||
lua_pushnumber(L, sharpness);
|
||||
lua_pushnumber(L, anisotropy);
|
||||
|
||||
return 3;
|
||||
return 2;
|
||||
}
|
||||
|
||||
int w_setLineWidth(lua_State *L)
|
||||
|
||||
@@ -77,6 +77,9 @@ int w_Image_setFilter(lua_State *L)
|
||||
return luaL_error(L, "%s", e.what());
|
||||
}
|
||||
|
||||
float anisotropy = (float) luaL_optnumber(L, 4, 1.0);
|
||||
t->setAnisotropy(anisotropy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -90,7 +93,8 @@ int w_Image_getFilter(lua_State *L)
|
||||
Image::getConstant(f.mag, magstr);
|
||||
lua_pushstring(L, minstr);
|
||||
lua_pushstring(L, magstr);
|
||||
return 2;
|
||||
lua_pushnumber(L, t->getAnisotropy());
|
||||
return 3;
|
||||
}
|
||||
|
||||
int w_Image_setMipmapFilter(lua_State *L)
|
||||
@@ -117,9 +121,8 @@ int w_Image_setMipmapFilter(lua_State *L)
|
||||
}
|
||||
|
||||
float sharpness = luaL_optnumber(L, 3, 0);
|
||||
float anisotropy = luaL_optnumber(L, 4, 0);
|
||||
|
||||
t->setMipmapSharpness(sharpness, anisotropy);
|
||||
t->setMipmapSharpness(sharpness);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -130,19 +133,15 @@ int w_Image_getMipmapFilter(lua_State *L)
|
||||
|
||||
const Image::Filter &f = t->getFilter();
|
||||
|
||||
float sharpness, anisotropy;
|
||||
t->getMipmapSharpness(&sharpness, &anisotropy);
|
||||
|
||||
const char *mipmapstr;
|
||||
if (Image::getConstant(f.mipmap, mipmapstr))
|
||||
lua_pushstring(L, mipmapstr);
|
||||
else
|
||||
lua_pushnil(L); // only return a mipmap filter if mipmapping is enabled
|
||||
|
||||
lua_pushnumber(L, sharpness);
|
||||
lua_pushnumber(L, anisotropy);
|
||||
lua_pushnumber(L, t->getMipmapSharpness());
|
||||
|
||||
return 3;
|
||||
return 2;
|
||||
}
|
||||
|
||||
int w_Image_setWrap(lua_State *L)
|
||||
|
||||
Reference in New Issue
Block a user