finderrors.c
author Ryan C. Gordon <icculus@icculus.org>
Wed, 28 May 2008 10:27:47 -0400
branchtrunk
changeset 334 5aebcea77f47
parent 262 0f1531ac2578
child 437 a97a9b21087b
permissions -rw-r--r--
Cleaned up the shader type string code. No sense in running a conditional every time, just store the literal at start.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
244
30ceb789b9a1 More comment headers.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
     1
/**
30ceb789b9a1 More comment headers.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
     2
 * MojoShader; generate shader programs from bytecode of compiled
30ceb789b9a1 More comment headers.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
     3
 *  Direct3D shaders.
30ceb789b9a1 More comment headers.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
     4
 *
30ceb789b9a1 More comment headers.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
     5
 * Please see the file LICENSE.txt in the source's root directory.
30ceb789b9a1 More comment headers.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
     6
 *
30ceb789b9a1 More comment headers.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
     7
 *  This file written by Ryan C. Gordon.
30ceb789b9a1 More comment headers.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
     8
 */
30ceb789b9a1 More comment headers.
Ryan C. Gordon <icculus@icculus.org>
parents: 238
diff changeset
     9
153
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
#include <stdio.h>
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
#include <stdlib.h>
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
#include <string.h>
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
#include <stdarg.h>
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
#include <sys/types.h>
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
#include <errno.h>
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
#include "mojoshader.h"
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
169
7e9d90724cf8 Push parsed shaders through GLSL compiler to see what breaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 153
diff changeset
    19
#if FINDERRORS_COMPILE_SHADERS
7e9d90724cf8 Push parsed shaders through GLSL compiler to see what breaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 153
diff changeset
    20
#include "SDL.h"
7e9d90724cf8 Push parsed shaders through GLSL compiler to see what breaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 153
diff changeset
    21
#endif
7e9d90724cf8 Push parsed shaders through GLSL compiler to see what breaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 153
diff changeset
    22
254
13184ff204b9 More Windows patches.
Ryan C. Gordon <icculus@icculus.org>
parents: 247
diff changeset
    23
#ifdef _MSC_VER
256
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    24
#define WIN32_LEAN_AND_MEAN 1
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    25
#include <windows.h>
260
5b5fc8c5661b More Windows fixes: include malloc.h for alloca() support.
Ryan C. Gordon <icculus@icculus.org>
parents: 259
diff changeset
    26
#include <malloc.h>  // for alloca().
254
13184ff204b9 More Windows patches.
Ryan C. Gordon <icculus@icculus.org>
parents: 247
diff changeset
    27
#define snprintf _snprintf
256
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    28
#else
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    29
#include <dirent.h>
254
13184ff204b9 More Windows patches.
Ryan C. Gordon <icculus@icculus.org>
parents: 247
diff changeset
    30
#endif
13184ff204b9 More Windows patches.
Ryan C. Gordon <icculus@icculus.org>
parents: 247
diff changeset
    31
170
9d71c08c756e Ripped out the multithreading from finderrors.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 169
diff changeset
    32
#define report printf
169
7e9d90724cf8 Push parsed shaders through GLSL compiler to see what breaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 153
diff changeset
    33
