Fix rendering of the clip visual tools with detached video

Originally committed to SVN as r5847.
This commit is contained in:
Thomas Goyne 2011-11-12 01:23:40 +00:00
parent 51149104d9
commit 4be9c302d3
5 changed files with 21 additions and 23 deletions

View File

@ -348,9 +348,12 @@ static void APIENTRY glMultiDrawArraysFallback(GLenum mode, const GLint *first,
}
#endif
void OpenGLWrapper::DrawMultiPolygon(std::vector<float> const& points, std::vector<int> &start, std::vector<int> &count, Vector2D video_size, bool invert) {
void OpenGLWrapper::DrawMultiPolygon(std::vector<float> const& points, std::vector<int> &start, std::vector<int> &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<float> 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<float> 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

View File

@ -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<float> const& points, std::vector<int> &start, std::vector<int> &count, Vector2D video_size, bool invert);
void DrawMultiPolygon(std::vector<float> const& points, std::vector<int> &start, std::vector<int> &count, Vector2D video_pos, Vector2D video_size, bool invert);
static bool IsExtensionSupported(const char *ext);
};

View File

@ -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;

View File

@ -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));
}
}

View File

@ -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;