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:
authorClément Foucault <foucault.clem@gmail.com>2018-12-11 20:18:36 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-12-11 20:18:36 +0300
commit1b8e1bb6351415912d7106bca6488c6c0dd50cc3 (patch)
tree2b30515198ccf9dc832cc48274751a1b1736ff7e /source/blender
parent2a6bc4a82cb3201ac623512e3f9f53f3890ecae2 (diff)
DRW: Add polygon offset mode.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/draw/intern/DRW_render.h4
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c26
2 files changed, 28 insertions, 2 deletions
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 519c907a6a4..89aa55c56b2 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -283,8 +283,8 @@ typedef enum {
DRW_STATE_CULL_FRONT = (1 << 9),
DRW_STATE_WIRE = (1 << 10),
DRW_STATE_POINT = (1 << 11),
- /* DRW_STATE_STIPPLE_2 = (1 << 12), */ /* Not used */
- /* DRW_STATE_STIPPLE_3 = (1 << 13), */ /* Not used */
+ DRW_STATE_OFFSET_POSITIVE = (1 << 12), /* Polygon offset. Does not work with lines and points. */
+ DRW_STATE_OFFSET_NEGATIVE = (1 << 13), /* Polygon offset. Does not work with lines and points. */
/* DRW_STATE_STIPPLE_4 = (1 << 14), */ /* Not used */
DRW_STATE_BLEND = (1 << 15),
DRW_STATE_ADDITIVE = (1 << 16),
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 8eefd058719..985c4a73775 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -342,6 +342,32 @@ void drw_state_set(DRWState state)
}
}
+ /* Polygon Offset */
+ {
+ int test;
+ if (CHANGED_ANY_STORE_VAR(
+ DRW_STATE_OFFSET_POSITIVE |
+ DRW_STATE_OFFSET_NEGATIVE,
+ test)) {
+ if (test) {
+ glEnable(GL_POLYGON_OFFSET_FILL);
+ /* Stencil Write */
+ if ((state & DRW_STATE_OFFSET_POSITIVE) != 0) {
+ glPolygonOffset(1.0f, 1.0f);
+ }
+ else if ((state & DRW_STATE_OFFSET_NEGATIVE) != 0) {
+ glPolygonOffset(-1.0f, -1.0f);
+ }
+ else {
+ BLI_assert(0);
+ }
+ }
+ else {
+ glDisable(GL_POLYGON_OFFSET_FILL);
+ }
+ }
+ }
+
#undef CHANGED_TO
#undef CHANGED_ANY
#undef CHANGED_ANY_STORE_VAR