Debian Codegraph @

utils/availableprofiles.c

raw symbols SCIP
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 static void *lookup(const char *fnname, void *unused)
15 {
16 (void) unused;
17 return SDL_GL_GetProcAddress(fnname);
18 } // lookup
19
20 static int check_available(void)
21 {
22 const char **avail = NULL;
23 int total = MOJOSHADER_glAvailableProfiles(lookup, NULL, NULL, 0, NULL, NULL, NULL);
24 if (total > 0)
25 {
26 avail = (const char **) alloca(sizeof (const char *) * total);
27 total = MOJOSHADER_glAvailableProfiles(lookup, NULL, avail, total, NULL, NULL, NULL);
28 } // if
29
30 if (total <= 0)
31 fprintf(stderr, "No profiles available.\n");
32 else
33 {
34 int i;
35 for (i = 0; i < total; i++)
36 {
37 printf("%s (Shader Model %d)\n", avail[i],
38 MOJOSHADER_maxShaderModel(avail[i]));
39 } // for
40 } // else
41
42 return 0;
43 } // check_available
44
45
46 int main(int argc, char **argv)
47 {
48 int retval = 1;
49
50 #if 0
51 printf("MojoShader availableprofile\n");
52 printf("Compiled against changeset %s\n", MOJOSHADER_CHANGESET);
53 printf("Linked against changeset %s\n", MOJOSHADER_changeset());
54 printf("\n");
55 #endif
56
57 SDL_Window *sdlwindow = NULL;
58 if (SDL_Init(SDL_INIT_VIDEO) == -1)
59 fprintf(stderr, "SDL_Init() error: %s\n", SDL_GetError());
60 else if (SDL_GL_LoadLibrary(NULL) == -1)
61 fprintf(stderr, "SDL_GL_LoadLibrary() error: %s\n", SDL_GetError());
62 else if ((sdlwindow = SDL_CreateWindow(argv[0], SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_OPENGL)) == NULL)
63 fprintf(stderr, "SDL_CreateWindow() error: %s\n", SDL_GetError());
64 else if (SDL_GL_CreateContext(sdlwindow) == NULL)
65 fprintf(stderr, "SDL_GL_CreateContext() error: %s\n", SDL_GetError());
66 else
67 retval = check_available();
68
69 SDL_Quit();
70 return retval;
71 } // main
72
73 // end of availableprofiles.c ...
74