Anisotropic filtering.
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 2m19s
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 2m19s
This commit is contained in:
@@ -32,7 +32,7 @@ CPMAddPackage(
|
||||
|
||||
CPMAddPackage(
|
||||
NAME GLAD
|
||||
URL https://git.redacted.cc/Redacted/glad/archive/v2.1ext_fbo_depthtexture_shadow.zip
|
||||
URL https://git.redacted.cc/Redacted/glad/archive/v2.1ext_fbo_depthtexture_shadow_anisotropic.zip
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
|
@@ -34,20 +34,31 @@ namespace JGL {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO come up with a cleaner way to type out sample-rates before release.
|
||||
// :shrug:, I'm not very creative. - Redacted.
|
||||
enum class MSAA_SAMPLE_RATE : u8 {
|
||||
MSAA_NONE = 0,
|
||||
NONE = 0,
|
||||
MSAA_2X = 1,
|
||||
MSAA_4X = 2,
|
||||
MSAA_8X = 3
|
||||
};
|
||||
|
||||
enum class ANISOTROPY_SAMPLE_RATE : u8 {
|
||||
NONE = 0,
|
||||
ANISOTROPY_2X = 2,
|
||||
ANISOTROPY_4X = 4,
|
||||
ANISOTROPY_8X = 8,
|
||||
ANISOTROPY_16X = 16
|
||||
};
|
||||
|
||||
enum class FilteringMode : u8 {
|
||||
NEAREST = 0, // Fastest for 2D, Sometimes causes graphical issues.
|
||||
BILINEAR = 1, // Fast and pretty, The best for 2D.
|
||||
|
||||
MIPMAP_NEAREST = 2, // Nearest with mipmaps. The fastest for 3D, Sometimes causes graphical issues. Uses more vram.
|
||||
// Mipmapping uses approx 30% more v-ram.
|
||||
MIPMAP_NEAREST = 2, // Nearest with mipmaps. The fastest for 3D, Sometimes causes graphical issues.
|
||||
MIPMAP_BILINEAR = 3, // Bilinear with mipmaps, Fast and pretty. Uses more vram.
|
||||
MIPMAP_TRILINEAR = 4 // The prettiest. Still decent speed. Uses more vram.
|
||||
MIPMAP_TRILINEAR = 4 // Prettier, But still looks weird at very steep angles.
|
||||
};
|
||||
|
||||
enum class WrappingMode : u8 {
|
||||
@@ -61,7 +72,7 @@ namespace JGL {
|
||||
|
||||
static std::string to_string(const JGL::MSAA_SAMPLE_RATE& sample_rate) {
|
||||
switch (sample_rate) {
|
||||
case MSAA_SAMPLE_RATE::MSAA_NONE:
|
||||
case MSAA_SAMPLE_RATE::NONE:
|
||||
return "No MSAA";
|
||||
case MSAA_SAMPLE_RATE::MSAA_2X:
|
||||
return "MSAA 2x";
|
||||
@@ -75,7 +86,7 @@ namespace JGL {
|
||||
}
|
||||
static int to_int(const JGL::MSAA_SAMPLE_RATE& sample_rate) {
|
||||
switch (sample_rate) {
|
||||
case MSAA_SAMPLE_RATE::MSAA_NONE:
|
||||
case MSAA_SAMPLE_RATE::NONE:
|
||||
return 0;
|
||||
case MSAA_SAMPLE_RATE::MSAA_2X:
|
||||
return 2;
|
||||
|
@@ -21,7 +21,7 @@ private:
|
||||
GLuint framebuffer_object = 0;
|
||||
GLuint depth_buffer = 0;
|
||||
const Texture* texture = nullptr;
|
||||
MSAA_SAMPLE_RATE msaa_sample_rate = MSAA_SAMPLE_RATE::MSAA_NONE;
|
||||
MSAA_SAMPLE_RATE msaa_sample_rate = MSAA_SAMPLE_RATE::NONE;
|
||||
GLuint msaa_framebuffer_object = 0;
|
||||
GLuint msaa_depth_buffer = 0;
|
||||
GLuint msaa_render_buffer = 0;
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
/// @note The CPU thread this is called from & the GPU cannot do anything while this takes place. It's very slow.
|
||||
[[nodiscard]] std::vector<GLfloat> GetPixels() const;
|
||||
|
||||
[[nodiscard]] static Vector2i MaximumSize();
|
||||
[[nodiscard]] static Vector2i MaxSize();
|
||||
public:
|
||||
/// Create a Render Target from a Render Target that already exists.
|
||||
/** @note Render Targets that are copies of another will copy the Texture.
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
/// @param use_depth Whether or not this Render Target will have depth information.
|
||||
/// @param sample_rate The MSAA sample rate this Render Target will use.
|
||||
explicit RenderTarget(const Vector2i& size, const Color4& clear_color = Colors::Transparent, bool use_depth = false,
|
||||
MSAA_SAMPLE_RATE sample_rate = MSAA_SAMPLE_RATE::MSAA_NONE, FilteringMode filteirng_mode = FilteringMode::NEAREST);
|
||||
MSAA_SAMPLE_RATE sample_rate = MSAA_SAMPLE_RATE::NONE, FilteringMode filteirng_mode = FilteringMode::NEAREST);
|
||||
|
||||
/// Deletes this Render Target.
|
||||
/** @note If this Render Target was made with a Texture that already existed
|
||||
|
@@ -20,6 +20,7 @@ protected:
|
||||
ColorFormat format = ColorFormat::RGBA;
|
||||
FilteringMode filtering_mode;
|
||||
WrappingMode wrapping_mode;
|
||||
ANISOTROPY_SAMPLE_RATE anisotropy;
|
||||
void load(const unsigned char* pixels);
|
||||
std::vector<unsigned char> png(const std::filesystem::path& file);
|
||||
std::vector<unsigned char> bmp(const std::filesystem::path& file);
|
||||
@@ -33,6 +34,8 @@ public:
|
||||
[[nodiscard]] FilteringMode GetFilteringMode() const;
|
||||
/// @returns The way this texture behaves when used on geometry of different sizes.
|
||||
[[nodiscard]] WrappingMode GetWrappingMode() const;
|
||||
/// @returns The current level of anisotropic filtering for this texture.
|
||||
[[nodiscard]] ANISOTROPY_SAMPLE_RATE GetAnisotropySampleRate() const;
|
||||
/// @returns The orientation of this texture in v-ram.
|
||||
/// @note true is right-side-up because OpenGL defaults to upside-down.
|
||||
[[nodiscard]] bool Inverted() const;
|
||||
@@ -40,23 +43,29 @@ public:
|
||||
/// @returns The raw pixels this texture is made up of.
|
||||
/// @note This will read-back from the GPU. Slow.
|
||||
[[nodiscard]] std::vector<Color4> GetPixelData() const;
|
||||
/// @returns The biggest size for a texture on this system.
|
||||
/// @note on modern systems this is *usually* ridiculous.
|
||||
[[nodiscard]] static Vector2i MaximumSize();
|
||||
public:
|
||||
/// Load a texture from a file,
|
||||
explicit Texture(const std::filesystem::path& file, FilteringMode filtering_mode = FilteringMode::BILINEAR, WrappingMode wrapping_mode = WrappingMode::CLAMP_TO_EDGE, bool invert_y = true);
|
||||
explicit Texture(const std::filesystem::path& file, FilteringMode filtering_mode = FilteringMode::BILINEAR,
|
||||
ANISOTROPY_SAMPLE_RATE anisotropy = ANISOTROPY_SAMPLE_RATE::NONE, WrappingMode wrapping_mode = WrappingMode::CLAMP_TO_EDGE, bool invert_y = true);
|
||||
/// Load a texture from raw pixels.
|
||||
Texture(const Color4* pixels, const Vector2i& size, const ColorFormat& format, FilteringMode filtering_mode, WrappingMode wrapping_mode);
|
||||
Texture(const Color4* pixels, const Vector2i& size, FilteringMode filtering_mode = FilteringMode::BILINEAR,
|
||||
ANISOTROPY_SAMPLE_RATE anisotropy = ANISOTROPY_SAMPLE_RATE::NONE, WrappingMode wrapping_mode = WrappingMode::CLAMP_TO_EDGE);
|
||||
/// Load a texture from raw pixels.
|
||||
Texture(const Color3* pixels, const Vector2i& size, const ColorFormat& format, FilteringMode filtering_mode, WrappingMode wrapping_mode);
|
||||
Texture(const Color3* pixels, const Vector2i& size, FilteringMode filtering_mode = FilteringMode::BILINEAR,
|
||||
ANISOTROPY_SAMPLE_RATE anisotropy = ANISOTROPY_SAMPLE_RATE::NONE, WrappingMode wrapping_mode = WrappingMode::CLAMP_TO_EDGE);
|
||||
/// Construct a Texture Atlas from many different textures.
|
||||
/// @note THIS IS UNFINISHED.
|
||||
Texture(const Texture* textures, const size_t& texture_count);
|
||||
/// Initialize a texture filled with trash data.
|
||||
/// @see RenderTarget
|
||||
explicit Texture(const Vector2i& size, FilteringMode filtering_mode = FilteringMode::NEAREST);
|
||||
|
||||
Texture(const Texture& rhs);
|
||||
~Texture();
|
||||
public:
|
||||
/// @returns True if this system supports anisotropy.
|
||||
// TODO add a similar mechanism for MSAA so the extension isn't required.
|
||||
static ANISOTROPY_SAMPLE_RATE MaxAnisotropySampleRate();
|
||||
/// @returns The biggest size for a texture on this system.
|
||||
/// @note on modern systems this is *usually* ridiculous.
|
||||
[[nodiscard]] static Vector2i MaxSize();
|
||||
};
|
2
main.cpp
2
main.cpp
@@ -131,7 +131,7 @@ public:
|
||||
image = new Texture("assets/sprites/Re3D.png", FilteringMode::BILINEAR);
|
||||
image_mask = new Texture("assets/sprites/alpha_mask_2.png");
|
||||
j2d_render_target = new RenderTarget({540, 500}, {0,0,0,0}, false,
|
||||
MSAA_SAMPLE_RATE::MSAA_8X, FilteringMode::MIPMAP_TRILINEAR);
|
||||
MSAA_SAMPLE_RATE::NONE, FilteringMode::MIPMAP_TRILINEAR);
|
||||
|
||||
//Texture::MultiplyByAlphaMask(*image, *image_mask);
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ void JGL::RenderTarget::Erase() {
|
||||
glDeleteFramebuffers(1, &framebuffer_object);
|
||||
|
||||
if (MSAAEnabled())
|
||||
SetMSAAEnabled(MSAA_SAMPLE_RATE::MSAA_NONE);
|
||||
SetMSAAEnabled(MSAA_SAMPLE_RATE::NONE);
|
||||
}
|
||||
|
||||
Color4 JGL::RenderTarget::GetClearColor() const {
|
||||
@@ -116,7 +116,7 @@ JGL::RenderTarget::RenderTarget(const Vector2i& size, const Color4& clear_color,
|
||||
this->size = size;
|
||||
texture_created_by_us = true;
|
||||
|
||||
if (sample_rate != MSAA_SAMPLE_RATE::MSAA_NONE)
|
||||
if (sample_rate != MSAA_SAMPLE_RATE::NONE)
|
||||
SetMSAAEnabled(sample_rate);
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ void JGL::RenderTarget::Resize(const Vector2i& new_size) {
|
||||
//Disable & Re-enable MSAA so the msaa buffer is remade with the correct dimensions.
|
||||
if (MSAAEnabled()) {
|
||||
MSAA_SAMPLE_RATE current_sample_rate = msaa_sample_rate;
|
||||
SetMSAAEnabled(MSAA_SAMPLE_RATE::MSAA_NONE);
|
||||
SetMSAAEnabled(MSAA_SAMPLE_RATE::NONE);
|
||||
SetMSAAEnabled(current_sample_rate);
|
||||
}
|
||||
}
|
||||
@@ -182,7 +182,7 @@ JGL::MSAA_SAMPLE_RATE JGL::RenderTarget::GetMSAASampleRate() const {
|
||||
}
|
||||
|
||||
bool JGL::RenderTarget::MSAAEnabled() const {
|
||||
return msaa_sample_rate != MSAA_SAMPLE_RATE::MSAA_NONE;
|
||||
return msaa_sample_rate != MSAA_SAMPLE_RATE::NONE;
|
||||
}
|
||||
|
||||
bool JGL::RenderTarget::SetMSAAEnabled(JGL::MSAA_SAMPLE_RATE sample_rate) {
|
||||
@@ -195,7 +195,7 @@ bool JGL::RenderTarget::SetMSAAEnabled(JGL::MSAA_SAMPLE_RATE sample_rate) {
|
||||
return false;
|
||||
|
||||
// Remove it if they request no msaa or if what they requested is different than what they already have.
|
||||
if (sample_rate == MSAA_SAMPLE_RATE::MSAA_NONE || msaa_sample_rate != MSAA_SAMPLE_RATE::MSAA_NONE) {
|
||||
if (sample_rate == MSAA_SAMPLE_RATE::NONE || msaa_sample_rate != MSAA_SAMPLE_RATE::NONE) {
|
||||
if(using_depth)
|
||||
glDeleteRenderbuffers(1, &msaa_depth_buffer);
|
||||
|
||||
@@ -205,10 +205,10 @@ bool JGL::RenderTarget::SetMSAAEnabled(JGL::MSAA_SAMPLE_RATE sample_rate) {
|
||||
msaa_framebuffer_object = 0;
|
||||
msaa_depth_buffer = 0;
|
||||
msaa_render_buffer = 0;
|
||||
msaa_sample_rate = MSAA_SAMPLE_RATE::MSAA_NONE;
|
||||
msaa_sample_rate = MSAA_SAMPLE_RATE::NONE;
|
||||
|
||||
// Only return here if they specifically requested no MSAA. else continue to change mode.
|
||||
if (sample_rate == MSAA_SAMPLE_RATE::MSAA_NONE)
|
||||
if (sample_rate == MSAA_SAMPLE_RATE::NONE)
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ bool JGL::RenderTarget::SetMSAAEnabled(JGL::MSAA_SAMPLE_RATE sample_rate) {
|
||||
msaa_sample_rate = sample_rate;
|
||||
|
||||
if (failure)
|
||||
SetMSAAEnabled(MSAA_SAMPLE_RATE::MSAA_NONE);
|
||||
SetMSAAEnabled(MSAA_SAMPLE_RATE::NONE);
|
||||
return failure;
|
||||
}
|
||||
|
||||
@@ -348,8 +348,8 @@ JGL::RenderTarget::RenderTarget(const JGL::RenderTarget& rhs) {
|
||||
operator delete(this_render_target);
|
||||
}
|
||||
|
||||
Vector2i JGL::RenderTarget::MaximumSize() {
|
||||
return Texture::MaximumSize();
|
||||
Vector2i JGL::RenderTarget::MaxSize() {
|
||||
return Texture::MaxSize();
|
||||
}
|
||||
|
||||
void JGL::RenderTarget::RegenerateMipMaps() {
|
||||
|
@@ -9,8 +9,8 @@
|
||||
|
||||
using namespace JGL;
|
||||
|
||||
Texture::Texture(const std::filesystem::path& file, FilteringMode filtering_mode, WrappingMode wrapping_mode, bool invert_y) :
|
||||
invert_y(invert_y), filtering_mode(filtering_mode), wrapping_mode(wrapping_mode) {
|
||||
Texture::Texture(const std::filesystem::path& file, FilteringMode filtering_mode, ANISOTROPY_SAMPLE_RATE anisotropy, WrappingMode wrapping_mode, bool invert_y) :
|
||||
invert_y(invert_y), filtering_mode(filtering_mode), anisotropy(anisotropy), wrapping_mode(wrapping_mode) {
|
||||
std::vector<unsigned char> pixels{};
|
||||
|
||||
std::ifstream ifStream(file, std::ios::in | std::ios::binary);
|
||||
@@ -30,7 +30,7 @@ invert_y(invert_y), filtering_mode(filtering_mode), wrapping_mode(wrapping_mode)
|
||||
|
||||
|
||||
if (invert_y) {
|
||||
unsigned int row_size = size.x * 4;;
|
||||
unsigned int row_size = size.x * 4;
|
||||
if (format == ColorFormat::RGB)
|
||||
row_size = size.x * 3;
|
||||
|
||||
@@ -100,7 +100,7 @@ std::vector<unsigned char> Texture::bmp(const std::filesystem::path& file) {
|
||||
|
||||
Texture::Texture(const Vector2i& size, FilteringMode filtering_mode) : invert_y(true), format(ColorFormat::RGBA), size(size), filtering_mode(filtering_mode), wrapping_mode(WrappingMode::CLAMP_TO_EDGE) {
|
||||
if (SizeExceedsMaximum(size))
|
||||
Logger::Error("Creating a texture where the size is bigger than the maximum for this system.");
|
||||
Logger::Error("Creating a texture where the size is bigger than the maximum for this system, use Texture::MaximumSize() to check for this beforehand.");
|
||||
GLuint previous_texture;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*) &previous_texture);
|
||||
|
||||
@@ -138,6 +138,7 @@ Texture::Texture(const Vector2i& size, FilteringMode filtering_mode) : invert_y(
|
||||
glBindTexture(GL_TEXTURE_2D, previous_texture);
|
||||
}
|
||||
void Texture::load(const unsigned char* pixels) {
|
||||
// TODO a static member function to query for this.
|
||||
if (SizeExceedsMaximum(size))
|
||||
Logger::Error("Creating a texture where the size is bigger than the maximum for this system.");
|
||||
|
||||
@@ -169,17 +170,9 @@ void Texture::load(const unsigned char* pixels) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER),
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||
|
||||
if (filtering_mode == FilteringMode::NEAREST)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST),
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
else if (filtering_mode == FilteringMode::BILINEAR)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR),
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
else if (filtering_mode == FilteringMode::MIPMAP_NEAREST ||
|
||||
filtering_mode == FilteringMode::MIPMAP_BILINEAR ||
|
||||
filtering_mode == FilteringMode::MIPMAP_TRILINEAR) {
|
||||
if (filtering_mode == FilteringMode::MIPMAP_NEAREST ||
|
||||
filtering_mode == FilteringMode::MIPMAP_BILINEAR ||
|
||||
filtering_mode == FilteringMode::MIPMAP_TRILINEAR) {
|
||||
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
@@ -195,6 +188,28 @@ void Texture::load(const unsigned char* pixels) {
|
||||
else if (filtering_mode == FilteringMode::MIPMAP_TRILINEAR)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR),
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
if (anisotropy != ANISOTROPY_SAMPLE_RATE::NONE) {
|
||||
if (anisotropy > MaxAnisotropySampleRate())
|
||||
Logger::Error("Anisotropy set higher than the maximum value for this system, disabled, use Texture::MaxAnisotropy()."),
|
||||
anisotropy = ANISOTROPY_SAMPLE_RATE::NONE;
|
||||
else
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, (int) anisotropy);
|
||||
}
|
||||
}
|
||||
|
||||
else if (filtering_mode == FilteringMode::NEAREST || filtering_mode == FilteringMode::BILINEAR) {
|
||||
if (filtering_mode == FilteringMode::NEAREST)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST),
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
else if (filtering_mode == FilteringMode::BILINEAR)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR),
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
if (anisotropy != ANISOTROPY_SAMPLE_RATE::NONE)
|
||||
Logger::Error("Anisotropy only applies when using mipmaps with a 3D perspective, disabled."),
|
||||
anisotropy = ANISOTROPY_SAMPLE_RATE::NONE;
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_2D, previous_texture);
|
||||
}
|
||||
@@ -246,13 +261,13 @@ WrappingMode Texture::GetWrappingMode() const {
|
||||
return wrapping_mode;
|
||||
}
|
||||
|
||||
Texture::Texture(const Color4* pixels, const Vector2i& size, const ColorFormat& format, FilteringMode filtering_mode, WrappingMode wrapping_mode) :
|
||||
size(size), format(format), filtering_mode(filtering_mode), wrapping_mode(wrapping_mode) {
|
||||
Texture::Texture(const Color4* pixels, const Vector2i& size, FilteringMode filtering_mode, ANISOTROPY_SAMPLE_RATE anisotropy, WrappingMode wrapping_mode) :
|
||||
size(size), format(ColorFormat::RGBA), filtering_mode(filtering_mode), anisotropy(anisotropy), wrapping_mode(wrapping_mode) {
|
||||
load((unsigned char*) pixels);
|
||||
}
|
||||
|
||||
Texture::Texture(const Color3* pixels, const Vector2i& size, const ColorFormat& format, FilteringMode filtering_mode, WrappingMode wrapping_mode) :
|
||||
size(size), format(format), filtering_mode(filtering_mode), wrapping_mode(wrapping_mode) {
|
||||
Texture::Texture(const Color3* pixels, const Vector2i& size, FilteringMode filtering_mode, ANISOTROPY_SAMPLE_RATE anisotropy, WrappingMode wrapping_mode) :
|
||||
size(size), format(ColorFormat::RGB), filtering_mode(filtering_mode), anisotropy(anisotropy), wrapping_mode(wrapping_mode) {
|
||||
load((unsigned char*) pixels);
|
||||
}
|
||||
|
||||
@@ -300,13 +315,34 @@ Texture::Texture(const Texture* textures, const size_t& texture_count) {
|
||||
|
||||
bool Texture::SizeExceedsMaximum(const Vector2i& s) {
|
||||
|
||||
auto max_size = Texture::MaximumSize();
|
||||
auto max_size = Texture::MaxSize();
|
||||
return s.x > max_size.x || s.y > max_size.y;
|
||||
}
|
||||
|
||||
Vector2i Texture::MaximumSize() {
|
||||
Vector2i Texture::MaxSize() {
|
||||
GLint max_size;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_size);
|
||||
|
||||
return { max_size, max_size };
|
||||
}
|
||||
|
||||
ANISOTROPY_SAMPLE_RATE Texture::MaxAnisotropySampleRate() {
|
||||
if (!GLAD_GL_ARB_texture_filter_anisotropic)
|
||||
return ANISOTROPY_SAMPLE_RATE::NONE;
|
||||
|
||||
float anisotropy;
|
||||
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &anisotropy);
|
||||
|
||||
if (anisotropy == 2)
|
||||
return ANISOTROPY_SAMPLE_RATE::ANISOTROPY_2X;
|
||||
else if (anisotropy == 4)
|
||||
return ANISOTROPY_SAMPLE_RATE::ANISOTROPY_4X;
|
||||
else if (anisotropy == 8)
|
||||
return ANISOTROPY_SAMPLE_RATE::ANISOTROPY_8X;
|
||||
else
|
||||
return ANISOTROPY_SAMPLE_RATE::ANISOTROPY_16X;
|
||||
}
|
||||
|
||||
ANISOTROPY_SAMPLE_RATE Texture::GetAnisotropySampleRate() const {
|
||||
return anisotropy;
|
||||
}
|
||||
|
Reference in New Issue
Block a user