Browse Source

remove mipmap texture filter from min_filter for rectangle textures

Palana 12 years ago
parent
commit
1dde992990
2 changed files with 24 additions and 2 deletions
  1. 23 1
      libobs-opengl/gl-subsystem.c
  2. 1 1
      libobs/graphics/graphics.h

+ 23 - 1
libobs-opengl/gl-subsystem.c

@@ -182,6 +182,24 @@ enum gs_texture_type device_gettexturetype(device_t device,
 	return texture->type;
 	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)
 static bool load_texture_sampler(texture_t tex, samplerstate_t ss)
 {
 {
 	bool success = true;
 	bool success = true;
@@ -196,8 +214,12 @@ static bool load_texture_sampler(texture_t tex, samplerstate_t ss)
 
 
 	samplerstate_addref(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,
 	if (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_MIN_FILTER,
-				ss->min_filter))
+				min_filter))
 		success = false;
 		success = false;
 	if (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_MAG_FILTER,
 	if (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_MAG_FILTER,
 				ss->mag_filter))
 				ss->mag_filter))

+ 1 - 1
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);
 EXPORT void     texture_unmap(texture_t tex);
 /** special-case function (GL only) - specifies whether the texture is a
 /** special-case function (GL only) - specifies whether the texture is a
  * GL_TEXTURE_RECTANGLE type, which doesn't use normalized texture
  * 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 bool     texture_isrect(texture_t tex);
 
 
 EXPORT void     cubetexture_destroy(texture_t cubetex);
 EXPORT void     cubetexture_destroy(texture_t cubetex);