[Bf-blender-cvs] [5e889ebf19] blender2.8: OpenGL: no more display lists

Mike Erwin noreply at git.blender.org
Tue Feb 28 19:16:06 CET 2017


Commit: 5e889ebf19ae1bd3daf6930473dc1d19029bf837
Author: Mike Erwin
Date:   Tue Feb 28 13:15:11 2017 -0500
Branches: blender2.8
https://developer.blender.org/rB5e889ebf19ae1bd3daf6930473dc1d19029bf837

OpenGL: no more display lists

Part of the OpenGL core profile upgrade (T49165)

Use the Batch drawing API (GPU_batch.h) when you want do draw something multiple times.

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

M	source/blender/editors/space_graph/graph_draw.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/editors/space_view3d/view3d_draw_legacy.c
M	source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp
M	source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h

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

diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index cdc7d62e26..99a3886235 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -388,31 +388,20 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
  */
 static void draw_fcurve_sample_control(float x, float y, float xscale, float yscale, float hsize)
 {
-	static GLuint displist = 0;
-	
-	/* initialize X shape */
-	if (displist == 0) {
-		displist = glGenLists(1);
-		glNewList(displist, GL_COMPILE);
-		
-		glBegin(GL_LINES);
-		glVertex2f(-0.7f, -0.7f);
-		glVertex2f(+0.7f, +0.7f);
-			
-		glVertex2f(-0.7f, +0.7f);
-		glVertex2f(+0.7f, -0.7f);
-		glEnd();  /* GL_LINES */
-		
-		glEndList();
-	}
 	
 	/* adjust view transform before starting */
 	glTranslatef(x, y, 0.0f);
 	glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);
-	
-	/* draw! */
-	glCallList(displist);
-	
+
+	/* draw X shape */
+	glBegin(GL_LINES);
+	glVertex2f(-0.7f, -0.7f);
+	glVertex2f(+0.7f, +0.7f);
+
+	glVertex2f(-0.7f, +0.7f);
+	glVertex2f(+0.7f, -0.7f);
+	glEnd();  /* GL_LINES */
+
 	/* restore view transform */
 	glScalef(xscale / hsize, yscale / hsize, 1.0);
 	glTranslatef(-x, -y, 0.0f);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 52cdaa6291..80f833404d 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -1665,22 +1665,10 @@ bool view3d_camera_border_hack_test = false;
 
 static void draw_bundle_sphere(void)
 {
-	static GLuint displist = 0;
-
-	if (displist == 0) {
-		GLUquadricObj *qobj;
-
-		displist = glGenLists(1);
-		glNewList(displist, GL_COMPILE);
-		qobj = gluNewQuadric();
-		gluQuadricDrawStyle(qobj, GLU_FILL);
-		gluSphere(qobj, 0.05, 8, 8);
-		gluDeleteQuadric(qobj);
-
-		glEndList();
-	}
-
-	glCallList(displist);
+	GLUquadricObj *qobj = gluNewQuadric();
+	gluQuadricDrawStyle(qobj, GLU_FILL);
+	gluSphere(qobj, 0.05, 8, 8);
+	gluDeleteQuadric(qobj);
 }
 
 static void draw_viewport_object_reconstruction(
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index b66bc8897a..8edd3abce0 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -945,11 +945,9 @@ static void draw_dupli_objects_color(
 	LodLevel *savedlod;
 	Base tbase = {NULL};
 	BoundBox bb, *bb_tmp; /* use a copy because draw_object, calls clear_mesh_caches */
-	GLuint displist = 0;
 	unsigned char color_rgb[3];
 	const short dflag_dupli = dflag | DRAW_CONSTCOLOR;
 	short transflag;
-	bool use_displist = false;  /* -1 is initialize */
 	char dt;
 	short dtx;
 	DupliApplyData *apply_data;
@@ -1014,71 +1012,16 @@ static void draw_dupli_objects_color(
 			glColor3ubv(color_rgb);
 		}
 		
-		/* generate displist, test for new object */
-		if (dob_prev && dob_prev->ob != dob->ob) {
-			if (use_displist == true)
-				glDeleteLists(displist, 1);
-			
-			use_displist = false;
-		}
-		
 		if ((bb_tmp = BKE_object_boundbox_get(dob->ob))) {
 			bb = *bb_tmp; /* must make a copy  */
 			testbb = true;
 		}
 
 		if (!testbb || ED_view3d_boundbox_clip_ex(rv3d, &bb, dob->mat)) {
-			/* generate displist */
-			if (use_displist == false) {
-				
-				/* note, since this was added, its checked (dob->type == OB_DUPLIGROUP)
-				 * however this is very slow, it was probably needed for the NLA
-				 * offset feature (used in group-duplicate.blend but no longer works in 2.5)
-				 * so for now it should be ok to - campbell */
-				
-				if ( /* if this is the last no need  to make a displist */
-				     (dob_next == NULL || dob_next->ob != dob->ob) ||
-				     /* lamp drawing messes with matrices, could be handled smarter... but this works */
-				     (dob->ob->type == OB_LAMP) ||
-				     (dob->type == OB_DUPLIGROUP && dob->animated) ||
-				     !bb_tmp ||
-				     draw_glsl_material(scene, dob->ob, v3d, dt) ||
-				     check_object_draw_texture(scene, v3d, dt) ||
-				     (v3d->flag2 & V3D_SOLID_MATCAP) != 0)
-				{
-					// printf("draw_dupli_objects_color: skipping displist for %s\n", dob->ob->id.name + 2);
-					use_displist = false;
-				}
-				else {
-					// printf("draw_dupli_objects_color: using displist for %s\n", dob->ob->id.name + 2);
-					
-					/* disable boundbox check for list creation */
-					BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 1);
-					/* need this for next part of code */
-					unit_m4(dob->ob->obmat);    /* obmat gets restored */
-					
-					displist = glGenLists(1);
-					glNewList(displist, GL_COMPILE);
-					draw_object(scene, sl, ar, v3d, &tbase, dflag_dupli);
-					glEndList();
-					
-					use_displist = true;
-					BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 0);
-				}		
-			}
-			
-			if (use_displist) {
-				glPushMatrix();
-				glMultMatrixf(dob->mat);
-				glCallList(displist);
-				glPopMatrix();
-			}	
-			else {
-				copy_m4_m4(dob->ob->obmat, dob->mat);
-				GPU_begin_dupli_object(dob);
-				draw_object(scene, sl, ar, v3d, &tbase, dflag_dupli);
-				GPU_end_dupli_object();
-			}
+			copy_m4_m4(dob->ob->obmat, dob->mat);
+			GPU_begin_dupli_object(dob);
+			draw_object(scene, sl, ar, v3d, &tbase, dflag_dupli);
+			GPU_end_dupli_object();
 		}
 		
 		tbase.object->dt = dt;
