Rename the sampler filters so that they use the same naming convention as modern graphics APIs

This commit is contained in:
Magnus Norddahl 2019-12-29 18:54:22 +01:00
parent 12fd006c61
commit ca3fa76e32
7 changed files with 26 additions and 24 deletions

View file

@ -265,10 +265,10 @@ namespace CodeImp.DoomBuilder.Rendering
public void SetSamplerFilter(TextureFilter filter)
{
SetSamplerFilter(filter, filter, TextureFilter.None, 0.0f);
SetSamplerFilter(filter, filter, MipmapFilter.None, 0.0f);
}
public void SetSamplerFilter(TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy)
public void SetSamplerFilter(TextureFilter minfilter, TextureFilter magfilter, MipmapFilter mipfilter, float maxanisotropy)
{
RenderDevice_SetSamplerFilter(Handle, minfilter, magfilter, mipfilter, maxanisotropy);
}
@ -437,11 +437,11 @@ namespace CodeImp.DoomBuilder.Rendering
SetSamplerState(TextureAddress.Wrap);
//mxd. It's still nice to have anisotropic filtering when texture filtering is disabled
TextureFilter magminfilter = (General.Settings.VisualBilinear ? TextureFilter.Linear : TextureFilter.Point);
TextureFilter magminfilter = (General.Settings.VisualBilinear ? TextureFilter.Linear : TextureFilter.Nearest);
SetSamplerFilter(
General.Settings.FilterAnisotropy > 1.0f ? TextureFilter.Anisotropic : magminfilter,
magminfilter,
General.Settings.VisualBilinear ? TextureFilter.Linear : TextureFilter.None, // [SB] use None, otherwise textures are still filtered
magminfilter,
General.Settings.VisualBilinear ? MipmapFilter.Linear : MipmapFilter.Nearest,
General.Settings.FilterAnisotropy);
// Initialize presentations
@ -514,7 +514,7 @@ namespace CodeImp.DoomBuilder.Rendering
static extern void RenderDevice_SetTexture(IntPtr handle, IntPtr texture);
[DllImport("BuilderNative", CallingConvention = CallingConvention.Cdecl)]
static extern void RenderDevice_SetSamplerFilter(IntPtr handle, TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy);
static extern void RenderDevice_SetSamplerFilter(IntPtr handle, TextureFilter minfilter, TextureFilter magfilter, MipmapFilter mipfilter, float maxanisotropy);
[DllImport("BuilderNative", CallingConvention = CallingConvention.Cdecl)]
static extern void RenderDevice_SetSamplerState(IntPtr handle, TextureAddress address);
@ -675,5 +675,6 @@ namespace CodeImp.DoomBuilder.Rendering
public enum FillMode : int { Solid, Wireframe }
public enum TextureAddress : int { Wrap, Clamp }
public enum PrimitiveType : int { LineList, TriangleList, TriangleStrip }
public enum TextureFilter : int { None, Point, Linear, Anisotropic }
public enum TextureFilter : int { Nearest, Linear }
public enum MipmapFilter : int { None, Nearest, Linear}
}

View file

@ -493,7 +493,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetUniform(UniformName.projection, worldmatrix * viewmatrix * Matrix.Scaling(1f, -1f, 1f));
else
graphics.SetUniform(UniformName.projection, worldmatrix * viewmatrix);
graphics.SetSamplerFilter(bilinear ? TextureFilter.Linear : TextureFilter.Point);
graphics.SetSamplerFilter(bilinear ? TextureFilter.Linear : TextureFilter.Nearest);
}
private void SetThings2DSettings(float alpha)

View file

@ -310,8 +310,8 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetUniform(UniformName.fogcolor, General.Colors.Background.ToColorValue());
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
graphics.SetUniform(UniformName.highlightcolor, new Color4()); //mxd
TextureFilter texFilter = General.Settings.VisualBilinear ? TextureFilter.Linear : TextureFilter.Point;
graphics.SetSamplerFilter(texFilter, texFilter, TextureFilter.Linear, General.Settings.FilterAnisotropy);
TextureFilter texFilter = General.Settings.VisualBilinear ? TextureFilter.Linear : TextureFilter.Nearest;
graphics.SetSamplerFilter(texFilter, texFilter, MipmapFilter.Linear, General.Settings.FilterAnisotropy);
// Texture addressing
graphics.SetSamplerState(TextureAddress.Wrap);
@ -2014,7 +2014,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetUniform(UniformName.projection, world * view2d);
graphics.SetUniform(UniformName.texturefactor, new Color4(1f, 1f, 1f, 1f));
graphics.SetUniform(UniformName.rendersettings, new Vector4(1.0f, 1.0f, 0.0f, 1.0f));
graphics.SetSamplerFilter(General.Settings.VisualBilinear ? TextureFilter.Linear : TextureFilter.Point);
graphics.SetSamplerFilter(General.Settings.VisualBilinear ? TextureFilter.Linear : TextureFilter.Nearest);
// Texture
if (crosshairbusy)

