[Bf-blender-cvs] [8dfc31f61fa] master: Cleanup: GPU: Encapsulate glProvokingVertex

Clément Foucault noreply at git.blender.org
Sat Jul 18 03:08:17 CEST 2020


Commit: 8dfc31f61fac5a6301d6bfb17eda74ea4fffe384
Author: Clément Foucault
Date:   Fri Jul 17 20:26:12 2020 +0200
Branches: master
https://developer.blender.org/rB8dfc31f61fac5a6301d6bfb17eda74ea4fffe384

Cleanup: GPU: Encapsulate glProvokingVertex

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

M	source/blender/editors/uvedit/uvedit_draw.c
M	source/blender/gpu/GPU_state.h
M	source/blender/gpu/intern/gpu_state.c

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

diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index c1408c12120..df8d3cfb8db 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -408,7 +408,7 @@ static void draw_uvs(SpaceImage *sima,
     {
       /* We could modify the vbo's data filling
        * instead of modifying the provoking vert. */
-      glProvokingVertex(GL_FIRST_VERTEX_CONVENTION);
+      GPU_provoking_vertex(GPU_VERTEX_FIRST);
 
       UI_GetThemeColor3fv(TH_EDGE_SELECT, col2);
       col2[3] = overlay_alpha;
@@ -464,7 +464,7 @@ static void draw_uvs(SpaceImage *sima,
       GPU_batch_draw(batch->edges);
       GPU_depth_test(false);
 
-      glProvokingVertex(GL_LAST_VERTEX_CONVENTION);
+      GPU_provoking_vertex(GPU_VERTEX_LAST);
     }
 
     if (sima->flag & SI_SMOOTH_UV) {
diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h
index c9f745a680d..0f0a8a5dd6e 100644
--- a/source/blender/gpu/GPU_state.h
+++ b/source/blender/gpu/GPU_state.h
@@ -46,6 +46,11 @@ typedef enum eGPUFaceCull {
   GPU_CULL_BACK,
 } eGPUFaceCull;
 
+typedef enum eGPUProvokingVertex {
+  GPU_VERTEX_FIRST = 0,
+  GPU_VERTEX_LAST, /* Default */
+} eGPUProvokingVertex;
+
 /* Initialize
  * - sets the default Blender opengl state, if in doubt, check
  *   the contents of this function
@@ -60,6 +65,7 @@ void GPU_blend_set_func_separate(eGPUBlendFunction src_rgb,
                                  eGPUBlendFunction dst_alpha);
 void GPU_face_culling(eGPUFaceCull culling);
 void GPU_front_facing(bool invert);
+void GPU_provoking_vertex(eGPUProvokingVertex vert);
 void GPU_depth_range(float near, float far);
 void GPU_depth_test(bool enable);
 bool GPU_depth_test_enabled(void);
diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.c
index c8f51b14343..f1b842403f9 100644
--- a/source/blender/gpu/intern/gpu_state.c
+++ b/source/blender/gpu/intern/gpu_state.c
@@ -94,6 +94,12 @@ void GPU_front_facing(bool invert)
   glFrontFace((invert) ? GL_CW : GL_CCW);
 }
 
+void GPU_provoking_vertex(eGPUProvokingVertex vert)
+{
+  glProvokingVertex((vert == GPU_VERTEX_FIRST) ? GL_FIRST_VERTEX_CONVENTION :
+                                                 GL_LAST_VERTEX_CONVENTION);
+}
+
 void GPU_depth_range(float near, float far)
 {
   /* glDepthRangef is only for OpenGL 4.1 or higher */



More information about the Bf-blender-cvs mailing list