test/testdyngl.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/test/testdyngl.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/test/testdyngl.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -29,21 +29,21 @@
     1.4  
     1.5  /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
     1.6  static void
     1.7 -quit (int rc)
     1.8 +quit(int rc)
     1.9  {
    1.10 -    SDL_Quit ();
    1.11 -    exit (rc);
    1.12 +    SDL_Quit();
    1.13 +    exit(rc);
    1.14  }
    1.15  
    1.16  void *
    1.17 -get_funcaddr (const char *p)
    1.18 +get_funcaddr(const char *p)
    1.19  {
    1.20 -    void *f = SDL_GL_GetProcAddress (p);
    1.21 +    void *f = SDL_GL_GetProcAddress(p);
    1.22      if (f) {
    1.23          return f;
    1.24      } else {
    1.25 -        printf ("Unable to get function pointer for %s\n", p);
    1.26 -        quit (1);
    1.27 +        printf("Unable to get function pointer for %s\n", p);
    1.28 +        quit(1);
    1.29      }
    1.30      return NULL;
    1.31  }
    1.32 @@ -72,31 +72,31 @@
    1.33  glfuncs;
    1.34  
    1.35  void
    1.36 -init_glfuncs (glfuncs * f)
    1.37 +init_glfuncs(glfuncs * f)
    1.38  {
    1.39 -    f->glBegin = get_funcaddr ("glBegin");
    1.40 -    f->glEnd = get_funcaddr ("glEnd");
    1.41 -    f->glVertex3f = get_funcaddr ("glVertex3f");
    1.42 -    f->glClearColor = get_funcaddr ("glClearColor");
    1.43 -    f->glClear = get_funcaddr ("glClear");
    1.44 -    f->glDisable = get_funcaddr ("glDisable");
    1.45 -    f->glEnable = get_funcaddr ("glEnable");
    1.46 -    f->glColor4ub = get_funcaddr ("glColor4ub");
    1.47 -    f->glPointSize = get_funcaddr ("glPointSize");
    1.48 -    f->glHint = get_funcaddr ("glHint");
    1.49 -    f->glBlendFunc = get_funcaddr ("glBlendFunc");
    1.50 -    f->glMatrixMode = get_funcaddr ("glMatrixMode");
    1.51 -    f->glLoadIdentity = get_funcaddr ("glLoadIdentity");
    1.52 -    f->glOrtho = get_funcaddr ("glOrtho");
    1.53 -    f->glRotatef = get_funcaddr ("glRotatef");
    1.54 -    f->glViewport = get_funcaddr ("glViewport");
    1.55 -    f->glFogf = get_funcaddr ("glFogf");
    1.56 +    f->glBegin = get_funcaddr("glBegin");
    1.57 +    f->glEnd = get_funcaddr("glEnd");
    1.58 +    f->glVertex3f = get_funcaddr("glVertex3f");
    1.59 +    f->glClearColor = get_funcaddr("glClearColor");
    1.60 +    f->glClear = get_funcaddr("glClear");
    1.61 +    f->glDisable = get_funcaddr("glDisable");
    1.62 +    f->glEnable = get_funcaddr("glEnable");
    1.63 +    f->glColor4ub = get_funcaddr("glColor4ub");
    1.64 +    f->glPointSize = get_funcaddr("glPointSize");
    1.65 +    f->glHint = get_funcaddr("glHint");
    1.66 +    f->glBlendFunc = get_funcaddr("glBlendFunc");
    1.67 +    f->glMatrixMode = get_funcaddr("glMatrixMode");
    1.68 +    f->glLoadIdentity = get_funcaddr("glLoadIdentity");
    1.69 +    f->glOrtho = get_funcaddr("glOrtho");
    1.70 +    f->glRotatef = get_funcaddr("glRotatef");
    1.71 +    f->glViewport = get_funcaddr("glViewport");
    1.72 +    f->glFogf = get_funcaddr("glFogf");
    1.73  }
    1.74  
    1.75  #define NB_PIXELS 1000
    1.76  
    1.77  int
    1.78 -main (int argc, char *argv[])
    1.79 +main(int argc, char *argv[])
    1.80  {
    1.81      glfuncs f;
    1.82      int i;
    1.83 @@ -109,96 +109,95 @@
    1.84          gl_library = argv[1];
    1.85      }
    1.86  
    1.87 -    if (SDL_Init (SDL_INIT_VIDEO) < 0) {
    1.88 -        printf ("Unable to init SDL : %s\n", SDL_GetError ());
    1.89 +    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
    1.90 +        printf("Unable to init SDL : %s\n", SDL_GetError());
    1.91          return (1);
    1.92      }
    1.93  
    1.94 -    if (SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1) < 0) {
    1.95 -        printf ("Unable to set GL attribute : %s\n", SDL_GetError ());
    1.96 -        quit (1);
    1.97 +    if (SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) < 0) {
    1.98 +        printf("Unable to set GL attribute : %s\n", SDL_GetError());
    1.99 +        quit(1);
   1.100      }
   1.101  
   1.102 -    if (SDL_GL_LoadLibrary (gl_library) < 0) {
   1.103 -        printf ("Unable to dynamically open GL lib : %s\n", SDL_GetError ());
   1.104 -        quit (1);
   1.105 +    if (SDL_GL_LoadLibrary(gl_library) < 0) {
   1.106 +        printf("Unable to dynamically open GL lib : %s\n", SDL_GetError());
   1.107 +        quit(1);
   1.108      }
   1.109  
   1.110 -    if (SDL_SetVideoMode (640, 480, 0, SDL_OPENGL) == NULL) {
   1.111 -        printf ("Unable to open video mode : %s\n", SDL_GetError ());
   1.112 -        quit (1);
   1.113 +    if (SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL) {
   1.114 +        printf("Unable to open video mode : %s\n", SDL_GetError());
   1.115 +        quit(1);
   1.116      }
   1.117  
   1.118      /* Set the window manager title bar */
   1.119 -    SDL_WM_SetCaption ("SDL Dynamic OpenGL Loading Test", "testdyngl");
   1.120 +    SDL_WM_SetCaption("SDL Dynamic OpenGL Loading Test", "testdyngl");
   1.121  
   1.122 -    init_glfuncs (&f);
   1.123 +    init_glfuncs(&f);
   1.124  
   1.125      for (i = 0; i < NB_PIXELS; i++) {
   1.126 -        pixels[3 * i] = rand () % 250 - 125;
   1.127 -        pixels[3 * i + 1] = rand () % 250 - 125;
   1.128 -        pixels[3 * i + 2] = rand () % 250 - 125;
   1.129 +        pixels[3 * i] = rand() % 250 - 125;
   1.130 +        pixels[3 * i + 1] = rand() % 250 - 125;
   1.131 +        pixels[3 * i + 2] = rand() % 250 - 125;
   1.132      }
   1.133  
   1.134 -    f.glViewport (0, 0, 640, 480);
   1.135 +    f.glViewport(0, 0, 640, 480);
   1.136  
   1.137 -    f.glMatrixMode (GL_PROJECTION);
   1.138 -    f.glLoadIdentity ();
   1.139 -    f.glOrtho (-100, 100, -100, 100, -500, 500);
   1.140 +    f.glMatrixMode(GL_PROJECTION);
   1.141 +    f.glLoadIdentity();
   1.142 +    f.glOrtho(-100, 100, -100, 100, -500, 500);
   1.143  
   1.144 -    f.glMatrixMode (GL_MODELVIEW);
   1.145 -    f.glLoadIdentity ();
   1.146 +    f.glMatrixMode(GL_MODELVIEW);
   1.147 +    f.glLoadIdentity();
   1.148  
   1.149 -    f.glEnable (GL_DEPTH_TEST);
   1.150 -    f.glDisable (GL_TEXTURE_2D);
   1.151 -    f.glEnable (GL_BLEND);
   1.152 -    f.glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   1.153 +    f.glEnable(GL_DEPTH_TEST);
   1.154 +    f.glDisable(GL_TEXTURE_2D);
   1.155 +    f.glEnable(GL_BLEND);
   1.156 +    f.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   1.157  
   1.158 -    f.glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
   1.159 -    f.glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   1.160 +    f.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
   1.161 +    f.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   1.162  
   1.163 -    f.glEnable (GL_POINT_SMOOTH);
   1.164 -    f.glHint (GL_POINT_SMOOTH_HINT, GL_NICEST);
   1.165 -    f.glPointSize (5.0f);
   1.166 -    f.glEnable (GL_FOG);
   1.167 -    f.glFogf (GL_FOG_START, -500);
   1.168 -    f.glFogf (GL_FOG_END, 500);
   1.169 -    f.glFogf (GL_FOG_DENSITY, 0.005);
   1.170 +    f.glEnable(GL_POINT_SMOOTH);
   1.171 +    f.glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
   1.172 +    f.glPointSize(5.0f);
   1.173 +    f.glEnable(GL_FOG);
   1.174 +    f.glFogf(GL_FOG_START, -500);
   1.175 +    f.glFogf(GL_FOG_END, 500);
   1.176 +    f.glFogf(GL_FOG_DENSITY, 0.005);
   1.177  
   1.178      do {
   1.179 -        f.glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   1.180 +        f.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   1.181  
   1.182 -        f.glRotatef (2.0, 1.0, 1.0, 1.0);
   1.183 -        f.glRotatef (1.0, 0.0, 1.0, 1.0);
   1.184 +        f.glRotatef(2.0, 1.0, 1.0, 1.0);
   1.185 +        f.glRotatef(1.0, 0.0, 1.0, 1.0);
   1.186  
   1.187 -        f.glColor4ub (255, 255, 255, 255);
   1.188 -        f.glBegin (GL_POINTS);
   1.189 +        f.glColor4ub(255, 255, 255, 255);
   1.190 +        f.glBegin(GL_POINTS);
   1.191          for (i = 0; i < NB_PIXELS; i++) {
   1.192 -            f.glVertex3f (pixels[3 * i], pixels[3 * i + 1],
   1.193 -                          pixels[3 * i + 2]);
   1.194 +            f.glVertex3f(pixels[3 * i], pixels[3 * i + 1], pixels[3 * i + 2]);
   1.195          }
   1.196 -        f.glEnd ();
   1.197 -        SDL_GL_SwapBuffers ();
   1.198 +        f.glEnd();
   1.199 +        SDL_GL_SwapBuffers();
   1.200  
   1.201 -        while (SDL_PollEvent (&event)) {
   1.202 +        while (SDL_PollEvent(&event)) {
   1.203              if (event.type & SDL_KEYDOWN)
   1.204                  done = 1;
   1.205          }
   1.206  
   1.207 -        SDL_Delay (20);
   1.208 +        SDL_Delay(20);
   1.209      }
   1.210      while (!done);
   1.211  
   1.212 -    SDL_Quit ();
   1.213 +    SDL_Quit();
   1.214      return 0;
   1.215  }
   1.216  
   1.217  #else /* HAVE_OPENGL */
   1.218  
   1.219  int
   1.220 -main (int argc, char *argv[])
   1.221 +main(int argc, char *argv[])
   1.222  {
   1.223 -    printf ("No OpenGL support on this system\n");
   1.224 +    printf("No OpenGL support on this system\n");
   1.225      return 1;
   1.226  }
   1.227