From 1dde9929908a3bba4b173edbe47d242ec47c7699 Mon Sep 17 00:00:00 2001 From: Palana Date: Sun, 22 Dec 2013 04:47:01 +0100 Subject: [PATCH] remove mipmap texture filter from min_filter for rectangle textures --- libobs-opengl/gl-subsystem.c | 24 +++++++++++++++++++++++- libobs/graphics/graphics.h | 2 +- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/libobs-opengl/gl-subsystem.c b/libobs-opengl/gl-subsystem.c index cc27e4c78..b869876cd 100644 --- a/libobs-opengl/gl-subsystem.c +++ b/libobs-opengl/gl-subsystem.c @@ -182,6 +182,24 @@ enum gs_texture_type device_gettexturetype(device_t device, return texture->type; } +static void strip_mipmap_filter(GLint *filter) +{ + switch (*filter) { + case GL_NEAREST: + case GL_LINEAR: + return; + case GL_NEAREST_MIPMAP_NEAREST: + case GL_NEAREST_MIPMAP_LINEAR: + *filter = GL_NEAREST; + return; + case GL_LINEAR_MIPMAP_NEAREST: + case GL_LINEAR_MIPMAP_LINEAR: + *filter = GL_LINEAR; + return; + } + *filter = GL_NEAREST; +} + static bool load_texture_sampler(texture_t tex, samplerstate_t ss) { bool success = true; @@ -196,8 +214,12 @@ static bool load_texture_sampler(texture_t tex, samplerstate_t ss) samplerstate_addref(ss); + GLint min_filter = ss->min_filter; + if (texture_isrect(tex)) + strip_mipmap_filter(&min_filter); + if (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_MIN_FILTER, - ss->min_filter)) + min_filter)) success = false; if (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_MAG_FILTER, ss->mag_filter)) diff --git a/libobs/graphics/graphics.h b/libobs/graphics/graphics.h index 05aeec851..87e584c38 100644 --- a/libobs/graphics/graphics.h +++ b/libobs/graphics/graphics.h @@ -643,7 +643,7 @@ EXPORT bool texture_map(texture_t tex, void **ptr, uint32_t *row_bytes); EXPORT void texture_unmap(texture_t tex); /** special-case function (GL only) - specifies whether the texture is a * GL_TEXTURE_RECTANGLE type, which doesn't use normalized texture - * coordinates */ + * coordinates, doesn't support mipmapping, and requires address clamping */ EXPORT bool texture_isrect(texture_t tex); EXPORT void cubetexture_destroy(texture_t cubetex);