View file

@ -135,7 +135,7 @@ extern "C"
device->SetTexture(texture);
}
void RenderDevice_SetSamplerFilter(RenderDevice* device, TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy)
void RenderDevice_SetSamplerFilter(RenderDevice* device, TextureFilter minfilter, TextureFilter magfilter, MipmapFilter mipfilter, float maxanisotropy)
{
device->SetSamplerFilter(minfilter, magfilter, mipfilter, maxanisotropy);
}

View file

@ -35,7 +35,8 @@ enum class FillMode : int { Solid, Wireframe };
enum class TextureAddress : int { Wrap, Clamp };
enum class ShaderFlags : int { None, Debug };
enum class PrimitiveType : int { LineList, TriangleList, TriangleStrip };
enum class TextureFilter : int { None, Point, Linear, Anisotropic };
enum class TextureFilter : int { Nearest, Linear };
enum class MipmapFilter : int { None, Nearest, Linear };
enum class UniformType : int { Vec4f, Vec3f, Vec2f, Float, Mat4 };
typedef int UniformName;
@ -69,7 +70,7 @@ public:
virtual void SetZEnable(bool value) = 0;
virtual void SetZWriteEnable(bool value) = 0;
virtual void SetTexture(Texture* texture) = 0;
virtual void SetSamplerFilter(TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy) = 0;
virtual void SetSamplerFilter(TextureFilter minfilter, TextureFilter magfilter, MipmapFilter mipfilter, float maxanisotropy) = 0;
virtual void SetSamplerState(TextureAddress address) = 0;
virtual bool Draw(PrimitiveType type, int startIndex, int primitiveCount) = 0;
virtual bool DrawIndexed(PrimitiveType type, int startIndex, int primitiveCount) = 0;

View file

@ -261,11 +261,11 @@ void GLRenderDevice::SetTexture(Texture* texture)
}
}
void GLRenderDevice::SetSamplerFilter(TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy)
void GLRenderDevice::SetSamplerFilter(TextureFilter minfilter, TextureFilter magfilter, MipmapFilter mipfilter, float maxanisotropy)
{
SamplerFilterKey key;
key.MinFilter = GetGLMinFilter(minfilter, mipfilter);
key.MagFilter = (magfilter == TextureFilter::Point || magfilter == TextureFilter::None) ? GL_NEAREST : GL_LINEAR;
key.MagFilter = (magfilter == TextureFilter::Nearest) ? GL_NEAREST : GL_LINEAR;
key.MaxAnisotropy = maxanisotropy;
if (mSamplerFilterKey != key)
{
@ -277,25 +277,25 @@ void GLRenderDevice::SetSamplerFilter(TextureFilter minfilter, TextureFilter mag
}
}
GLint GLRenderDevice::GetGLMinFilter(TextureFilter filter, TextureFilter mipfilter)
GLint GLRenderDevice::GetGLMinFilter(TextureFilter filter, MipmapFilter mipfilter)
{
if (mipfilter == TextureFilter::Linear)
if (mipfilter == MipmapFilter::Linear)
{
if (filter == TextureFilter::Point || filter == TextureFilter::None)
if (filter == TextureFilter::Nearest)
return GL_NEAREST_MIPMAP_LINEAR;
else
return GL_LINEAR_MIPMAP_LINEAR;
}
else if (mipfilter == TextureFilter::Point)
else if (mipfilter == MipmapFilter::Nearest)
{
if (filter == TextureFilter::Point || filter == TextureFilter::None)
if (filter == TextureFilter::Nearest)
return GL_NEAREST_MIPMAP_NEAREST;
else
return GL_LINEAR_MIPMAP_NEAREST;
}
else
{
if (filter == TextureFilter::Point || filter == TextureFilter::None)
if (filter == TextureFilter::Nearest)
return GL_NEAREST;
else
return GL_LINEAR;

View file

@ -55,7 +55,7 @@ public:
void SetZEnable(bool value) override;
void SetZWriteEnable(bool value) override;
void SetTexture(Texture* texture) override;
void SetSamplerFilter(TextureFilter minfilter, TextureFilter magfilter, TextureFilter mipfilter, float maxanisotropy) override;
void SetSamplerFilter(TextureFilter minfilter, TextureFilter magfilter, MipmapFilter mipfilter, float maxanisotropy) override;
void SetSamplerState(TextureAddress address) override;
bool Draw(PrimitiveType type, int startIndex, int primitiveCount) override;
bool DrawIndexed(PrimitiveType type, int startIndex, int primitiveCount) override;
@ -99,7 +99,7 @@ public:
GLShader* GetActiveShader();
GLint GetGLMinFilter(TextureFilter filter, TextureFilter mipfilter);
GLint GetGLMinFilter(TextureFilter filter, MipmapFilter mipfilter);
static std::mutex& GetMutex();
static void DeleteObject(GLVertexBuffer* buffer);