bestprofile.c
branchtrunk
changeset 406 682e9073a9cf
equal deleted inserted replaced
405:e2cffb40e8b8 406:682e9073a9cf
       
     1 /**
       
     2  * MojoShader; generate shader programs from bytecode of compiled
       
     3  *  Direct3D shaders.
       
     4  *
       
     5  * Please see the file LICENSE.txt in the source's root directory.
       
     6  *
       
     7  *  This file written by Ryan C. Gordon.
       
     8  */
       
     9 
       
    10 #include <stdio.h>
       
    11 #include "mojoshader.h"
       
    12 #include "SDL.h"
       
    13 
       
    14 int main(int argc, char **argv)
       
    15 {
       
    16     int retval = 1;
       
    17 
       
    18     #if 0
       
    19     printf("MojoShader bestprofile\n");
       
    20     printf("Compiled against version %d\n", MOJOSHADER_VERSION);
       
    21     printf("Linked against version %d\n", MOJOSHADER_version());
       
    22     printf("\n");
       
    23     #endif
       
    24 
       
    25     if (SDL_Init(SDL_INIT_VIDEO) == -1)
       
    26         fprintf(stderr, "SDL_Init(SDL_INIT_VIDEO) error: %s\n", SDL_GetError());
       
    27     else
       
    28     {
       
    29         SDL_GL_LoadLibrary(NULL);
       
    30         if (SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL)
       
    31             fprintf(stderr, "SDL_SetVideoMode() error: %s\n", SDL_GetError());
       
    32         else
       
    33         {
       
    34             const char *best = MOJOSHADER_glBestProfile(SDL_GL_GetProcAddress);
       
    35             MOJOSHADER_glContext *ctx;
       
    36             ctx = MOJOSHADER_glCreateContext(best, SDL_GL_GetProcAddress, 0, 0, 0);
       
    37             if (ctx == NULL)
       
    38                 printf("MOJOSHADER_glCreateContext() fail: %s\n", MOJOSHADER_glGetError());
       
    39             else
       
    40             {
       
    41                 printf("%s\n", best);
       
    42                 retval = 0;  // success.
       
    43                 MOJOSHADER_glDestroyContext(ctx);
       
    44             } // else
       
    45         } // else
       
    46         SDL_Quit();
       
    47     } // else
       
    48 
       
    49     return retval;
       
    50 } // main
       
    51 
       
    52 // end of bestprofile.c ...
       
    53