OpenGLRenderer: Implement TextureSampler (and texture units)
This commit is contained in:
@@ -2,34 +2,28 @@
|
||||
// This file is part of the "Nazara Engine - OpenGL Renderer"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#if 0
|
||||
|
||||
#include <Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Utils.hpp>
|
||||
#include <stdexcept>
|
||||
#include <Nazara/OpenGLRenderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
OpenGLTextureSampler::OpenGLTextureSampler(Vk::Device& device, TextureSamplerInfo samplerInfo)
|
||||
OpenGLTextureSampler::OpenGLTextureSampler(OpenGLDevice& device, TextureSamplerInfo samplerInfo)
|
||||
{
|
||||
VkSamplerCreateInfo createInfo = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO };
|
||||
createInfo.magFilter = ToOpenGL(samplerInfo.magFilter);
|
||||
createInfo.minFilter = ToOpenGL(samplerInfo.minFilter);
|
||||
createInfo.addressModeU = ToOpenGL(samplerInfo.wrapModeU);
|
||||
createInfo.addressModeV = ToOpenGL(samplerInfo.wrapModeV);
|
||||
createInfo.addressModeW = ToOpenGL(samplerInfo.wrapModeW);
|
||||
createInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK;
|
||||
createInfo.mipmapMode = ToOpenGL(samplerInfo.mipmapMode);
|
||||
if (!m_sampler.Create(device))
|
||||
throw std::runtime_error("failed to create sampler object");
|
||||
|
||||
if (samplerInfo.anisotropyLevel > 0.f)
|
||||
{
|
||||
createInfo.anisotropyEnable = VK_TRUE;
|
||||
createInfo.maxAnisotropy = samplerInfo.anisotropyLevel;
|
||||
}
|
||||
// In OpenGL, min and mipmap sampler are part of the same enum
|
||||
|
||||
if (!m_sampler.Create(device, createInfo))
|
||||
throw std::runtime_error("Failed to create sampler: " + TranslateOpenGLError(m_sampler.GetLastErrorCode()));
|
||||
m_sampler.SetParameteri(GL_TEXTURE_MIN_FILTER, ToOpenGL(samplerInfo.minFilter, samplerInfo.mipmapMode));
|
||||
m_sampler.SetParameteri(GL_TEXTURE_MAG_FILTER, ToOpenGL(samplerInfo.magFilter));
|
||||
|
||||
m_sampler.SetParameteri(GL_TEXTURE_WRAP_S, ToOpenGL(samplerInfo.wrapModeU));
|
||||
m_sampler.SetParameteri(GL_TEXTURE_WRAP_T, ToOpenGL(samplerInfo.wrapModeV));
|
||||
m_sampler.SetParameteri(GL_TEXTURE_WRAP_R, ToOpenGL(samplerInfo.wrapModeW));
|
||||
|
||||
if (samplerInfo.anisotropyLevel > 1.f)
|
||||
m_sampler.SetParameterf(GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerInfo.anisotropyLevel);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user