Commit: e12432ac71166ae97b6444b35fe3187ab147f999
Author: Mike Erwin
Date:   Thu Apr 9 03:30:43 2015 -0400
Branches: GPU_data_request
https://developer.blender.org/rBe12432ac71166ae97b6444b35fe3187ab147f999

state tracking API - pass NULL to use defaults

reduces typing needed

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

M       source/blender/editors/space_view3d/drawobject.c
M       source/blender/gpu/intern/gpux_state.c

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

diff --git a/source/blender/editors/space_view3d/drawobject.c 
b/source/blender/editors/space_view3d/drawobject.c
index 8e513f5..a1c1168 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -2048,7 +2048,7 @@ static void drawcamera_new_new(Scene *scene, View3D *v3d, 
RegionView3D *rv3d, Ba
                GPUx_set_line_vertices(elem, 2,  2,3);
                GPUx_set_line_vertices(elem, 3,  3,0);
 
-               GPUx_draw_lines(&default_state.common, &default_state.line, 
verts, elem);
+               GPUx_draw_lines(NULL, NULL, verts, elem);
 
                GPUx_element_list_discard(elem);
                GPUx_vertex_buffer_discard(verts);
@@ -2096,7 +2096,7 @@ static void drawcamera_new_new(Scene *scene, View3D *v3d, 
RegionView3D *rv3d, Ba
                GPUx_set_line_vertices(elem, 9,  6,7);
                GPUx_set_line_vertices(elem, 10, 7,5);
 
-               GPUx_draw_lines(&default_state.common, &default_state.line, 
verts, elem);
+               GPUx_draw_lines(NULL, NULL, verts, elem);
 
                GPUx_element_list_discard(elem);
 
@@ -2107,7 +2107,7 @@ static void drawcamera_new_new(Scene *scene, View3D *v3d, 
RegionView3D *rv3d, Ba
                        elem = GPUx_element_list_create(GL_TRIANGLES, 1, 7);
                        GPUx_set_triangle_vertices(elem, 0,  5,6,7);
 
-                       GPUx_draw_triangles(&default_state.common, 
&default_state.polygon, verts, elem);
+                       GPUx_draw_triangles(NULL, NULL, verts, elem);
 
                        GPUx_element_list_discard(elem);
                }
@@ -4508,7 +4508,7 @@ static bool draw_mesh_object_new_new(Scene *scene, 
ARegion *ar, View3D *v3d, Reg
                        }
 
                        GPUx_vertex_buffer_prime(verts);
-                       GPUx_draw_lines(&default_state.common, 
&default_state.line, verts, elem);
+                       GPUx_draw_lines(NULL, NULL, verts, elem);
                }
 
                if (elem)
diff --git a/source/blender/gpu/intern/gpux_state.c 
b/source/blender/gpu/intern/gpux_state.c
index a447a1d..c5cef43 100644
--- a/source/blender/gpu/intern/gpux_state.c
+++ b/source/blender/gpu/intern/gpux_state.c
@@ -45,6 +45,9 @@ void GPUx_reset_draw_state()
 
 void GPUx_set_common_state(const CommonDrawState *state)
 {
+       if (state == NULL)
+               state = &default_state.common;
+
        if (state->blend != current.common.blend) {
                if (state->blend)
                        glEnable(GL_BLEND);
@@ -80,6 +83,9 @@ void GPUx_set_common_state(const CommonDrawState *state)
 
 void GPUx_set_point_state(const PointDrawState *state)
 {
+       if (state == NULL)
+               state = &default_state.point;
+
        if (state->smooth != current.point.smooth) {
                if (state->smooth)
                        glEnable(GL_POINT_SMOOTH);
@@ -96,6 +102,9 @@ void GPUx_set_point_state(const PointDrawState *state)
 
 void GPUx_set_line_state(const LineDrawState *state)
 {
+       if (state == NULL)
+               state = &default_state.line;
+
        if (state->smooth != current.line.smooth) {
                if (state->smooth)
                        glEnable(GL_LINE_SMOOTH);
@@ -138,12 +147,18 @@ static GLenum faces_to_cull(const PolygonDrawState *state)
 
 void GPUx_set_polygon_state(const PolygonDrawState *state)
 {
-       const GLenum cull = faces_to_cull(state);
-       const GLenum curr_cull = faces_to_cull(&current.polygon);
-       if (cull != curr_cull) {
+       if (state == NULL)
+               state = &default_state.polygon;
+
+       if (state->draw_front != current.polygon.draw_front ||
+           state->draw_back != current.polygon.draw_back) {
+
+               const GLenum cull = faces_to_cull(state);
+
                if (cull == GL_NONE)
                        glDisable(GL_CULL_FACE);
                else {
+                       const GLenum curr_cull = 
faces_to_cull(&current.polygon);
                        if (curr_cull == GL_NONE)
                                glEnable(GL_CULL_FACE);
                        glCullFace(cull);

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

Reply via email to