utils/bestprofile.c
author Ryan C. Gordon <icculus@icculus.org>
Sun, 15 Feb 2009 02:25:26 -0500
changeset 628 33da6087aa48
parent 588 ef3d2efa822d
child 901 a9f799b93150
permissions -rw-r--r--
Moved the "public API" comment to what is now, in fact, the real public API. :)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
406
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/**
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
 * MojoShader; generate shader programs from bytecode of compiled
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
 *  Direct3D shaders.
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
 *
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
 * Please see the file LICENSE.txt in the source's root directory.
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
 *
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
 *  This file written by Ryan C. Gordon.
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
 */
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
#include <stdio.h>
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
#include "mojoshader.h"
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
#include "SDL.h"
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
int main(int argc, char **argv)
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
{
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
    int retval = 1;
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
    #if 0
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
    printf("MojoShader bestprofile\n");
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
    printf("Compiled against version %d\n", MOJOSHADER_VERSION);
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
    printf("Linked against version %d\n", MOJOSHADER_version());
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
    printf("\n");
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
    #endif
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
    if (SDL_Init(SDL_INIT_VIDEO) == -1)
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
        fprintf(stderr, "SDL_Init(SDL_INIT_VIDEO) error: %s\n", SDL_GetError());
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
    else
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
    {
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
        SDL_GL_LoadLibrary(NULL);
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
        if (SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL)
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
            fprintf(stderr, "SDL_SetVideoMode() error: %s\n", SDL_GetError());
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
        else
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
        {
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
            const char *best = MOJOSHADER_glBestProfile(SDL_GL_GetProcAddress);
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
            MOJOSHADER_glContext *ctx;
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
            ctx = MOJOSHADER_glCreateContext(best, SDL_GL_GetProcAddress, 0, 0, 0);
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
            if (ctx == NULL)
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
                printf("MOJOSHADER_glCreateContext() fail: %s\n", MOJOSHADER_glGetError());
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
            else
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
            {
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
                printf("%s\n", best);
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
                retval = 0;  // success.
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
                MOJOSHADER_glDestroyContext(ctx);
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
            } // else
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
        } // else
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
        SDL_Quit();
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
    } // else
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
    return retval;
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
} // main
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
// end of bestprofile.c ...
682e9073a9cf Added bestprofile program.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53