[Bf-blender-cvs] [7a75581d92a] blender2.8: OpenGL: transition away from GL_QUADS

Mike Erwin noreply at git.blender.org
Fri Apr 7 21:11:51 CEST 2017


Commit: 7a75581d92ad1df005f1da23a84a3d0aea20188e
Author: Mike Erwin
Date:   Fri Apr 7 15:03:24 2017 -0400
Branches: blender2.8
https://developer.blender.org/rB7a75581d92ad1df005f1da23a84a3d0aea20188e

OpenGL: transition away from GL_QUADS

Single quads are drawn as a TRIANGLE_FAN, with 4 verts in the same order.

Multiple quads now use PRIM_QUADS_XXX and will need further work. Only 8 places still use this.

Part of T49043

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

M	source/blender/blenfont/intern/blf_font.c
M	source/blender/draw/intern/draw_view.c
M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/editors/space_clip/clip_draw.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_sequencer/sequencer_draw.c
M	source/blender/editors/space_time/space_time.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/windowmanager/intern/wm_draw.c
M	source/blender/windowmanager/intern/wm_gesture.c
M	source/blender/windowmanager/intern/wm_operators.c
M	source/blender/windowmanager/intern/wm_stereo.c

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

diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index d0293eccf3a..3702c70be35 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -206,7 +206,7 @@ static void blf_font_draw_ex(
 
 	blf_font_ensure_ascii_table(font);
 
-	immBeginAtMost(GL_QUADS, verts_needed(font, str, len));
+	immBeginAtMost(PRIM_QUADS_XXX, verts_needed(font, str, len));
 	/* at most because some glyphs might be clipped & not drawn */
 
 	while ((i < len) && str[i]) {
@@ -253,7 +253,7 @@ static void blf_font_draw_ascii_ex(
 
 	blf_font_ensure_ascii_table(font);
 
-	immBeginAtMost(GL_QUADS, verts_needed(font, str, len));
+	immBeginAtMost(PRIM_QUADS_XXX, verts_needed(font, str, len));
 
 	while ((c = *(str++)) && len--) {
 		BLI_assert(c < 128);
@@ -293,7 +293,7 @@ int blf_font_draw_mono(FontBLF *font, const char *str, size_t len, int cwidth)
 
 	blf_font_ensure_ascii_table(font);
 
-	immBeginAtMost(GL_QUADS, verts_needed(font, str, len));
+	immBeginAtMost(PRIM_QUADS_XXX, verts_needed(font, str, len));
 
 	while ((i < len) && str[i]) {
 		BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table);
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index a0f0fb1a9ee..b5f4a13587d 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -568,7 +568,7 @@ void DRW_draw_background(void)
 		UI_GetThemeColor3ubv(TH_LOW_GRAD, col_lo);
 		UI_GetThemeColor3ubv(TH_HIGH_GRAD, col_hi);
 
-		immBegin(GL_QUADS, 4);
+		immBegin(PRIM_TRIANGLE_FAN, 4);
 		immAttrib3ubv(color, col_lo);
 		immVertex2f(pos, -1.0f, -1.0f);
 		immVertex2f(pos, 1.0f, -1.0f);
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 229aecc21ae..7e33de7b271 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -740,7 +740,7 @@ static void gp_draw_stroke_2d(const bGPDspoint *points, int totpoints, short thi
 		unsigned int color = VertexFormat_add_attrib(format, "color", COMP_U8, 4, NORMALIZE_INT_TO_FLOAT);
 
 		immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR);
-		immBegin(GL_QUADS, (totpoints - 2) * 4 + 12);
+		immBegin(PRIM_QUADS_XXX, (totpoints - 2) * 4 + 12);
 
 		for (i = 0, pt1 = points, pt2 = points + 1; i < (totpoints - 1); i++, pt1++, pt2++) {
 			float s0[2], s1[2];     /* segment 'center' points */
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 89d9fe992ba..5e4cb9c1ba1 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1195,7 +1195,7 @@ static void ui_draw_colorband_handle_tri(unsigned int pos, float x1, float y1, f
 
 static void ui_draw_colorband_handle_box(unsigned int pos, float x1, float y1, float x2, float y2, bool fill)
 {
-	immBegin(fill ? GL_QUADS : GL_LINE_LOOP, 4);
+	immBegin(fill ? PRIM_TRIANGLE_FAN : PRIM_LINE_LOOP, 4);
 	immVertex2f(pos, x1, y1);
 	immVertex2f(pos, x1, y2);
 	immVertex2f(pos, x2, y2);
@@ -1916,6 +1916,9 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
 
 /* ****************************************************** */
 
+/* TODO: high quality UI drop shadows using GLSL shader and single draw call
+ * would replace / modify the following 3 functions  - merwin
+ */
 
 static void ui_shadowbox(unsigned pos, unsigned color, float minx, float miny, float maxx, float maxy, float shadsize, unsigned char alpha)
 {
@@ -1954,7 +1957,7 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx,
 
 	immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR);
 
-	immBegin(GL_QUADS, 36);
+	immBegin(PRIM_QUADS_XXX, 36);
 
 	/* accumulated outline boxes to make shade not linear, is more pleasant */
 	ui_shadowbox(pos, color, minx, miny, maxx, maxy, 11.0, (20 * alpha) >> 8);
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 44ef95ee0b6..9405de93cc5 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -684,7 +684,7 @@ static void paint_draw_tex_overlay(UnifiedPaintSettings *ups, Brush *brush,
 		/* draw textured quad */
 		immUniform1i("image", GL_TEXTURE0);
 
-		immBegin(GL_QUADS, 4);
+		immBegin(PRIM_TRIANGLE_FAN, 4);
 		immAttrib2f(texCoord, 0.0f, 0.0f);
 		immVertex2f(pos, quad.xmin, quad.ymin);
 		immAttrib2f(texCoord, 1.0f, 0.0f);
@@ -773,7 +773,7 @@ static void paint_draw_cursor_overlay(UnifiedPaintSettings *ups, Brush *brush,
 		/* draw textured quad */
 		immUniform1i("image", GL_TEXTURE0);
 
-		immBegin(GL_QUADS, 4);
+		immBegin(PRIM_TRIANGLE_FAN, 4);
 		immAttrib2f(texCoord, 0.0f, 0.0f);
 		immVertex2f(pos, quad.xmin, quad.ymin);
 		immAttrib2f(texCoord, 1.0f, 0.0f);
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index dc40f083bc6..274e9b0f684 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -1108,7 +1108,7 @@ static void draw_plane_marker_image(Scene *scene,
 			immUniform4f("color", 1.0f, 1.0f, 1.0f, plane_track->image_opacity);
 			immUniform1i("image", GL_TEXTURE0);
 
-			immBegin(GL_QUADS, 4);
+			immBegin(PRIM_TRIANGLE_FAN, 4);
 
 			immAttrib2f(texCoord, 0.0f, 0.0f);
 			immVertex2f(pos, 0.0f, 0.0f);
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index cfe6e6a2bb5..92193e93fbe 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1799,7 +1799,7 @@ static void outliner_back(ARegion *ar)
 	int tot = (int)floor(ystart - ar->v2d.cur.ymin + 2 * UI_UNIT_Y) / (2 * UI_UNIT_Y);
 
 	if (tot > 0) {
-		immBegin(GL_QUADS, 4 * tot);
+		immBegin(PRIM_QUADS_XXX, 4 * tot);
 		while (tot--) {
 			y1 -= 2 * UI_UNIT_Y;
 			y2 = y1 + UI_UNIT_Y;
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index a7a638d0952..13847efd22a 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1313,7 +1313,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
 	immUniform4f("color", 1.0f, 1.0f, 1.0f, 1.0f);
 	immUniform1i("image", GL_TEXTURE0);
 
-	immBegin(GL_QUADS, 4);
+	immBegin(PRIM_TRIANGLE_FAN, 4);
 
 	if (draw_overlay) {
 		if (sseq->overlay_type == SEQ_DRAW_OVERLAY_RECT) {
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index 9844a8053db..7dbf99dda90 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -215,7 +215,7 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene)
 		immUniformColor4fv(col);
 
 		if (len > 0) {
-			immBeginAtMost(GL_QUADS, len);
+			immBeginAtMost(PRIM_QUADS_XXX, len);
 
 			/* draw a quad for each cached frame */
 			for (int i = sta; i <= end; i++) {
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 726a67a5d74..291592a0a4c 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -1876,7 +1876,7 @@ static void draw_viewport_reconstruction(
 /* camera frame */
 static void drawcamera_frame(float vec[4][3], bool filled, unsigned pos)
 {
-	immBegin(filled ? GL_QUADS : GL_LINE_LOOP, 4);
+	immBegin(filled ? PRIM_TRIANGLE_FAN : PRIM_LINE_LOOP, 4);
 	immVertex3fv(pos, vec[0]);
 	immVertex3fv(pos, vec[1]);
 	immVertex3fv(pos, vec[2]);
@@ -1905,7 +1905,7 @@ static void drawcamera_volume(float near_plane[4][3], float far_plane[4][3], boo
 	drawcamera_frame(far_plane, filled, pos);
 
 	if (filled) {
-		immBegin(GL_QUADS, 16); /* TODO(merwin): use GL_TRIANGLE_STRIP here */
+		immBegin(PRIM_QUADS_XXX, 16); /* TODO(merwin): use PRIM_TRIANGLE_STRIP here */
 		immVertex3fv(pos, near_plane[0]);
 		immVertex3fv(pos, far_plane[0]);
 		immVertex3fv(pos, far_plane[1]);
@@ -5582,7 +5582,7 @@ static bool drawDispList(Scene *scene, SceneLayer *sl, View3D *v3d, RegionView3D
 /* *********** drawing for particles ************* */
 /* stride :   offset size in bytes
  * col[4] :   the color to use when *color is NULL, can be also NULL */
-static void draw_vertex_array(int dt, const float *vert, const float *nor, const float *color, int stride, int vert_ct, float col[4])
+static void draw_vertex_array(PrimitiveType prim_type, const float *vert, const float *nor, const float *color, int stride, int vert_ct, float col[4])
 {
 	VertexFormat format = {0};
 	unsigned int pos_id, nor_id, col_id;
@@ -5604,7 +5604,7 @@ static void draw_vertex_array(int dt, const float *vert, const float *nor, const
 		if (color) VertexBuffer_fill_attrib_stride(vbo, col_id, stride, color);
 	}
 
-	Batch *batch = Batch_create(dt, vbo, NULL);
+	Batch *batch = Batch_create(prim_type, vbo, NULL);
 	if (nor && color) {
 		Batch_set_builtin_program(batch, GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR);
 		Batch_Uniform3f(batch, "light", 0.0f, 0.0f, 1.0f);
@@ -5624,6 +5624,7 @@ static void draw_vertex_array(int dt, const float *vert, const float *nor, const
 	Batch_draw(batch);
 	Batch_discard_all(batch);
 }
+
 static void draw_particle_arrays_new(int draw_as, int ob_dt, int select,
                                      const float *vert, const float *nor, const float *color,
                                      int totpoint, float col[4])
@@ -5643,7 +5644,7 @@ static void draw_particle_arrays_new(int draw_as, int ob_dt, int select,
 			else
 				glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
 
-			draw_vertex_array(GL_QUADS, vert, nor, color, 0, 4 * totpoint, col);
+			draw_vertex_array(PRIM_QUADS_XXX, vert, nor, color, 0, 4 * totpoint, col);
 			break;
 		default:
 			draw_vertex_array(GL_POINTS, vert, nor, color, 0, totpoint, col);
@@ -8000,11 +8001,11 @@ static void imm_draw_box(const float vec[8][3

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list