On Mon, 28 Jun 2004, Filippos Papadopoulos wrote:
Hi. I am developing a 3d application in SuSE Linux 9.0 in C++. I ported the application in WinXP using VStudio2003. The fun stuff is that the application executes in Linux but it crashes immediatelly in WinXP. I think i found what is causing the segfault in windows. I have the following classes (which are bad-coded by the way ;) :
......
Sorry, this is the full Cone class: #include "Vertex3d.h" class Cone { public: GLuint selectionName; bool isSelected; Vertex3d bottomCentre; //to kentro ths bashs double bottomRadius; Vertex3d topCentre; //to kentro ths koryfhs double topRadius; float* vertices1; float* vertices2; float* Upper; float* Lower; float *table; Cone() { ; } Cone(Vertex3d bottomCentre, double bottomRadius, Vertex3d topCentre, double topRadius) { this->bottomCentre = bottomCentre; this->bottomRadius = bottomRadius; this->topCentre = topCentre; this->topRadius = topRadius; selectionName = 0; isSelected = false; vertices1 = (float *)malloc( sizeof(float) * 2 * (30 + 1) ); vertices2 = (float *)malloc( sizeof(float) * 2 * (30 + 1) ); Upper = (float *)malloc( sizeof(float) * 3 * (30 + 1) ); Lower = (float *)malloc( sizeof(float) * 3 * (30 + 1) );; } void draw() { //dhmiourgia baseon drawCircle(1, vertices1, bottomRadius, 8, bottomCentre.x, bottomCentre.y, bottomCentre.z); drawCircle(2, vertices2, topRadius, 8, topCentre.x, topCentre.y, topCentre.z); //dhmiourgia pleyron for(GLuint k=0; k < 8 ;k++) { glColor3d(0.51,0.91,1.0); glBegin(GL_QUADS);glTexCoord2f(1.0f,1.0f); glVertex3f( Upper[(k+0)*3+0 ] , Upper[ (k+0)*3+1 ] , Upper[ (k+0)*3+2 ] ); glTexCoord2f(0.0f,1.0f); glVertex3f( Lower[(k+0)*3+0 ] , Lower[ (k+0)*3+1 ] , Lower[ (k+0)*3+2 ] ); glTexCoord2f(1.0f,0.0f); glVertex3f( Lower[(k+1)*3+0 ] , Lower[ (k+1)*3+1 ] , Lower[ (k+1)*3+2 ] ); glTexCoord2f(0.0f,0.0f); glVertex3f( Upper[(k+1)*3+0 ] , Upper[ (k+1)*3+1 ] , Upper[ (k+1)*3+2 ] ); glEnd(); } } void drawCircle(int l, float *vertices, GLdouble radius, GLint slices, double cx, double cy, double cz) { float angle = (float) M_PI / (float) slices * 2.0f; GLint i; if(l==1) table=Upper; else if(l==2) table=Lower; /* Ari8mos shmeion = 'slices' . ayta briskontai pano se enan kyklo */ for( i=0; i<slices+1; i++ ) { vertices[ i*2 + 0 ] = cos( angle * i ); vertices[ i*2 + 1 ] = sin( angle * i ); } /* Bash tou konou */ for( i=0; i<slices; i++ ) { glColor3d(0.3 + 0.007*i, 0.3 + 0.007*i , 0.3 + 0.007*i); glBegin( GL_POLYGON); glNormal3f(cx * vertices[ (i+0)*2+0 ] * radius, cy +vertices[ (i+0)*2+1 ] * radius, 2*cz ); glVertex3f(cx + vertices[ (i+0)*2+0 ] * radius, cy +vertices[ (i+0)*2+1 ] * radius, cz ); table[(i+0)*3+0] = cx + vertices[ (i+0)*2+0 ] * radius; table[(i+0)*3+1] = cy + vertices[ (i+0)*2+1 ] * radius; table[(i+0)*3+2] = cz; glNormal3f(cx * vertices[ (i+1)*2+0 ] * radius, cy *vertices[ (i+1)*2+1 ] * radius, 2*cz ); glVertex3f(cx + vertices[ (i+1)*2+0 ] * radius, cy +vertices[ (i+1)*2+1 ] * radius, cz ); table[(i+1)*3+0] = cx + vertices[ (i+1)*2+0 ] * radius; table[(i+1)*3+1] = cy + vertices[ (i+1)*2+1 ] * radius; table[(i+1)*3+2] = cz; glNormal3f( cx, cy, cz ); glVertex3f( cx, cy, cz ); table[(i+2)*3+0] = cx; table[(i+2)*3+1] = cy; table[(i+2)*3+2] = cz; glNormal3f( 1, 1, 1 ); glEnd(); } } };