← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1562071-rendering_issues into lp:widelands

 

Miroslav Remák has proposed merging lp:~widelands-dev/widelands/bug-1562071-rendering_issues into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1562071 in widelands: "Visual glitch in chat overlay"
  https://bugs.launchpad.net/widelands/+bug/1562071

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1562071-rendering_issues/+merge/290183

Fixes bug #1562071 as well as chat overlay transparency.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1562071-rendering_issues into lp:widelands.
=== modified file 'src/graphic/blend_mode.h'
--- src/graphic/blend_mode.h	2015-01-27 08:09:56 +0000
+++ src/graphic/blend_mode.h	2016-03-27 21:17:15 +0000
@@ -22,6 +22,12 @@
 
 // Defines blending during blitting.
 enum class BlendMode {
+	// Normal blending, equivalent to:
+	// glEnable(GL_BLEND);
+	// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+	// glBlendEquation(GL_FUNC_ADD);
+	Default,
+
 	// Perform a normal blitting operation that respects the alpha channel if
 	// present.
 	UseAlpha,

=== modified file 'src/graphic/gl/fill_rect_program.cc'
--- src/graphic/gl/fill_rect_program.cc	2016-02-01 10:24:34 +0000
+++ src/graphic/gl/fill_rect_program.cc	2016-03-27 21:17:15 +0000
@@ -74,6 +74,9 @@
 		case BlendMode::Copy:
 			glDisable(GL_BLEND);
 			break;
+
+		default:
+			break;
 		}
 
 		glUseProgram(gl_program_.object());
@@ -164,6 +167,9 @@
 		case BlendMode::Copy:
 			glEnable(GL_BLEND);
 			break;
+
+		default:
+			break;
 		}
 	}
 }

=== modified file 'src/graphic/gl/utils.cc'
--- src/graphic/gl/utils.cc	2016-02-06 20:55:15 +0000
+++ src/graphic/gl/utils.cc	2016-03-27 21:17:15 +0000
@@ -204,6 +204,16 @@
 	}
 }
 
+void State::delete_texture(const GLuint texture)
+{
+	unbind_texture_if_bound(texture);
+	glDeleteTextures(1, &texture);
+
+	if (current_framebuffer_texture_ == texture) {
+		current_framebuffer_texture_ = 0;
+	}
+}
+
 void State::bind_framebuffer(const GLuint framebuffer, const GLuint texture) {
 	if (current_framebuffer_ == framebuffer && current_framebuffer_texture_ == texture) {
 		return;

=== modified file 'src/graphic/gl/utils.h'
--- src/graphic/gl/utils.h	2016-03-14 19:49:52 +0000
+++ src/graphic/gl/utils.h	2016-03-27 21:17:15 +0000
@@ -121,6 +121,8 @@
 	// needed before the texture is used as target for rendering.
 	void unbind_texture_if_bound(GLuint texture);
 
+	void delete_texture(GLuint texture);
+
 	// Calls glEnableVertexAttribArray on all 'entries' and disables all others
 	// that are activated. 'entries' is taken by value on purpose.
 	void enable_vertex_attrib_array(std::unordered_set<GLint> entries);

=== modified file 'src/graphic/rendertarget.cc'
--- src/graphic/rendertarget.cc	2016-03-14 19:49:52 +0000
+++ src/graphic/rendertarget.cc	2016-03-27 21:17:15 +0000
@@ -133,11 +133,11 @@
 	}
 }
 
-void RenderTarget::fill_rect(const Rect& rect, const RGBAColor& clr)
+void RenderTarget::fill_rect(const Rect& rect, const RGBAColor& clr, BlendMode blend_mode)
 {
 	Rect r(rect);
 	if (clip(r))
-		surface_->fill_rect(r, clr);
+		surface_->fill_rect(r, clr, blend_mode);
 }
 
 void RenderTarget::brighten_rect(const Rect& rect, int32_t factor)

=== modified file 'src/graphic/rendertarget.h'
--- src/graphic/rendertarget.h	2016-03-14 19:49:52 +0000
+++ src/graphic/rendertarget.h	2016-03-27 21:17:15 +0000
@@ -61,7 +61,7 @@
 								const RGBColor& color,
 								float width);
 	void draw_rect(const Rect&, const RGBColor&);
-	void fill_rect(const Rect&, const RGBAColor&);
+	void fill_rect(const Rect&, const RGBAColor&, BlendMode blend_mode = BlendMode::Copy);
 	void brighten_rect(const Rect&, int32_t factor);
 
 	void blit(const Point& dst,

=== modified file 'src/graphic/surface.cc'
--- src/graphic/surface.cc	2016-03-08 09:38:16 +0000
+++ src/graphic/surface.cc	2016-03-27 21:17:15 +0000
@@ -111,9 +111,9 @@
 
 }  // namespace
 
-void Surface::fill_rect(const Rect& rc, const RGBAColor& clr) {
+void Surface::fill_rect(const Rect& rc, const RGBAColor& clr, BlendMode blend_mode) {
 	const FloatRect rect = rect_to_gl_renderbuffer(width(), height(), rc);
-	do_fill_rect(rect, clr, BlendMode::Copy);
+	do_fill_rect(rect, clr, blend_mode);
 }
 
 void Surface::brighten_rect(const Rect& rc, const int32_t factor)

=== modified file 'src/graphic/surface.h'
--- src/graphic/surface.h	2016-02-19 19:10:44 +0000
+++ src/graphic/surface.h	2016-03-27 21:17:15 +0000
@@ -61,9 +61,8 @@
 	void
 	blit_monochrome(const Rect& dst, const Image&, const Rect& srcrc, const RGBAColor& multiplier);
 
-	/// Draws a filled rect to the destination. No blending takes place, the values
-	// in the target are just replaced (i.e. / BlendMode would be BlendMode::Copy).
-	void fill_rect(const Rect&, const RGBAColor&);
+	/// Draws a filled rect to the destination.
+	void fill_rect(const Rect&, const RGBAColor&, BlendMode blend_mode = BlendMode::Copy);
 
 	// Draw a 'width' pixel wide line to the destination. 'points' are taken by
 	// value on purpose.

=== modified file 'src/graphic/texture.cc'
--- src/graphic/texture.cc	2016-03-19 11:47:00 +0000
+++ src/graphic/texture.cc	2016-03-27 21:17:15 +0000
@@ -170,8 +170,7 @@
 Texture::~Texture()
 {
 	if (owns_texture_) {
-		Gl::State::instance().unbind_texture_if_bound(blit_data_.texture_id);
-		glDeleteTextures(1, &blit_data_.texture_id);
+		Gl::State::instance().delete_texture(blit_data_.texture_id);
 	}
 }
 

=== modified file 'src/wui/chatoverlay.cc'
--- src/wui/chatoverlay.cc	2016-02-25 08:47:48 +0000
+++ src/wui/chatoverlay.cc	2016-03-27 21:17:15 +0000
@@ -193,10 +193,9 @@
 	const int32_t top = get_h() - height - 2 * MARGIN;
 	const int width = std::min<int>(get_w(), im->width());
 
-	// TODO(unknown): alpha channel not respected
 	if (!m->transparent_) {
 		Rect rect(0, top, width, height);
-		dst.fill_rect(rect, RGBAColor(50, 50, 50, 128));
+		dst.fill_rect(rect, RGBAColor(50, 50, 50, 128), BlendMode::Default);
 	}
 	int32_t topcrop = im->height() - height;
 	Rect cropRect(0, topcrop, width, height);


Follow ups