mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Merged default into minor
--HG-- branch : minor
This commit is contained in:
@@ -109,6 +109,9 @@ void Graphics::restoreState(const DisplayState &s)
|
||||
|
||||
setColorMask(s.colorMask);
|
||||
setWireframe(s.wireframe);
|
||||
|
||||
setDefaultFilter(s.defaultFilter);
|
||||
setDefaultMipmapFilter(s.defaultMipmapFilter, s.defaultMipmapSharpness);
|
||||
}
|
||||
|
||||
void Graphics::restoreStateChecked(const DisplayState &s)
|
||||
@@ -166,6 +169,9 @@ void Graphics::restoreStateChecked(const DisplayState &s)
|
||||
|
||||
if (s.wireframe != cur.wireframe)
|
||||
setWireframe(s.wireframe);
|
||||
|
||||
setDefaultFilter(s.defaultFilter);
|
||||
setDefaultMipmapFilter(s.defaultMipmapFilter, s.defaultMipmapSharpness);
|
||||
}
|
||||
|
||||
void Graphics::setViewportSize(int width, int height)
|
||||
@@ -847,6 +853,7 @@ Graphics::BlendMode Graphics::getBlendMode() const
|
||||
void Graphics::setDefaultFilter(const Texture::Filter &f)
|
||||
{
|
||||
Texture::setDefaultFilter(f);
|
||||
states.back().defaultFilter = f;
|
||||
}
|
||||
|
||||
const Texture::Filter &Graphics::getDefaultFilter() const
|
||||
@@ -858,6 +865,9 @@ void Graphics::setDefaultMipmapFilter(Texture::FilterMode filter, float sharpnes
|
||||
{
|
||||
Image::setDefaultMipmapFilter(filter);
|
||||
Image::setDefaultMipmapSharpness(sharpness);
|
||||
|
||||
states.back().defaultMipmapFilter = filter;
|
||||
states.back().defaultMipmapSharpness = sharpness;
|
||||
}
|
||||
|
||||
void Graphics::getDefaultMipmapFilter(Texture::FilterMode *filter, float *sharpness) const
|
||||
@@ -1365,6 +1375,9 @@ Graphics::DisplayState::DisplayState()
|
||||
, font(nullptr)
|
||||
, shader(nullptr)
|
||||
, wireframe(false)
|
||||
, defaultFilter()
|
||||
, defaultMipmapFilter(Texture::FILTER_NEAREST)
|
||||
, defaultMipmapSharpness(0.0f)
|
||||
{
|
||||
// We should just directly initialize the array in the initializer list, but
|
||||
// that feature of C++11 is broken in Visual Studio 2013...
|
||||
@@ -1387,6 +1400,9 @@ Graphics::DisplayState::DisplayState(const DisplayState &other)
|
||||
, shader(other.shader)
|
||||
, canvases(other.canvases)
|
||||
, wireframe(other.wireframe)
|
||||
, defaultFilter(other.defaultFilter)
|
||||
, defaultMipmapFilter(other.defaultMipmapFilter)
|
||||
, defaultMipmapSharpness(other.defaultMipmapSharpness)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
colorMask[i] = other.colorMask[i];
|
||||
@@ -1419,6 +1435,10 @@ Graphics::DisplayState &Graphics::DisplayState::operator = (const DisplayState &
|
||||
|
||||
wireframe = other.wireframe;
|
||||
|
||||
defaultFilter = other.defaultFilter;
|
||||
defaultMipmapFilter = other.defaultMipmapFilter;
|
||||
defaultMipmapSharpness = other.defaultMipmapSharpness;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -456,6 +456,13 @@ private:
|
||||
|
||||
bool wireframe;
|
||||
|
||||
// Default filter.
|
||||
Texture::Filter defaultFilter;
|
||||
|
||||
// Default mipmap filter and sharpness.
|
||||
Texture::FilterMode defaultMipmapFilter;
|
||||
float defaultMipmapSharpness;
|
||||
|
||||
DisplayState();
|
||||
DisplayState(const DisplayState &other);
|
||||
~DisplayState();
|
||||
|
||||
@@ -529,58 +529,6 @@ void OpenGL::setTextureFilter(graphics::Texture::Filter &f)
|
||||
f.anisotropy = 1.0f;
|
||||
}
|
||||
|
||||
graphics::Texture::Filter OpenGL::getTextureFilter()
|
||||
{
|
||||
GLint gmin, gmag;
|
||||
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, &gmin);
|
||||
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, &gmag);
|
||||
|
||||
Texture::Filter f;
|
||||
|
||||
switch (gmin)
|
||||
{
|
||||
case GL_NEAREST:
|
||||
f.min = Texture::FILTER_NEAREST;
|
||||
f.mipmap = Texture::FILTER_NONE;
|
||||
break;
|
||||
case GL_NEAREST_MIPMAP_NEAREST:
|
||||
f.min = f.mipmap = Texture::FILTER_NEAREST;
|
||||
break;
|
||||
case GL_NEAREST_MIPMAP_LINEAR:
|
||||
f.min = Texture::FILTER_NEAREST;
|
||||
f.mipmap = Texture::FILTER_LINEAR;
|
||||
break;
|
||||
case GL_LINEAR_MIPMAP_NEAREST:
|
||||
f.min = Texture::FILTER_LINEAR;
|
||||
f.mipmap = Texture::FILTER_NEAREST;
|
||||
break;
|
||||
case GL_LINEAR_MIPMAP_LINEAR:
|
||||
f.min = f.mipmap = Texture::FILTER_LINEAR;
|
||||
break;
|
||||
case GL_LINEAR:
|
||||
default:
|
||||
f.min = Texture::FILTER_LINEAR;
|
||||
f.mipmap = Texture::FILTER_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (gmag)
|
||||
{
|
||||
case GL_NEAREST:
|
||||
f.mag = Texture::FILTER_NEAREST;
|
||||
break;
|
||||
case GL_LINEAR:
|
||||
default:
|
||||
f.mag = Texture::FILTER_LINEAR;
|
||||
break;
|
||||
}
|
||||
|
||||
if (GLAD_EXT_texture_filter_anisotropic)
|
||||
glGetTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, &f.anisotropy);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
void OpenGL::setTextureWrap(const graphics::Texture::Wrap &w)
|
||||
{
|
||||
GLint gs, gt;
|
||||
|
||||
@@ -276,11 +276,6 @@ public:
|
||||
**/
|
||||
void setTextureFilter(graphics::Texture::Filter &f);
|
||||
|
||||
/**
|
||||
* Returns the texture filter mode for the currently bound texture.
|
||||
**/
|
||||
graphics::Texture::Filter getTextureFilter();
|
||||
|
||||
/**
|
||||
* Sets the texture wrap mode for the currently bound texture.
|
||||
**/
|
||||
|
||||
Reference in New Issue
Block a user