From 4be9c302d3ba522c830e7468840163e2bab3cdc1 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sat, 12 Nov 2011 01:23:40 +0000 Subject: [PATCH] Fix rendering of the clip visual tools with detached video Originally committed to SVN as r5847. --- aegisub/src/gl_wrap.cpp | 19 +++++++------------ aegisub/src/gl_wrap.h | 3 ++- aegisub/src/video_display.cpp | 6 +++--- aegisub/src/visual_tool_clip.cpp | 14 ++++++++------ aegisub/src/visual_tool_vector_clip.cpp | 2 +- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/aegisub/src/gl_wrap.cpp b/aegisub/src/gl_wrap.cpp index b1f93180b..7854fd966 100644 --- a/aegisub/src/gl_wrap.cpp +++ b/aegisub/src/gl_wrap.cpp @@ -348,9 +348,12 @@ static void APIENTRY glMultiDrawArraysFallback(GLenum mode, const GLint *first, } #endif -void OpenGLWrapper::DrawMultiPolygon(std::vector const& points, std::vector &start, std::vector &count, Vector2D video_size, bool invert) { +void OpenGLWrapper::DrawMultiPolygon(std::vector const& points, std::vector &start, std::vector &count, Vector2D video_pos, Vector2D video_size, bool invert) { GL_EXT(PFNGLMULTIDRAWARRAYSPROC, glMultiDrawArrays); + float real_line_a = line_a; + line_a = 0; + // The following is nonzero winding-number PIP based on stencils // Draw to stencil only @@ -362,14 +365,8 @@ void OpenGLWrapper::DrawMultiPolygon(std::vector const& points, std::vect glStencilFunc(GL_NEVER, 128, 0xFF); glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); - VertexArray buf(2, 4); - buf.Set(0, Vector2D()); - buf.Set(1, Vector2D(video_size, 0)); - buf.Set(2, video_size); - buf.Set(3, Vector2D(0, video_size)); - glColor4f(0, 0, 0, 1); - glDisable(GL_BLEND); - buf.Draw(GL_QUADS, false); + Vector2D video_max = video_pos + video_size; + DrawRectangle(video_pos, video_max); // Increment the winding number for each forward facing triangle glStencilOp(GL_INCR, GL_INCR, GL_INCR); @@ -388,14 +385,12 @@ void OpenGLWrapper::DrawMultiPolygon(std::vector const& points, std::vect // Draw the actual rectangle glColorMask(1, 1, 1, 1); - float real_line_a = line_a; - line_a = 0; // VSFilter draws when the winding number is nonzero, so we want to draw the // mask when the winding number is zero (where 128 is zero due to the lack of // wrapping combined with unsigned numbers) glStencilFunc(invert ? GL_EQUAL : GL_NOTEQUAL, 128, 0xFF); - DrawRectangle(Vector2D(), video_size); + DrawRectangle(video_pos, video_max); glDisable(GL_STENCIL_TEST); // Draw lines diff --git a/aegisub/src/gl_wrap.h b/aegisub/src/gl_wrap.h index 87470b52c..1dcb26f05 100644 --- a/aegisub/src/gl_wrap.h +++ b/aegisub/src/gl_wrap.h @@ -77,9 +77,10 @@ public: /// @param points List of coordinates /// @param start Indices in points which are the start of a new polygon /// @param count Number of points in each polygon + /// @param video_pos Top-left corner of the visible area /// @param video_size Bottom-right corner of the visible area /// @param invert Draw the area outside the polygons instead - void DrawMultiPolygon(std::vector const& points, std::vector &start, std::vector &count, Vector2D video_size, bool invert); + void DrawMultiPolygon(std::vector const& points, std::vector &start, std::vector &count, Vector2D video_pos, Vector2D video_size, bool invert); static bool IsExtensionSupported(const char *ext); }; diff --git a/aegisub/src/video_display.cpp b/aegisub/src/video_display.cpp index 32b9f2655..8afdda058 100644 --- a/aegisub/src/video_display.cpp +++ b/aegisub/src/video_display.cpp @@ -228,11 +228,11 @@ catch (const agi::Exception &err) { } void VideoDisplay::DrawOverscanMask(float horizontal_percent, float vertical_percent) const { - Vector2D size(w * horizontal_percent / 2, h * vertical_percent / 2); - int rad1 = h * 0.05; + Vector2D v(viewport_width, viewport_height); + Vector2D size = Vector2D(horizontal_percent, vertical_percent) / 2 * v; + int rad1 = viewport_height * 0.05; Vector2D gap = size + rad1; int rad2 = gap.Len() + 1; - Vector2D v(w, h); Vector2D igap = v - gap; Vector2D isize = v - size; diff --git a/aegisub/src/visual_tool_clip.cpp b/aegisub/src/visual_tool_clip.cpp index eefc60f61..9661729ee 100644 --- a/aegisub/src/visual_tool_clip.cpp +++ b/aegisub/src/visual_tool_clip.cpp @@ -88,12 +88,14 @@ void VisualToolClip::Draw() { gl.DrawRectangle(cur_1, cur_2); } else { - Vector2D p1 = cur_1.Min(cur_2); - Vector2D p2 = cur_1.Max(cur_2); - gl.DrawRectangle(Vector2D(0, 0), Vector2D(video_res, p1)); - gl.DrawRectangle(Vector2D(0, p2), video_res); - gl.DrawRectangle(Vector2D(0, p1), Vector2D(p1, p2)); - gl.DrawRectangle(Vector2D(p2, p1), Vector2D(video_res, p2)); + Vector2D v_min = video_pos; + Vector2D v_max = video_pos + video_res; + Vector2D c_min = cur_1.Min(cur_2); + Vector2D c_max = cur_1.Max(cur_2); + gl.DrawRectangle(v_min, Vector2D(v_max, c_min)); + gl.DrawRectangle(Vector2D(v_min, c_max), v_max); + gl.DrawRectangle(Vector2D(v_min, c_min), Vector2D(c_min, c_max)); + gl.DrawRectangle(Vector2D(c_max, c_min), Vector2D(v_max, c_max)); } } diff --git a/aegisub/src/visual_tool_vector_clip.cpp b/aegisub/src/visual_tool_vector_clip.cpp index a9bde7b59..2147e5de6 100644 --- a/aegisub/src/visual_tool_vector_clip.cpp +++ b/aegisub/src/visual_tool_vector_clip.cpp @@ -105,7 +105,7 @@ void VisualToolVectorClip::Draw() { gl.SetLineColour(colour[3], 1.f, 2); gl.SetFillColour(wxColour(0, 0, 0), 0.5f); - gl.DrawMultiPolygon(points, start, count, video_res, !inverse); + gl.DrawMultiPolygon(points, start, count, video_pos, video_res, !inverse); Vector2D pt; float t;