[Bf-blender-cvs] [2d71d13] master: OpenGL: fixes related to GL_POINTS

Mike Erwin noreply at git.blender.org
Sat Jan 16 05:52:06 CET 2016


Commit: 2d71d13ea2cb7a7640e5139dc24341bd58416d57
Author: Mike Erwin
Date:   Fri Jan 15 22:59:42 2016 -0500
Branches: master
https://developer.blender.org/rB2d71d13ea2cb7a7640e5139dc24341bd58416d57

OpenGL: fixes related to GL_POINTS

I put all usage of GL_POINTS under the microscope. Fixed problems &
optimized a couple of spots.

- reduce calls to glPointSize by about 50%
- draw selected & unselected vertices together for UV editor & EditMesh
- draw initial gpencil stroke point the proper size
- a few other smaller fixes

New policy: each GL_POINTS draw call needs to set its desired point
size. This eliminates half our calls to glPointSize (setting it back to
its 1.0 default after every draw).

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

M	source/blender/editors/armature/reeb.c
M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/mask/mask_draw.c
M	source/blender/editors/mesh/editmesh_loopcut.c
M	source/blender/editors/space_clip/clip_draw.c
M	source/blender/editors/space_graph/graph_draw.c
M	source/blender/editors/space_view3d/drawanimviz.c
M	source/blender/editors/space_view3d/drawarmature.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/editors/space_view3d/drawsimdebug.c
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/editors/uvedit/uvedit_draw.c
M	source/blender/editors/uvedit/uvedit_smart_stitch.c
M	source/blender/gpu/intern/gpu_compositing.c

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

diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c
index a1c1f4f..2d58689 100644
--- a/source/blender/editors/armature/reeb.c
+++ b/source/blender/editors/armature/reeb.c
@@ -3432,7 +3432,6 @@ void REEB_draw()
 	glEnable(GL_DEPTH_TEST);
 	
 	glLineWidth(1.0);
-	glPointSize(1.0);
 }
 
 #endif
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index f207c71..d5c7c52 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -105,9 +105,9 @@ static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickn
 	if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D))
 		return;
 	
-	/* if drawing a single point, draw it larger */
 	if (totpoints == 1) {
-		/* draw point */
+		/* if drawing a single point, draw it larger */
+		glPointSize((float)(thickness + 2) * points->pressure);
 		glBegin(GL_POINTS);
 		glVertex2iv(&points->x);
 		glEnd();
@@ -1123,7 +1123,6 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy,
 	
 	/* restore initial gl conditions */
 	glLineWidth(1.0);
-	glPointSize(1.0);
 	glColor4f(0, 0, 0, 1);
 }
 
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index e7f5f1b..749fa22 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -728,6 +728,8 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
 		/* LUMA (1 channel) */
 		glBlendFunc(GL_ONE, GL_ONE);
 		glColor3f(alpha, alpha, alpha);
+		glPointSize(1.0);
+
 		if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) {
 
 			glBlendFunc(GL_ONE, GL_ONE);
@@ -944,6 +946,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
 		glScalef(diam, diam, 0.f);
 
 		glVertexPointer(2, GL_FLOAT, 0, scopes->vecscope);
+		glPointSize(1.0);
 		glDrawArrays(GL_POINTS, 0, scopes->waveform_tot);
 		
 		glDisableClientState(GL_VERTEX_ARRAY);
@@ -1517,7 +1520,6 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti
 		glVertex2fv(fac);
 	}
 	glEnd();
-	glPointSize(1.0f);
 	
 	/* restore scissortest */
 	glScissor(scissor[0], scissor[1], scissor[2], scissor[3]);
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 727c2d8..74af0aa 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -387,8 +387,6 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline
 		draw_circle(x, y, 6.0f, false, xscale, yscale);
 	}
 
-	glPointSize(1.0f);
-
 	if (is_smooth) {
 		glDisable(GL_LINE_SMOOTH);
 		glDisable(GL_BLEND);
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index 7236b41..c35a360 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -117,8 +117,6 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
 			glVertexPointer(3, GL_FLOAT, 0, lcd->points);
 			glDrawArrays(GL_POINTS, 0, lcd->totpoint);
 			glDisableClientState(GL_VERTEX_ARRAY);
-
-			glPointSize(1.0f);
 		}
 
 		glPopMatrix();
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index e00ebc1..77934bb 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -467,7 +467,6 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
 		glVertex2f(path[i][0], path[i][1]);
 	}
 	glEnd();
-	glPointSize(1.0f);
 }
 
 static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
@@ -495,12 +494,10 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
 		if (isect_point_quad_v2(p, marker->pattern_corners[0], marker->pattern_corners[1],
 		                        marker->pattern_corners[2], marker->pattern_corners[3]))
 		{
-			if (tiny) glPointSize(3.0f);
-			else glPointSize(4.0f);
+			glPointSize(tiny ? 3.0f : 4.0f);
 			glBegin(GL_POINTS);
 			glVertex2f(pos[0], pos[1]);
 			glEnd();
-			glPointSize(1.0f);
 		}
 		else {
 			if (!tiny) glLineWidth(3.0f);
@@ -612,15 +609,10 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
 		if (isect_point_quad_v2(p, marker->pattern_corners[0], marker->pattern_corners[1],
 		                        marker->pattern_corners[2], marker->pattern_corners[3]))
 		{
-			if (!tiny)
-				glPointSize(2.0f);
-
+			glPointSize(tiny ? 1.0f : 2.0f);
 			glBegin(GL_POINTS);
 			glVertex2f(pos[0], pos[1]);
 			glEnd();
-
-			if (!tiny)
-				glPointSize(1.0f);
 		}
 		else {
 			glBegin(GL_LINES);
@@ -1451,7 +1443,6 @@ static void draw_tracking_tracks(SpaceClip *sc, Scene *scene, ARegion *ar, Movie
 			track = track->next;
 		}
 
-		glPointSize(1.0f);
 		glDisable(GL_POINT_SMOOTH);
 	}
 
@@ -1677,7 +1668,6 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
 		}
 
 		glLineWidth(1.0f);