256
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    34
static int do_file(const char *profile, const char *dname, const char *fn, int *total)
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    35
{
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    36
    int do_quit = 0;
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    37
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    38
    #if FINDERRORS_COMPILE_SHADERS
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    39
    SDL_Event e;  // pump event queue to keep OS happy.
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    40
    while (SDL_PollEvent(&e))
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    41
    {
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    42
        if (e.type == SDL_QUIT)
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    43
            do_quit = 1;
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    44
    } // while
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    45
    SDL_GL_SwapBuffers();
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    46
    #endif
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    47
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    48
    if (do_quit)
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    49
    {
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    50
        report("FAIL: user requested quit!\n");
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    51
        return 0;
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    52
    } // if
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    53
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    54
    if (strstr(fn, ".bytecode") == NULL)
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    55
        return 1;
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    56
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    57
    (*total)++;
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    58
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    59
    char *fname = (char *) alloca(strlen(fn) + strlen(dname) + 1);
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    60
    sprintf(fname, "%s/%s", dname, fn);
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    61
    FILE *io = fopen(fname, "rb");
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    62
    if (io == NULL)
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    63
    {
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    64
        report("FAIL: %s fopen() failed.\n", fname);
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    65
        return 1;
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    66
    } // if
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    67
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    68
    static unsigned char buf[1024 * 256];
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    69
    int rc = fread(buf, 1, sizeof (buf), io);
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    70
    fclose(io);
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    71
    if (rc == -1)
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    72
    {
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    73
        report("FAIL: %s %s\n", fname, strerror(errno));
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    74
        return 1;
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    75
    } // if
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    76
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    77
    #if FINDERRORS_COMPILE_SHADERS
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    78
    MOJOSHADER_glShader *shader = MOJOSHADER_glCompileShader(buf, rc);
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    79
    if (shader == NULL)
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    80
        report("FAIL: %s %s\n", fname, MOJOSHADER_glGetError());
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    81
    else
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    82
        report("PASS: %s\n", fname);
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    83
    MOJOSHADER_glDeleteShader(shader);
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    84
    #else
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    85
    const MOJOSHADER_parseData *pd = MOJOSHADER_parse(profile, buf, rc, 0, 0, 0);
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    86
    if (pd->error != NULL)
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    87
        report("FAIL: %s %s\n", fname, pd->error);
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    88
    else
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    89
        report("PASS: %s\n", fname);
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    90
    MOJOSHADER_freeParseData(pd);
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    91
    #endif
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    92
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    93
    return 1;
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    94
} // do_file
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    95
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
    96
170
9d71c08c756e Ripped out the multithreading from finderrors.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 169
diff changeset
    97
