← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 1975: 1- move subdivideTriangle in the glNewList section. No reason to do that elsewhere.

 

------------------------------------------------------------
revno: 1975
committer: Bruno Chareyre <bchareyre@r1arduina>
branch nick: trunk
timestamp: Mon 2010-01-18 12:06:09 +0100
message:
  1- move subdivideTriangle in the glNewList section. No reason to do that elsewhere.
  2- Suggest using glList even when stripes=false (commented code) for better performance.
  Both changes affected by this bug for now : https://bugs.launchpad.net/yade/+bug/509084.
modified:
  pkg/common/RenderingEngine/Gl1_Sphere.cpp


--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription.
=== modified file 'pkg/common/RenderingEngine/Gl1_Sphere.cpp'
--- pkg/common/RenderingEngine/Gl1_Sphere.cpp	2010-01-05 20:02:43 +0000
+++ pkg/common/RenderingEngine/Gl1_Sphere.cpp	2010-01-18 11:06:09 +0000
@@ -28,7 +28,17 @@
 		if (wire || wire2) glutWireSphere(r,glutSlices,glutStacks);
 		else {
  			if(stripes) { glScalef(r,r,r); drawSphere();}
-			else glutSolidSphere(r,glutSlices,glutStacks);
+			else {
+// 				if(glSphereList<0) {
+// 					glSphereList = glGenLists(1);
+// 					glNewList(glSphereList,GL_COMPILE);
+// 					//glShadeModel(GL_SMOOTH); glDisable(GL_LIGHTING);
+// 					glutSolidSphere(1,glutSlices,glutStacks);
+// 					glEndList();}
+// 				
+// 				glScalef(r,r,r);
+// 				glCallList(glSphereList);}
+				glutSolidSphere(r,glutSlices,glutStacks);}
 		}
 	if(glutNormalize) glPopAttrib();
 	return;
@@ -44,15 +54,10 @@
 // https://blueprints.launchpad.net/yade/+spec/sphere-gl-stripes
 
 void Gl1_Sphere::drawSphere(){
-	int depth=1; // used to be function argument, but called only from 1 place, always with 1
-	if(vertices.size()==0) initGlLists();
+	if(glSphereList<0) initGlLists();
 	glShadeModel(GL_SMOOTH);
 	//glScalef(radius,radius,radius);
 	glCallList(glSphereList);
-	// render the sphere now
-	for(int i=0;i<20;i++)
-		subdivideTriangle(vertices[(unsigned int)faces[i][0]],vertices[(unsigned int)faces[i][1]],vertices[(unsigned int)faces[i][2]],depth);
-	
 }
 
 void Gl1_Sphere::subdivideTriangle(Vector3r& v1,Vector3r& v2,Vector3r& v3, int depth){
@@ -135,6 +140,10 @@
 	glSphereList = glGenLists(1);
 	glNewList(glSphereList,GL_COMPILE);
 		glEnable(GL_LIGHTING);
-		drawSphere();
+		glShadeModel(GL_SMOOTH);	
+		// render the sphere now
+		for(int i=0;i<20;i++)
+			subdivideTriangle(vertices[(unsigned int)faces[i][0]],vertices[(unsigned int)faces[i][1]],vertices[(unsigned int)faces[i][2]],1);
+		//drawSphere();
 	glEndList();
 }


Follow ups