availableprofiles.c
author Ryan C. Gordon <icculus@icculus.org>
Fri, 12 Dec 2008 00:58:10 -0500
changeset 503 ec8e7739cf5d
parent 458 b91904879798
permissions -rw-r--r--
Let finderrors work on assembly programs.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
423
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
/**
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
 * MojoShader; generate shader programs from bytecode of compiled
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
 *  Direct3D shaders.
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
 *
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
 * Please see the file LICENSE.txt in the source's root directory.
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
 *
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
 *  This file written by Ryan C. Gordon.
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
 */
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
#include <stdio.h>
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
#include "mojoshader.h"
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
#include "SDL.h"
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
static int check_available(void)
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
{
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
    const char **avail = NULL;
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
    int total = MOJOSHADER_glAvailableProfiles(SDL_GL_GetProcAddress, NULL, 0);
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
    if (total > 0)
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
    {
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
        avail = (const char **) alloca(sizeof (const char *) * total);
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
        total = MOJOSHADER_glAvailableProfiles(SDL_GL_GetProcAddress, avail, total);
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
    } // if
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
    if (total <= 0)
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
        fprintf(stderr, "No profiles available.\n");
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
    else
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
    {
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
        int i;
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
        for (i = 0; i < total; i++)
458
b91904879798 Added MOJOSHADER_maxShaderModel().
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    30
        {
b91904879798 Added MOJOSHADER_maxShaderModel().
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    31
            printf("%s (Shader Model %d)\n", avail[i],
b91904879798 Added MOJOSHADER_maxShaderModel().
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    32
                   MOJOSHADER_maxShaderModel(avail[i]));
b91904879798 Added MOJOSHADER_maxShaderModel().
Ryan C. Gordon <icculus@icculus.org>
parents: 423
diff changeset
    33
        } // for
423
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
    } // else
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
    return 0;
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
} // check_available
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
int main(int argc, char **argv)
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
{
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
    int retval = 1;
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
    #if 0
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
    printf("MojoShader availableprofile\n");
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
    printf("Compiled against version %d\n", MOJOSHADER_VERSION);
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
    printf("Linked against version %d\n", MOJOSHADER_version());
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
    printf("\n");
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
    #endif
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
    if (SDL_Init(SDL_INIT_VIDEO) == -1)
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
        fprintf(stderr, "SDL_Init(SDL_INIT_VIDEO) error: %s\n", SDL_GetError());
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
    else
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
    {
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
        SDL_GL_LoadLibrary(NULL);
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
        if (SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL)
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
            fprintf(stderr, "SDL_SetVideoMode() error: %s\n", SDL_GetError());
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
        else
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
            retval = check_available();
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
        SDL_Quit();
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
    } // else
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
    return retval;
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
} // main
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
// end of availableprofiles.c ...
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67