fix some bugs

This commit is contained in:
Paolo Cignoni 2005-07-11 09:04:26 +00:00
parent b8ef9d77a9
commit 2d2bbfb454
1 changed files with 19 additions and 17 deletions

View File

@ -159,7 +159,7 @@ namespace vcg
glVertex3d(1,0,1); glVertex3d(1,0,1);
glEnd(); glEnd();
if (useDisplList) if (useDisplList)
glEndList(); glEndList();
} }
@ -235,6 +235,7 @@ namespace vcg
///draw a cone ///draw a cone
static void Cone(int slices,double lenght,double width,bool useDisplList) static void Cone(int slices,double lenght,double width,bool useDisplList)
{ {
assert(!glGetError());
static std::map<int,GLint> Disp_listMap; static std::map<int,GLint> Disp_listMap;
GLint cone_List=-1; GLint cone_List=-1;
std::map<int,GLint>::const_iterator it=Disp_listMap.find(slices); std::map<int,GLint>::const_iterator it=Disp_listMap.find(slices);
@ -249,14 +250,14 @@ namespace vcg
} }
glScaled(lenght,width,width); glScaled(lenght,width,width);
assert(!glGetError());
if (((!glIsList(cone_List))&&(useDisplList))||(!useDisplList)) if (((!glIsList(cone_List))&&(useDisplList))||(!useDisplList))
{ {
int h=1; int h=1;
vcg::Point3f p0; vcg::Point3f p0;
vcg::Point3f P[2]; vcg::Point3f P[2];
vcg::Point3f N[2]; vcg::Point3f N[2];
assert(!glGetError());
glScaled(lenght,width,width); glScaled(lenght,width,width);
if (useDisplList) if (useDisplList)
{ {
@ -265,14 +266,14 @@ namespace vcg
} }
for(h=0; h < 2; ++h) for(h=0; h < 2; ++h)
{ {
assert(!glGetError());
//glBegin(GL_TRIANGLE_FAN); //glBegin(GL_TRIANGLE_FAN);
p0 = Point3f(0,0,0); p0 = Point3f(0,0,0);
if(h==0) p0[0]+=1.f; if(h==0) p0[0]+=1.f;
//glNormal3f(1,0.0,0.0); //glNormal3f(1,0.0,0.0);
//glVertex3d(p0[0],p0[1],p0[2]); //glVertex3d(p0[0],p0[1],p0[2]);
N[0]= Point3f( 1.f,sinf(0),cosf(0) ); N[0]= Point3f( 1.f,sinf(0),cosf(0) );
P[0]= Point3f( 0,sinf(0),cosf(0)); P[0]= Point3f( 0,sinf(0),cosf(0));
int b; int b;
for(b = 1; b <= slices; ++b) for(b = 1; b <= slices; ++b)
{ {
@ -280,20 +281,21 @@ namespace vcg
if (b==slices) angle=0; if (b==slices) angle=0;
N[1] = Point3f( 1.f, sinf(angle), cosf(angle) ); N[1] = Point3f( 1.f, sinf(angle), cosf(angle) );
P[1] = Point3f( 0, sinf(angle), cosf(angle)); P[1] = Point3f( 0, sinf(angle), cosf(angle));
assert(!glGetError());
glBegin(GL_TRIANGLES); glBegin(GL_TRIANGLES);
Point3f n = ( (P[0]-p0) ^ (P[2]-p0) ).Normalize(); Point3f n = ( (P[0]-p0) ^ (P[2]-p0) ).Normalize();
glNormal3f(n[0],n[1],n[2]); glNormal3f(n[0],n[1],n[2]);
glVertex3f(p0[0],p0[1],p0[2]); glVertex3f(p0[0],p0[1],p0[2]);
glNormal3f(N[0][0],N[0][1],N[0][2]); glNormal3f(N[0][0],N[0][1],N[0][2]);
glVertex3f(P[0][0],P[0][1],P[0][2]); glVertex3f(P[0][0],P[0][1],P[0][2]);
glNormal3f(N[1][0],N[1][1],N[1][2]); glNormal3f(N[1][0],N[1][1],N[1][2]);
glVertex3f(P[1][0],P[1][1],P[1][2]); glVertex3f(P[1][0],P[1][1],P[1][2]);
glEnd(); glEnd();
N[0] = N[1]; assert(!glGetError());
N[0] = N[1];
P[0] = P[1]; P[0] = P[1];
} }
glEnd(); //glEnd();
} }
if (useDisplList) if (useDisplList)
glEndList(); glEndList();