availableprofiles.c
author Ryan C. Gordon <icculus@icculus.org>
Mon, 08 Feb 2010 04:02:01 -0500
branchtrunk
changeset 819 7c157b0d5026
parent 423 ee393c1cf3b4
child 458 b91904879798
permissions -rw-r--r--
Closing the "trunk" branch. (it's a relic of the conversion from Subversion to Mercurial).
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++)
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
            printf("%s\n", avail[i]);
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
    } // else
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
    return 0;
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
} // check_available
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
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
int main(int argc, char **argv)
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
    int retval = 1;
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
    #if 0
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
    printf("MojoShader availableprofile\n");
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
    printf("Compiled against version %d\n", MOJOSHADER_VERSION);
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
    printf("Linked against version %d\n", MOJOSHADER_version());
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
    printf("\n");
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
    #endif
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
    if (SDL_Init(SDL_INIT_VIDEO) == -1)
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
        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
    50
    else
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
    {
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
        SDL_GL_LoadLibrary(NULL);
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
        if (SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL)
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
            fprintf(stderr, "SDL_SetVideoMode() error: %s\n", SDL_GetError());
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
        else
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
            retval = check_available();
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
        SDL_Quit();
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
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
    return retval;
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
} // main
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
// end of availableprofiles.c ...
ee393c1cf3b4 Added availableprofiles.c ...
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64