[Bf-blender-cvs] [8e02106d0dd] blender2.8: GLRefactor: partially remove gl calls from source/blender/editors.

Ray Molenkamp noreply at git.blender.org
Thu Jun 28 03:07:32 CEST 2018


Commit: 8e02106d0ddc7b31844d26037a824d56d3c65663
Author: Ray Molenkamp
Date:   Wed Jun 27 19:07:23 2018 -0600
Branches: blender2.8
https://developer.blender.org/rB8e02106d0ddc7b31844d26037a824d56d3c65663

GLRefactor: partially remove gl calls from source/blender/editors.

This translates the gl calls to the new GPU_ wrappers from D3501.

Given it's tedious and repetitive work, this patch does as much as it can with search + replace, the remainder of the gl calls will need to be manually dealt with on a case by case basis.

This fixes 13 of the 28 failing editors when building without opengl.

For the list of substitutions see D3502

Reviewers: brecht

Differential Revision: https://developer.blender.org/D3502

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

M	source/blender/editors/animation/anim_channels_defines.c
M	source/blender/editors/animation/anim_draw.c
M	source/blender/editors/animation/anim_markers.c
M	source/blender/editors/animation/keyframes_draw.c
M	source/blender/editors/curve/editcurve_paint.c
M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/editors/gpencil/gpencil_brush.c
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/interface/interface_region_hud.c
M	source/blender/editors/interface/interface_region_search.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/interface/resources.c
M	source/blender/editors/interface/view2d.c
M	source/blender/editors/manipulator_library/manipulator_draw_utils.c
M	source/blender/editors/manipulator_library/manipulator_types/arrow2d_manipulator.c
M	source/blender/editors/manipulator_library/manipulator_types/arrow3d_manipulator.c
M	source/blender/editors/manipulator_library/manipulator_types/button2d_manipulator.c
M	source/blender/editors/manipulator_library/manipulator_types/cage2d_manipulator.c
M	source/blender/editors/manipulator_library/manipulator_types/cage3d_manipulator.c
M	source/blender/editors/manipulator_library/manipulator_types/dial3d_manipulator.c
M	source/blender/editors/manipulator_library/manipulator_types/grab3d_manipulator.c
M	source/blender/editors/manipulator_library/manipulator_types/primitive3d_manipulator.c
M	source/blender/editors/mask/mask_draw.c
M	source/blender/editors/mesh/editmesh_knife.c
M	source/blender/editors/mesh/editmesh_loopcut.c
M	source/blender/editors/physics/particle_edit.c
M	source/blender/editors/render/render_opengl.c
M	source/blender/editors/screen/area.c
M	source/blender/editors/screen/glutil.c
M	source/blender/editors/screen/screen_draw.c
M	source/blender/editors/screen/screendump.c
M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/editors/sculpt_paint/paint_image.c
M	source/blender/editors/sculpt_paint/paint_stroke.c
M	source/blender/editors/sculpt_paint/paint_utils.c
M	source/blender/editors/sculpt_paint/sculpt_uv.c
M	source/blender/editors/space_action/action_draw.c
M	source/blender/editors/space_action/space_action.c
M	source/blender/editors/space_clip/clip_dopesheet_draw.c
M	source/blender/editors/space_clip/clip_draw.c
M	source/blender/editors/space_clip/clip_graph_draw.c
M	source/blender/editors/space_clip/clip_utils.c
M	source/blender/editors/space_clip/space_clip.c
M	source/blender/editors/space_console/space_console.c
M	source/blender/editors/space_file/file_draw.c
M	source/blender/editors/space_file/space_file.c
M	source/blender/editors/space_graph/graph_draw.c
M	source/blender/editors/space_graph/space_graph.c
M	source/blender/editors/space_image/image_draw.c
M	source/blender/editors/space_image/space_image.c
M	source/blender/editors/space_info/info_draw.c
M	source/blender/editors/space_info/space_info.c
M	source/blender/editors/space_info/textview.c
M	source/blender/editors/space_nla/nla_draw.c
M	source/blender/editors/space_nla/space_nla.c
M	source/blender/editors/space_node/drawnode.c
M	source/blender/editors/space_node/node_draw.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/outliner_ops.c
M	source/blender/editors/space_outliner/space_outliner.c
M	source/blender/editors/space_script/space_script.c
M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/editors/space_text/space_text.c
M	source/blender/editors/space_text/text_draw.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/editors/space_view3d/drawvolume.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/editors/space_view3d/view3d_draw_legacy.c
M	source/blender/editors/space_view3d/view3d_manipulator_navigate_type.c
M	source/blender/editors/space_view3d/view3d_manipulator_ruler.c
M	source/blender/editors/space_view3d/view3d_ruler.c
M	source/blender/editors/space_view3d/view3d_view.c
M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform_constraints.c
M	source/blender/editors/transform/transform_snap.c
M	source/blender/editors/util/ed_util.c
M	source/blender/editors/uvedit/uvedit_draw.c
M	source/blender/editors/uvedit/uvedit_smart_stitch.c

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

diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index e4213a8d907..f0bde9dcdfb 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -70,6 +70,7 @@
 #include "BKE_context.h"
 
 #include "GPU_immediate.h"
+#include "GPU_state.h"
 
 #include "DEG_depsgraph.h"
 
@@ -3832,8 +3833,8 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
 		selected = 0;
 
 	/* set blending again, as may not be set in previous step */
-	glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-	glEnable(GL_BLEND);
+	GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+	GPU_blend(true);
 
 	/* step 1) draw backdrop ...........................................  */
 	if (acf->draw_backdrop)
@@ -3852,7 +3853,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
 	}
 
 	/* turn off blending, since not needed anymore... */
-	glDisable(GL_BLEND);
+	GPU_blend(false);
 
 	/* step 4) draw special toggles  .................................
 	 *	- in Graph Editor, checkboxes for visibility in curves area
@@ -3930,7 +3931,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float
 			/* FIXME: replace hardcoded color here, and check on extents! */
 			immUniformColor3f(1.0f, 0.0f, 0.0f);
 
-			glLineWidth(2.0f);
+			GPU_line_width(2.0f);
 
 			immBegin(GWN_PRIM_LINES, 2);
 			immVertex2f(pos, (float)offset, yminc);
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index c2cfb877745..953898a0586 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -64,6 +64,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 /* *************************************************** */
 /* CURRENT FRAME DRAWING */
@@ -138,7 +139,7 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag)
 	const float time = scene->r.cfra + scene->r.subframe;
 	const float x = (float)(time * scene->r.framelen);
 
-	glLineWidth((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0);
+	GPU_line_width((flag & DRAWCFRA_WIDE) ? 3.0 : 2.0);
 
 	Gwn_VertFormat *format = immVertexFormat();
 	unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -166,8 +167,8 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
 
 	/* only draw this if preview range is set */
 	if (PRVRANGEON) {
-		glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-		glEnable(GL_BLEND);
+		GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+		GPU_blend(true);
 
 		Gwn_VertFormat *format = immVertexFormat();
 		unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -187,7 +188,7 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
 
 		immUnbindProgram();
 
-		glDisable(GL_BLEND);
+		GPU_blend(false);
 	}
 }
 
@@ -199,8 +200,8 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width)
 void ANIM_draw_framerange(Scene *scene, View2D *v2d)
 {
 	/* draw darkened area outside of active timeline frame range */
-	glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
-	glEnable(GL_BLEND);
+	GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+	GPU_blend(true);
 
 	Gwn_VertFormat *format = immVertexFormat();
 	unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
@@ -216,7 +217,7 @@ void ANIM_draw_framerange(Scene *scene, View2D *v2d)
 		immRectf(pos, v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax);
 	}
 
-	glDisable(GL_BLEND);
+	GPU_blend(false);
 
 	/* thin lines where the actual frames are */
 	immUniformThemeColorShade(TH_BACK, -60);
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index c4fbc86a389..2815bc58d7a 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -61,6 +61,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "UI_interface.h"
 #include "UI_interface_icons.h"
