~ubuntu-branches/ubuntu/precise/freeglut/precise-proposed

« back to all changes in this revision

Viewing changes to progs/demos/Fractals/fractals.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2010-01-18 18:39:10 UTC
  • mfrom: (1.1.2 upstream) (4.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100118183910-02xjmec7ghpw9olx
Tags: 2.6.0-0ubuntu1
* New upstream version. LP: #499415.
  - Ubuntu changes are found in the new upstream version.
* debian/patches/02_fix_GLUT_CURSOR_INHERIT_bug.diff: Remove, applied
  upstream.
* Don't touch kfreebsd and hurd patches, just disable them.
* debian/freeglut3.install: Adjust minor soversion.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
AffineTrans ;
34
34
 
35
35
/* Number of levels to draw the fractal */
36
 
static int num_levels = 0 ;
 
36
static int num_levels = 4 ;
37
37
 
38
38
/* The definition of the fractal */
39
39
static int num_trans ;
40
40
static AffineTrans *affine ;
41
41
 
 
42
/* Flag telling us to keep executing the main loop */
 
43
static int continue_in_main_loop = 1;
 
44
 
42
45
/* the window title */
43
46
char window_title [ 80 ] ;
44
47
 
125
128
  
126
129
  switch (key) {
127
130
  case 27:  /* Escape key */
128
 
    glutLeaveMainLoop () ;
 
131
    continue_in_main_loop = 0 ;
129
132
    break;
130
133
 
131
134
  case '+' :
208
211
}
209
212
 
210
213
 
 
214
static void
 
215
checkedFGets ( char *s, int size, FILE *stream )
 
216
{
 
217
  if ( fgets ( s, size, stream ) == NULL ) {
 
218
    fprintf ( stderr, "fgets failed\n");
 
219
    exit ( EXIT_FAILURE );
 
220
  }
 
221
}
 
222
 
 
223
 
211
224
void readConfigFile ( char *fnme )
212
225
{
213
226
  FILE *fptr = fopen ( fnme, "rt" ) ;
214
227
  int i ;
215
 
  char inputline [ 256 ] , *line ;
 
228
  char inputline [ 256 ] ;
216
229
 
217
230
  if ( fptr )
218
231
  {
219
232
    /* Read a header line */
220
 
    line = fgets ( inputline, 256, fptr ) ;
 
233
    checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
221
234
 
222
235
    /* Read a comment line */
223
 
    line = fgets ( inputline, 256, fptr ) ;
 
236
    checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
224
237
 
225
238
    /* Read the window title */
226
 
    line = fgets ( inputline, 256, fptr ) ;
 
239
    checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
227
240
    /* We assume here that this line will not exceed 79 characters plus a 
228
241
       newline (window_title is 80 characters long). That'll cause a buffer 
229
242
       overflow. For a simple program like  this, though, we're letting it 
232
245
    sscanf ( inputline, "%[a-zA-Z0-9!@#$%^&*()+=/\\_-\" ]", window_title ) ; 
233
246
 
234
247
    /* Read a comment line */
235
 
    line = fgets ( inputline, 256, fptr ) ;
 
248
    checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
236
249
 
237
250
    /* Read the number of affine transformations */
238
 
    line = fgets ( inputline, 256, fptr ) ;
 
251
    checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
239
252
    sscanf ( inputline, "%d", &num_trans ) ;
240
253
 
241
254
    affine = (AffineTrans *)malloc ( num_trans * sizeof(AffineTrans) ) ;
242
255
 
243
256
    /* Read a comment line */
244
 
    line = fgets ( inputline, 256, fptr ) ;
 
257
    checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
245
258
 
246
259
    for ( i = 0; i < num_trans; i++ )
247
260
    {
248
261
      /* Read an affine transformation definition */
249
 
      line = fgets ( inputline, 256, fptr ) ;
 
262
      checkedFGets ( inputline, sizeof ( inputline ), fptr ) ;
250
263
      sscanf ( inputline, "%lf %lf %lf %lf %lf %lf", &affine[i].a00, &affine[i].a01,
251
264
                       &affine[i].a10, &affine[i].a11, &affine[i].b0, &affine[i].b1 ) ;
252
265
    }
311
324
  glutSpecialFunc(Special);
312
325
  glutDisplayFunc(Display);
313
326
 
314
 
  glutMainLoop();
 
327
#ifdef WIN32
 
328
#endif
 
329
 
 
330
  while ( continue_in_main_loop )
 
331
    glutMainLoopEvent();
315
332
 
316
333
  printf ( "Back from the 'freeglut' main loop\n" ) ;
317
334