Manipulator: tweak shape drawing

Draw triangles over wire for a more subtle outline.
This commit is contained in:
Campbell Barton
2018-01-20 19:41:41 +11:00
parent a3716f5945
commit da53eb3748
2 changed files with 8 additions and 9 deletions

View File

@@ -114,8 +114,8 @@ static void button2d_draw_intern(
/* We shouldn't need the +1, but a NULL char is set. */
char *polys = MEM_mallocN(polys_len + 1, __func__);
RNA_property_string_get(mpr->ptr, prop, polys);
button->shape_batch[0] = GPU_batch_tris_from_poly_2d_encoded((uchar *)polys, polys_len, NULL);
button->shape_batch[1] = GPU_batch_wire_from_poly_2d_encoded((uchar *)polys, polys_len, NULL);
button->shape_batch[0] = GPU_batch_wire_from_poly_2d_encoded((uchar *)polys, polys_len, NULL);
button->shape_batch[1] = GPU_batch_tris_from_poly_2d_encoded((uchar *)polys, polys_len, NULL);
MEM_freeN(polys);
}
}
@@ -137,17 +137,17 @@ static void button2d_draw_intern(
glEnable(GL_LINE_SMOOTH);
glLineWidth(1.0f);
for (uint i = 0; i < ARRAY_SIZE(button->shape_batch) && button->shape_batch[i]; i++) {
/* Invert line color for wire. */
color[0] = 1.0f - color[0];
color[1] = 1.0f - color[1];
color[2] = 1.0f - color[2];
GWN_batch_program_set_builtin(button->shape_batch[i], GPU_SHADER_2D_UNIFORM_COLOR);
GWN_batch_uniform_4f(button->shape_batch[i], "color", UNPACK4(color));
GWN_batch_draw(button->shape_batch[i]);
if (i == 0) {
/* Invert line color. */
color[0] = 1.0f - color[0];
color[1] = 1.0f - color[1];
color[2] = 1.0f - color[2];
}
}
glDisable(GL_POLYGON_SMOOTH);
glDisable(GL_LINE_SMOOTH);
gpuPopMatrix();
}
else if (button->icon != ICON_NONE) {

View File

@@ -201,7 +201,6 @@ static void WIDGETGROUP_navigate_setup(const bContext *UNUSED(C), wmManipulatorG
mpr->ptr, prop,
(const char *)info->shape, info->shape_size);
/* don't fade icons so much */
copy_v3_fl(mpr->color, 0.0f);
mpr->color[3] = 0.5f;
}