-		glPointSize(1.0f);
 	}
 
 	glPopMatrix();
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 5e17476..b5b308f 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -112,9 +112,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
 			glVertex2f(fed->time, fed->max);
 		}
 	}
-	glEnd();  /* GL_POINTS */
-	
-	glPointSize(1.0f);
+	glEnd();
 }
 
 /* *************************** */
@@ -152,7 +150,7 @@ static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo),
 		}
 	}
 	
-	glEnd();  /* GL_POINTS */
+	glEnd();
 }
 
 
@@ -288,8 +286,6 @@ static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short
 	
 	set_fcurve_vertex_color(fcu, 1);
 	draw_fcurve_vertices_keyframes(fcu, sipo, v2d, !(fcu->flag & FCURVE_PROTECTED), 1);
-	
-	glPointSize(1.0f);
 }
 
 /* Handles ---------------- */
@@ -915,8 +911,6 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
 			glBegin(GL_POINTS);
 			glVertex2f(x, y);
 			glEnd();
-			
-			glPointSize(1.0f);
 		}
 	}
 }
diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c
index d753ad6..9872b05 100644
--- a/source/blender/editors/space_view3d/drawanimviz.c
+++ b/source/blender/editors/space_view3d/drawanimviz.c
@@ -220,7 +220,6 @@ void draw_motion_path_instance(Scene *scene,
 		glVertex3fv(mpv->co);
 		glEnd();
 		
-		glPointSize(1.0f);
 		UI_ThemeColor(TH_TEXT_HI);
 	}
 	
@@ -305,8 +304,6 @@ void draw_motion_path_instance(Scene *scene,
 		}
 		glEnd();
 		
-		glPointSize(1.0f);
-		
 		/* Draw frame numbers of keyframes  */
 		if (avs->path_viewflag & MOTIONPATH_VIEW_KFNOS) {
 			float co[3];
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index e35c700..6a3e8f2 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -1000,6 +1000,12 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned
 	/* this chunk not in object mode */
 	if (armflag & (ARM_EDITMODE | ARM_POSEMODE)) {
 		glLineWidth(4.0f);
+		if (G.f & G_PICKSEL) {
+			/* no bitmap in selection mode, crashes 3d cards...
+			 * instead draw a solid point the same size */
+			glPointSize(8.0f);
+		}
+
 		if (armflag & ARM_POSEMODE)
 			set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
 		else if (armflag & ARM_EDITMODE) {
@@ -1008,7 +1014,7 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned
 		
 		/*	Draw root point if we are not connected */
 		if ((boneflag & BONE_CONNECTED) == 0) {
-			if (G.f & G_PICKSEL) {  /* no bitmap in selection mode, crashes 3d cards... */
+			if (G.f & G_PICKSEL) {
 				GPU_select_load_id(id | BONESEL_ROOT);
 				glBegin(GL_POINTS);
 				glVertex3f(0.0f, 0.0f, 0.0f);
@@ -2587,7 +2593,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base)
 
 /* ********************************** Armature Drawing - Main ************************* */
 
-/* called from drawobject.c, return 1 if nothing was drawn
+/* called from drawobject.c, return true if nothing was drawn
  * (ob_wire_col == NULL) when drawing ghost */
 bool draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
                    const short dt, const short dflag, const unsigned char ob_wire_col[4],
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index de79468..5b95c04 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -135,7 +135,6 @@ typedef struct drawDMVerts_userData {
 	unsigned char th_vertex_select[4];
 	unsigned char th_vertex[4];
 	unsigned char th_skin_root[4];
-	float th_vertex_size;
 
 	/* for skin node drawing */
 	int cd_vskin_offset;
@@ -972,7 +971,6 @@ static void drawshadbuflimits(Lamp *la, float mat[4][4])
 	glVertex3fv(sta);
 	glVertex3fv(end);
 	glEnd();
-	glPointSize(1.0);
 }
 
 static void spotvolume(float lvec[3], float vvec[3], const float inp)
@@ -1501,7 +1499,6 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
 	glBegin(GL_POINTS);
 	glVertex3fv(vec);
 	glEnd();
-	glPointSize(1.0);
 	
 	glDisable(GL_BLEND);
 	
@@ -1529,7 +1526,6 @@ static void draw_limit_line(float sta, float end, const short dflag, const unsig
 		glVertex3f(0.0, 0.0, -sta);
 		glVertex3f(0.0, 0.0, -end);
 		glEnd();
-		glPointSize(1.0);
 	}
 }
 
@@ -2234,7 +2230,6 @@ static void lattice_draw_verts(Lattice *lt, DispList *dl, BPoint *actbp, short s
 	}
 	
 	glEnd();
-	glPointSize(1.0);
 }
 
 static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, int actdef_wcol)
@@ -2567,20 +2562,13 @@ static void draw_dm_verts__mapFunc(void *userData, int index, const float co[3],
 			}
 		}
 
-		/* draw a

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list