Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-01-20 10:41:11 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-01-20 10:45:27 +0300
commita3716f5945b4ea0451281e9ae4ba9e43d2793938 (patch)
tree98cc02b347a1c136e45f5fbfdf488c0ae3846953 /source/blender/editors/manipulator_library
parente969ac64137e53c0a375886d5e175f1e6b05073a (diff)
GPU_batch: Add GPU_batch_wire_from_poly_2d_encoded
Draws wire around polygon shapes: better visibility w/ any background color.
Diffstat (limited to 'source/blender/editors/manipulator_library')
-rw-r--r--source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c b/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
index a60204b5f0a..2951ad84c0d 100644
--- a/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
+++ b/source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
@@ -69,7 +69,7 @@ typedef struct ButtonManipulator2D {
bool is_init;
/* Use an icon or shape */
int icon;
- Gwn_Batch *shape_batch;
+ Gwn_Batch *shape_batch[2];
} ButtonManipulator2D;
#define CIRCLE_RESOLUTION 32
@@ -114,7 +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 = GPU_batch_from_poly_2d_encoded((uchar *)polys, polys_len, NULL);
+ 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);
MEM_freeN(polys);
}
}
@@ -131,11 +132,21 @@ static void button2d_draw_intern(
glEnable(GL_BLEND);
if (select == false) {
- if (button->shape_batch != NULL) {
+ if (button->shape_batch[0] != NULL) {
glEnable(GL_POLYGON_SMOOTH);
- GWN_batch_program_set_builtin(button->shape_batch, GPU_SHADER_2D_UNIFORM_COLOR);
- GWN_batch_uniform_4f(button->shape_batch, "color", UNPACK4(color));
- GWN_batch_draw(button->shape_batch);
+ glEnable(GL_LINE_SMOOTH);
+ glLineWidth(1.0f);
+ for (uint i = 0; i < ARRAY_SIZE(button->shape_batch) && button->shape_batch[i]; i++) {
+ 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);
gpuPopMatrix();
}
@@ -203,7 +214,10 @@ static int manipulator_button2d_cursor_get(wmManipulator *UNUSED(mpr))
static void manipulator_button2d_free(wmManipulator *mpr)
{
ButtonManipulator2D *shape = (ButtonManipulator2D *)mpr;
- GWN_BATCH_DISCARD_SAFE(shape->shape_batch);
+
+ for (uint i = 0; i < ARRAY_SIZE(shape->shape_batch); i++) {
+ GWN_BATCH_DISCARD_SAFE(shape->shape_batch[i]);
+ }
}
/** \} */