@@ -389,8 +390,8 @@ static void draw_marker(
 #endif
 	int icon_id;
 
-	glEnable(GL_BLEND);
-	glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+	GPU_blend(true);
+	GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
 	/* vertical line - dotted */
 #ifdef DURIAN_CAMERA_SWITCH
@@ -405,7 +406,7 @@ static void draw_marker(
 		immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
 
 		float viewport_size[4];
-		glGetFloatv(GL_VIEWPORT, viewport_size);
+		GPU_viewport_size_getf(viewport_size);
 		immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
 
 		if (marker->flag & SELECT) {
@@ -444,7 +445,7 @@ static void draw_marker(
 
 	UI_icon_draw(xpos - 0.45f * UI_DPI_ICON_SIZE, yoffs + UI_DPI_ICON_SIZE, icon_id);
 
-	glDisable(GL_BLEND);
+	GPU_blend(false);
 
 	/* and the marker name too, shifted slightly to the top-right */
 #ifdef DURIAN_CAMERA_SWITCH
@@ -491,12 +492,12 @@ void ED_markers_draw(const bContext *C, int flag)
 		const unsigned char shade[4] = {0, 0, 0, 16};
 		immUniformColor4ubv(shade);
 
-		glEnable(GL_BLEND);
-		glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+		GPU_blend(true);
+		GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
 
 		immRectf(pos, v2d->cur.xmin, 0, v2d->cur.xmax, UI_MARKER_MARGIN_Y);
 
-		glDisable(GL_BLEND);
+		GPU_blend(false);
 
 		immUnbindProgram();
 	}
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index d1377703949..859eb05e7b9 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -54,6 +54,7 @@
 
 #include "GPU_draw.h"
 #include "GPU_immediate.h"
+#include "GPU_state.h"
 
 #include "UI_resources.h"
 #include "UI_view2d.h"
@@ -561,7 +562,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
 	const float icon_sz = U.widget_unit * 0.5f * yscale_fac;
 	const float half_icon_sz = 0.5f * icon_sz;
 
-	glEnable(GL_BLEND);
+	GPU_blend(true);
 
 	/* locked channels are less strongly shown, as feedback for locked channels in DopeSheet */
 	/* TODO: allow this opacity factor to be themed? */
@@ -654,7 +655,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
 		}
 	}
 
-	glDisable(GL_BLEND);
+	GPU_blend(false);
 }
 
 /* *************************** Channel Drawing Funcs *************************** */
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 887f3dd13da..e679b04f25d 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -53,6 +53,7 @@
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
 #include "GPU_matrix.h"
+#include "GPU_state.h"
 
 #include "curve_intern.h"
 
@@ -433,15 +434,15 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
 			unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
 			immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
 
-			glEnable(GL_BLEND);
-			glEnable(GL_LINE_SMOOTH);
+			GPU_blend(true);
+			GPU_line_smooth(true);
 
 			imm_cpack(0x0);
 			immBegin(GWN_PRIM_LINE_STRIP, stroke_len);
-			glLineWidth(3.0f);
+			GPU_line_width(3.0f);
 
 			if (v3d->zbuf) {
-				glDisable(GL_DEPTH_TEST);
+				GPU_depth_test(false);
 			}
 
 			for (int i = 0; i < stroke_len; i++) {
@@ -452,7 +453,7 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
 
 			imm_cpack(0xffffffff);
 			immBegin(GWN_PRIM_LINE_STRIP, stroke_len);
-			glLineWidth(1.0f);
+			GPU_line_width(1.0f);
 
 			for (int i = 0; i < stroke_len; i++) {
 				immVertex3fv(pos, coord_array[i]);
@@ -461,11 +462,11 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
 			immEnd();
 
 			if (v3d->zbuf) {
-				glEnable(GL_DEPTH_TEST);
+				GPU_depth_test(true);
 			}
 
-			glDisable(GL_BLEND);
-			glDisable(GL_LINE_SMOOTH);
+			GPU_blend(false);
+			GPU_line_smooth(false);
 
 			immUnbindProgram();
 		}
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index a30cb578046..a79a5052eb8 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -64,6 +64,7 @@
 
 #include "GPU_immediate.h"
 #include "GPU_draw.h"
+#include "GPU_state.h"
 
 #include "ED_gpencil.h"
 #include "ED_screen.h"
@@ -215,7 +216,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
 
 	if (totpoints == 1) {
 		/* if drawing a single point, draw it larger */
-		glPointSize((float)(thickness + 2) * points->pressure);
+		GPU_point_size((float)(thickness + 2) * points->pressure);
 		immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR);
 		immBegin(GWN_PRIM_POINTS, 1);
 		gp_set_tpoint_varying_color(pt, ink, color);
@@ -225,7 +226,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
 		float oldpressure = points[0].pressure;
 
 		/* draw stroke curve */
-		glLineWidth(max_ff(oldpressure * thickness, 1.0));
+		GPU_line_width(max_ff(oldpressure * thickness, 1.0));
 		immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
 		immBeginAtMost(GWN_PRIM_LINE_STRIP, totpoints);
 
@@ -245,7 +246,7 @@ static void gp_draw_stroke_buffer(const tGPspoint *points, int totpoints, short
 				immEnd();
 				draw_points = 0;
 
-				glLineWidth(max_ff(pt-

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list