make indent
authorBob Pendleton <bob@pendleton.com>
Tue, 24 Jul 2007 18:46:45 +0000
changeset 221359a667370c57
parent 2212 fdadda42d4d4
child 2214 e7164a4dac62
make indent
Xcode/SDLTest/libsdlmain_prefix.h
Xcode/TemplatesForProjectBuilder/SDL Application/SDLMain.h
Xcode/TemplatesForProjectBuilder/SDL Application/main.c
Xcode/TemplatesForProjectBuilder/SDL Cocoa Application/SDLMain.h
Xcode/TemplatesForProjectBuilder/SDL Cocoa Application/main.c
Xcode/TemplatesForProjectBuilder/SDL Custom Cocoa Application/MyController.h
Xcode/TemplatesForProjectBuilder/SDL Custom Cocoa Application/MyCustomView.h
Xcode/TemplatesForProjectBuilder/SDL Custom Cocoa Application/MyCustomWindow.h
Xcode/TemplatesForProjectBuilder/SDL Custom Cocoa Application/SDLMain.h
Xcode/TemplatesForProjectBuilder/SDL Custom Cocoa Application/prefix.h
Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/SDLMain.h
Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/atlantis/atlantis.c
Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/atlantis/atlantis.h
Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/atlantis/swim.c
Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/main.c
Xcode/TemplatesForXcode/SDL Application/SDLMain.h
Xcode/TemplatesForXcode/SDL Application/main.c
Xcode/TemplatesForXcode/SDL Cocoa Application/SDLMain.h
Xcode/TemplatesForXcode/SDL Cocoa Application/main.c
Xcode/TemplatesForXcode/SDL Custom Cocoa Application/MyController.h
Xcode/TemplatesForXcode/SDL Custom Cocoa Application/MyCustomView.h
Xcode/TemplatesForXcode/SDL Custom Cocoa Application/MyCustomWindow.h
Xcode/TemplatesForXcode/SDL Custom Cocoa Application/SDLMain.h
Xcode/TemplatesForXcode/SDL OpenGL Application/SDLMain.h
Xcode/TemplatesForXcode/SDL OpenGL Application/atlantis/atlantis.c
Xcode/TemplatesForXcode/SDL OpenGL Application/atlantis/atlantis.h
Xcode/TemplatesForXcode/SDL OpenGL Application/atlantis/swim.c
Xcode/TemplatesForXcode/SDL OpenGL Application/main.c
src/video/x11/SDL_x11gamma.c
src/video/x11/SDL_x11gamma.h
src/video/x11/SDL_x11window.c
     1.1 --- a/Xcode/SDLTest/libsdlmain_prefix.h	Mon Jul 23 18:46:09 2007 +0000
     1.2 +++ b/Xcode/SDLTest/libsdlmain_prefix.h	Tue Jul 24 18:46:45 2007 +0000
     1.3 @@ -10,4 +10,4 @@
     1.4  #include <Cocoa/Cocoa.h>
     1.5  #include <Carbon/Carbon.h>
     1.6  #include "SDL.h"
     1.7 -#include "SDLMain.h"
     1.8 \ No newline at end of file
     1.9 +#include "SDLMain.h"
     2.1 --- a/Xcode/TemplatesForProjectBuilder/SDL Application/SDLMain.h	Mon Jul 23 18:46:09 2007 +0000
     2.2 +++ b/Xcode/TemplatesForProjectBuilder/SDL Application/SDLMain.h	Tue Jul 24 18:46:45 2007 +0000
     2.3 @@ -7,5 +7,4 @@
     2.4  
     2.5  #import <Cocoa/Cocoa.h>
     2.6  
     2.7 -@interface SDLMain : NSObject
     2.8 -@end
     2.9 +@ interface SDLMain:NSObject @ end
     3.1 --- a/Xcode/TemplatesForProjectBuilder/SDL Application/main.c	Mon Jul 23 18:46:09 2007 +0000
     3.2 +++ b/Xcode/TemplatesForProjectBuilder/SDL Application/main.c	Tue Jul 24 18:46:45 2007 +0000
     3.3 @@ -4,7 +4,7 @@
     3.4     Please see the SDL documentation for details on using the SDL API:
     3.5     /Developer/Documentation/SDL/docs.html
     3.6  */
     3.7 -   
     3.8 +
     3.9  #include <stdio.h>
    3.10  #include <stdlib.h>
    3.11  #include <string.h>
    3.12 @@ -12,54 +12,54 @@
    3.13  
    3.14  #include "SDL.h"
    3.15  
    3.16 -int main(int argc, char *argv[])
    3.17 +int
    3.18 +main(int argc, char *argv[])
    3.19  {
    3.20 -	Uint32 initflags = SDL_INIT_VIDEO;  /* See documentation for details */
    3.21 -	SDL_Surface *screen;
    3.22 -	Uint8  video_bpp = 0;
    3.23 -	Uint32 videoflags = SDL_SWSURFACE;
    3.24 -	int    done;
    3.25 -        SDL_Event event;
    3.26 +    Uint32 initflags = SDL_INIT_VIDEO;  /* See documentation for details */
    3.27 +    SDL_Surface *screen;
    3.28 +    Uint8 video_bpp = 0;
    3.29 +    Uint32 videoflags = SDL_SWSURFACE;
    3.30 +    int done;
    3.31 +    SDL_Event event;
    3.32  
    3.33 -	/* Initialize the SDL library */
    3.34 -	if ( SDL_Init(initflags) < 0 ) {
    3.35 -		fprintf(stderr, "Couldn't initialize SDL: %s\n",
    3.36 -			SDL_GetError());
    3.37 -		exit(1);
    3.38 -	}
    3.39 +    /* Initialize the SDL library */
    3.40 +    if (SDL_Init(initflags) < 0) {
    3.41 +        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    3.42 +        exit(1);
    3.43 +    }
    3.44  
    3.45 -	/* Set 640x480 video mode */
    3.46 -	screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
    3.47 -        if (screen == NULL) {
    3.48 -		fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
    3.49 -                        video_bpp, SDL_GetError());
    3.50 -		SDL_Quit();
    3.51 -		exit(2);
    3.52 -	}
    3.53 +    /* Set 640x480 video mode */
    3.54 +    screen = SDL_SetVideoMode(640, 480, video_bpp, videoflags);
    3.55 +    if (screen == NULL) {
    3.56 +        fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
    3.57 +                video_bpp, SDL_GetError());
    3.58 +        SDL_Quit();
    3.59 +        exit(2);
    3.60 +    }
    3.61  
    3.62 -	done = 0;
    3.63 -	while ( !done ) {
    3.64 +    done = 0;
    3.65 +    while (!done) {
    3.66  
    3.67 -		/* Check for events */
    3.68 -		while ( SDL_PollEvent(&event) ) {
    3.69 -			switch (event.type) {
    3.70 +        /* Check for events */
    3.71 +        while (SDL_PollEvent(&event)) {
    3.72 +            switch (event.type) {
    3.73  
    3.74 -				case SDL_MOUSEMOTION:
    3.75 -					break;
    3.76 -				case SDL_MOUSEBUTTONDOWN:
    3.77 -					break;
    3.78 -				case SDL_KEYDOWN:
    3.79 -					/* Any keypress quits the app... */
    3.80 -				case SDL_QUIT:
    3.81 -					done = 1;
    3.82 -					break;
    3.83 -				default:
    3.84 -					break;
    3.85 -			}
    3.86 -		}
    3.87 -	}
    3.88 -	
    3.89 -	/* Clean up the SDL library */
    3.90 -	SDL_Quit();
    3.91 -	return(0);
    3.92 +            case SDL_MOUSEMOTION:
    3.93 +                break;
    3.94 +            case SDL_MOUSEBUTTONDOWN:
    3.95 +                break;
    3.96 +            case SDL_KEYDOWN:
    3.97 +                /* Any keypress quits the app... */
    3.98 +            case SDL_QUIT:
    3.99 +                done = 1;
   3.100 +                break;
   3.101 +            default:
   3.102 +                break;
   3.103 +            }
   3.104 +        }
   3.105 +    }
   3.106 +
   3.107 +    /* Clean up the SDL library */
   3.108 +    SDL_Quit();
   3.109 +    return (0);
   3.110  }
     4.1 --- a/Xcode/TemplatesForProjectBuilder/SDL Cocoa Application/SDLMain.h	Mon Jul 23 18:46:09 2007 +0000
     4.2 +++ b/Xcode/TemplatesForProjectBuilder/SDL Cocoa Application/SDLMain.h	Tue Jul 24 18:46:45 2007 +0000
     4.3 @@ -7,11 +7,10 @@
     4.4  
     4.5  #import <Cocoa/Cocoa.h>
     4.6  
     4.7 -@interface SDLMain : NSObject
     4.8 -- (IBAction)prefsMenu:(id)sender;
     4.9 -- (IBAction)newGame:(id)sender;
    4.10 -- (IBAction)openGame:(id)sender;
    4.11 -- (IBAction)saveGame:(id)sender;
    4.12 -- (IBAction)saveGameAs:(id)sender;
    4.13 -- (IBAction)help:(id)sender;
    4.14 +@ interface SDLMain: NSObject - (IBAction) prefsMenu:(id) sender;
    4.15 +-(IBAction) newGame:(id) sender;
    4.16 +-(IBAction) openGame:(id) sender;
    4.17 +-(IBAction) saveGame:(id) sender;
    4.18 +-(IBAction) saveGameAs:(id) sender;
    4.19 +-(IBAction) help:(id) sender;
    4.20  @end
     5.1 --- a/Xcode/TemplatesForProjectBuilder/SDL Cocoa Application/main.c	Mon Jul 23 18:46:09 2007 +0000
     5.2 +++ b/Xcode/TemplatesForProjectBuilder/SDL Cocoa Application/main.c	Tue Jul 24 18:46:45 2007 +0000
     5.3 @@ -4,7 +4,7 @@
     5.4     Please see the SDL documentation for details on using the SDL API:
     5.5     /Developer/Documentation/SDL/docs.html
     5.6  */
     5.7 -   
     5.8 +
     5.9  #include <stdio.h>
    5.10  #include <stdlib.h>
    5.11  #include <string.h>
    5.12 @@ -12,54 +12,54 @@
    5.13  
    5.14  #include "SDL.h"
    5.15  
    5.16 -int main(int argc, char *argv[])
    5.17 +int
    5.18 +main(int argc, char *argv[])
    5.19  {
    5.20 -	Uint32 initflags = SDL_INIT_VIDEO;  /* See documentation for details */
    5.21 -	SDL_Surface *screen;
    5.22 -	Uint8  video_bpp = 0;
    5.23 -	Uint32 videoflags = SDL_SWSURFACE;
    5.24 -	int    done;
    5.25 -        SDL_Event event;
    5.26 +    Uint32 initflags = SDL_INIT_VIDEO;  /* See documentation for details */
    5.27 +    SDL_Surface *screen;
    5.28 +    Uint8 video_bpp = 0;
    5.29 +    Uint32 videoflags = SDL_SWSURFACE;
    5.30 +    int done;
    5.31 +    SDL_Event event;
    5.32  
    5.33 -	/* Initialize the SDL library */
    5.34 -	if ( SDL_Init(initflags) < 0 ) {
    5.35 -		fprintf(stderr, "Couldn't initialize SDL: %s\n",
    5.36 -			SDL_GetError());
    5.37 -		exit(1);
    5.38 -	}
    5.39 +    /* Initialize the SDL library */
    5.40 +    if (SDL_Init(initflags) < 0) {
    5.41 +        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
    5.42 +        exit(1);
    5.43 +    }
    5.44  
    5.45 -	/* Set 640x480 video mode */
    5.46 -	screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
    5.47 -        if (screen == NULL) {
    5.48 -		fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
    5.49 -                        video_bpp, SDL_GetError());
    5.50 -		SDL_Quit();
    5.51 -		exit(2);
    5.52 -	}
    5.53 +    /* Set 640x480 video mode */
    5.54 +    screen = SDL_SetVideoMode(640, 480, video_bpp, videoflags);
    5.55 +    if (screen == NULL) {
    5.56 +        fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
    5.57 +                video_bpp, SDL_GetError());
    5.58 +        SDL_Quit();
    5.59 +        exit(2);
    5.60 +    }
    5.61  
    5.62 -	done = 0;
    5.63 -	while ( !done ) {
    5.64 +    done = 0;
    5.65 +    while (!done) {
    5.66  
    5.67 -		/* Check for events */
    5.68 -		while ( SDL_PollEvent(&event) ) {
    5.69 -			switch (event.type) {
    5.70 +        /* Check for events */
    5.71 +        while (SDL_PollEvent(&event)) {
    5.72 +            switch (event.type) {
    5.73  
    5.74 -				case SDL_MOUSEMOTION:
    5.75 -					break;
    5.76 -				case SDL_MOUSEBUTTONDOWN:
    5.77 -					break;
    5.78 -				case SDL_KEYDOWN:
    5.79 -					/* Any keypress quits the app... */
    5.80 -				case SDL_QUIT:
    5.81 -					done = 1;
    5.82 -					break;
    5.83 -				default:
    5.84 -					break;
    5.85 -			}
    5.86 -		}
    5.87 -	}
    5.88 -	
    5.89 -	/* Clean up the SDL library */
    5.90 -	SDL_Quit();
    5.91 -	return(0);
    5.92 +            case SDL_MOUSEMOTION:
    5.93 +                break;
    5.94 +            case SDL_MOUSEBUTTONDOWN:
    5.95 +                break;
    5.96 +            case SDL_KEYDOWN:
    5.97 +                /* Any keypress quits the app... */
    5.98 +            case SDL_QUIT:
    5.99 +                done = 1;
   5.100 +                break;
   5.101 +            default:
   5.102 +                break;
   5.103 +            }
   5.104 +        }
   5.105 +    }
   5.106 +
   5.107 +    /* Clean up the SDL library */
   5.108 +    SDL_Quit();
   5.109 +    return (0);
   5.110  }
     6.1 --- a/Xcode/TemplatesForProjectBuilder/SDL Custom Cocoa Application/MyController.h	Mon Jul 23 18:46:09 2007 +0000
     6.2 +++ b/Xcode/TemplatesForProjectBuilder/SDL Custom Cocoa Application/MyController.h	Tue Jul 24 18:46:45 2007 +0000
     6.3 @@ -9,38 +9,34 @@
     6.4  #import <Cocoa/Cocoa.h>
     6.5  #import "SDL.h"
     6.6  
     6.7 -extern id gController; // instance of this class from nib
     6.8 +extern id gController;          // instance of this class from nib
     6.9  
    6.10  // Declare SDL_QuartzWindowDelegate (defined in SDL.framework)
    6.11 -@interface SDL_QuartzWindowDelegate : NSObject
    6.12 +@interface SDL_QuartzWindowDelegate: NSObject @ end @ interface MyController:NSObject {
    6.13 +    // Interface Builder Outlets
    6.14 +    IBOutlet id _framesPerSecond;
    6.15 +    IBOutlet id _numSprites;
    6.16 +    IBOutlet id _window;
    6.17 +    IBOutlet id _view;
    6.18 +
    6.19 +    // Private instance variables
    6.20 +    int _nSprites;
    6.21 +    int _max_speed;
    6.22 +    int _doFlip;
    6.23 +    Uint8 *_mem;
    6.24 +
    6.25 +    SDL_Surface *_screen;
    6.26 +    SDL_Surface *_sprite;
    6.27 +    SDL_Rect *_sprite_rects;
    6.28 +    SDL_Rect *_positions;
    6.29 +    SDL_Rect *_velocities;
    6.30 +    int _sprites_visible;
    6.31 +    Uint16 _sprite_w, _sprite_h;
    6.32 +
    6.33 +    int _mouse_x, _mouse_y;
    6.34 +}
    6.35 +
    6.36 +// Interface Builder Actions
    6.37 +-(IBAction) changeNumberOfSprites:(id) sender;
    6.38 +-(IBAction) selectUpdateMode:(id) sender;
    6.39  @end
    6.40 -
    6.41 -@interface MyController : NSObject
    6.42 -{
    6.43 -    // Interface Builder Outlets
    6.44 -    IBOutlet id 	_framesPerSecond;
    6.45 -    IBOutlet id 	_numSprites;
    6.46 -    IBOutlet id 	_window;
    6.47 -    IBOutlet id 	_view;
    6.48 -    
    6.49 -    // Private instance variables
    6.50 -    int          _nSprites;
    6.51 -    int          _max_speed;
    6.52 -    int          _doFlip;
    6.53 -    Uint8*       _mem;
    6.54 -    
    6.55 -    SDL_Surface* _screen;
    6.56 -    SDL_Surface* _sprite;
    6.57 -    SDL_Rect*    _sprite_rects;
    6.58 -    SDL_Rect*    _positions;
    6.59 -    SDL_Rect*    _velocities;
    6.60 -    int          _sprites_visible;
    6.61 -    Uint16       _sprite_w, _sprite_h;
    6.62 -    
    6.63 -    int 		 _mouse_x, _mouse_y;
    6.64 -}
    6.65 -// Interface Builder Actions
    6.66 -- (IBAction)changeNumberOfSprites:(id)sender;
    6.67 -- (IBAction)selectUpdateMode:(id)sender;
    6.68 -@end
    6.69 -
     7.1 --- a/Xcode/TemplatesForProjectBuilder/SDL Custom Cocoa Application/MyCustomView.h	Mon Jul 23 18:46:09 2007 +0000
     7.2 +++ b/Xcode/TemplatesForProjectBuilder/SDL Custom Cocoa Application/MyCustomView.h	Tue Jul 24 18:46:45 2007 +0000
     7.3 @@ -9,8 +9,7 @@
     7.4  #import <AppKit/AppKit.h>
     7.5  
     7.6  
     7.7 -@interface MyCustomView : NSQuickDrawView
     7.8 -{
     7.9 +@ interface MyCustomView:NSQuickDrawView {
    7.10  }
    7.11  
    7.12  @end
     8.1 --- a/Xcode/TemplatesForProjectBuilder/SDL Custom Cocoa Application/MyCustomWindow.h	Mon Jul 23 18:46:09 2007 +0000
     8.2 +++ b/Xcode/TemplatesForProjectBuilder/SDL Custom Cocoa Application/MyCustomWindow.h	Tue Jul 24 18:46:45 2007 +0000
     8.3 @@ -11,17 +11,11 @@
     8.4  // Be a subclass of SDL_QuartzWindow so SDL will
     8.5  // handle the redraw problems when minimizing the window
     8.6  // This class is defined in SDL.framework
     8.7 -@interface SDL_QuartzWindow : NSWindow
     8.8 -@end
     8.9 -
    8.10 +@ interface SDL_QuartzWindow:NSWindow @ end
    8.11  // Also assign SDL_QuartzWindowDelegate to the window
    8.12  // to perform other tasks. You can subclass this delegate
    8.13  // if you want to add your own delegation methods
    8.14  // This class is defined in SDL.framework
    8.15 -@interface SDL_QuartzWindowDelegate : NSObject
    8.16 -@end
    8.17 -
    8.18 +@ interface SDL_QuartzWindowDelegate:NSObject @ end
    8.19  // Declare our custom class
    8.20 -@interface MyCustomWindow : SDL_QuartzWindow
    8.21 -@end
    8.22 -
    8.23 +@ interface MyCustomWindow:SDL_QuartzWindow @ end
     9.1 --- a/Xcode/TemplatesForProjectBuilder/SDL Custom Cocoa Application/SDLMain.h	Mon Jul 23 18:46:09 2007 +0000
     9.2 +++ b/Xcode/TemplatesForProjectBuilder/SDL Custom Cocoa Application/SDLMain.h	Tue Jul 24 18:46:45 2007 +0000
     9.3 @@ -7,8 +7,8 @@
     9.4  
     9.5  #import <Cocoa/Cocoa.h>
     9.6  
     9.7 -@interface SDLMain : NSObject
     9.8 -{
     9.9 +@ interface SDLMain:NSObject {
    9.10      IBOutlet id _controller;
    9.11  }
    9.12 +
    9.13  @end
    10.1 --- a/Xcode/TemplatesForProjectBuilder/SDL Custom Cocoa Application/prefix.h	Mon Jul 23 18:46:09 2007 +0000
    10.2 +++ b/Xcode/TemplatesForProjectBuilder/SDL Custom Cocoa Application/prefix.h	Tue Jul 24 18:46:45 2007 +0000
    10.3 @@ -9,4 +9,3 @@
    10.4  
    10.5  #include <Foundation/Foundation.h>
    10.6  #include <Cocoa/Cocoa.h>
    10.7 -
    11.1 --- a/Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/SDLMain.h	Mon Jul 23 18:46:09 2007 +0000
    11.2 +++ b/Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/SDLMain.h	Tue Jul 24 18:46:45 2007 +0000
    11.3 @@ -7,5 +7,4 @@
    11.4  
    11.5  #import <Cocoa/Cocoa.h>
    11.6  
    11.7 -@interface SDLMain : NSObject
    11.8 -@end
    11.9 +@ interface SDLMain:NSObject @ end
    12.1 --- a/Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/atlantis/atlantis.c	Mon Jul 23 18:46:09 2007 +0000
    12.2 +++ b/Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/atlantis/atlantis.c	Tue Jul 24 18:46:45 2007 +0000
    12.3 @@ -54,46 +54,49 @@
    12.4  
    12.5  int w_win = 640;
    12.6  int h_win = 480;
    12.7 -GLint count  = 0;
    12.8 +GLint count = 0;
    12.9  GLenum StrMode = GL_VENDOR;
   12.10  
   12.11  GLboolean moving;
   12.12  
   12.13 -static double mtime(void)
   12.14 +static double
   12.15 +mtime(void)
   12.16  {
   12.17 -   struct timeval tk_time;
   12.18 -   struct timezone tz;
   12.19 -   
   12.20 -   gettimeofday(&tk_time, &tz);
   12.21 -   
   12.22 -   return 4294.967296 * tk_time.tv_sec + 0.000001 * tk_time.tv_usec;
   12.23 +    struct timeval tk_time;
   12.24 +    struct timezone tz;
   12.25 +
   12.26 +    gettimeofday(&tk_time, &tz);
   12.27 +
   12.28 +    return 4294.967296 * tk_time.tv_sec + 0.000001 * tk_time.tv_usec;
   12.29  }
   12.30  
   12.31 -static double filter(double in, double *save)
   12.32 +static double
   12.33 +filter(double in, double *save)
   12.34  {
   12.35 -	static double k1 = 0.9;
   12.36 -	static double k2 = 0.05;
   12.37 +    static double k1 = 0.9;
   12.38 +    static double k2 = 0.05;
   12.39  
   12.40 -	save[3] = in;
   12.41 -	save[1] = save[0]*k1 + k2*(save[3] + save[2]);
   12.42 +    save[3] = in;
   12.43 +    save[1] = save[0] * k1 + k2 * (save[3] + save[2]);
   12.44  
   12.45 -	save[0]=save[1];
   12.46 -	save[2]=save[3];
   12.47 +    save[0] = save[1];
   12.48 +    save[2] = save[3];
   12.49  
   12.50 -	return(save[1]);
   12.51 +    return (save[1]);
   12.52  }
   12.53  
   12.54 -void DrawStr(const char *str)
   12.55 +void
   12.56 +DrawStr(const char *str)
   12.57  {
   12.58 -	GLint i = 0;
   12.59 -	
   12.60 -	if(!str) return;
   12.61 -        
   12.62 -	while(str[i])
   12.63 -	{
   12.64 -		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]);
   12.65 -		i++;
   12.66 -	}
   12.67 +    GLint i = 0;
   12.68 +
   12.69 +    if (!str)
   12.70 +        return;
   12.71 +
   12.72 +    while (str[i]) {
   12.73 +        glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]);
   12.74 +        i++;
   12.75 +    }
   12.76  }
   12.77  
   12.78  void
   12.79 @@ -134,18 +137,18 @@
   12.80  void
   12.81  Atlantis_Init(void)
   12.82  {
   12.83 -    static float ambient[] = {0.2, 0.2, 0.2, 1.0};
   12.84 -    static float diffuse[] = {1.0, 1.0, 1.0, 1.0};
   12.85 -    static float position[] = {0.0, 1.0, 0.0, 0.0};
   12.86 -    static float mat_shininess[] = {90.0};
   12.87 -    static float mat_specular[] = {0.8, 0.8, 0.8, 1.0};
   12.88 -    static float mat_diffuse[] = {0.46, 0.66, 0.795, 1.0};
   12.89 -    static float mat_ambient[] = {0.3, 0.4, 0.5, 1.0};
   12.90 -    static float lmodel_ambient[] = {0.4, 0.4, 0.4, 1.0};
   12.91 -    static float lmodel_localviewer[] = {0.0};
   12.92 +    static float ambient[] = { 0.2, 0.2, 0.2, 1.0 };
   12.93 +    static float diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
   12.94 +    static float position[] = { 0.0, 1.0, 0.0, 0.0 };
   12.95 +    static float mat_shininess[] = { 90.0 };
   12.96 +    static float mat_specular[] = { 0.8, 0.8, 0.8, 1.0 };
   12.97 +    static float mat_diffuse[] = { 0.46, 0.66, 0.795, 1.0 };
   12.98 +    static float mat_ambient[] = { 0.3, 0.4, 0.5, 1.0 };
   12.99 +    static float lmodel_ambient[] = { 0.4, 0.4, 0.4, 1.0 };
  12.100 +    static float lmodel_localviewer[] = { 0.0 };
  12.101      //GLfloat map1[4] = {0.0, 0.0, 0.0, 0.0};
  12.102      //GLfloat map2[4] = {0.0, 0.0, 0.0, 0.0};
  12.103 -    static float fog_color[] = {0.0, 0.5, 0.9, 1.0};
  12.104 +    static float fog_color[] = { 0.0, 0.5, 0.9, 1.0 };
  12.105  
  12.106      glFrontFace(GL_CCW);
  12.107  
  12.108 @@ -168,9 +171,9 @@
  12.109      InitFishs();
  12.110  
  12.111      glEnable(GL_FOG);
  12.112 -	glFogi(GL_FOG_MODE, GL_EXP);
  12.113 -	glFogf(GL_FOG_DENSITY, 0.0000025);
  12.114 -	glFogfv(GL_FOG_COLOR, fog_color);
  12.115 +    glFogi(GL_FOG_MODE, GL_EXP);
  12.116 +    glFogf(GL_FOG_DENSITY, 0.0000025);
  12.117 +    glFogfv(GL_FOG_COLOR, fog_color);
  12.118  
  12.119      glClearColor(0.0, 0.5, 0.9, 1.0);
  12.120  }
  12.121 @@ -178,14 +181,15 @@
  12.122  void
  12.123  Atlantis_Reshape(int width, int height)
  12.124  {
  12.125 -	w_win = width;
  12.126 -	h_win = height;
  12.127 -	
  12.128 +    w_win = width;
  12.129 +    h_win = height;
  12.130 +
  12.131      glViewport(0, 0, width, height);
  12.132  
  12.133      glMatrixMode(GL_PROJECTION);
  12.134      glLoadIdentity();
  12.135 -    gluPerspective(60.0, (GLfloat) width / (GLfloat) height, 20000.0, 300000.0);
  12.136 +    gluPerspective(60.0, (GLfloat) width / (GLfloat) height, 20000.0,
  12.137 +                   300000.0);
  12.138      glMatrixMode(GL_MODELVIEW);
  12.139  }
  12.140  
  12.141 @@ -212,42 +216,42 @@
  12.142  {
  12.143      switch (key) {
  12.144      case 't':
  12.145 -    	Timing = !Timing;
  12.146 -    break;
  12.147 +        Timing = !Timing;
  12.148 +        break;
  12.149      case ' ':
  12.150 -    	switch(StrMode)
  12.151 -    	{
  12.152 -		    case GL_EXTENSIONS:
  12.153 -    			StrMode = GL_VENDOR;
  12.154 -		    break;
  12.155 -		    case GL_VENDOR:
  12.156 -		    	StrMode = GL_RENDERER;
  12.157 -		    break;
  12.158 -		    case GL_RENDERER:
  12.159 -		    	StrMode = GL_VERSION;
  12.160 -		    break;
  12.161 -		    case GL_VERSION:
  12.162 -		    	StrMode = GL_EXTENSIONS;
  12.163 -		    break;
  12.164 -		}
  12.165 -	break;
  12.166 -    case 27:           /* Esc will quit */
  12.167 +        switch (StrMode) {
  12.168 +        case GL_EXTENSIONS:
  12.169 +            StrMode = GL_VENDOR;
  12.170 +            break;
  12.171 +        case GL_VENDOR:
  12.172 +            StrMode = GL_RENDERER;
  12.173 +            break;
  12.174 +        case GL_RENDERER:
  12.175 +            StrMode = GL_VERSION;
  12.176 +            break;
  12.177 +        case GL_VERSION:
  12.178 +            StrMode = GL_EXTENSIONS;
  12.179 +            break;
  12.180 +        }
  12.181 +        break;
  12.182 +    case 27:                   /* Esc will quit */
  12.183          exit(1);
  12.184 -    break;
  12.185 -    case 's':             		/* "s" start animation */
  12.186 +        break;
  12.187 +    case 's':                  /* "s" start animation */
  12.188          moving = GL_TRUE;
  12.189          //glutIdleFunc(Animate);
  12.190 -    break;
  12.191 -    case 'a':          			/* "a" stop animation */
  12.192 +        break;
  12.193 +    case 'a':                  /* "a" stop animation */
  12.194          moving = GL_FALSE;
  12.195          //glutIdleFunc(NULL);
  12.196 -    break;
  12.197 -    case '.':          			/* "." will advance frame */
  12.198 +        break;
  12.199 +    case '.':                  /* "." will advance frame */
  12.200          if (!moving) {
  12.201              Atlantis_Animate();
  12.202          }
  12.203      }
  12.204  }
  12.205 +
  12.206  /*
  12.207  void Display(void)
  12.208  {
  12.209 @@ -273,10 +277,10 @@
  12.210  Atlantis_Display(void)
  12.211  {
  12.212      int i;
  12.213 -    static double th[4] = {0.0, 0.0, 0.0, 0.0};
  12.214 -	static double t1 = 0.0, t2 = 0.0, t;
  12.215 -	char num_str[128];
  12.216 -    
  12.217 +    static double th[4] = { 0.0, 0.0, 0.0, 0.0 };
  12.218 +    static double t1 = 0.0, t2 = 0.0, t;
  12.219 +    char num_str[128];
  12.220 +
  12.221      t1 = t2;
  12.222  
  12.223      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  12.224 @@ -303,56 +307,59 @@
  12.225      glScalef(0.45, 0.45, 0.3);
  12.226      DrawWhale(&babyWhale);
  12.227      glPopMatrix();
  12.228 -    
  12.229 -    if(Timing)
  12.230 -    {
  12.231 -		t2 = mtime();
  12.232 -		t = t2 - t1;
  12.233 -		if(t > 0.0001) t = 1.0 / t;
  12.234 -		
  12.235 -		glDisable(GL_LIGHTING);
  12.236 -		//glDisable(GL_DEPTH_TEST);
  12.237 -		
  12.238 -		glColor3f(1.0, 0.0, 0.0);
  12.239 -		
  12.240 -		glMatrixMode (GL_PROJECTION);
  12.241 -		glPushMatrix();
  12.242 -		glLoadIdentity();
  12.243 -		glOrtho(0, w_win, 0, h_win, -10.0, 10.0);
  12.244 -		
  12.245 -		glRasterPos2f(5.0, 5.0);
  12.246 -		
  12.247 -		switch(StrMode)
  12.248 -		{
  12.249 -			case GL_VENDOR:
  12.250 -				sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win);
  12.251 -				DrawStr(num_str);
  12.252 -				DrawStr(glGetString(GL_VENDOR));
  12.253 -			break;
  12.254 -			case GL_RENDERER:
  12.255 -				sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win);
  12.256 -				DrawStr(num_str);
  12.257 -				DrawStr(glGetString(GL_RENDERER));
  12.258 -			break;
  12.259 -			case GL_VERSION:
  12.260 -				sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win);
  12.261 -				DrawStr(num_str);
  12.262 -				DrawStr(glGetString(GL_VERSION));
  12.263 -			break;
  12.264 -			case GL_EXTENSIONS:
  12.265 -				sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win);
  12.266 -				DrawStr(num_str);
  12.267 -				DrawStr(glGetString(GL_EXTENSIONS));
  12.268 -			break;
  12.269 -		}
  12.270 -		
  12.271 -		glPopMatrix();
  12.272 -		glMatrixMode(GL_MODELVIEW);
  12.273 -		
  12.274 -		glEnable(GL_LIGHTING);
  12.275 -		//glEnable(GL_DEPTH_TEST);
  12.276 -	}
  12.277 -	
  12.278 +
  12.279 +    if (Timing) {
  12.280 +        t2 = mtime();
  12.281 +        t = t2 - t1;
  12.282 +        if (t > 0.0001)
  12.283 +            t = 1.0 / t;
  12.284 +
  12.285 +        glDisable(GL_LIGHTING);
  12.286 +        //glDisable(GL_DEPTH_TEST);
  12.287 +
  12.288 +        glColor3f(1.0, 0.0, 0.0);
  12.289 +
  12.290 +        glMatrixMode(GL_PROJECTION);
  12.291 +        glPushMatrix();
  12.292 +        glLoadIdentity();
  12.293 +        glOrtho(0, w_win, 0, h_win, -10.0, 10.0);
  12.294 +
  12.295 +        glRasterPos2f(5.0, 5.0);
  12.296 +
  12.297 +        switch (StrMode) {
  12.298 +        case GL_VENDOR:
  12.299 +            sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th),
  12.300 +                    w_win, h_win);
  12.301 +            DrawStr(num_str);
  12.302 +            DrawStr(glGetString(GL_VENDOR));
  12.303 +            break;
  12.304 +        case GL_RENDERER:
  12.305 +            sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th),
  12.306 +                    w_win, h_win);
  12.307 +            DrawStr(num_str);
  12.308 +            DrawStr(glGetString(GL_RENDERER));
  12.309 +            break;
  12.310 +        case GL_VERSION:
  12.311 +            sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th),
  12.312 +                    w_win, h_win);
  12.313 +            DrawStr(num_str);
  12.314 +            DrawStr(glGetString(GL_VERSION));
  12.315 +            break;
  12.316 +        case GL_EXTENSIONS:
  12.317 +            sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th),
  12.318 +                    w_win, h_win);
  12.319 +            DrawStr(num_str);
  12.320 +            DrawStr(glGetString(GL_EXTENSIONS));
  12.321 +            break;
  12.322 +        }
  12.323 +
  12.324 +        glPopMatrix();
  12.325 +        glMatrixMode(GL_MODELVIEW);
  12.326 +
  12.327 +        glEnable(GL_LIGHTING);
  12.328 +        //glEnable(GL_DEPTH_TEST);
  12.329 +    }
  12.330 +
  12.331      count++;
  12.332  
  12.333      glutSwapBuffers();
  12.334 @@ -456,4 +463,4 @@
  12.335      glutMainLoop();
  12.336      return 0;             // ANSI C requires main to return int.
  12.337  }
  12.338 -*/
  12.339 \ No newline at end of file
  12.340 +*/
    13.1 --- a/Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/atlantis/atlantis.h	Mon Jul 23 18:46:09 2007 +0000
    13.2 +++ b/Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/atlantis/atlantis.h	Tue Jul 24 18:46:45 2007 +0000
    13.3 @@ -43,7 +43,8 @@
    13.4  
    13.5  #define WHALESPEED 250.0
    13.6  
    13.7 -typedef struct _fishRec {
    13.8 +typedef struct _fishRec
    13.9 +{
   13.10      float x, y, z, phi, theta, psi, v;
   13.11      float xt, yt, zt;
   13.12      float htail, vtail;
    14.1 --- a/Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/atlantis/swim.c	Mon Jul 23 18:46:09 2007 +0000
    14.2 +++ b/Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/atlantis/swim.c	Tue Jul 24 18:46:45 2007 +0000
    14.3 @@ -35,7 +35,7 @@
    14.4   * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
    14.5   */
    14.6  #include <math.h>
    14.7 -#include <stdlib.h>  /* For rand(). */
    14.8 +#include <stdlib.h>             /* For rand(). */
    14.9  #include <GLUT/glut.h>
   14.10  #include "atlantis.h"
   14.11  
   14.12 @@ -57,8 +57,10 @@
   14.13      fish->theta = 0.0;
   14.14      fish->psi -= 0.5;
   14.15  
   14.16 -    fish->x += WHALESPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
   14.17 -    fish->y += WHALESPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
   14.18 +    fish->x +=
   14.19 +        WHALESPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
   14.20 +    fish->y +=
   14.21 +        WHALESPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
   14.22      fish->z += WHALESPEED * fish->v * sin(fish->theta / RAD);
   14.23  }
   14.24  
   14.25 @@ -152,8 +154,10 @@
   14.26          }
   14.27      }
   14.28  
   14.29 -    fish->x += SHARKSPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
   14.30 -    fish->y += SHARKSPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
   14.31 +    fish->x +=
   14.32 +        SHARKSPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
   14.33 +    fish->y +=
   14.34 +        SHARKSPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
   14.35      fish->z += SHARKSPEED * fish->v * sin(fish->theta / RAD);
   14.36  }
   14.37  
    15.1 --- a/Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/main.c	Mon Jul 23 18:46:09 2007 +0000
    15.2 +++ b/Xcode/TemplatesForProjectBuilder/SDL OpenGL Application/main.c	Tue Jul 24 18:46:45 2007 +0000
    15.3 @@ -4,7 +4,7 @@
    15.4     Please see the SDL documentation for details on using the SDL API:
    15.5     /Developer/Documentation/SDL/docs.html
    15.6  */
    15.7 -   
    15.8 +
    15.9  #include <stdio.h>
   15.10  #include <stdlib.h>
   15.11  #include <string.h>
   15.12 @@ -12,168 +12,176 @@
   15.13  
   15.14  #include "SDL.h"
   15.15  
   15.16 -extern void Atlantis_Init ();
   15.17 -extern void Atlantis_Reshape (int w, int h);
   15.18 -extern void Atlantis_Animate ();
   15.19 -extern void Atlantis_Display ();
   15.20 +extern void Atlantis_Init();
   15.21 +extern void Atlantis_Reshape(int w, int h);
   15.22 +extern void Atlantis_Animate();
   15.23 +extern void Atlantis_Display();
   15.24  
   15.25  static SDL_Surface *gScreen;
   15.26  
   15.27 -static void initAttributes ()
   15.28 +static void
   15.29 +initAttributes()
   15.30  {
   15.31      // Setup attributes we want for the OpenGL context
   15.32 -    
   15.33 +
   15.34      int value;
   15.35 -    
   15.36 +
   15.37      // Don't set color bit sizes (SDL_GL_RED_SIZE, etc)
   15.38      //    Mac OS X will always use 8-8-8-8 ARGB for 32-bit screens and
   15.39      //    5-5-5 RGB for 16-bit screens
   15.40 -    
   15.41 +
   15.42      // Request a 16-bit depth buffer (without this, there is no depth buffer)
   15.43      value = 16;
   15.44 -    SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, value);
   15.45 -    
   15.46 -    
   15.47 +    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, value);
   15.48 +
   15.49 +
   15.50      // Request double-buffered OpenGL
   15.51      //     The fact that windows are double-buffered on Mac OS X has no effect
   15.52      //     on OpenGL double buffering.
   15.53      value = 1;
   15.54 -    SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, value);
   15.55 +    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, value);
   15.56  }
   15.57  
   15.58 -static void printAttributes ()
   15.59 +static void
   15.60 +printAttributes()
   15.61  {
   15.62      // Print out attributes of the context we created
   15.63      int nAttr;
   15.64      int i;
   15.65 -    
   15.66 -    int  attr[] = { SDL_GL_RED_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_GREEN_SIZE,
   15.67 -                    SDL_GL_ALPHA_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_DEPTH_SIZE };
   15.68 -                    
   15.69 -    char *desc[] = { "Red size: %d bits\n", "Blue size: %d bits\n", "Green size: %d bits\n",
   15.70 -                     "Alpha size: %d bits\n", "Color buffer size: %d bits\n", 
   15.71 -                     "Depth bufer size: %d bits\n" };
   15.72 +
   15.73 +    int attr[] = { SDL_GL_RED_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_GREEN_SIZE,
   15.74 +        SDL_GL_ALPHA_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_DEPTH_SIZE
   15.75 +    };
   15.76 +
   15.77 +    char *desc[] =
   15.78 +        { "Red size: %d bits\n", "Blue size: %d bits\n",
   15.79 + "Green size: %d bits\n",
   15.80 +        "Alpha size: %d bits\n", "Color buffer size: %d bits\n",
   15.81 +        "Depth bufer size: %d bits\n"
   15.82 +    };
   15.83  
   15.84      nAttr = sizeof(attr) / sizeof(int);
   15.85 -    
   15.86 +
   15.87      for (i = 0; i < nAttr; i++) {
   15.88 -    
   15.89 +
   15.90          int value;
   15.91 -        SDL_GL_GetAttribute (attr[i], &value);
   15.92 -        printf (desc[i], value);
   15.93 -    } 
   15.94 +        SDL_GL_GetAttribute(attr[i], &value);
   15.95 +        printf(desc[i], value);
   15.96 +    }
   15.97  }
   15.98  
   15.99 -static void createSurface (int fullscreen)
  15.100 +static void
  15.101 +createSurface(int fullscreen)
  15.102  {
  15.103      Uint32 flags = 0;
  15.104 -    
  15.105 +
  15.106      flags = SDL_OPENGL;
  15.107      if (fullscreen)
  15.108          flags |= SDL_FULLSCREEN;
  15.109 -    
  15.110 +
  15.111      // Create window
  15.112 -    gScreen = SDL_SetVideoMode (640, 480, 0, flags);
  15.113 +    gScreen = SDL_SetVideoMode(640, 480, 0, flags);
  15.114      if (gScreen == NULL) {
  15.115 -		
  15.116 -        fprintf (stderr, "Couldn't set 640x480 OpenGL video mode: %s\n",
  15.117 -                 SDL_GetError());
  15.118 -		SDL_Quit();
  15.119 -		exit(2);
  15.120 -	}
  15.121 +
  15.122 +        fprintf(stderr, "Couldn't set 640x480 OpenGL video mode: %s\n",
  15.123 +                SDL_GetError());
  15.124 +        SDL_Quit();
  15.125 +        exit(2);
  15.126 +    }
  15.127  }
  15.128  
  15.129 -static void initGL ()
  15.130 +static void
  15.131 +initGL()
  15.132  {
  15.133 -    Atlantis_Init ();
  15.134 -    Atlantis_Reshape (gScreen->w, gScreen->h);
  15.135 +    Atlantis_Init();
  15.136 +    Atlantis_Reshape(gScreen->w, gScreen->h);
  15.137  }
  15.138  
  15.139 -static void drawGL ()
  15.140 +static void
  15.141 +drawGL()
  15.142  {
  15.143 -    Atlantis_Animate ();
  15.144 -    Atlantis_Display ();
  15.145 +    Atlantis_Animate();
  15.146 +    Atlantis_Display();
  15.147  }
  15.148  
  15.149 -static void mainLoop ()
  15.150 +static void
  15.151 +mainLoop()
  15.152  {
  15.153      SDL_Event event;
  15.154      int done = 0;
  15.155      int fps = 24;
  15.156 -	int delay = 1000/fps;
  15.157 +    int delay = 1000 / fps;
  15.158      int thenTicks = -1;
  15.159      int nowTicks;
  15.160 -    
  15.161 -    while ( !done ) {
  15.162  
  15.163 -		/* Check for events */
  15.164 -		while ( SDL_PollEvent (&event) ) {
  15.165 -			switch (event.type) {
  15.166 +    while (!done) {
  15.167  
  15.168 -				case SDL_MOUSEMOTION:
  15.169 -					break;
  15.170 -				case SDL_MOUSEBUTTONDOWN:
  15.171 -					break;
  15.172 -				case SDL_KEYDOWN:
  15.173 -					/* Any keypress quits the app... */
  15.174 -				case SDL_QUIT:
  15.175 -					done = 1;
  15.176 -					break;
  15.177 -				default:
  15.178 -					break;
  15.179 -			}
  15.180 -		}
  15.181 -    
  15.182 +        /* Check for events */
  15.183 +        while (SDL_PollEvent(&event)) {
  15.184 +            switch (event.type) {
  15.185 +
  15.186 +            case SDL_MOUSEMOTION:
  15.187 +                break;
  15.188 +            case SDL_MOUSEBUTTONDOWN:
  15.189 +                break;
  15.190 +            case SDL_KEYDOWN:
  15.191 +                /* Any keypress quits the app... */
  15.192 +            case SDL_QUIT:
  15.193 +                done = 1;
  15.194 +                break;
  15.195 +            default:
  15.196 +                break;
  15.197 +            }
  15.198 +        }
  15.199 +
  15.200          // Draw at 24 hz
  15.201          //     This approach is not normally recommended - it is better to
  15.202          //     use time-based animation and run as fast as possible
  15.203 -        drawGL ();
  15.204 -        SDL_GL_SwapBuffers ();
  15.205 +        drawGL();
  15.206 +        SDL_GL_SwapBuffers();
  15.207  
  15.208          // Time how long each draw-swap-delay cycle takes
  15.209          // and adjust delay to get closer to target framerate
  15.210          if (thenTicks > 0) {
  15.211 -            nowTicks = SDL_GetTicks ();
  15.212 -            delay += (1000/fps - (nowTicks-thenTicks));
  15.213 +            nowTicks = SDL_GetTicks();
  15.214 +            delay += (1000 / fps - (nowTicks - thenTicks));
  15.215              thenTicks = nowTicks;
  15.216              if (delay < 0)
  15.217 -                delay = 1000/fps;
  15.218 -        }
  15.219 -        else {
  15.220 -            thenTicks = SDL_GetTicks ();
  15.221 +                delay = 1000 / fps;
  15.222 +        } else {
  15.223 +            thenTicks = SDL_GetTicks();
  15.224          }
  15.225  
  15.226 -        SDL_Delay (delay);
  15.227 -	}
  15.228 +        SDL_Delay(delay);
  15.229 +    }
  15.230  }
  15.231  
  15.232 -int main(int argc, char *argv[])
  15.233 +int
  15.234 +main(int argc, char *argv[])
  15.235  {
  15.236 -	// Init SDL video subsystem
  15.237 -	if ( SDL_Init (SDL_INIT_VIDEO) < 0 ) {
  15.238 -		
  15.239 -        fprintf(stderr, "Couldn't initialize SDL: %s\n",
  15.240 -			SDL_GetError());
  15.241 -		exit(1);
  15.242 -	}
  15.243 +    // Init SDL video subsystem
  15.244 +    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
  15.245  
  15.246 +        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
  15.247 +        exit(1);
  15.248 +    }
  15.249      // Set GL context attributes
  15.250 -    initAttributes ();
  15.251 -    
  15.252 +    initAttributes();
  15.253 +
  15.254      // Create GL context
  15.255 -    createSurface (0);
  15.256 -    
  15.257 +    createSurface(0);
  15.258 +
  15.259      // Get GL context attributes
  15.260 -    printAttributes ();
  15.261 -    
  15.262 +    printAttributes();
  15.263 +
  15.264      // Init GL state
  15.265 -    initGL ();
  15.266 -    
  15.267 +    initGL();
  15.268 +
  15.269      // Draw, get events...
  15.270 -    mainLoop ();
  15.271 -    
  15.272 +    mainLoop();
  15.273 +
  15.274      // Cleanup
  15.275 -	SDL_Quit();
  15.276 -	
  15.277 +    SDL_Quit();
  15.278 +
  15.279      return 0;
  15.280  }
    16.1 --- a/Xcode/TemplatesForXcode/SDL Application/SDLMain.h	Mon Jul 23 18:46:09 2007 +0000
    16.2 +++ b/Xcode/TemplatesForXcode/SDL Application/SDLMain.h	Tue Jul 24 18:46:45 2007 +0000
    16.3 @@ -7,5 +7,4 @@
    16.4  
    16.5  #import <Cocoa/Cocoa.h>
    16.6  
    16.7 -@interface SDLMain : NSObject
    16.8 -@end
    16.9 +@ interface SDLMain:NSObject @ end
    17.1 --- a/Xcode/TemplatesForXcode/SDL Application/main.c	Mon Jul 23 18:46:09 2007 +0000
    17.2 +++ b/Xcode/TemplatesForXcode/SDL Application/main.c	Tue Jul 24 18:46:45 2007 +0000
    17.3 @@ -4,7 +4,7 @@
    17.4     Please see the SDL documentation for details on using the SDL API:
    17.5     /Developer/Documentation/SDL/docs.html
    17.6  */
    17.7 -   
    17.8 +
    17.9  #include <stdio.h>
   17.10  #include <stdlib.h>
   17.11  #include <string.h>
   17.12 @@ -12,54 +12,54 @@
   17.13  
   17.14  #include "SDL.h"
   17.15  
   17.16 -int main(int argc, char *argv[])
   17.17 +int
   17.18 +main(int argc, char *argv[])
   17.19  {
   17.20 -	Uint32 initflags = SDL_INIT_VIDEO;  /* See documentation for details */
   17.21 -	SDL_Surface *screen;
   17.22 -	Uint8  video_bpp = 0;
   17.23 -	Uint32 videoflags = SDL_SWSURFACE;
   17.24 -	int    done;
   17.25 -        SDL_Event event;
   17.26 +    Uint32 initflags = SDL_INIT_VIDEO;  /* See documentation for details */
   17.27 +    SDL_Surface *screen;
   17.28 +    Uint8 video_bpp = 0;
   17.29 +    Uint32 videoflags = SDL_SWSURFACE;
   17.30 +    int done;
   17.31 +    SDL_Event event;
   17.32  
   17.33 -	/* Initialize the SDL library */
   17.34 -	if ( SDL_Init(initflags) < 0 ) {
   17.35 -		fprintf(stderr, "Couldn't initialize SDL: %s\n",
   17.36 -			SDL_GetError());
   17.37 -		exit(1);
   17.38 -	}
   17.39 +    /* Initialize the SDL library */
   17.40 +    if (SDL_Init(initflags) < 0) {
   17.41 +        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   17.42 +        exit(1);
   17.43 +    }
   17.44  
   17.45 -	/* Set 640x480 video mode */
   17.46 -	screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
   17.47 -        if (screen == NULL) {
   17.48 -		fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
   17.49 -                        video_bpp, SDL_GetError());
   17.50 -		SDL_Quit();
   17.51 -		exit(2);
   17.52 -	}
   17.53 +    /* Set 640x480 video mode */
   17.54 +    screen = SDL_SetVideoMode(640, 480, video_bpp, videoflags);
   17.55 +    if (screen == NULL) {
   17.56 +        fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
   17.57 +                video_bpp, SDL_GetError());
   17.58 +        SDL_Quit();
   17.59 +        exit(2);
   17.60 +    }
   17.61  
   17.62 -	done = 0;
   17.63 -	while ( !done ) {
   17.64 +    done = 0;
   17.65 +    while (!done) {
   17.66  
   17.67 -		/* Check for events */
   17.68 -		while ( SDL_PollEvent(&event) ) {
   17.69 -			switch (event.type) {
   17.70 +        /* Check for events */
   17.71 +        while (SDL_PollEvent(&event)) {
   17.72 +            switch (event.type) {
   17.73  
   17.74 -				case SDL_MOUSEMOTION:
   17.75 -					break;
   17.76 -				case SDL_MOUSEBUTTONDOWN:
   17.77 -					break;
   17.78 -				case SDL_KEYDOWN:
   17.79 -					/* Any keypress quits the app... */
   17.80 -				case SDL_QUIT:
   17.81 -					done = 1;
   17.82 -					break;
   17.83 -				default:
   17.84 -					break;
   17.85 -			}
   17.86 -		}
   17.87 -	}
   17.88 -	
   17.89 -	/* Clean up the SDL library */
   17.90 -	SDL_Quit();
   17.91 -	return(0);
   17.92 +            case SDL_MOUSEMOTION:
   17.93 +                break;
   17.94 +            case SDL_MOUSEBUTTONDOWN:
   17.95 +                break;
   17.96 +            case SDL_KEYDOWN:
   17.97 +                /* Any keypress quits the app... */
   17.98 +            case SDL_QUIT:
   17.99 +                done = 1;
  17.100 +                break;
  17.101 +            default:
  17.102 +                break;
  17.103 +            }
  17.104 +        }
  17.105 +    }
  17.106 +
  17.107 +    /* Clean up the SDL library */
  17.108 +    SDL_Quit();
  17.109 +    return (0);
  17.110  }
    18.1 --- a/Xcode/TemplatesForXcode/SDL Cocoa Application/SDLMain.h	Mon Jul 23 18:46:09 2007 +0000
    18.2 +++ b/Xcode/TemplatesForXcode/SDL Cocoa Application/SDLMain.h	Tue Jul 24 18:46:45 2007 +0000
    18.3 @@ -7,11 +7,10 @@
    18.4  
    18.5  #import <Cocoa/Cocoa.h>
    18.6  
    18.7 -@interface SDLMain : NSObject
    18.8 -- (IBAction)prefsMenu:(id)sender;
    18.9 -- (IBAction)newGame:(id)sender;
   18.10 -- (IBAction)openGame:(id)sender;
   18.11 -- (IBAction)saveGame:(id)sender;
   18.12 -- (IBAction)saveGameAs:(id)sender;
   18.13 -- (IBAction)help:(id)sender;
   18.14 +@ interface SDLMain: NSObject - (IBAction) prefsMenu:(id) sender;
   18.15 +-(IBAction) newGame:(id) sender;
   18.16 +-(IBAction) openGame:(id) sender;
   18.17 +-(IBAction) saveGame:(id) sender;
   18.18 +-(IBAction) saveGameAs:(id) sender;
   18.19 +-(IBAction) help:(id) sender;
   18.20  @end
    19.1 --- a/Xcode/TemplatesForXcode/SDL Cocoa Application/main.c	Mon Jul 23 18:46:09 2007 +0000
    19.2 +++ b/Xcode/TemplatesForXcode/SDL Cocoa Application/main.c	Tue Jul 24 18:46:45 2007 +0000
    19.3 @@ -4,7 +4,7 @@
    19.4     Please see the SDL documentation for details on using the SDL API:
    19.5     /Developer/Documentation/SDL/docs.html
    19.6  */
    19.7 -   
    19.8 +
    19.9  #include <stdio.h>
   19.10  #include <stdlib.h>
   19.11  #include <string.h>
   19.12 @@ -12,54 +12,54 @@
   19.13  
   19.14  #include "SDL.h"
   19.15  
   19.16 -int main(int argc, char *argv[])
   19.17 +int
   19.18 +main(int argc, char *argv[])
   19.19  {
   19.20 -	Uint32 initflags = SDL_INIT_VIDEO;  /* See documentation for details */
   19.21 -	SDL_Surface *screen;
   19.22 -	Uint8  video_bpp = 0;
   19.23 -	Uint32 videoflags = SDL_SWSURFACE;
   19.24 -	int    done;
   19.25 -        SDL_Event event;
   19.26 +    Uint32 initflags = SDL_INIT_VIDEO;  /* See documentation for details */
   19.27 +    SDL_Surface *screen;
   19.28 +    Uint8 video_bpp = 0;
   19.29 +    Uint32 videoflags = SDL_SWSURFACE;
   19.30 +    int done;
   19.31 +    SDL_Event event;
   19.32  
   19.33 -	/* Initialize the SDL library */
   19.34 -	if ( SDL_Init(initflags) < 0 ) {
   19.35 -		fprintf(stderr, "Couldn't initialize SDL: %s\n",
   19.36 -			SDL_GetError());
   19.37 -		exit(1);
   19.38 -	}
   19.39 +    /* Initialize the SDL library */
   19.40 +    if (SDL_Init(initflags) < 0) {
   19.41 +        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
   19.42 +        exit(1);
   19.43 +    }
   19.44  
   19.45 -	/* Set 640x480 video mode */
   19.46 -	screen=SDL_SetVideoMode(640,480, video_bpp, videoflags);
   19.47 -        if (screen == NULL) {
   19.48 -		fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
   19.49 -                        video_bpp, SDL_GetError());
   19.50 -		SDL_Quit();
   19.51 -		exit(2);
   19.52 -	}
   19.53 +    /* Set 640x480 video mode */
   19.54 +    screen = SDL_SetVideoMode(640, 480, video_bpp, videoflags);
   19.55 +    if (screen == NULL) {
   19.56 +        fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
   19.57 +                video_bpp, SDL_GetError());
   19.58 +        SDL_Quit();
   19.59 +        exit(2);
   19.60 +    }
   19.61  
   19.62 -	done = 0;
   19.63 -	while ( !done ) {
   19.64 +    done = 0;
   19.65 +    while (!done) {
   19.66  
   19.67 -		/* Check for events */
   19.68 -		while ( SDL_PollEvent(&event) ) {
   19.69 -			switch (event.type) {
   19.70 +        /* Check for events */
   19.71 +        while (SDL_PollEvent(&event)) {
   19.72 +            switch (event.type) {
   19.73  
   19.74 -				case SDL_MOUSEMOTION:
   19.75 -					break;
   19.76 -				case SDL_MOUSEBUTTONDOWN:
   19.77 -					break;
   19.78 -				case SDL_KEYDOWN:
   19.79 -					/* Any keypress quits the app... */
   19.80 -				case SDL_QUIT:
   19.81 -					done = 1;
   19.82 -					break;
   19.83 -				default:
   19.84 -					break;
   19.85 -			}
   19.86 -		}
   19.87 -	}
   19.88 -	
   19.89 -	/* Clean up the SDL library */
   19.90 -	SDL_Quit();
   19.91 -	return(0);
   19.92 +            case SDL_MOUSEMOTION:
   19.93 +                break;
   19.94 +            case SDL_MOUSEBUTTONDOWN:
   19.95 +                break;
   19.96 +            case SDL_KEYDOWN:
   19.97 +                /* Any keypress quits the app... */
   19.98 +            case SDL_QUIT:
   19.99 +                done = 1;
  19.100 +                break;
  19.101 +            default:
  19.102 +                break;
  19.103 +            }
  19.104 +        }
  19.105 +    }
  19.106 +
  19.107 +    /* Clean up the SDL library */
  19.108 +    SDL_Quit();
  19.109 +    return (0);
  19.110  }
    20.1 --- a/Xcode/TemplatesForXcode/SDL Custom Cocoa Application/MyController.h	Mon Jul 23 18:46:09 2007 +0000
    20.2 +++ b/Xcode/TemplatesForXcode/SDL Custom Cocoa Application/MyController.h	Tue Jul 24 18:46:45 2007 +0000
    20.3 @@ -9,38 +9,34 @@
    20.4  #import <Cocoa/Cocoa.h>
    20.5  #import "SDL.h"
    20.6  
    20.7 -extern id gController; // instance of this class from nib
    20.8 +extern id gController;          // instance of this class from nib
    20.9  
   20.10  // Declare SDL_QuartzWindowDelegate (defined in SDL.framework)
   20.11 -@interface SDL_QuartzWindowDelegate : NSObject
   20.12 +@interface SDL_QuartzWindowDelegate: NSObject @ end @ interface MyController:NSObject {
   20.13 +    // Interface Builder Outlets
   20.14 +    IBOutlet id _framesPerSecond;
   20.15 +    IBOutlet id _numSprites;
   20.16 +    IBOutlet id _window;
   20.17 +    IBOutlet id _view;
   20.18 +
   20.19 +    // Private instance variables
   20.20 +    int _nSprites;
   20.21 +    int _max_speed;
   20.22 +    int _doFlip;
   20.23 +    Uint8 *_mem;
   20.24 +
   20.25 +    SDL_Surface *_screen;
   20.26 +    SDL_Surface *_sprite;
   20.27 +    SDL_Rect *_sprite_rects;
   20.28 +    SDL_Rect *_positions;
   20.29 +    SDL_Rect *_velocities;
   20.30 +    int _sprites_visible;
   20.31 +    Uint16 _sprite_w, _sprite_h;
   20.32 +
   20.33 +    int _mouse_x, _mouse_y;
   20.34 +}
   20.35 +
   20.36 +// Interface Builder Actions
   20.37 +-(IBAction) changeNumberOfSprites:(id) sender;
   20.38 +-(IBAction) selectUpdateMode:(id) sender;
   20.39  @end
   20.40 -
   20.41 -@interface MyController : NSObject
   20.42 -{
   20.43 -    // Interface Builder Outlets
   20.44 -    IBOutlet id 	_framesPerSecond;
   20.45 -    IBOutlet id 	_numSprites;
   20.46 -    IBOutlet id 	_window;
   20.47 -    IBOutlet id 	_view;
   20.48 -    
   20.49 -    // Private instance variables
   20.50 -    int          _nSprites;
   20.51 -    int          _max_speed;
   20.52 -    int          _doFlip;
   20.53 -    Uint8*       _mem;
   20.54 -    
   20.55 -    SDL_Surface* _screen;
   20.56 -    SDL_Surface* _sprite;
   20.57 -    SDL_Rect*    _sprite_rects;
   20.58 -    SDL_Rect*    _positions;
   20.59 -    SDL_Rect*    _velocities;
   20.60 -    int          _sprites_visible;
   20.61 -    Uint16       _sprite_w, _sprite_h;
   20.62 -    
   20.63 -    int 		 _mouse_x, _mouse_y;
   20.64 -}
   20.65 -// Interface Builder Actions
   20.66 -- (IBAction)changeNumberOfSprites:(id)sender;
   20.67 -- (IBAction)selectUpdateMode:(id)sender;
   20.68 -@end
   20.69 -
    21.1 --- a/Xcode/TemplatesForXcode/SDL Custom Cocoa Application/MyCustomView.h	Mon Jul 23 18:46:09 2007 +0000
    21.2 +++ b/Xcode/TemplatesForXcode/SDL Custom Cocoa Application/MyCustomView.h	Tue Jul 24 18:46:45 2007 +0000
    21.3 @@ -9,8 +9,7 @@
    21.4  #import <AppKit/AppKit.h>
    21.5  
    21.6  
    21.7 -@interface MyCustomView : NSQuickDrawView
    21.8 -{
    21.9 +@ interface MyCustomView:NSQuickDrawView {
   21.10  }
   21.11  
   21.12  @end
    22.1 --- a/Xcode/TemplatesForXcode/SDL Custom Cocoa Application/MyCustomWindow.h	Mon Jul 23 18:46:09 2007 +0000
    22.2 +++ b/Xcode/TemplatesForXcode/SDL Custom Cocoa Application/MyCustomWindow.h	Tue Jul 24 18:46:45 2007 +0000
    22.3 @@ -11,17 +11,11 @@
    22.4  // Be a subclass of SDL_QuartzWindow so SDL will
    22.5  // handle the redraw problems when minimizing the window
    22.6  // This class is defined in SDL.framework
    22.7 -@interface SDL_QuartzWindow : NSWindow
    22.8 -@end
    22.9 -
   22.10 +@ interface SDL_QuartzWindow:NSWindow @ end
   22.11  // Also assign SDL_QuartzWindowDelegate to the window
   22.12  // to perform other tasks. You can subclass this delegate
   22.13  // if you want to add your own delegation methods
   22.14  // This class is defined in SDL.framework
   22.15 -@interface SDL_QuartzWindowDelegate : NSObject
   22.16 -@end
   22.17 -
   22.18 +@ interface SDL_QuartzWindowDelegate:NSObject @ end
   22.19  // Declare our custom class
   22.20 -@interface MyCustomWindow : SDL_QuartzWindow
   22.21 -@end
   22.22 -
   22.23 +@ interface MyCustomWindow:SDL_QuartzWindow @ end
    23.1 --- a/Xcode/TemplatesForXcode/SDL Custom Cocoa Application/SDLMain.h	Mon Jul 23 18:46:09 2007 +0000
    23.2 +++ b/Xcode/TemplatesForXcode/SDL Custom Cocoa Application/SDLMain.h	Tue Jul 24 18:46:45 2007 +0000
    23.3 @@ -7,8 +7,8 @@
    23.4  
    23.5  #import <Cocoa/Cocoa.h>
    23.6  
    23.7 -@interface SDLMain : NSObject
    23.8 -{
    23.9 +@ interface SDLMain:NSObject {
   23.10      IBOutlet id _controller;
   23.11  }
   23.12 +
   23.13  @end
    24.1 --- a/Xcode/TemplatesForXcode/SDL OpenGL Application/SDLMain.h	Mon Jul 23 18:46:09 2007 +0000
    24.2 +++ b/Xcode/TemplatesForXcode/SDL OpenGL Application/SDLMain.h	Tue Jul 24 18:46:45 2007 +0000
    24.3 @@ -7,5 +7,4 @@
    24.4  
    24.5  #import <Cocoa/Cocoa.h>
    24.6  
    24.7 -@interface SDLMain : NSObject
    24.8 -@end
    24.9 +@ interface SDLMain:NSObject @ end
    25.1 --- a/Xcode/TemplatesForXcode/SDL OpenGL Application/atlantis/atlantis.c	Mon Jul 23 18:46:09 2007 +0000
    25.2 +++ b/Xcode/TemplatesForXcode/SDL OpenGL Application/atlantis/atlantis.c	Tue Jul 24 18:46:45 2007 +0000
    25.3 @@ -54,46 +54,49 @@
    25.4  
    25.5  int w_win = 640;
    25.6  int h_win = 480;
    25.7 -GLint count  = 0;
    25.8 +GLint count = 0;
    25.9  GLenum StrMode = GL_VENDOR;
   25.10  
   25.11  GLboolean moving;
   25.12  
   25.13 -static double mtime(void)
   25.14 +static double
   25.15 +mtime(void)
   25.16  {
   25.17 -   struct timeval tk_time;
   25.18 -   struct timezone tz;
   25.19 -   
   25.20 -   gettimeofday(&tk_time, &tz);
   25.21 -   
   25.22 -   return 4294.967296 * tk_time.tv_sec + 0.000001 * tk_time.tv_usec;
   25.23 +    struct timeval tk_time;
   25.24 +    struct timezone tz;
   25.25 +
   25.26 +    gettimeofday(&tk_time, &tz);
   25.27 +
   25.28 +    return 4294.967296 * tk_time.tv_sec + 0.000001 * tk_time.tv_usec;
   25.29  }
   25.30  
   25.31 -static double filter(double in, double *save)
   25.32 +static double
   25.33 +filter(double in, double *save)
   25.34  {
   25.35 -	static double k1 = 0.9;
   25.36 -	static double k2 = 0.05;
   25.37 +    static double k1 = 0.9;
   25.38 +    static double k2 = 0.05;
   25.39  
   25.40 -	save[3] = in;
   25.41 -	save[1] = save[0]*k1 + k2*(save[3] + save[2]);
   25.42 +    save[3] = in;
   25.43 +    save[1] = save[0] * k1 + k2 * (save[3] + save[2]);
   25.44  
   25.45 -	save[0]=save[1];
   25.46 -	save[2]=save[3];
   25.47 +    save[0] = save[1];
   25.48 +    save[2] = save[3];
   25.49  
   25.50 -	return(save[1]);
   25.51 +    return (save[1]);
   25.52  }
   25.53  
   25.54 -void DrawStr(const char *str)
   25.55 +void
   25.56 +DrawStr(const char *str)
   25.57  {
   25.58 -	GLint i = 0;
   25.59 -	
   25.60 -	if(!str) return;
   25.61 -        
   25.62 -	while(str[i])
   25.63 -	{
   25.64 -		glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]);
   25.65 -		i++;
   25.66 -	}
   25.67 +    GLint i = 0;
   25.68 +
   25.69 +    if (!str)
   25.70 +        return;
   25.71 +
   25.72 +    while (str[i]) {
   25.73 +        glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, str[i]);
   25.74 +        i++;
   25.75 +    }
   25.76  }
   25.77  
   25.78  void
   25.79 @@ -134,18 +137,18 @@
   25.80  void
   25.81  Atlantis_Init(void)
   25.82  {
   25.83 -    static float ambient[] = {0.2, 0.2, 0.2, 1.0};
   25.84 -    static float diffuse[] = {1.0, 1.0, 1.0, 1.0};
   25.85 -    static float position[] = {0.0, 1.0, 0.0, 0.0};
   25.86 -    static float mat_shininess[] = {90.0};
   25.87 -    static float mat_specular[] = {0.8, 0.8, 0.8, 1.0};
   25.88 -    static float mat_diffuse[] = {0.46, 0.66, 0.795, 1.0};
   25.89 -    static float mat_ambient[] = {0.3, 0.4, 0.5, 1.0};
   25.90 -    static float lmodel_ambient[] = {0.4, 0.4, 0.4, 1.0};
   25.91 -    static float lmodel_localviewer[] = {0.0};
   25.92 +    static float ambient[] = { 0.2, 0.2, 0.2, 1.0 };
   25.93 +    static float diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
   25.94 +    static float position[] = { 0.0, 1.0, 0.0, 0.0 };
   25.95 +    static float mat_shininess[] = { 90.0 };
   25.96 +    static float mat_specular[] = { 0.8, 0.8, 0.8, 1.0 };
   25.97 +    static float mat_diffuse[] = { 0.46, 0.66, 0.795, 1.0 };
   25.98 +    static float mat_ambient[] = { 0.3, 0.4, 0.5, 1.0 };
   25.99 +    static float lmodel_ambient[] = { 0.4, 0.4, 0.4, 1.0 };
  25.100 +    static float lmodel_localviewer[] = { 0.0 };
  25.101      //GLfloat map1[4] = {0.0, 0.0, 0.0, 0.0};
  25.102      //GLfloat map2[4] = {0.0, 0.0, 0.0, 0.0};
  25.103 -    static float fog_color[] = {0.0, 0.5, 0.9, 1.0};
  25.104 +    static float fog_color[] = { 0.0, 0.5, 0.9, 1.0 };
  25.105  
  25.106      glFrontFace(GL_CCW);
  25.107  
  25.108 @@ -168,9 +171,9 @@
  25.109      InitFishs();
  25.110  
  25.111      glEnable(GL_FOG);
  25.112 -	glFogi(GL_FOG_MODE, GL_EXP);
  25.113 -	glFogf(GL_FOG_DENSITY, 0.0000025);
  25.114 -	glFogfv(GL_FOG_COLOR, fog_color);
  25.115 +    glFogi(GL_FOG_MODE, GL_EXP);
  25.116 +    glFogf(GL_FOG_DENSITY, 0.0000025);
  25.117 +    glFogfv(GL_FOG_COLOR, fog_color);
  25.118  
  25.119      glClearColor(0.0, 0.5, 0.9, 1.0);
  25.120  }
  25.121 @@ -178,14 +181,15 @@
  25.122  void
  25.123  Atlantis_Reshape(int width, int height)
  25.124  {
  25.125 -	w_win = width;
  25.126 -	h_win = height;
  25.127 -	
  25.128 +    w_win = width;
  25.129 +    h_win = height;
  25.130 +
  25.131      glViewport(0, 0, width, height);
  25.132  
  25.133      glMatrixMode(GL_PROJECTION);
  25.134      glLoadIdentity();
  25.135 -    gluPerspective(60.0, (GLfloat) width / (GLfloat) height, 20000.0, 300000.0);
  25.136 +    gluPerspective(60.0, (GLfloat) width / (GLfloat) height, 20000.0,
  25.137 +                   300000.0);
  25.138      glMatrixMode(GL_MODELVIEW);
  25.139  }
  25.140  
  25.141 @@ -212,42 +216,42 @@
  25.142  {
  25.143      switch (key) {
  25.144      case 't':
  25.145 -    	Timing = !Timing;
  25.146 -    break;
  25.147 +        Timing = !Timing;
  25.148 +        break;
  25.149      case ' ':
  25.150 -    	switch(StrMode)
  25.151 -    	{
  25.152 -		    case GL_EXTENSIONS:
  25.153 -    			StrMode = GL_VENDOR;
  25.154 -		    break;
  25.155 -		    case GL_VENDOR:
  25.156 -		    	StrMode = GL_RENDERER;
  25.157 -		    break;
  25.158 -		    case GL_RENDERER:
  25.159 -		    	StrMode = GL_VERSION;
  25.160 -		    break;
  25.161 -		    case GL_VERSION:
  25.162 -		    	StrMode = GL_EXTENSIONS;
  25.163 -		    break;
  25.164 -		}
  25.165 -	break;
  25.166 -    case 27:           /* Esc will quit */
  25.167 +        switch (StrMode) {
  25.168 +        case GL_EXTENSIONS:
  25.169 +            StrMode = GL_VENDOR;
  25.170 +            break;
  25.171 +        case GL_VENDOR:
  25.172 +            StrMode = GL_RENDERER;
  25.173 +            break;
  25.174 +        case GL_RENDERER:
  25.175 +            StrMode = GL_VERSION;
  25.176 +            break;
  25.177 +        case GL_VERSION:
  25.178 +            StrMode = GL_EXTENSIONS;
  25.179 +            break;
  25.180 +        }
  25.181 +        break;
  25.182 +    case 27:                   /* Esc will quit */
  25.183          exit(1);
  25.184 -    break;
  25.185 -    case 's':             		/* "s" start animation */
  25.186 +        break;
  25.187 +    case 's':                  /* "s" start animation */
  25.188          moving = GL_TRUE;
  25.189          //glutIdleFunc(Animate);
  25.190 -    break;
  25.191 -    case 'a':          			/* "a" stop animation */
  25.192 +        break;
  25.193 +    case 'a':                  /* "a" stop animation */
  25.194          moving = GL_FALSE;
  25.195          //glutIdleFunc(NULL);
  25.196 -    break;
  25.197 -    case '.':          			/* "." will advance frame */
  25.198 +        break;
  25.199 +    case '.':                  /* "." will advance frame */
  25.200          if (!moving) {
  25.201              Atlantis_Animate();
  25.202          }
  25.203      }
  25.204  }
  25.205 +
  25.206  /*
  25.207  void Display(void)
  25.208  {
  25.209 @@ -273,10 +277,10 @@
  25.210  Atlantis_Display(void)
  25.211  {
  25.212      int i;
  25.213 -    static double th[4] = {0.0, 0.0, 0.0, 0.0};
  25.214 -	static double t1 = 0.0, t2 = 0.0, t;
  25.215 -	char num_str[128];
  25.216 -    
  25.217 +    static double th[4] = { 0.0, 0.0, 0.0, 0.0 };
  25.218 +    static double t1 = 0.0, t2 = 0.0, t;
  25.219 +    char num_str[128];
  25.220 +
  25.221      t1 = t2;
  25.222  
  25.223      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  25.224 @@ -303,56 +307,59 @@
  25.225      glScalef(0.45, 0.45, 0.3);
  25.226      DrawWhale(&babyWhale);
  25.227      glPopMatrix();
  25.228 -    
  25.229 -    if(Timing)
  25.230 -    {
  25.231 -		t2 = mtime();
  25.232 -		t = t2 - t1;
  25.233 -		if(t > 0.0001) t = 1.0 / t;
  25.234 -		
  25.235 -		glDisable(GL_LIGHTING);
  25.236 -		//glDisable(GL_DEPTH_TEST);
  25.237 -		
  25.238 -		glColor3f(1.0, 0.0, 0.0);
  25.239 -		
  25.240 -		glMatrixMode (GL_PROJECTION);
  25.241 -		glPushMatrix();
  25.242 -		glLoadIdentity();
  25.243 -		glOrtho(0, w_win, 0, h_win, -10.0, 10.0);
  25.244 -		
  25.245 -		glRasterPos2f(5.0, 5.0);
  25.246 -		
  25.247 -		switch(StrMode)
  25.248 -		{
  25.249 -			case GL_VENDOR:
  25.250 -				sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th), w_win, h_win);
  25.251 -				DrawStr(num_str);
  25.252 -				DrawStr(glGetString(GL_VENDOR));
  25.253 -			break;
  25.254 -			case GL_RENDERER:
  25.255 -				sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th), w_win, h_win);
  25.256 -				DrawStr(num_str);
  25.257 -				DrawStr(glGetString(GL_RENDERER));
  25.258 -			break;
  25.259 -			case GL_VERSION:
  25.260 -				sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th), w_win, h_win);
  25.261 -				DrawStr(num_str);
  25.262 -				DrawStr(glGetString(GL_VERSION));
  25.263 -			break;
  25.264 -			case GL_EXTENSIONS:
  25.265 -				sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th), w_win, h_win);
  25.266 -				DrawStr(num_str);
  25.267 -				DrawStr(glGetString(GL_EXTENSIONS));
  25.268 -			break;
  25.269 -		}
  25.270 -		
  25.271 -		glPopMatrix();
  25.272 -		glMatrixMode(GL_MODELVIEW);
  25.273 -		
  25.274 -		glEnable(GL_LIGHTING);
  25.275 -		//glEnable(GL_DEPTH_TEST);
  25.276 -	}
  25.277 -	
  25.278 +
  25.279 +    if (Timing) {
  25.280 +        t2 = mtime();
  25.281 +        t = t2 - t1;
  25.282 +        if (t > 0.0001)
  25.283 +            t = 1.0 / t;
  25.284 +
  25.285 +        glDisable(GL_LIGHTING);
  25.286 +        //glDisable(GL_DEPTH_TEST);
  25.287 +
  25.288 +        glColor3f(1.0, 0.0, 0.0);
  25.289 +
  25.290 +        glMatrixMode(GL_PROJECTION);
  25.291 +        glPushMatrix();
  25.292 +        glLoadIdentity();
  25.293 +        glOrtho(0, w_win, 0, h_win, -10.0, 10.0);
  25.294 +
  25.295 +        glRasterPos2f(5.0, 5.0);
  25.296 +
  25.297 +        switch (StrMode) {
  25.298 +        case GL_VENDOR:
  25.299 +            sprintf(num_str, "%0.2f Hz, %dx%d, VENDOR: ", filter(t, th),
  25.300 +                    w_win, h_win);
  25.301 +            DrawStr(num_str);
  25.302 +            DrawStr(glGetString(GL_VENDOR));
  25.303 +            break;
  25.304 +        case GL_RENDERER:
  25.305 +            sprintf(num_str, "%0.2f Hz, %dx%d, RENDERER: ", filter(t, th),
  25.306 +                    w_win, h_win);
  25.307 +            DrawStr(num_str);
  25.308 +            DrawStr(glGetString(GL_RENDERER));
  25.309 +            break;
  25.310 +        case GL_VERSION:
  25.311 +            sprintf(num_str, "%0.2f Hz, %dx%d, VERSION: ", filter(t, th),
  25.312 +                    w_win, h_win);
  25.313 +            DrawStr(num_str);
  25.314 +            DrawStr(glGetString(GL_VERSION));
  25.315 +            break;
  25.316 +        case GL_EXTENSIONS:
  25.317 +            sprintf(num_str, "%0.2f Hz, %dx%d, EXTENSIONS: ", filter(t, th),
  25.318 +                    w_win, h_win);
  25.319 +            DrawStr(num_str);
  25.320 +            DrawStr(glGetString(GL_EXTENSIONS));
  25.321 +            break;
  25.322 +        }
  25.323 +
  25.324 +        glPopMatrix();
  25.325 +        glMatrixMode(GL_MODELVIEW);
  25.326 +
  25.327 +        glEnable(GL_LIGHTING);
  25.328 +        //glEnable(GL_DEPTH_TEST);
  25.329 +    }
  25.330 +
  25.331      count++;
  25.332  
  25.333      glutSwapBuffers();
  25.334 @@ -456,4 +463,4 @@
  25.335      glutMainLoop();
  25.336      return 0;             // ANSI C requires main to return int.
  25.337  }
  25.338 -*/
  25.339 \ No newline at end of file
  25.340 +*/
    26.1 --- a/Xcode/TemplatesForXcode/SDL OpenGL Application/atlantis/atlantis.h	Mon Jul 23 18:46:09 2007 +0000
    26.2 +++ b/Xcode/TemplatesForXcode/SDL OpenGL Application/atlantis/atlantis.h	Tue Jul 24 18:46:45 2007 +0000
    26.3 @@ -43,7 +43,8 @@
    26.4  
    26.5  #define WHALESPEED 250.0
    26.6  
    26.7 -typedef struct _fishRec {
    26.8 +typedef struct _fishRec
    26.9 +{
   26.10      float x, y, z, phi, theta, psi, v;
   26.11      float xt, yt, zt;
   26.12      float htail, vtail;
    27.1 --- a/Xcode/TemplatesForXcode/SDL OpenGL Application/atlantis/swim.c	Mon Jul 23 18:46:09 2007 +0000
    27.2 +++ b/Xcode/TemplatesForXcode/SDL OpenGL Application/atlantis/swim.c	Tue Jul 24 18:46:45 2007 +0000
    27.3 @@ -35,7 +35,7 @@
    27.4   * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
    27.5   */
    27.6  #include <math.h>
    27.7 -#include <stdlib.h>  /* For rand(). */
    27.8 +#include <stdlib.h>             /* For rand(). */
    27.9  #include <GLUT/glut.h>
   27.10  #include "atlantis.h"
   27.11  
   27.12 @@ -57,8 +57,10 @@
   27.13      fish->theta = 0.0;
   27.14      fish->psi -= 0.5;
   27.15  
   27.16 -    fish->x += WHALESPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
   27.17 -    fish->y += WHALESPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
   27.18 +    fish->x +=
   27.19 +        WHALESPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
   27.20 +    fish->y +=
   27.21 +        WHALESPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
   27.22      fish->z += WHALESPEED * fish->v * sin(fish->theta / RAD);
   27.23  }
   27.24  
   27.25 @@ -152,8 +154,10 @@
   27.26          }
   27.27      }
   27.28  
   27.29 -    fish->x += SHARKSPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
   27.30 -    fish->y += SHARKSPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
   27.31 +    fish->x +=
   27.32 +        SHARKSPEED * fish->v * cos(fish->psi / RAD) * cos(fish->theta / RAD);
   27.33 +    fish->y +=
   27.34 +        SHARKSPEED * fish->v * sin(fish->psi / RAD) * cos(fish->theta / RAD);
   27.35      fish->z += SHARKSPEED * fish->v * sin(fish->theta / RAD);
   27.36  }
   27.37  
    28.1 --- a/Xcode/TemplatesForXcode/SDL OpenGL Application/main.c	Mon Jul 23 18:46:09 2007 +0000
    28.2 +++ b/Xcode/TemplatesForXcode/SDL OpenGL Application/main.c	Tue Jul 24 18:46:45 2007 +0000
    28.3 @@ -4,7 +4,7 @@
    28.4     Please see the SDL documentation for details on using the SDL API:
    28.5     /Developer/Documentation/SDL/docs.html
    28.6  */
    28.7 -   
    28.8 +
    28.9  #include <stdio.h>
   28.10  #include <stdlib.h>
   28.11  #include <string.h>
   28.12 @@ -12,168 +12,176 @@
   28.13  
   28.14  #include "SDL.h"
   28.15  
   28.16 -extern void Atlantis_Init ();
   28.17 -extern void Atlantis_Reshape (int w, int h);
   28.18 -extern void Atlantis_Animate ();
   28.19 -extern void Atlantis_Display ();
   28.20 +extern void Atlantis_Init();
   28.21 +extern void Atlantis_Reshape(int w, int h);
   28.22 +extern void Atlantis_Animate();
   28.23 +extern void Atlantis_Display();
   28.24  
   28.25  static SDL_Surface *gScreen;
   28.26  
   28.27 -static void initAttributes ()
   28.28 +static void
   28.29 +initAttributes()
   28.30  {
   28.31      // Setup attributes we want for the OpenGL context
   28.32 -    
   28.33 +
   28.34      int value;
   28.35 -    
   28.36 +
   28.37      // Don't set color bit sizes (SDL_GL_RED_SIZE, etc)
   28.38      //    Mac OS X will always use 8-8-8-8 ARGB for 32-bit screens and
   28.39      //    5-5-5 RGB for 16-bit screens
   28.40 -    
   28.41 +
   28.42      // Request a 16-bit depth buffer (without this, there is no depth buffer)
   28.43      value = 16;
   28.44 -    SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, value);
   28.45 -    
   28.46 -    
   28.47 +    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, value);
   28.48 +
   28.49 +
   28.50      // Request double-buffered OpenGL
   28.51      //     The fact that windows are double-buffered on Mac OS X has no effect
   28.52      //     on OpenGL double buffering.
   28.53      value = 1;
   28.54 -    SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, value);
   28.55 +    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, value);
   28.56  }
   28.57  
   28.58 -static void printAttributes ()
   28.59 +static void
   28.60 +printAttributes()
   28.61  {
   28.62      // Print out attributes of the context we created
   28.63      int nAttr;
   28.64      int i;
   28.65 -    
   28.66 -    int  attr[] = { SDL_GL_RED_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_GREEN_SIZE,
   28.67 -                    SDL_GL_ALPHA_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_DEPTH_SIZE };
   28.68 -                    
   28.69 -    char *desc[] = { "Red size: %d bits\n", "Blue size: %d bits\n", "Green size: %d bits\n",
   28.70 -                     "Alpha size: %d bits\n", "Color buffer size: %d bits\n", 
   28.71 -                     "Depth bufer size: %d bits\n" };
   28.72 +
   28.73 +    int attr[] = { SDL_GL_RED_SIZE, SDL_GL_BLUE_SIZE, SDL_GL_GREEN_SIZE,
   28.74 +        SDL_GL_ALPHA_SIZE, SDL_GL_BUFFER_SIZE, SDL_GL_DEPTH_SIZE
   28.75 +    };
   28.76 +
   28.77 +    char *desc[] =
   28.78 +        { "Red size: %d bits\n", "Blue size: %d bits\n",
   28.79 + "Green size: %d bits\n",
   28.80 +        "Alpha size: %d bits\n", "Color buffer size: %d bits\n",
   28.81 +        "Depth bufer size: %d bits\n"
   28.82 +    };
   28.83  
   28.84      nAttr = sizeof(attr) / sizeof(int);
   28.85 -    
   28.86 +
   28.87      for (i = 0; i < nAttr; i++) {
   28.88 -    
   28.89 +
   28.90          int value;
   28.91 -        SDL_GL_GetAttribute (attr[i], &value);
   28.92 -        printf (desc[i], value);
   28.93 -    } 
   28.94 +        SDL_GL_GetAttribute(attr[i], &value);
   28.95 +        printf(desc[i], value);
   28.96 +    }
   28.97  }
   28.98  
   28.99 -static void createSurface (int fullscreen)
  28.100 +static void
  28.101 +createSurface(int fullscreen)
  28.102  {
  28.103      Uint32 flags = 0;
  28.104 -    
  28.105 +
  28.106      flags = SDL_OPENGL;
  28.107      if (fullscreen)
  28.108          flags |= SDL_FULLSCREEN;
  28.109 -    
  28.110 +
  28.111      // Create window
  28.112 -    gScreen = SDL_SetVideoMode (640, 480, 0, flags);
  28.113 +    gScreen = SDL_SetVideoMode(640, 480, 0, flags);
  28.114      if (gScreen == NULL) {
  28.115 -		
  28.116 -        fprintf (stderr, "Couldn't set 640x480 OpenGL video mode: %s\n",
  28.117 -                 SDL_GetError());
  28.118 -		SDL_Quit();
  28.119 -		exit(2);
  28.120 -	}
  28.121 +
  28.122 +        fprintf(stderr, "Couldn't set 640x480 OpenGL video mode: %s\n",
  28.123 +                SDL_GetError());
  28.124 +        SDL_Quit();
  28.125 +        exit(2);
  28.126 +    }
  28.127  }
  28.128  
  28.129 -static void initGL ()
  28.130 +static void
  28.131 +initGL()
  28.132  {
  28.133 -    Atlantis_Init ();
  28.134 -    Atlantis_Reshape (gScreen->w, gScreen->h);
  28.135 +    Atlantis_Init();
  28.136 +    Atlantis_Reshape(gScreen->w, gScreen->h);
  28.137  }
  28.138  
  28.139 -static void drawGL ()
  28.140 +static void
  28.141 +drawGL()
  28.142  {
  28.143 -    Atlantis_Animate ();
  28.144 -    Atlantis_Display ();
  28.145 +    Atlantis_Animate();
  28.146 +    Atlantis_Display();
  28.147  }
  28.148  
  28.149 -static void mainLoop ()
  28.150 +static void
  28.151 +mainLoop()
  28.152  {
  28.153      SDL_Event event;
  28.154      int done = 0;
  28.155      int fps = 24;
  28.156 -	int delay = 1000/fps;
  28.157 +    int delay = 1000 / fps;
  28.158      int thenTicks = -1;
  28.159      int nowTicks;
  28.160 -    
  28.161 -    while ( !done ) {
  28.162  
  28.163 -		/* Check for events */
  28.164 -		while ( SDL_PollEvent (&event) ) {
  28.165 -			switch (event.type) {
  28.166 +    while (!done) {
  28.167  
  28.168 -				case SDL_MOUSEMOTION:
  28.169 -					break;
  28.170 -				case SDL_MOUSEBUTTONDOWN:
  28.171 -					break;
  28.172 -				case SDL_KEYDOWN:
  28.173 -					/* Any keypress quits the app... */
  28.174 -				case SDL_QUIT:
  28.175 -					done = 1;
  28.176 -					break;
  28.177 -				default:
  28.178 -					break;
  28.179 -			}
  28.180 -		}
  28.181 -    
  28.182 +        /* Check for events */
  28.183 +        while (SDL_PollEvent(&event)) {
  28.184 +            switch (event.type) {
  28.185 +
  28.186 +            case SDL_MOUSEMOTION:
  28.187 +                break;
  28.188 +            case SDL_MOUSEBUTTONDOWN:
  28.189 +                break;
  28.190 +            case SDL_KEYDOWN:
  28.191 +                /* Any keypress quits the app... */
  28.192 +            case SDL_QUIT:
  28.193 +                done = 1;
  28.194 +                break;
  28.195 +            default:
  28.196 +                break;
  28.197 +            }
  28.198 +        }
  28.199 +
  28.200          // Draw at 24 hz
  28.201          //     This approach is not normally recommended - it is better to
  28.202          //     use time-based animation and run as fast as possible
  28.203 -        drawGL ();
  28.204 -        SDL_GL_SwapBuffers ();
  28.205 +        drawGL();
  28.206 +        SDL_GL_SwapBuffers();
  28.207  
  28.208          // Time how long each draw-swap-delay cycle takes
  28.209          // and adjust delay to get closer to target framerate
  28.210          if (thenTicks > 0) {
  28.211 -            nowTicks = SDL_GetTicks ();
  28.212 -            delay += (1000/fps - (nowTicks-thenTicks));
  28.213 +            nowTicks = SDL_GetTicks();
  28.214 +            delay += (1000 / fps - (nowTicks - thenTicks));
  28.215              thenTicks = nowTicks;
  28.216              if (delay < 0)
  28.217 -                delay = 1000/fps;
  28.218 -        }
  28.219 -        else {
  28.220 -            thenTicks = SDL_GetTicks ();
  28.221 +                delay = 1000 / fps;
  28.222 +        } else {
  28.223 +            thenTicks = SDL_GetTicks();
  28.224          }
  28.225  
  28.226 -        SDL_Delay (delay);
  28.227 -	}
  28.228 +        SDL_Delay(delay);
  28.229 +    }
  28.230  }
  28.231  
  28.232 -int main(int argc, char *argv[])
  28.233 +int
  28.234 +main(int argc, char *argv[])
  28.235  {
  28.236 -	// Init SDL video subsystem
  28.237 -	if ( SDL_Init (SDL_INIT_VIDEO) < 0 ) {
  28.238 -		
  28.239 -        fprintf(stderr, "Couldn't initialize SDL: %s\n",
  28.240 -			SDL_GetError());
  28.241 -		exit(1);
  28.242 -	}
  28.243 +    // Init SDL video subsystem
  28.244 +    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
  28.245  
  28.246 +        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
  28.247 +        exit(1);
  28.248 +    }
  28.249      // Set GL context attributes
  28.250 -    initAttributes ();
  28.251 -    
  28.252 +    initAttributes();
  28.253 +
  28.254      // Create GL context
  28.255 -    createSurface (0);
  28.256 -    
  28.257 +    createSurface(0);
  28.258 +
  28.259      // Get GL context attributes
  28.260 -    printAttributes ();
  28.261 -    
  28.262 +    printAttributes();
  28.263 +
  28.264      // Init GL state
  28.265 -    initGL ();
  28.266 -    
  28.267 +    initGL();
  28.268 +
  28.269      // Draw, get events...
  28.270 -    mainLoop ();
  28.271 -    
  28.272 +    mainLoop();
  28.273 +
  28.274      // Cleanup
  28.275 -	SDL_Quit();
  28.276 -	
  28.277 +    SDL_Quit();
  28.278 +
  28.279      return 0;
  28.280  }
    29.1 --- a/src/video/x11/SDL_x11gamma.c	Mon Jul 23 18:46:09 2007 +0000
    29.2 +++ b/src/video/x11/SDL_x11gamma.c	Tue Jul 24 18:46:45 2007 +0000
    29.3 @@ -23,6 +23,64 @@
    29.4  #include "../SDL_sysvideo.h"
    29.5  #include "SDL_x11video.h"
    29.6  
    29.7 +static int numCmaps = 0;
    29.8 +
    29.9 +typedef struct
   29.10 +{
   29.11 +    Display *display;
   29.12 +    int scrNum;
   29.13 +    XStandardColormap cmap;
   29.14 +    Visual visual;
   29.15 +} cmapTableEntry;
   29.16 +
   29.17 +cmapTableEntry *cmapTable = NULL;
   29.18 +
   29.19 +void
   29.20 +X11_TrackColormap(Display * display, int scrNum,
   29.21 +                  XStandardColormap * cmap, Visual * visual)
   29.22 +{
   29.23 +    int i;
   29.24 +    cmapTableEntry *newTable = NULL;
   29.25 +
   29.26 +    /* only tracking DirectColor colormaps because they're the only ones
   29.27 +       with gamma ramps */
   29.28 +    if (DirectColor != visual->class) {
   29.29 +        return;
   29.30 +    }
   29.31 +
   29.32 +    /* search the table to find out if we already have this one. We only
   29.33 +       want one entry for each display, screen number, visualid
   29.34 +       combination */
   29.35 +    for (i = 0; i < numCmaps; i++) {
   29.36 +        if (cmapTable[i].display == display &&
   29.37 +            cmapTable[i].scrNum == scrNum &&
   29.38 +            cmapTable[i].cmap.visualid == cmap->visualid) {
   29.39 +            return;
   29.40 +        }
   29.41 +    }
   29.42 +
   29.43 +    /* increase the table by one entry. If the table is NULL create the
   29.44 +       first entrty */
   29.45 +    newTable = SDL_malloc((numCmaps + 1) * sizeof(cmapTableEntry));
   29.46 +    if (NULL == newTable) {
   29.47 +        SDL_SetError("Out of memory in X11_TrackColormap()");
   29.48 +        return;
   29.49 +    }
   29.50 +
   29.51 +    if (NULL != cmapTable) {
   29.52 +        SDL_memcpy(newTable, cmapTable, numCmaps * sizeof(cmapTableEntry));
   29.53 +        SDL_free(cmapTable);
   29.54 +    }
   29.55 +    cmapTable = newTable;
   29.56 +
   29.57 +    cmapTable[numCmaps].display = display;
   29.58 +    cmapTable[numCmaps].scrNum = scrNum;
   29.59 +    SDL_memcpy(&cmapTable[numCmaps].cmap, cmap, sizeof(XStandardColormap));
   29.60 +    SDL_memcpy(&cmapTable[numCmaps].visual, visual, sizeof(Visual));
   29.61 +
   29.62 +    numCmaps++;
   29.63 +}
   29.64 +
   29.65  int
   29.66  X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
   29.67  {
    30.1 --- a/src/video/x11/SDL_x11gamma.h	Mon Jul 23 18:46:09 2007 +0000
    30.2 +++ b/src/video/x11/SDL_x11gamma.h	Tue Jul 24 18:46:45 2007 +0000
    30.3 @@ -24,6 +24,9 @@
    30.4  #ifndef _SDL_x11gamma_h
    30.5  #define _SDL_x11gamma_h
    30.6  
    30.7 +extern void X11_TrackColormap(Display * display, int scrNum,
    30.8 +                              XStandardColormap * cmap, Visual * visual);
    30.9 +
   30.10  extern int X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp);
   30.11  extern int X11_GetDisplayGammaRamp(_THIS, Uint16 * ramp);
   30.12  
    31.1 --- a/src/video/x11/SDL_x11window.c	Mon Jul 23 18:46:09 2007 +0000
    31.2 +++ b/src/video/x11/SDL_x11window.c	Tue Jul 24 18:46:45 2007 +0000
    31.3 @@ -184,22 +184,27 @@
    31.4      if (visual->class == DirectColor || visual->class == PseudoColor) {
    31.5          int nmaps;
    31.6          XStandardColormap *stdmaps;
    31.7 -        int i;
    31.8          Bool found = False;
    31.9  
   31.10 +        /* check to see if the colormap we need already exists */
   31.11          if (0 != XGetRGBColormaps(data->display,
   31.12                                    RootWindow(data->display,
   31.13                                               displaydata->screen), &stdmaps,
   31.14                                    &nmaps, XA_RGB_BEST_MAP)) {
   31.15 +            int i;
   31.16              for (i = 0; i < nmaps; i++) {
   31.17                  if (stdmaps[i].visualid == visual->visualid) {
   31.18                      xattr.colormap = stdmaps[i].colormap;
   31.19 +                    X11_TrackColormap(data->display, displaydata->screen,
   31.20 +                                      &stdmaps[i], visual);
   31.21                      found = True;
   31.22                      break;
   31.23                  }
   31.24              }
   31.25              XFree(stdmaps);
   31.26          }
   31.27 +
   31.28 +        /* it doesn't exist, so create it */
   31.29          if (!found) {
   31.30              int max = visual->map_entries - 1;
   31.31              XStandardColormap *cmap =
   31.32 @@ -207,8 +212,10 @@
   31.33                                      visual->visualid, depth,
   31.34                                      XA_RGB_BEST_MAP, None,
   31.35                                      max, max, max);
   31.36 -            if (cmap->visualid = visual->visualid) {
   31.37 +            if (NULL != cmap && cmap->visualid == visual->visualid) {
   31.38                  xattr.colormap = cmap->colormap;
   31.39 +                X11_TrackColormap(data->display, displaydata->screen, cmap,
   31.40 +                                  visual);
   31.41              } else {
   31.42                  SDL_SetError
   31.43                      ("Couldn't create window:XA_RGB_BEST_MAP not found");