GLuint glCreateSamplerGTC(GLenum mag, GLenum min, GLenum mip, GLenum wrap, GLfloat borderColor[4], GLenum compare) { assert(mag == GL_LINEAR || mag == GL_NEAREST); assert(min == GL_LINEAR || min == GL_NEAREST); assert(mip == GL_LINEAR || mip == GL_NEAREST); GLuint sampler = 0; glCreateSamplers(1, &sampler); GLint minFilter = GL_NONE; if (min == GL_LINEAR) minFilter = mip == GL_LINEAR ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR_MIPMAP_NEAREST; else minFilter = mip == GL_LINEAR ? GL_NEAREST_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST; glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, minFilter); glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, mag); glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, wrap); glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, wrap); glSamplerParameteri(sampler, GL_TEXTURE_WRAP_R, wrap); glSamplerParameterfv(sampler, GL_TEXTURE_BORDER_COLOR, borderColor); glSamplerParameteri(sampler, GL_TEXTURE_COMPARE_MODE, compare == GL_NONE ? GL_NONE : GL_COMPARE_R_TO_TEXTURE); glSamplerParameteri(sampler, GL_TEXTURE_COMPARE_FUNC, compare != GL_NONE ? compare : GL_LEQUAL); return sampler; }
bool initSampler() { glCreateSamplers(pipeline::MAX, &SamplerName[0]); glSamplerParameteri(SamplerName[pipeline::RENDER], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glSamplerParameteri(SamplerName[pipeline::RENDER], GL_TEXTURE_MAG_FILTER, GL_LINEAR); glSamplerParameteri(SamplerName[pipeline::RENDER], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glSamplerParameteri(SamplerName[pipeline::RENDER], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glSamplerParameteri(SamplerName[pipeline::RENDER], GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glSamplerParameterfv(SamplerName[pipeline::RENDER], GL_TEXTURE_BORDER_COLOR, &glm::vec4(0.0f)[0]); glSamplerParameterf(SamplerName[pipeline::RENDER], GL_TEXTURE_MIN_LOD, -1000.f); glSamplerParameterf(SamplerName[pipeline::RENDER], GL_TEXTURE_MAX_LOD, 1000.f); glSamplerParameterf(SamplerName[pipeline::RENDER], GL_TEXTURE_LOD_BIAS, 0.0f); glSamplerParameteri(SamplerName[pipeline::RENDER], GL_TEXTURE_COMPARE_MODE, GL_NONE); glSamplerParameteri(SamplerName[pipeline::RENDER], GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); glSamplerParameteri(SamplerName[pipeline::SPLASH], GL_TEXTURE_MIN_FILTER, GL_LINEAR); glSamplerParameteri(SamplerName[pipeline::SPLASH], GL_TEXTURE_MAG_FILTER, GL_LINEAR); glSamplerParameteri(SamplerName[pipeline::SPLASH], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glSamplerParameteri(SamplerName[pipeline::SPLASH], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glSamplerParameteri(SamplerName[pipeline::SPLASH], GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glSamplerParameterfv(SamplerName[pipeline::SPLASH], GL_TEXTURE_BORDER_COLOR, &glm::vec4(0.0f)[0]); glSamplerParameterf(SamplerName[pipeline::SPLASH], GL_TEXTURE_MIN_LOD, -1000.f); glSamplerParameterf(SamplerName[pipeline::SPLASH], GL_TEXTURE_MAX_LOD, 1000.f); glSamplerParameterf(SamplerName[pipeline::SPLASH], GL_TEXTURE_LOD_BIAS, 0.0f); glSamplerParameteri(SamplerName[pipeline::SPLASH], GL_TEXTURE_COMPARE_MODE, GL_NONE); glSamplerParameteri(SamplerName[pipeline::SPLASH], GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); return true; }
bool initSampler() { glCreateSamplers(1, &SamplerName); glSamplerParameteri(SamplerName, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); glSamplerParameteri(SamplerName, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glSamplerParameteri(SamplerName, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glSamplerParameteri(SamplerName, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glSamplerParameteri(SamplerName, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glSamplerParameterfv(SamplerName, GL_TEXTURE_BORDER_COLOR, &glm::vec4(0.0f)[0]); glSamplerParameterf(SamplerName, GL_TEXTURE_MIN_LOD, -1000.f); glSamplerParameterf(SamplerName, GL_TEXTURE_MAX_LOD, 1000.f); glSamplerParameterf(SamplerName, GL_TEXTURE_LOD_BIAS, 0.0f); glSamplerParameteri(SamplerName, GL_TEXTURE_COMPARE_MODE, GL_NONE); glSamplerParameteri(SamplerName, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); return true; }