Commit: 1b8e1bb6351415912d7106bca6488c6c0dd50cc3
Author: Clément Foucault
Date:   Tue Dec 11 18:18:36 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB1b8e1bb6351415912d7106bca6488c6c0dd50cc3

DRW: Add polygon offset mode.

===================================================================

M       source/blender/draw/intern/DRW_render.h
M       source/blender/draw/intern/draw_manager_exec.c

===================================================================

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

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to