Cleanup in texture structures and enums, added wrap mode to TextureCreateParams and fixed wrap mode in foreground texture (lens flare effect)

dev
Tomasz Kapuściński 2022-05-08 18:23:37 +02:00
parent a25ce2d5df
commit 56e0c915b5
13 changed files with 97 additions and 176 deletions

View File

@ -103,7 +103,7 @@ void CSettings::SaveSettings()
GetConfigFile().SetFloatProperty("Setup", "ShadowColor", engine->GetShadowColor()); GetConfigFile().SetFloatProperty("Setup", "ShadowColor", engine->GetShadowColor());
GetConfigFile().SetFloatProperty("Setup", "ShadowRange", engine->GetShadowRange()); GetConfigFile().SetFloatProperty("Setup", "ShadowRange", engine->GetShadowRange());
GetConfigFile().SetIntProperty("Setup", "MSAA", engine->GetMultiSample()); GetConfigFile().SetIntProperty("Setup", "MSAA", engine->GetMultiSample());
GetConfigFile().SetIntProperty("Setup", "FilterMode", engine->GetTextureFilterMode()); GetConfigFile().SetIntProperty("Setup", "FilterMode", static_cast<int>(engine->GetTextureFilterMode()));
GetConfigFile().SetBoolProperty("Setup", "ShadowMapping", engine->GetShadowMapping()); GetConfigFile().SetBoolProperty("Setup", "ShadowMapping", engine->GetShadowMapping());
GetConfigFile().SetBoolProperty("Setup", "ShadowMappingQuality", engine->GetShadowMappingQuality()); GetConfigFile().SetBoolProperty("Setup", "ShadowMappingQuality", engine->GetShadowMappingQuality());
GetConfigFile().SetIntProperty("Setup", "ShadowMappingResolution", GetConfigFile().SetIntProperty("Setup", "ShadowMappingResolution",
@ -265,7 +265,7 @@ void CSettings::LoadSettings()
engine->SetMultiSample(iValue); engine->SetMultiSample(iValue);
if (GetConfigFile().GetIntProperty("Setup", "FilterMode", iValue)) if (GetConfigFile().GetIntProperty("Setup", "FilterMode", iValue))
engine->SetTextureFilterMode(static_cast<Gfx::TexFilter>(iValue)); engine->SetTextureFilterMode(static_cast<Gfx::TextureFilter>(iValue));
if (GetConfigFile().GetBoolProperty("Setup", "ShadowMapping", bValue)) if (GetConfigFile().GetBoolProperty("Setup", "ShadowMapping", bValue))
engine->SetShadowMapping(bValue); engine->SetShadowMapping(bValue);

View File

@ -328,7 +328,7 @@ public:
//! Creates a depth texture with specific dimensions and depth //! Creates a depth texture with specific dimensions and depth
virtual Texture CreateDepthTexture(int width, int height, int depth) = 0; virtual Texture CreateDepthTexture(int width, int height, int depth) = 0;
//! Updates a part of texture from raw image data //! Updates a part of texture from raw image data
virtual void UpdateTexture(const Texture& texture, const glm::ivec2& offset, ImageData* data, TexImgFormat format) = 0; virtual void UpdateTexture(const Texture& texture, const glm::ivec2& offset, ImageData* data, TextureFormat format) = 0;
//! Deletes a given texture, freeing it from video memory //! Deletes a given texture, freeing it from video memory
virtual void DestroyTexture(const Texture &texture) = 0; virtual void DestroyTexture(const Texture &texture) = 0;
//! Deletes all textures created so far //! Deletes all textures created so far

View File

@ -24,9 +24,6 @@
#pragma once #pragma once
#include "graphics/core/color.h"
#include <glm/glm.hpp> #include <glm/glm.hpp>
@ -36,10 +33,10 @@ namespace Gfx
/** /**
* \enum TexImgFormat * \enum TextureFormat
* \brief Format of image data * \brief Format of image data
*/ */
enum class TexImgFormat : unsigned char enum class TextureFormat : unsigned char
{ {
//! Try to determine automatically (may not work) //! Try to determine automatically (may not work)
AUTO, AUTO,
@ -54,95 +51,31 @@ enum class TexImgFormat : unsigned char
}; };
/** /**
* \enum TexFilter * \enum TextureFilter
* \brief General texture filtering mode * \brief General texture filtering mode
* *
* Corresponds to typical options in game graphics settings. * Corresponds to typical options in game graphics settings.
*/ */
enum TexFilter enum class TextureFilter : unsigned char
{ {
TEX_FILTER_NEAREST, //! Nearest-neighbor filtering
TEX_FILTER_BILINEAR, NEAREST,
TEX_FILTER_TRILINEAR //! Linear filtering
}; BILINEAR,
//! Linear filtering with mipmapping
/** TRILINEAR,
* \enum TexMinFilter
* \brief Texture minification filter
*
* Corresponds to OpenGL modes but should translate to DirectX too.
*/
enum TexMinFilter
{
TEX_MIN_FILTER_NEAREST,
TEX_MIN_FILTER_LINEAR,
TEX_MIN_FILTER_NEAREST_MIPMAP_NEAREST,
TEX_MIN_FILTER_LINEAR_MIPMAP_NEAREST,
TEX_MIN_FILTER_NEAREST_MIPMAP_LINEAR,
TEX_MIN_FILTER_LINEAR_MIPMAP_LINEAR
};
/**
* \enum TexMagFilter
* \brief Texture magnification filter
*/
enum TexMagFilter
{
TEX_MAG_FILTER_NEAREST,
TEX_MAG_FILTER_LINEAR
}; };
/** /**
* \enum TexWrapMode * \enum TexWrapMode
* \brief Wrapping mode for texture coords * \brief Wrapping mode for texture coords
*/ */
enum TexWrapMode enum class TextureWrapMode : unsigned char
{ {
TEX_WRAP_CLAMP, //! UVs are clamped to edges
TEX_WRAP_CLAMP_TO_BORDER, CLAMP,
TEX_WRAP_REPEAT //! UVs are repeated
}; REPEAT,
/**
* \enum TexMixOperation
* \brief Multitexture mixing operation
*/
enum TexMixOperation
{
//! Default operation on default params (modulate on computed & texture)
TEX_MIX_OPER_DEFAULT,
//! = Arg1
TEX_MIX_OPER_REPLACE,
//! = Arg1 * Arg2
TEX_MIX_OPER_MODULATE,
//! = Arg1 + Arg2
TEX_MIX_OPER_ADD,
//! = Arg1 - Arg2
TEX_MIX_OPER_SUBTRACT
};
/**
* \enum TexMixArgument
* \brief Multitexture mixing argument
*/
enum TexMixArgument
{
//! Color from current texture
TEX_MIX_ARG_TEXTURE,
//! Color from texture unit 0
TEX_MIX_ARG_TEXTURE_0,
//! Color from texture unit 1
TEX_MIX_ARG_TEXTURE_1,
//! Color from texture unit 2
TEX_MIX_ARG_TEXTURE_2,
//! Color from texture unit 3
TEX_MIX_ARG_TEXTURE_3,
//! Color computed by previous texture unit (current in DirectX; previous in OpenGL)
TEX_MIX_ARG_COMPUTED_COLOR,
//! (Source) color of textured fragment (diffuse in DirectX; primary color in OpenGL)
TEX_MIX_ARG_SRC_COLOR,
//! Constant color (texture factor in DirectX; texture env color in OpenGL)
TEX_MIX_ARG_FACTOR
}; };
/** /**
@ -157,52 +90,13 @@ struct TextureCreateParams
//! Whether to generate mipmaps //! Whether to generate mipmaps
bool mipmap = false; bool mipmap = false;
//! Format of source image data //! Format of source image data
TexImgFormat format = TexImgFormat::RGB; TextureFormat format = TextureFormat::RGB;
//! General texture filtering mode //! General texture filtering mode
TexFilter filter = TEX_FILTER_NEAREST; TextureFilter filter = TextureFilter::NEAREST;
//! Wrap mode for texture coordinates
TextureWrapMode wrap = TextureWrapMode::REPEAT;
//! Pad the image to nearest power of 2 dimensions //! Pad the image to nearest power of 2 dimensions
bool padToNearestPowerOfTwo = false; bool padToNearestPowerOfTwo = false;
//! Loads the default values
void LoadDefault()
{
*this = TextureCreateParams();
}
};
/**
* \struct TextureStageParams
* \brief Parameters for a texture unit
*
* These params define the behavior of texturing units (stages).
* They can be changed freely and are features of graphics engine, not any particular texture.
*/
struct TextureStageParams
{
//! Mixing operation done on color values
TexMixOperation colorOperation = TEX_MIX_OPER_DEFAULT;
//! 1st argument of color operations
TexMixArgument colorArg1 = TEX_MIX_ARG_COMPUTED_COLOR;
//! 2nd argument of color operations
TexMixArgument colorArg2 = TEX_MIX_ARG_TEXTURE;
//! Mixing operation done on alpha values
TexMixOperation alphaOperation = TEX_MIX_OPER_DEFAULT;
//! 1st argument of alpha operations
TexMixArgument alphaArg1 = TEX_MIX_ARG_COMPUTED_COLOR;
//! 2nd argument of alpha operations
TexMixArgument alphaArg2 = TEX_MIX_ARG_TEXTURE;
//! Wrap mode for 1st tex coord
TexWrapMode wrapS = TEX_WRAP_REPEAT;
//! Wrap mode for 2nd tex coord
TexWrapMode wrapT = TEX_WRAP_REPEAT;
//! Constant color factor (for TEX_MIX_ARG_FACTOR)
Color factor;
//! Loads the default values
void LoadDefault()
{
*this = TextureStageParams();
}
}; };
/** /**
@ -217,9 +111,9 @@ struct Texture
//! ID of the texture in graphics engine; 0 = invalid texture //! ID of the texture in graphics engine; 0 = invalid texture
unsigned int id = 0; unsigned int id = 0;
//! Size of texture //! Size of texture
glm::ivec2 size; glm::ivec2 size = { 0, 0 };
//! Original size of texture (as loaded from image) //! Original size of texture (as loaded from image)
glm::ivec2 originalSize; glm::ivec2 originalSize = { 0, 0 };
//! Whether the texture has alpha channel //! Whether the texture has alpha channel
bool alpha = false; bool alpha = false;

View File

@ -276,11 +276,11 @@ CEngine::CEngine(CApplication *app, CSystemUtils* systemUtils)
m_shadowColor = 0.5f; m_shadowColor = 0.5f;
m_defaultTexParams.format = TexImgFormat::AUTO; m_defaultTexParams.format = TextureFormat::AUTO;
m_defaultTexParams.filter = TEX_FILTER_BILINEAR; m_defaultTexParams.filter = TextureFilter::BILINEAR;
m_terrainTexParams.format = TexImgFormat::AUTO; m_terrainTexParams.format = TextureFormat::AUTO;
m_terrainTexParams.filter = TEX_FILTER_BILINEAR; m_terrainTexParams.filter = TextureFilter::BILINEAR;
// Compute bias matrix for shadow mapping // Compute bias matrix for shadow mapping
glm::mat4 temp1, temp2; glm::mat4 temp1, temp2;
@ -418,8 +418,8 @@ bool CEngine::Create()
Math::LoadOrthoProjectionMatrix(m_matProjInterface, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f); Math::LoadOrthoProjectionMatrix(m_matProjInterface, 0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f);
TextureCreateParams params; TextureCreateParams params;
params.format = TexImgFormat::AUTO; params.format = TextureFormat::AUTO;
params.filter = TEX_FILTER_NEAREST; params.filter = TextureFilter::NEAREST;
params.mipmap = false; params.mipmap = false;
m_miceTexture = LoadTexture("textures/interface/mouse.png", params); m_miceTexture = LoadTexture("textures/interface/mouse.png", params);
@ -1943,8 +1943,14 @@ bool CEngine::LoadAllTextures()
else else
m_backgroundTex.SetInvalid(); m_backgroundTex.SetInvalid();
if (! m_foregroundName.empty()) if (!m_foregroundName.empty())
m_foregroundTex = LoadTexture(m_foregroundName); {
TextureCreateParams params = m_defaultTexParams;
params.wrap = TextureWrapMode::CLAMP;
params.filter = TextureFilter::BILINEAR;
params.mipmap = false;
m_foregroundTex = LoadTexture(m_foregroundName, params);
}
else else
m_foregroundTex.SetInvalid(); m_foregroundTex.SetInvalid();
@ -2347,8 +2353,14 @@ void CEngine::SetForegroundName(const std::string& name)
m_foregroundName = name; m_foregroundName = name;
if (! m_foregroundName.empty() && !m_foregroundTex.Valid()) if (!m_foregroundName.empty() && !m_foregroundTex.Valid())
m_foregroundTex = LoadTexture(m_foregroundName); {
TextureCreateParams params;
params.wrap = TextureWrapMode::CLAMP;
params.filter = TextureFilter::BILINEAR;
params.mipmap = false;
m_foregroundTex = LoadTexture(m_foregroundName, params);
}
} }
void CEngine::SetOverFront(bool front) void CEngine::SetOverFront(bool front)
@ -2399,16 +2411,16 @@ float CEngine::GetClippingDistance()
return m_clippingDistance; return m_clippingDistance;
} }
void CEngine::SetTextureFilterMode(TexFilter value) void CEngine::SetTextureFilterMode(TextureFilter value)
{ {
if(m_defaultTexParams.filter == value && m_terrainTexParams.filter == value) return; if(m_defaultTexParams.filter == value && m_terrainTexParams.filter == value) return;
m_defaultTexParams.filter = m_terrainTexParams.filter = value; m_defaultTexParams.filter = m_terrainTexParams.filter = value;
m_defaultTexParams.mipmap = m_terrainTexParams.mipmap = (value == TEX_FILTER_TRILINEAR); m_defaultTexParams.mipmap = m_terrainTexParams.mipmap = (value == TextureFilter::TRILINEAR);
ReloadAllTextures(); ReloadAllTextures();
} }
TexFilter CEngine::GetTextureFilterMode() TextureFilter CEngine::GetTextureFilterMode()
{ {
return m_terrainTexParams.filter; return m_terrainTexParams.filter;
} }
@ -3177,8 +3189,8 @@ void CEngine::Capture3DScene()
image.surface = SDL_CreateRGBSurfaceFrom(blured.get(), newWidth, newHeight, 32, 0, 0, 0, 0, 0xFF000000); image.surface = SDL_CreateRGBSurfaceFrom(blured.get(), newWidth, newHeight, 32, 0, 0, 0, 0, 0xFF000000);
TextureCreateParams params; TextureCreateParams params;
params.filter = TEX_FILTER_BILINEAR; params.filter = TextureFilter::BILINEAR;
params.format = TexImgFormat::RGBA; params.format = TextureFormat::RGBA;
params.mipmap = false; params.mipmap = false;
m_capturedWorldTexture = m_device->CreateTexture(&image, params); m_capturedWorldTexture = m_device->CreateTexture(&image, params);

View File

@ -850,8 +850,8 @@ public:
//@{ //@{
//! Management the texture filter mode //! Management the texture filter mode
// NOTE: This is an user configuration setting // NOTE: This is an user configuration setting
void SetTextureFilterMode(TexFilter value); void SetTextureFilterMode(TextureFilter value);
TexFilter GetTextureFilterMode(); TextureFilter GetTextureFilterMode();
//@} //@}
//@{ //@{

View File

@ -1364,7 +1364,7 @@ CharTexture CText::CreateCharTexture(UTF8Char ch, CachedFont* font)
Texture tex; Texture tex;
tex.id = texture.id; tex.id = texture.id;
m_device->UpdateTexture(tex, texture.charPos, &imageData, TexImgFormat::RGBA); m_device->UpdateTexture(tex, texture.charPos, &imageData, TextureFormat::RGBA);
imageData.surface = nullptr; imageData.surface = nullptr;
@ -1402,8 +1402,8 @@ FontTexture CText::CreateFontTexture(const glm::ivec2& tileSize)
data.surface = textureSurface; data.surface = textureSurface;
TextureCreateParams createParams; TextureCreateParams createParams;
createParams.format = TexImgFormat::RGBA; createParams.format = TextureFormat::RGBA;
createParams.filter = TEX_FILTER_NEAREST; createParams.filter = TextureFilter::NEAREST;
createParams.mipmap = false; createParams.mipmap = false;
Texture tex = m_device->CreateTexture(&data, createParams); Texture tex = m_device->CreateTexture(&data, createParams);

View File

@ -356,15 +356,15 @@ Texture CGL33Device::CreateTexture(ImageData *data, const TextureCreateParams &p
switch (params.filter) switch (params.filter)
{ {
case TEX_FILTER_NEAREST: case TextureFilter::NEAREST:
minF = GL_NEAREST; minF = GL_NEAREST;
magF = GL_NEAREST; magF = GL_NEAREST;
break; break;
case TEX_FILTER_BILINEAR: case TextureFilter::BILINEAR:
minF = GL_LINEAR; minF = GL_LINEAR;
magF = GL_LINEAR; magF = GL_LINEAR;
break; break;
case TEX_FILTER_TRILINEAR: case TextureFilter::TRILINEAR:
minF = GL_LINEAR_MIPMAP_LINEAR; minF = GL_LINEAR_MIPMAP_LINEAR;
magF = GL_LINEAR; magF = GL_LINEAR;
mipmapLevel = CEngine::GetInstance().GetTextureMipmapLevel(); mipmapLevel = CEngine::GetInstance().GetTextureMipmapLevel();
@ -374,6 +374,21 @@ Texture CGL33Device::CreateTexture(ImageData *data, const TextureCreateParams &p
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minF); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minF);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magF); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magF);
GLint wrap = GL_REPEAT;
switch (params.wrap)
{
case TextureWrapMode::REPEAT:
wrap = GL_REPEAT;
break;
case TextureWrapMode::CLAMP:
wrap = GL_CLAMP;
break;
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap);
// Set mipmap level and automatic mipmap generation if neccesary // Set mipmap level and automatic mipmap generation if neccesary
if (params.mipmap) if (params.mipmap)
{ {
@ -457,7 +472,7 @@ Texture CGL33Device::CreateDepthTexture(int width, int height, int depth)
return result; return result;
} }
void CGL33Device::UpdateTexture(const Texture& texture, const glm::ivec2& offset, ImageData* data, TexImgFormat format) void CGL33Device::UpdateTexture(const Texture& texture, const glm::ivec2& offset, ImageData* data, TextureFormat format)
{ {
if (texture.id == 0) return; if (texture.id == 0) return;

View File

@ -110,7 +110,7 @@ public:
Texture CreateTexture(CImage *image, const TextureCreateParams &params) override; Texture CreateTexture(CImage *image, const TextureCreateParams &params) override;
Texture CreateTexture(ImageData *data, const TextureCreateParams &params) override; Texture CreateTexture(ImageData *data, const TextureCreateParams &params) override;
Texture CreateDepthTexture(int width, int height, int depth) override; Texture CreateDepthTexture(int width, int height, int depth) override;
void UpdateTexture(const Texture& texture, const glm::ivec2& offset, ImageData* data, TexImgFormat format) override; void UpdateTexture(const Texture& texture, const glm::ivec2& offset, ImageData* data, TextureFormat format) override;
void DestroyTexture(const Texture &texture) override; void DestroyTexture(const Texture &texture) override;
void DestroyAllTextures() override; void DestroyAllTextures() override;

View File

@ -522,7 +522,7 @@ std::unique_ptr<CFrameBufferPixels> GetGLFrameBufferPixels(const glm::ivec2& siz
return pixels; return pixels;
} }
PreparedTextureData PrepareTextureData(ImageData* imageData, TexImgFormat format) PreparedTextureData PrepareTextureData(ImageData* imageData, TextureFormat format)
{ {
PreparedTextureData texData; PreparedTextureData texData;
@ -530,27 +530,27 @@ PreparedTextureData PrepareTextureData(ImageData* imageData, TexImgFormat format
texData.sourceFormat = 0; texData.sourceFormat = 0;
if (format == TexImgFormat::RGB) if (format == TextureFormat::RGB)
{ {
texData.sourceFormat = GL_RGB; texData.sourceFormat = GL_RGB;
texData.alpha = false; texData.alpha = false;
} }
else if (format == TexImgFormat::BGR) else if (format == TextureFormat::BGR)
{ {
texData.sourceFormat = GL_BGR; texData.sourceFormat = GL_BGR;
texData.alpha = false; texData.alpha = false;
} }
else if (format == TexImgFormat::RGBA) else if (format == TextureFormat::RGBA)
{ {
texData.sourceFormat = GL_RGBA; texData.sourceFormat = GL_RGBA;
texData.alpha = true; texData.alpha = true;
} }
else if (format == TexImgFormat::BGRA) else if (format == TextureFormat::BGRA)
{ {
texData.sourceFormat = GL_BGRA; texData.sourceFormat = GL_BGRA;
texData.alpha = true; texData.alpha = true;
} }
else if (format == TexImgFormat::AUTO) else if (format == TextureFormat::AUTO)
{ {
if (imageData->surface->format->BytesPerPixel == 4) if (imageData->surface->format->BytesPerPixel == 4)
{ {

View File

@ -43,7 +43,7 @@ class CFrameBufferPixels;
struct DeviceConfig; struct DeviceConfig;
enum class PrimitiveType : unsigned char; enum class PrimitiveType : unsigned char;
enum class Type : unsigned char; enum class Type : unsigned char;
enum class TexImgFormat : unsigned char; enum class TextureFormat : unsigned char;
bool InitializeGLEW(); bool InitializeGLEW();
@ -99,7 +99,7 @@ struct PreparedTextureData
bool alpha = false; bool alpha = false;
}; };
PreparedTextureData PrepareTextureData(ImageData* imageData, TexImgFormat format); PreparedTextureData PrepareTextureData(ImageData* imageData, TextureFormat format);
std::unique_ptr<CFrameBufferPixels> GetGLFrameBufferPixels(const glm::ivec2& size); std::unique_ptr<CFrameBufferPixels> GetGLFrameBufferPixels(const glm::ivec2& size);

View File

@ -1186,8 +1186,8 @@ void CEdit::DrawImage(const glm::vec2& pos, std::string name, float width,
//m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); //m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);
Gfx::TextureCreateParams params; Gfx::TextureCreateParams params;
params.format = Gfx::TexImgFormat::AUTO; params.format = Gfx::TextureFormat::AUTO;
params.filter = Gfx::TEX_FILTER_BILINEAR; params.filter = Gfx::TextureFilter::BILINEAR;
params.padToNearestPowerOfTwo = true; params.padToNearestPowerOfTwo = true;
Gfx::Texture tex = m_engine->LoadTexture(PrepareImageFilename(name), params); Gfx::Texture tex = m_engine->LoadTexture(PrepareImageFilename(name), params);

View File

@ -126,8 +126,8 @@ void CImage::Draw()
if ( m_filename[0] != 0 ) // displays an image? if ( m_filename[0] != 0 ) // displays an image?
{ {
Gfx::TextureCreateParams params; Gfx::TextureCreateParams params;
params.format = Gfx::TexImgFormat::AUTO; params.format = Gfx::TextureFormat::AUTO;
params.filter = Gfx::TEX_FILTER_BILINEAR; params.filter = Gfx::TextureFilter::BILINEAR;
params.padToNearestPowerOfTwo = true; params.padToNearestPowerOfTwo = true;
Gfx::Texture tex = m_engine->LoadTexture(m_filename, params); Gfx::Texture tex = m_engine->LoadTexture(m_filename, params);
renderer->SetTexture(tex); renderer->SetTexture(tex);

View File

@ -186,9 +186,9 @@ void CScreenSetupGraphics::CreateInterface()
pes = pw->CreateEnumSlider(pos, ddim, 0, EVENT_INTERFACE_TEXTURE_FILTER); pes = pw->CreateEnumSlider(pos, ddim, 0, EVENT_INTERFACE_TEXTURE_FILTER);
pes->SetState(STATE_SHADOW); pes->SetState(STATE_SHADOW);
pes->SetPossibleValues({ pes->SetPossibleValues({
{ Gfx::TEX_FILTER_NEAREST, "Nearest" }, { static_cast<int>(Gfx::TextureFilter::NEAREST), "Nearest" },
{ Gfx::TEX_FILTER_BILINEAR, "Bilinear" }, { static_cast<int>(Gfx::TextureFilter::BILINEAR), "Bilinear" },
{ Gfx::TEX_FILTER_TRILINEAR, "Trilinear" } { static_cast<int>(Gfx::TextureFilter::TRILINEAR), "Trilinear" }
}); });
pos.y += ddim.y/2; pos.y += ddim.y/2;
pos.x += 0.005f; pos.x += 0.005f;
@ -418,13 +418,13 @@ void CScreenSetupGraphics::UpdateSetupButtons()
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_FILTER)); pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_FILTER));
if ( pes != nullptr ) if ( pes != nullptr )
{ {
pes->SetVisibleValue(m_engine->GetTextureFilterMode()); pes->SetVisibleValue(static_cast<int>(m_engine->GetTextureFilterMode()));
} }
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_MIPMAP)); pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_MIPMAP));
if ( pes != nullptr ) if ( pes != nullptr )
{ {
pes->SetState(STATE_ENABLE, m_engine->GetTextureFilterMode() == Gfx::TEX_FILTER_TRILINEAR); pes->SetState(STATE_ENABLE, m_engine->GetTextureFilterMode() == Gfx::TextureFilter::TRILINEAR);
pes->SetVisibleValue(m_engine->GetTextureMipmapLevel()); pes->SetVisibleValue(m_engine->GetTextureMipmapLevel());
} }
@ -471,7 +471,7 @@ void CScreenSetupGraphics::ChangeSetupButtons()
if ( pes != nullptr ) if ( pes != nullptr )
{ {
int valueIndex = pes->GetVisibleValueIndex(); int valueIndex = pes->GetVisibleValueIndex();
m_engine->SetTextureFilterMode(static_cast<Gfx::TexFilter>(valueIndex)); m_engine->SetTextureFilterMode(static_cast<Gfx::TextureFilter>(valueIndex));
} }
pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_MIPMAP)); pes = static_cast<CEnumSlider*>(pw->SearchControl(EVENT_INTERFACE_TEXTURE_MIPMAP));
@ -543,9 +543,9 @@ void CScreenSetupGraphics::ChangeSetupQuality(int quality)
if ( quality == 0 ) m_engine->SetTextureAnisotropyLevel(2); if ( quality == 0 ) m_engine->SetTextureAnisotropyLevel(2);
if ( quality > 0 ) m_engine->SetTextureAnisotropyLevel(8); if ( quality > 0 ) m_engine->SetTextureAnisotropyLevel(8);
if ( quality < 0 ) { m_engine->SetTextureFilterMode(Gfx::TEX_FILTER_BILINEAR); } if ( quality < 0 ) { m_engine->SetTextureFilterMode(Gfx::TextureFilter::BILINEAR); }
if ( quality == 0 ) { m_engine->SetTextureFilterMode(Gfx::TEX_FILTER_TRILINEAR); m_engine->SetTextureMipmapLevel(4); m_engine->SetTextureAnisotropyLevel(4); } if ( quality == 0 ) { m_engine->SetTextureFilterMode(Gfx::TextureFilter::TRILINEAR); m_engine->SetTextureMipmapLevel(4); m_engine->SetTextureAnisotropyLevel(4); }
if ( quality > 0 ) { m_engine->SetTextureFilterMode(Gfx::TEX_FILTER_TRILINEAR); m_engine->SetTextureMipmapLevel(8); m_engine->SetTextureAnisotropyLevel(8); } if ( quality > 0 ) { m_engine->SetTextureFilterMode(Gfx::TextureFilter::TRILINEAR); m_engine->SetTextureMipmapLevel(8); m_engine->SetTextureAnisotropyLevel(8); }
if ( quality < 0 ) { m_engine->SetShadowMapping(false); m_engine->SetShadowMappingQuality(false); } if ( quality < 0 ) { m_engine->SetShadowMapping(false); m_engine->SetShadowMappingQuality(false); }
else { m_engine->SetShadowMapping(true); m_engine->SetShadowMappingQuality(true); m_engine->SetShadowMappingOffscreen(true); } else { m_engine->SetShadowMapping(true); m_engine->SetShadowMappingQuality(true); m_engine->SetShadowMappingOffscreen(true); }