bobsta 0 Newbie Poster

I am trying to render multiple scenes in different window. I am confident that the data is correctly read in from the .txt file and used to initialise the Beam and Segment objects (each Beam object comprises >=1 Segment)

However when I attempt to render the scenes the program tries to render segment 2 i.e. a third segment (0,1,...n) which results in a Segmentation fault (crash) g++ (SUSE Linux) 4.3.2 [gcc-4_3-branch revision 141291]

for (segmentsRendered=1;segmentsRendered<1+(pBeam->segments);segmentsRendered++){
	    window[segmentsRendered]=0;
	    sprintf(title,"Segment %d BEV",segmentsRendered);
	    std::cout << "Window title " << segmentsRendered << " is \" " << title << " \"\n";
	    window[segmentsRendered]=glutCreateWindow(title);
	    
	    std::cout << "\nSegment " << segmentsRendered << "\n";
	   
	    glutDisplayFunc(renderScene);
	   //Set handler functions
	    glutKeyboardFunc(handleKeypress);
	    glutReshapeFunc(handleResize);
	  }

void renderScene(){
  
    std::cout << "\nStart rendering scene now with pointer: "<< pBeam << "... ";
      pBeam->renderMLC(segmentsRendered-1);
     
  	glutSwapBuffers();
}

I have tried to localise the problem by printing stuff to the screen.

Found 40 leaf pairs for Beam 0x8054e90

Leaf boundaries : -80 0x8055340 -76 -72 -68 -64 -60 -56 -52 -48 -44 -40 -36 -32 -28 -24 -20 -16 -12 -8 -4 0 4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80

Parked position : 110

Found 2 segments for this beam

Reading in segment 1 of beam

Leaf positions : 110 110 110 110 110 110 110 110 110 110 110 -4 -15 -18 -17 -15 -19 -16 -24 -23 -22 -20 -20 -22 -23 -24 -27 -29 -28 -29 -27 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 27 31 26 15 22 27 29 32 34 33 29 43 44 48 48 51 54 57 13 10 110 110 110 110 110 110 110 110 110

Finished writing segment!
Reading in segment 2 of beam

Leaf positions : 110 110 110 110 110 110 110 110 110 110 110 -4 -3 -15 -17 -15 -12 -16 -16 -24 -22 -17 -14 -21 -23 -24 -27 -28 -28 -29 -27 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 110 8 9 18 9 9 10 8 4 3 4 8 10 10 13 17 15 14 13 13 24 110 110 110 110 110 110 110 110 110

Finished writing segment!
Closing file now !

Will try to render 2 segment(s)
Window title 1 is " Segment 1 BEV "

Segment 1
Window title 2 is " Segment 2 BEV "

Segment 2

Start rendering scene now with pointer: 0x8054e90...
[B]Starting to render BEV for segment 2
[/B]
[3]+  Segmentation fault      ./transform MLC2Seg.txt

I am probably making a fundamental mistake (since I am new to GLUT and OpenGL) but would very much appreciate some assistance.

Thanks

Mark