OpenGL: cleanup
- LINE_STRIP to LINES when only drawing one - group state changes for easier reading - general cleanup
This commit is contained in:
parent
8c596e08e7
commit
1d88773b1f
|
@ -111,23 +111,17 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const
|
|||
void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
float vec[2];
|
||||
|
||||
|
||||
/* Draw a light green line to indicate current frame */
|
||||
vec[0] = (float)(scene->r.cfra * scene->r.framelen);
|
||||
|
||||
UI_ThemeColor(TH_CFRAME);
|
||||
if (flag & DRAWCFRA_WIDE)
|
||||
glLineWidth(3.0);
|
||||
else
|
||||
glLineWidth(2.0);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
vec[1] = v2d->cur.ymin - 500.0f; /* XXX arbitrary... want it go to bottom */
|
||||
glVertex2fv(vec);
|
||||
|
||||
vec[1] = v2d->cur.ymax;
|
||||
glVertex2fv(vec);
|
||||
|
||||
const float x = (float)(scene->r.cfra * scene->r.framelen);
|
||||
|
||||
glLineWidth((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(x, v2d->cur.ymin - 500.0f); /* XXX arbitrary... want it go to bottom */
|
||||
glVertex2f(x, v2d->cur.ymax);
|
||||
glEnd();
|
||||
|
||||
glLineWidth(1.0);
|
||||
|
@ -135,7 +129,7 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
|
|||
/* Draw current frame number in a little box */
|
||||
if (flag & DRAWCFRA_SHOW_NUMBOX) {
|
||||
UI_view2d_view_orthoSpecial(CTX_wm_region(C), v2d, 1);
|
||||
draw_cfra_number(scene, v2d, vec[0], (flag & DRAWCFRA_UNIT_SECONDS) != 0);
|
||||
draw_cfra_number(scene, v2d, x, (flag & DRAWCFRA_UNIT_SECONDS) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -514,30 +514,25 @@ static void histogram_draw_one(
|
|||
float r, float g, float b, float alpha,
|
||||
float x, float y, float w, float h, const float *data, int res, const bool is_line)
|
||||
{
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glColor4f(r, g, b, alpha);
|
||||
|
||||
if (is_line) {
|
||||
glLineWidth(1.5);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glColor4f(r, g, b, alpha);
|
||||
|
||||
/* curve outline */
|
||||
glLineWidth(1.5);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (int i = 0; i < res; i++) {
|
||||
float x2 = x + i * (w / (float)res);
|
||||
glVertex2f(x2, y + (data[i] * h));
|
||||
}
|
||||
glEnd();
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
|
||||
glLineWidth(1.0);
|
||||
}
|
||||
else {
|
||||
/* under the curve */
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
glColor4f(r, g, b, alpha);
|
||||
|
||||
glShadeModel(GL_FLAT);
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glVertex2f(x, y);
|
||||
|
@ -553,15 +548,15 @@ static void histogram_draw_one(
|
|||
glColor4f(0.f, 0.f, 0.f, 0.25f);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
for (int i = 0; i < res; i++) {
|
||||
float x2 = x + i * (w / (float)res);
|
||||
glVertex2f(x2, y + (data[i] * h));
|
||||
}
|
||||
glEnd();
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
|
||||
#define HISTOGRAM_TOT_GRID_LINES 4
|
||||
|
@ -1644,7 +1639,6 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
|
|||
glEnd();
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glDisable(GL_BLEND);
|
||||
glLineWidth(1.0f);
|
||||
|
||||
/* restore scissortest */
|
||||
glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
|
||||
|
|
|
@ -481,6 +481,8 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
|
|||
px[0] = 1.0f / width / sc->zoom;
|
||||
px[1] = 1.0f / height / sc->zoom;
|
||||
|
||||
glLineWidth(tiny ? 1.0f : 3.0f);
|
||||
|
||||
if ((marker->flag & MARKER_DISABLED) == 0) {
|
||||
float pos[2];
|
||||
float p[2];
|
||||
|
@ -500,7 +502,6 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
|
|||
glEnd();
|
||||
}
|
||||
else {
|
||||
if (!tiny) glLineWidth(3.0f);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(pos[0] + px[0] * 2, pos[1]);
|
||||
glVertex2f(pos[0] + px[0] * 8, pos[1]);
|
||||
|
@ -522,9 +523,6 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
|
|||
glPushMatrix();
|
||||
glTranslate2fv(marker_pos);
|
||||
|
||||
if (!tiny)
|
||||
glLineWidth(3.0f);
|
||||
|
||||
if (sc->flag & SC_SHOW_MARKER_PATTERN) {
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2fv(marker->pattern_corners[0]);
|
||||
|
@ -795,7 +793,6 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
|
|||
track_colors(track, act, col, scol);
|
||||
|
||||
if (outline) {
|
||||
glLineWidth(3.0f);
|
||||
UI_ThemeColor(TH_MARKER_OUTLINE);
|
||||
}
|
||||
|
||||
|
@ -854,6 +851,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
|
|||
|
||||
BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
|
||||
|
||||
glLineWidth(outline ? 3.0f : 1.0f);
|
||||
|
||||
glEnable(GL_LINE_STIPPLE);
|
||||
glLineStipple(3, 0xaaaa);
|
||||
|
||||
|
@ -1149,17 +1148,18 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
|
|||
draw_plane_marker_image(scene, plane_track, plane_marker);
|
||||
}
|
||||
|
||||
if (draw_outline) {
|
||||
if (!tiny) {
|
||||
glLineWidth(3.0f);
|
||||
}
|
||||
}
|
||||
else if (tiny) {
|
||||
glLineStipple(3, 0xaaaa);
|
||||
glEnable(GL_LINE_STIPPLE);
|
||||
}
|
||||
|
||||
if (draw_plane_quad) {
|
||||
|
||||
const bool stipple = !draw_outline && tiny;
|
||||
const bool thick = draw_outline && !tiny;
|
||||
|
||||
if (stipple) {
|
||||
glLineStipple(3, 0xaaaa);
|
||||
glEnable(GL_LINE_STIPPLE);
|
||||
}
|
||||
|
||||
glLineWidth(thick ? 3.0f : 1.0f);
|
||||
|
||||
/* Draw rectangle itself. */
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2fv(plane_marker->corners[0]);
|
||||
|
@ -1173,22 +1173,28 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
|
|||
float end_point[2];
|
||||
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
|
||||
getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[1], end_point);
|
||||
glColor3f(1.0, 0.0, 0.0f);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2fv(plane_marker->corners[0]);
|
||||
glVertex2fv(end_point);
|
||||
glEnd();
|
||||
|
||||
getArrowEndPoint(width, height, sc->zoom, plane_marker->corners[0], plane_marker->corners[3], end_point);
|
||||
glColor3f(0.0, 1.0, 0.0f);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2fv(plane_marker->corners[0]);
|
||||
glVertex2fv(end_point);
|
||||
|
||||
glEnd();
|
||||
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
if (stipple)
|
||||
glDisable(GL_LINE_STIPPLE);
|
||||
|
||||
if (thick)
|
||||
glLineWidth(1.0f);
|
||||
}
|
||||
|
||||
/* Draw sliders. */
|
||||
|
@ -1199,15 +1205,6 @@ static void draw_plane_marker_ex(SpaceClip *sc, Scene *scene, MovieTrackingPlane
|
|||
3.0f * px[0], 3.0f * px[1], draw_outline, px);
|
||||
}
|
||||
}
|
||||
|
||||
if (draw_outline) {
|
||||
if (!tiny) {
|
||||
glLineWidth(1.0f);
|
||||
}
|
||||
}
|
||||
else if (tiny) {
|
||||
glDisable(GL_LINE_STIPPLE);
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_plane_marker_outline(SpaceClip *sc, Scene *scene, MovieTrackingPlaneTrack *plane_track,
|
||||
|
|
|
@ -247,20 +247,17 @@ void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
|
|||
{
|
||||
View2D *v2d = &ar->v2d;
|
||||
float xscale, yscale;
|
||||
float vec[2];
|
||||
|
||||
/* Draw a light green line to indicate current frame */
|
||||
vec[0] = (float)(sc->user.framenr * scene->r.framelen);
|
||||
|
||||
UI_ThemeColor(TH_CFRAME);
|
||||
|
||||
float x = (float)(sc->user.framenr * scene->r.framelen);
|
||||
|
||||
glLineWidth(2.0);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
vec[1] = v2d->cur.ymin;
|
||||
glVertex2fv(vec);
|
||||
|
||||
vec[1] = v2d->cur.ymax;
|
||||
glVertex2fv(vec);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(x, v2d->cur.ymin);
|
||||
glVertex2f(x, v2d->cur.ymax);
|
||||
glEnd();
|
||||
|
||||
glLineWidth(1.0);
|
||||
|
|
|
@ -267,49 +267,40 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar)
|
|||
|
||||
/* horizontal component of value-cursor (value line before the current frame line) */
|
||||
if ((sipo->flag & SIPO_NODRAWCURSOR) == 0) {
|
||||
float vec[2];
|
||||
|
||||
float y = sipo->cursorVal;
|
||||
|
||||
/* Draw a green line to indicate the cursor value */
|
||||
vec[1] = sipo->cursorVal;
|
||||
|
||||
UI_ThemeColorShadeAlpha(TH_CFRAME, -10, -50);
|
||||
glLineWidth(2.0);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
vec[0] = v2d->cur.xmin;
|
||||
glVertex2fv(vec);
|
||||
|
||||
vec[0] = v2d->cur.xmax;
|
||||
glVertex2fv(vec);
|
||||
glEnd(); // GL_LINE_STRIP
|
||||
glDisable(GL_BLEND);
|
||||
glLineWidth(2.0);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(v2d->cur.xmin, y);
|
||||
glVertex2f(v2d->cur.xmax, y);
|
||||
glEnd();
|
||||
|
||||
glLineWidth(1.0);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
/* current frame or vertical component of vertical component of the cursor */
|
||||
if (sipo->mode == SIPO_MODE_DRIVERS) {
|
||||
/* cursor x-value */
|
||||
float vec[2];
|
||||
|
||||
vec[0] = sipo->cursorTime;
|
||||
float x = sipo->cursorTime;
|
||||
|
||||
/* to help differentiate this from the current frame, draw slightly darker like the horizontal one */
|
||||
UI_ThemeColorShadeAlpha(TH_CFRAME, -40, -50);
|
||||
glEnable(GL_BLEND);
|
||||
glLineWidth(2.0);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
vec[1] = v2d->cur.ymin;
|
||||
glVertex2fv(vec);
|
||||
|
||||
vec[1] = v2d->cur.ymax;
|
||||
glVertex2fv(vec);
|
||||
glEnd(); // GL_LINE_STRIP
|
||||
glDisable(GL_BLEND);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(x, v2d->cur.ymin);
|
||||
glVertex2f(x, v2d->cur.ymax);
|
||||
glEnd();
|
||||
|
||||
glLineWidth(1.0);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
else {
|
||||
/* current frame */
|
||||
|
|
|
@ -275,10 +275,8 @@ void setTransformViewAspect(TransInfo *t, float r_aspect[3])
|
|||
|
||||
static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy)
|
||||
{
|
||||
float divx, divy;
|
||||
|
||||
divx = BLI_rcti_size_x(&v2d->mask);
|
||||
divy = BLI_rcti_size_y(&v2d->mask);
|
||||
float divx = BLI_rcti_size_x(&v2d->mask);
|
||||
float divy = BLI_rcti_size_y(&v2d->mask);
|
||||
|
||||
r_vec[0] = BLI_rctf_size_x(&v2d->cur) * dx / divx;
|
||||
r_vec[1] = BLI_rctf_size_y(&v2d->cur) * dy / divy;
|
||||
|
@ -287,14 +285,11 @@ static void convertViewVec2D(View2D *v2d, float r_vec[3], int dx, int dy)
|
|||
|
||||
static void convertViewVec2D_mask(View2D *v2d, float r_vec[3], int dx, int dy)
|
||||
{
|
||||
float divx, divy;
|
||||
float mulx, muly;
|
||||
float divx = BLI_rcti_size_x(&v2d->mask);
|
||||
float divy = BLI_rcti_size_y(&v2d->mask);
|
||||
|
||||
divx = BLI_rcti_size_x(&v2d->mask);
|
||||
divy = BLI_rcti_size_y(&v2d->mask);
|
||||
|
||||
mulx = BLI_rctf_size_x(&v2d->cur);
|
||||
muly = BLI_rctf_size_y(&v2d->cur);
|
||||
float mulx = BLI_rctf_size_x(&v2d->cur);
|
||||
float muly = BLI_rctf_size_y(&v2d->cur);
|
||||
|
||||
/* difference with convertViewVec2D */
|
||||
/* clamp w/h, mask only */
|
||||
|
@ -1716,7 +1711,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
|
|||
UI_ThemeColor(TH_VIEW_OVERLAY);
|
||||
|
||||
setlinestyle(3);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2iv(t->mval);
|
||||
glVertex2fv(cent);
|
||||
glEnd();
|
||||
|
@ -1728,7 +1723,6 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
|
|||
glLineWidth(3.0);
|
||||
drawArrow(UP, 5, 10, 5);
|
||||
drawArrow(DOWN, 5, 10, 5);
|
||||
glLineWidth(1.0);
|
||||
break;
|
||||
case HLP_HARROW:
|
||||
UI_ThemeColor(TH_VIEW_OVERLAY);
|
||||
|
@ -1738,7 +1732,6 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
|
|||
glLineWidth(3.0);
|
||||
drawArrow(RIGHT, 5, 10, 5);
|
||||
drawArrow(LEFT, 5, 10, 5);
|
||||
glLineWidth(1.0);
|
||||
break;
|
||||
case HLP_VARROW:
|
||||
UI_ThemeColor(TH_VIEW_OVERLAY);
|
||||
|
@ -1748,7 +1741,6 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
|
|||
glLineWidth(3.0);
|
||||
drawArrow(UP, 5, 10, 5);
|
||||
drawArrow(DOWN, 5, 10, 5);
|
||||
glLineWidth(1.0);
|
||||
break;
|
||||
case HLP_ANGLE:
|
||||
{
|
||||
|
@ -1760,7 +1752,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
|
|||
UI_ThemeColor(TH_VIEW_OVERLAY);
|
||||
|
||||
setlinestyle(3);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2iv(t->mval);
|
||||
glVertex2fv(cent);
|
||||
glEnd();
|
||||
|
@ -1785,8 +1777,6 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
|
|||
glRotatef(RAD2DEGF(angle + delta_angle), 0, 0, 1);
|
||||
|
||||
drawArrowHead(UP, 5);
|
||||
|
||||
glLineWidth(1.0);
|
||||
break;
|
||||
}
|
||||
case HLP_TRACKBALL:
|
||||
|
@ -1809,12 +1799,12 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
|
|||
|
||||
drawArrow(UP, 5, 10, 5);
|
||||
drawArrow(DOWN, 5, 10, 5);
|
||||
glLineWidth(1.0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
glLineWidth(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -696,7 +696,7 @@ void drawConstraint(TransInfo *t)
|
|||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
setlinestyle(1);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glBegin(GL_LINES);
|
||||
glVertex3fv(t->center_global);
|
||||
glVertex3fv(vec);
|
||||
glEnd();
|
||||
|
|
|
@ -1040,7 +1040,7 @@ void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis
|
|||
glColor3ubv(col2);
|
||||
|
||||
setlinestyle(0);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glBegin(GL_LINES);
|
||||
glVertex3fv(v1);
|
||||
glVertex3fv(v2);
|
||||
glEnd();
|
||||
|
|
|
@ -316,7 +316,7 @@ void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *ar, void *arg_info
|
|||
|
||||
UI_ThemeColor(TH_VIEW_OVERLAY);
|
||||
setlinestyle(3);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glBegin(GL_LINES);
|
||||
glVertex2iv(mval_dst);
|
||||
glVertex2fv(mval_src);
|
||||
glEnd();
|
||||
|
|
Loading…
Reference in New Issue