@@ -1093,9 +1036,6 @@ static void draw_dupli_objects_color(
 	}
 
 	free_object_duplilist(lb);
-	
-	if (use_displist)
-		glDeleteLists(displist, 1);
 }
 
 void draw_dupli_objects(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v3d, BaseLegacy *base)
diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp
index 9c462bb6b2..6f5491fc8e 100644
--- a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp
+++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.cpp
@@ -51,7 +51,6 @@ IndexedFaceSet::IndexedFaceSet() : Rep()
 	_MISize = 0;
 	_TIndices = NULL;
 	_TISize = 0;
-	_displayList = 0;
 }
 
 IndexedFaceSet::IndexedFaceSet(float *iVertices, unsigned iVSize, float *iNormals, unsigned iNSize,
@@ -150,8 +149,6 @@ IndexedFaceSet::IndexedFaceSet(float *iVertices, unsigned iVSize, float *iNormal
 		_TISize = iTISize;
 		_TIndices = iTIndices;
 	}
-
-	_displayList = 0;
 }
 
 IndexedFaceSet::IndexedFaceSet(const IndexedFaceSet& iBrother) : Rep(iBrother)
@@ -215,8 +212,6 @@ IndexedFaceSet::IndexedFaceSet(const IndexedFaceSet& iBrother) : Rep(iBrother)
 		_TIndices = new unsigned[_TISize];
 		memcpy(_TIndices, iBrother.tindices(), _TISize * sizeof(unsigned));
 	}
-
-	_displayList = 0;
 }
 
 IndexedFaceSet::~IndexedFaceSet()
@@ -276,10 +271,6 @@ IndexedFaceSet::~IndexedFaceSet()
 		delete[] _TIndices;
 		_TIndices = NULL;
 	}
-
-	// should find a way to deallocates the displayList
-	// glDeleteLists(GLuint list, GLSizei range)
-	_displayList = 0;
 }
 
 void IndexedFaceSet::accept(SceneVisitor& v)
diff --git a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
index 8d7bf986bd..16dea6f907 100644
--- a/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
+++ b/source/blender/freestyle/intern/scene_graph/IndexedFaceSet.h
@@ -150,8 +150,6 @@ public:
 		std::swap(_MISize, ioOther._MISize);
 		std::swap(_TISize, ioOther._TISize);
 
-		std::swap(_displayList, ioOther._displayList);
-
 		Rep::swap(ioOther);
 	}
 
@@ -173,12 +171,6 @@ public:
 	/*! Compute the Bounding Box */
 	virtual void ComputeBBox();
 
-	/*! modifiers */
-	inline void setDisplayList(unsigned int index)
-	{
-		_displayList = index;
-	}
-
 	/*! Accessors */
 	virtual const float *vertices() const
 	{
@@ -280,11 +272,6 @@ public:
 		return _TISize;
 	}
 
-	inline unsigned int displayList() const
-	{
-		return _displayList;
-	}
-
 protected:
 	float *_Vertices;
 	float *_Normals;
@@ -311,8 +298,6 @@ protected:
 	unsigned _MISize;
 	unsigned _TISize;
 
-	unsigned int _displayList;
-
 #ifdef WITH_CXX_GUARDEDALLOC
 	MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:IndexedFaceSet")
 #endif




More information about the Bf-blender-cvs mailing list