mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	render/wlr_texture: clamp texture coordinates to edge by default
Clamping texture coordinates prevents OpenGL from blending the left and right edge (or top and bottom edge) when scaling textures with GL_LINEAR filtering. This prevents visual artifacts like swaywm/sway#5809. Per discussion on IRC, this behaviour is made default. Compositors that want the wrapping behaviour (e.g. for tiled patterns) can override this by doing: struct wlr_gles2_texture_attribs attribs; wlr_gles2_texture_get_attribs(texture, &attribs); glBindTexture(attribs.target, attribs.tex); glTexParameteri(attribs.target, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(attribs.target, GL_TEXTURE_WRAP_T, GL_REPEAT); glBindTexture(attribs.target, 0);
This commit is contained in:
		
							parent
							
								
									01d21cdd9f
								
							
						
					
					
						commit
						975d14b799
					
				
					 1 changed files with 6 additions and 0 deletions
				
			
		| 
						 | 
					@ -164,6 +164,8 @@ struct wlr_texture *gles2_texture_from_pixels(struct wlr_renderer *wlr_renderer,
 | 
				
			||||||
	glGenTextures(1, &texture->tex);
 | 
						glGenTextures(1, &texture->tex);
 | 
				
			||||||
	glBindTexture(GL_TEXTURE_2D, texture->tex);
 | 
						glBindTexture(GL_TEXTURE_2D, texture->tex);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 | 
				
			||||||
 | 
						glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 | 
				
			||||||
	glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, stride / (fmt->bpp / 8));
 | 
						glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, stride / (fmt->bpp / 8));
 | 
				
			||||||
	glTexImage2D(GL_TEXTURE_2D, 0, fmt->gl_format, width, height, 0,
 | 
						glTexImage2D(GL_TEXTURE_2D, 0, fmt->gl_format, width, height, 0,
 | 
				
			||||||
		fmt->gl_format, fmt->gl_type, data);
 | 
							fmt->gl_format, fmt->gl_type, data);
 | 
				
			||||||
| 
						 | 
					@ -232,6 +234,8 @@ struct wlr_texture *gles2_texture_from_wl_drm(struct wlr_renderer *wlr_renderer,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	glGenTextures(1, &texture->tex);
 | 
						glGenTextures(1, &texture->tex);
 | 
				
			||||||
	glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture->tex);
 | 
						glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture->tex);
 | 
				
			||||||
 | 
						glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 | 
				
			||||||
 | 
						glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 | 
				
			||||||
	renderer->procs.glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES,
 | 
						renderer->procs.glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES,
 | 
				
			||||||
		texture->image);
 | 
							texture->image);
 | 
				
			||||||
	glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0);
 | 
						glBindTexture(GL_TEXTURE_EXTERNAL_OES, 0);
 | 
				
			||||||
| 
						 | 
					@ -311,6 +315,8 @@ struct wlr_texture *gles2_texture_from_dmabuf(struct wlr_renderer *wlr_renderer,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	glGenTextures(1, &texture->tex);
 | 
						glGenTextures(1, &texture->tex);
 | 
				
			||||||
	glBindTexture(texture->target, texture->tex);
 | 
						glBindTexture(texture->target, texture->tex);
 | 
				
			||||||
 | 
						glTexParameteri(texture->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 | 
				
			||||||
 | 
						glTexParameteri(texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 | 
				
			||||||
	renderer->procs.glEGLImageTargetTexture2DOES(texture->target, texture->image);
 | 
						renderer->procs.glEGLImageTargetTexture2DOES(texture->target, texture->image);
 | 
				
			||||||
	glBindTexture(texture->target, 0);
 | 
						glBindTexture(texture->target, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue