diff --git a/ui/gl/gl_image.cpp b/ui/gl/gl_image.cpp index 1e8daa7..3527faf 100644 --- a/ui/gl/gl_image.cpp +++ b/ui/gl/gl_image.cpp @@ -11,17 +11,21 @@ namespace Ui::GL { namespace details { -void GenerateTextures(QOpenGLFunctions &f, gsl::span values) { +void GenerateTextures( + QOpenGLFunctions &f, + gsl::span values, + GLint filter, + GLint clamp) { Expects(!values.empty()); f.glGenTextures(values.size(), values.data()); + for (const auto texture : values) { 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_T, clamp); - f.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - f.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + f.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); + 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() && subimage.height() <= _image.height()); - _textures.ensureCreated(f); + _textures.ensureCreated(f, GL_NEAREST); if (!subimage.isValid()) { subimage = _image.size(); } diff --git a/ui/gl/gl_image.h b/ui/gl/gl_image.h index 64c091d..6965752 100644 --- a/ui/gl/gl_image.h +++ b/ui/gl/gl_image.h @@ -13,7 +13,11 @@ namespace Ui::GL { namespace details { -void GenerateTextures(QOpenGLFunctions &f, gsl::span values); +void GenerateTextures( + QOpenGLFunctions &f, + gsl::span values, + GLint filter, + GLint clamp); void DestroyTextures(QOpenGLFunctions &f, gsl::span values); void GenerateFramebuffers(QOpenGLFunctions &f, gsl::span values); @@ -26,9 +30,16 @@ class Textures final { public: static_assert(Count > 0); - void ensureCreated(QOpenGLFunctions &f) { + void ensureCreated( + QOpenGLFunctions &f, + GLint filter = GL_LINEAR, + GLint clamp = GL_CLAMP_TO_EDGE) { if (!created()) { - details::GenerateTextures(f, gsl::make_span(_values)); + details::GenerateTextures( + f, + gsl::make_span(_values), + filter, + clamp); } } void destroy(QOpenGLFunctions &f) { diff --git a/ui/gl/gl_shader.cpp b/ui/gl/gl_shader.cpp index 7a04d1e..d504863 100644 --- a/ui/gl/gl_shader.cpp +++ b/ui/gl/gl_shader.cpp @@ -74,11 +74,9 @@ uniform sampler2D u_texture; uniform sampler2D v_texture; )", .body = R"( -// float y = texture2D(y_texture, v_texcoord).r; float y = texture2D(y_texture, v_texcoord).r - 0.0625; float u = texture2D(u_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( 1.164 * y + 1.596 * v, 1.164 * y - 0.392 * u - 0.813 * v,