Skip to content

Latest commit

 

History

History
74 lines (62 loc) · 2.06 KB

availableprofiles.c

File metadata and controls

74 lines (62 loc) · 2.06 KB
 
Jul 3, 2008
Jul 3, 2008
1
2
3
4
5
6
7
8
9
10
11
12
13
/**
* MojoShader; generate shader programs from bytecode of compiled
* Direct3D shaders.
*
* Please see the file LICENSE.txt in the source's root directory.
*
* This file written by Ryan C. Gordon.
*/
#include <stdio.h>
#include "mojoshader.h"
#include "SDL.h"
Mar 31, 2010
Mar 31, 2010
14
15
16
17
18
19
static void *lookup(const char *fnname, void *unused)
{
(void) unused;
return SDL_GL_GetProcAddress(fnname);
} // lookup
Jul 3, 2008
Jul 3, 2008
20
21
22
static int check_available(void)
{
const char **avail = NULL;
Oct 11, 2012
Oct 11, 2012
23
int total = MOJOSHADER_glAvailableProfiles(lookup, NULL, NULL, 0, NULL, NULL, NULL);
Jul 3, 2008
Jul 3, 2008
24
25
26
if (total > 0)
{
avail = (const char **) alloca(sizeof (const char *) * total);
Oct 11, 2012
Oct 11, 2012
27
total = MOJOSHADER_glAvailableProfiles(lookup, NULL, avail, total, NULL, NULL, NULL);
Jul 3, 2008
Jul 3, 2008
28
29
30
31
32
33
34
35
} // if
if (total <= 0)
fprintf(stderr, "No profiles available.\n");
else
{
int i;
for (i = 0; i < total; i++)
Nov 8, 2008
Nov 8, 2008
36
37
38
39
{
printf("%s (Shader Model %d)\n", avail[i],
MOJOSHADER_maxShaderModel(avail[i]));
} // for
Jul 3, 2008
Jul 3, 2008
40
41
42
43
44
45
46
47
48
49
50
51
} // else
return 0;
} // check_available
int main(int argc, char **argv)
{
int retval = 1;
#if 0
printf("MojoShader availableprofile\n");
Mar 24, 2010
Mar 24, 2010
52
53
printf("Compiled against changeset %s\n", MOJOSHADER_CHANGESET);
printf("Linked against changeset %s\n", MOJOSHADER_changeset());
Jul 3, 2008
Jul 3, 2008
54
55
56
printf("\n");
#endif
Feb 21, 2014
Feb 21, 2014
57
SDL_Window *sdlwindow = NULL;
Jul 3, 2008
Jul 3, 2008
58
if (SDL_Init(SDL_INIT_VIDEO) == -1)
Feb 21, 2014
Feb 21, 2014
59
60
61
62
63
64
65
fprintf(stderr, "SDL_Init() error: %s\n", SDL_GetError());
else if (SDL_GL_LoadLibrary(NULL) == -1)
fprintf(stderr, "SDL_GL_LoadLibrary() error: %s\n", SDL_GetError());
else if ((sdlwindow = SDL_CreateWindow(argv[0], SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_OPENGL)) == NULL)
fprintf(stderr, "SDL_CreateWindow() error: %s\n", SDL_GetError());
else if (SDL_GL_CreateContext(sdlwindow) == NULL)
fprintf(stderr, "SDL_GL_CreateContext() error: %s\n", SDL_GetError());
Jul 3, 2008
Jul 3, 2008
66
else
Feb 21, 2014
Feb 21, 2014
67
retval = check_available();
Jul 3, 2008
Jul 3, 2008
68
Feb 21, 2014
Feb 21, 2014
69
SDL_Quit();
Jul 3, 2008
Jul 3, 2008
70
71
72
73
return retval;
} // main
// end of availableprofiles.c ...