static int do_dir(const char *dname, const char *profile)
153
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
{
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
    int total = 0;
256
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   100
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   101
#ifdef _MSC_VER
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   102
    WIN32_FIND_DATA dent;
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   103
    HANDLE dirp = INVALID_HANDLE_VALUE;
259
68ba103e17e4 More Windows fixes.
Ryan C. Gordon <icculus@icculus.org>
parents: 258
diff changeset
   104
    FindFirstFileA(dname, &dent);
256
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   105
    if (dirp != INVALID_HANDLE_VALUE)
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   106
    {
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   107
        do
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   108
        {
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   109
            if (!do_file(profile, dname, dent.cFileName, &total))
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   110
                break;
259
68ba103e17e4 More Windows fixes.
Ryan C. Gordon <icculus@icculus.org>
parents: 258
diff changeset
   111
        } while (FindNextFileA(dirp, &dent) != 0);
256
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   112
        CloseHandle(dirp);
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   113
    } // if
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   114
#else
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   115
    struct dirent *dent = NULL;
153
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
    DIR *dirp = opendir(dname);
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
    if (dirp != NULL)
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
    {
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
        while ((dent = readdir(dirp)) != NULL)
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
        {
256
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   121
            if (!do_file(profile, dname, dent->d_name, &total))
172
f81c6cb14140 finderrors.c now pumps event queue and paints the SDL window.
Ryan C. Gordon <icculus@icculus.org>
parents: 170
diff changeset
   122
                break;
153
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   123
        } // while
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   124
        closedir(dirp);
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   125
    } // if
256
8339b461ef26 More Windows support.
Ryan C. Gordon <icculus@icculus.org>
parents: 254
diff changeset
   126
#endif
153
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   127
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   128
    return total;
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   129
} // do_dir
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   130
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   132
int main(int argc, char **argv)
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   133
{
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   134
    //printf("MojoShader finderrors\n");
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   135
    //printf("Compiled against version %d\n", MOJOSHADER_VERSION);
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   136
    //printf("Linked against version %d\n", MOJOSHADER_version());
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   137
    //printf("\n");
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   138
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   139
    if (argc <= 2)
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   140
        printf("\n\nUSAGE: %s <profile> [dir1] ... [dirN]\n\n", argv[0]);
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   141
    else
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   142
    {
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   143
        int total = 0;
170
9d71c08c756e Ripped out the multithreading from finderrors.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 169
diff changeset
   144
        int i;
224
4acaf8199665 Moved finderrors.c from GL calls to MOJOSHADER_gl* functions.
Ryan C. Gordon <icculus@icculus.org>
parents: 188
diff changeset
   145
        const char *profile = argv[1];
153
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   146
169
7e9d90724cf8 Push parsed shaders through GLSL compiler to see what breaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 153
diff changeset
   147
        #if FINDERRORS_COMPILE_SHADERS
7e9d90724cf8 Push parsed shaders through GLSL compiler to see what breaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 153
diff changeset
   148
        SDL_Init(SDL_INIT_VIDEO);
224
4acaf8199665 Moved finderrors.c from GL calls to MOJOSHADER_gl* functions.
Ryan C. Gordon <icculus@icculus.org>
parents: 188
diff changeset
   149
        SDL_GL_LoadLibrary(NULL);
169
7e9d90724cf8 Push parsed shaders through GLSL compiler to see what breaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 153
diff changeset
   150
        SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);
262
0f1531ac2578 Implemented MOJOSHADER_glBestProfile().
Ryan C. Gordon <icculus@icculus.org>
parents: 260
diff changeset
   151
        printf("Best profile is '%s'\n", MOJOSHADER_glBestProfile(SDL_GL_GetProcAddress));
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 228
diff changeset
   152
        MOJOSHADER_glContext *ctx;
238
e98f14da2897 Renamed glInit and glDeinit to glCreateContext and glDestroyContext.
Ryan C. Gordon <icculus@icculus.org>
parents: 237
diff changeset
   153
        ctx = MOJOSHADER_glCreateContext(profile, SDL_GL_GetProcAddress, 0, 0, 0);
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 228
diff changeset
   154
        if (ctx == NULL)
227
c6192a343fef Check return value from MOJOSHADER_glInit().
Ryan C. Gordon <icculus@icculus.org>
parents: 224
diff changeset
   155
        {
238
e98f14da2897 Renamed glInit and glDeinit to glCreateContext and glDestroyContext.
Ryan C. Gordon <icculus@icculus.org>
parents: 237
diff changeset
   156
            printf("MOJOSHADER_glCreateContext() fail: %s\n", MOJOSHADER_glGetError());
227
c6192a343fef Check return value from MOJOSHADER_glInit().
Ryan C. Gordon <icculus@icculus.org>
parents: 224
diff changeset
   157
            SDL_Quit();
c6192a343fef Check return value from MOJOSHADER_glInit().
Ryan C. Gordon <icculus@icculus.org>
parents: 224
diff changeset
   158
            return 1;
c6192a343fef Check return value from MOJOSHADER_glInit().
Ryan C. Gordon <icculus@icculus.org>
parents: 224
diff changeset
   159
        } // if
237
09f35dfc1d7e OpenGL glue now allows for multiple contexts.
Ryan C. Gordon <icculus@icculus.org>
parents: 228
diff changeset
   160
        MOJOSHADER_glMakeContextCurrent(ctx);
169
7e9d90724cf8 Push parsed shaders through GLSL compiler to see what breaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 153
diff changeset
   161
        #endif
7e9d90724cf8 Push parsed shaders through GLSL compiler to see what breaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 153
diff changeset
   162
153
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   163
        for (i = 2; i < argc; i++)
170
9d71c08c756e Ripped out the multithreading from finderrors.c ...
Ryan C. Gordon <icculus@icculus.org>
parents: 169
diff changeset
   164
            total += do_dir(argv[i], profile);
153
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   166
        printf("Saw %d bytecode files.\n", total);
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   167
169
7e9d90724cf8 Push parsed shaders through GLSL compiler to see what breaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 153
diff changeset
   168
        #if FINDERRORS_COMPILE_SHADERS
238
e98f14da2897 Renamed glInit and glDeinit to glCreateContext and glDestroyContext.
Ryan C. Gordon <icculus@icculus.org>
parents: 237
diff changeset
   169
        MOJOSHADER_glDestroyContext(ctx);
169
7e9d90724cf8 Push parsed shaders through GLSL compiler to see what breaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 153
diff changeset
   170
        SDL_Quit();
7e9d90724cf8 Push parsed shaders through GLSL compiler to see what breaks.
Ryan C. Gordon <icculus@icculus.org>
parents: 153
diff changeset
   171
        #endif
153
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   172
    } // else
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   174
    return 0;
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   175
} // main
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   176
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   177
// end of finderrors.c ...
4410cc03dade Added finderrors.c to revision control.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   178