test/testshader.c
changeset 7639 9406b7dd2f2d
parent 7517 965d57022c01
child 7663 53fe1b64eb2d
     1.1 --- a/test/testshader.c	Mon Aug 12 22:00:21 2013 -0700
     1.2 +++ b/test/testshader.c	Wed Aug 14 23:30:10 2013 -0700
     1.3 @@ -11,7 +11,6 @@
     1.4  */
     1.5  /* This is a simple example of using GLSL shaders with SDL */
     1.6  
     1.7 -#include <stdio.h> /* for printf() */
     1.8  #include "SDL.h"
     1.9  
    1.10  #ifdef HAVE_OPENGL
    1.11 @@ -139,7 +138,7 @@
    1.12          glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
    1.13          info = SDL_stack_alloc(char, length+1);
    1.14          glGetInfoLogARB(shader, length, NULL, info);
    1.15 -        fprintf(stderr, "Failed to compile shader:\n%s\n%s", source, info);
    1.16 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:\n%s\n%s", source, info);
    1.17          SDL_stack_free(info);
    1.18  
    1.19          return SDL_FALSE;
    1.20 @@ -245,7 +244,7 @@
    1.21      /* Compile all the shaders */
    1.22      for (i = 0; i < NUM_SHADERS; ++i) {
    1.23          if (!CompileShaderProgram(&shaders[i])) {
    1.24 -            fprintf(stderr, "Unable to compile shader!\n");
    1.25 +            SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to compile shader!\n");
    1.26              return SDL_FALSE;
    1.27          }
    1.28      }
    1.29 @@ -422,29 +421,32 @@
    1.30      GLuint texture;
    1.31      GLfloat texcoords[4];
    1.32  
    1.33 +	/* Enable standard application logging */
    1.34 +    SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
    1.35 +
    1.36      /* Initialize SDL for video output */
    1.37      if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
    1.38 -        fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
    1.39 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s\n", SDL_GetError());
    1.40          exit(1);
    1.41      }
    1.42  
    1.43      /* Create a 640x480 OpenGL screen */
    1.44      window = SDL_CreateWindow( "Shader Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL );
    1.45      if ( !window ) {
    1.46 -        fprintf(stderr, "Unable to create OpenGL window: %s\n", SDL_GetError());
    1.47 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError());
    1.48          SDL_Quit();
    1.49          exit(2);
    1.50      }
    1.51  
    1.52      if ( !SDL_GL_CreateContext(window)) {
    1.53 -        fprintf(stderr, "Unable to create OpenGL context: %s\n", SDL_GetError());
    1.54 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL context: %s\n", SDL_GetError());
    1.55          SDL_Quit();
    1.56          exit(2);
    1.57      }
    1.58  
    1.59      surface = SDL_LoadBMP("icon.bmp");
    1.60      if ( ! surface ) {
    1.61 -        fprintf(stderr, "Unable to load icon.bmp: %s\n", SDL_GetError());
    1.62 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load icon.bmp: %s\n", SDL_GetError());
    1.63          SDL_Quit();
    1.64          exit(3);
    1.65      }
    1.66 @@ -454,9 +456,9 @@
    1.67      /* Loop, drawing and checking events */
    1.68      InitGL(640, 480);
    1.69      if (InitShaders()) {
    1.70 -        printf("Shaders supported, press SPACE to cycle them.\n");
    1.71 +        SDL_Log("Shaders supported, press SPACE to cycle them.\n");
    1.72      } else {
    1.73 -        printf("Shaders not supported!\n");
    1.74 +        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Shaders not supported!\n");
    1.75      }
    1.76      done = 0;
    1.77      while ( ! done ) {
    1.78 @@ -489,7 +491,7 @@
    1.79  int
    1.80  main(int argc, char *argv[])
    1.81  {
    1.82 -    printf("No OpenGL support on this system\n");
    1.83 +    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "No OpenGL support on this system\n");
    1.84      return 1;
    1.85  }
    1.86