UI: Draw curve map with solid color

Differential Revision: https://developer.blender.org/D3891
This commit is contained in:
Charlie Jolly 2018-11-02 18:56:45 +00:00
parent d2b4eaa137
commit f2858fbb9a
1 changed files with 26 additions and 15 deletions

View File

@ -1765,43 +1765,54 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
}
immEnd();
}
immUnbindProgram();
/* the curve */
immUniformColor3ubv((unsigned char *)wcol->item);
GPU_line_smooth(true);
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3ubvAlpha((unsigned char *)wcol->item, 128);
GPU_blend(true);
immBegin(GPU_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2);
GPU_polygon_smooth(true);
immBegin(GPU_PRIM_TRI_STRIP, (CM_TABLE * 2 + 2) + 4);
if (cuma->table == NULL)
curvemapping_changed(cumap, false);
CurveMapPoint *cmp = cuma->table;
float fx, fy;
/* first point */
if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
immVertex2f(pos, rect->xmin, rect->ymin + zoomy * (cmp[0].y - offsy));
fx = rect->xmin;
fy = rect->ymin + zoomy * (cmp[0].y - offsy);
}
else {
float fx = rect->xmin + zoomx * (cmp[0].x - offsx + cuma->ext_in[0]);
float fy = rect->ymin + zoomy * (cmp[0].y - offsy + cuma->ext_in[1]);
immVertex2f(pos, fx, fy);
fx = rect->xmin + zoomx * (cmp[0].x - offsx + cuma->ext_in[0]);
fy = rect->ymin + zoomy * (cmp[0].y - offsy + cuma->ext_in[1]);
}
immVertex2f(pos, fx, rect->ymin);
immVertex2f(pos, fx, fy);
/* curve */
for (int a = 0; a <= CM_TABLE; a++) {
float fx = rect->xmin + zoomx * (cmp[a].x - offsx);
float fy = rect->ymin + zoomy * (cmp[a].y - offsy);
fx = rect->xmin + zoomx * (cmp[a].x - offsx);
fy = rect->ymin + zoomy * (cmp[a].y - offsy);
immVertex2f(pos, fx, rect->ymin);
immVertex2f(pos, fx, fy);
}
/* last point */
if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) {
immVertex2f(pos, rect->xmax, rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy));
fx = rect->xmax;
fy = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy);
}
else {
float fx = rect->xmin + zoomx * (cmp[CM_TABLE].x - offsx - cuma->ext_out[0]);
float fy = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy - cuma->ext_out[1]);
immVertex2f(pos, fx, fy);
fx = rect->xmin + zoomx * (cmp[CM_TABLE].x - offsx - cuma->ext_out[0]);
fy = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy - cuma->ext_out[1]);
}
immVertex2f(pos, fx, rect->ymin);
immVertex2f(pos, fx, fy);
immEnd();
GPU_line_smooth(false);
GPU_polygon_smooth(false);
GPU_blend(false);
immUnbindProgram();
@ -1812,7 +1823,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
cmp = cuma->curve;
GPU_point_size(3.0f);
GPU_point_size(4.0f);
immBegin(GPU_PRIM_POINTS, cuma->totpoint);
for (int a = 0; a < cuma->totpoint; a++) {
float color[4];