utils/bestprofile.c
changeset 1134 be31bd0ee0a2
parent 1117 f6712bf72c19
--- a/utils/bestprofile.c	Fri Feb 07 15:57:54 2014 -0500
+++ b/utils/bestprofile.c	Fri Feb 21 12:41:25 2014 -0500
@@ -28,30 +28,30 @@
     printf("\n");
     #endif
 
+    SDL_Window *sdlwindow = NULL;
     if (SDL_Init(SDL_INIT_VIDEO) == -1)
-        fprintf(stderr, "SDL_Init(SDL_INIT_VIDEO) error: %s\n", SDL_GetError());
+        fprintf(stderr, "SDL_Init() error: %s\n", SDL_GetError());
+    else if (SDL_GL_LoadLibrary(NULL) == -1)
+        fprintf(stderr, "SDL_GL_LoadLibrary() error: %s\n", SDL_GetError());
+    else if ((sdlwindow = SDL_CreateWindow(argv[0], SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_OPENGL)) == NULL)
+        fprintf(stderr, "SDL_CreateWindow() error: %s\n", SDL_GetError());
+    else if (SDL_GL_CreateContext(sdlwindow) == NULL)
+        fprintf(stderr, "SDL_GL_CreateContext() error: %s\n", SDL_GetError());
     else
     {
-        SDL_GL_LoadLibrary(NULL);
-        if (SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL)
-            fprintf(stderr, "SDL_SetVideoMode() error: %s\n", SDL_GetError());
+        const char *best = MOJOSHADER_glBestProfile(lookup, NULL, NULL, NULL, NULL);
+        MOJOSHADER_glContext *ctx = MOJOSHADER_glCreateContext(best, lookup, 0, 0, 0, 0);
+        if (ctx == NULL)
+            printf("MOJOSHADER_glCreateContext() fail: %s\n", MOJOSHADER_glGetError());
         else
         {
-            const char *best = MOJOSHADER_glBestProfile(lookup, NULL, NULL, NULL, NULL);
-            MOJOSHADER_glContext *ctx;
-            ctx = MOJOSHADER_glCreateContext(best, lookup, 0, 0, 0, 0);
-            if (ctx == NULL)
-                printf("MOJOSHADER_glCreateContext() fail: %s\n", MOJOSHADER_glGetError());
-            else
-            {
-                printf("%s\n", best);
-                retval = 0;  // success.
-                MOJOSHADER_glDestroyContext(ctx);
-            } // else
+            printf("%s\n", best);
+            retval = 0;  // success.
+            MOJOSHADER_glDestroyContext(ctx);
         } // else
-        SDL_Quit();
     } // else
 
+    SDL_Quit();
     return retval;
 } // main