Allow setting other filter/clamp in GL::Textures.
This commit is contained in:
parent
35236988b7
commit
4ae6d31963
3 changed files with 23 additions and 10 deletions
|
|
@ -11,17 +11,21 @@
|
||||||
namespace Ui::GL {
|
namespace Ui::GL {
|
||||||
namespace details {
|
namespace details {
|
||||||
|
|
||||||
void GenerateTextures(QOpenGLFunctions &f, gsl::span<GLuint> values) {
|
void GenerateTextures(
|
||||||
|
QOpenGLFunctions &f,
|
||||||
|
gsl::span<GLuint> values,
|
||||||
|
GLint filter,
|
||||||
|
GLint clamp) {
|
||||||
Expects(!values.empty());
|
Expects(!values.empty());
|
||||||
|
|
||||||
f.glGenTextures(values.size(), values.data());
|
f.glGenTextures(values.size(), values.data());
|
||||||
|
|
||||||
for (const auto texture : values) {
|
for (const auto texture : values) {
|
||||||
f.glBindTexture(GL_TEXTURE_2D, texture);
|
f.glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
const auto clamp = GL_CLAMP_TO_EDGE;
|
|
||||||
f.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, clamp);
|
f.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, clamp);
|
||||||
f.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, clamp);
|
f.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, clamp);
|
||||||
f.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
f.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
|
||||||
f.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
f.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,7 +72,7 @@ void Image::bind(QOpenGLFunctions &f, QSize subimage) {
|
||||||
Expects(subimage.width() <= _image.width()
|
Expects(subimage.width() <= _image.width()
|
||||||
&& subimage.height() <= _image.height());
|
&& subimage.height() <= _image.height());
|
||||||
|
|
||||||
_textures.ensureCreated(f);
|
_textures.ensureCreated(f, GL_NEAREST);
|
||||||
if (!subimage.isValid()) {
|
if (!subimage.isValid()) {
|
||||||
subimage = _image.size();
|
subimage = _image.size();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,11 @@
|
||||||
namespace Ui::GL {
|
namespace Ui::GL {
|
||||||
namespace details {
|
namespace details {
|
||||||
|
|
||||||
void GenerateTextures(QOpenGLFunctions &f, gsl::span<GLuint> values);
|
void GenerateTextures(
|
||||||
|
QOpenGLFunctions &f,
|
||||||
|
gsl::span<GLuint> values,
|
||||||
|
GLint filter,
|
||||||
|
GLint clamp);
|
||||||
void DestroyTextures(QOpenGLFunctions &f, gsl::span<GLuint> values);
|
void DestroyTextures(QOpenGLFunctions &f, gsl::span<GLuint> values);
|
||||||
|
|
||||||
void GenerateFramebuffers(QOpenGLFunctions &f, gsl::span<GLuint> values);
|
void GenerateFramebuffers(QOpenGLFunctions &f, gsl::span<GLuint> values);
|
||||||
|
|
@ -26,9 +30,16 @@ class Textures final {
|
||||||
public:
|
public:
|
||||||
static_assert(Count > 0);
|
static_assert(Count > 0);
|
||||||
|
|
||||||
void ensureCreated(QOpenGLFunctions &f) {
|
void ensureCreated(
|
||||||
|
QOpenGLFunctions &f,
|
||||||
|
GLint filter = GL_LINEAR,
|
||||||
|
GLint clamp = GL_CLAMP_TO_EDGE) {
|
||||||
if (!created()) {
|
if (!created()) {
|
||||||
details::GenerateTextures(f, gsl::make_span(_values));
|
details::GenerateTextures(
|
||||||
|
f,
|
||||||
|
gsl::make_span(_values),
|
||||||
|
filter,
|
||||||
|
clamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void destroy(QOpenGLFunctions &f) {
|
void destroy(QOpenGLFunctions &f) {
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,9 @@ uniform sampler2D u_texture;
|
||||||
uniform sampler2D v_texture;
|
uniform sampler2D v_texture;
|
||||||
)",
|
)",
|
||||||
.body = R"(
|
.body = R"(
|
||||||
// float y = texture2D(y_texture, v_texcoord).r;
|
|
||||||
float y = texture2D(y_texture, v_texcoord).r - 0.0625;
|
float y = texture2D(y_texture, v_texcoord).r - 0.0625;
|
||||||
float u = texture2D(u_texture, v_texcoord).r - 0.5;
|
float u = texture2D(u_texture, v_texcoord).r - 0.5;
|
||||||
float v = texture2D(v_texture, v_texcoord).r - 0.5;
|
float v = texture2D(v_texture, v_texcoord).r - 0.5;
|
||||||
// result = vec4(y + 1.403 * v, y - 0.344 * u - 0.714 * v, y + 1.77 * u, 1);
|
|
||||||
result = vec4(
|
result = vec4(
|
||||||
1.164 * y + 1.596 * v,
|
1.164 * y + 1.596 * v,
|
||||||
1.164 * y - 0.392 * u - 0.813 * v,
|
1.164 * y - 0.392 * u - 0.813 * v,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue