Skip to content

Latest commit

 

History

History
59 lines (51 loc) · 1.79 KB

bestprofile.c

File metadata and controls

59 lines (51 loc) · 1.79 KB
 
Jun 29, 2008
Jun 29, 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
Jun 29, 2008
Jun 29, 2008
20
21
22
23
24
25
int main(int argc, char **argv)
{
int retval = 1;
#if 0
printf("MojoShader bestprofile\n");
Mar 24, 2010
Mar 24, 2010
26
27
printf("Compiled against changeset %s\n", MOJOSHADER_CHANGESET);
printf("Linked against changeset %s\n", MOJOSHADER_changeset());
Jun 29, 2008
Jun 29, 2008
28
29
30
printf("\n");
#endif
Feb 21, 2014
Feb 21, 2014
31
SDL_Window *sdlwindow = NULL;
Jun 29, 2008
Jun 29, 2008
32
if (SDL_Init(SDL_INIT_VIDEO) == -1)
Feb 21, 2014
Feb 21, 2014
33
34
35
36
37
38
39
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());
Jun 29, 2008
Jun 29, 2008
40
41
else
{
Feb 21, 2014
Feb 21, 2014
42
43
44
45
const char *best = MOJOSHADER_glBestProfile(lookup, NULL, NULL, NULL, NULL);
MOJOSHADER_glContext *ctx = MOJOSHADER_glCreateContext(best, lookup, 0, 0, 0, 0);
if (ctx == NULL)
printf("MOJOSHADER_glCreateContext() fail: %s\n", MOJOSHADER_glGetError());
Jun 29, 2008
Jun 29, 2008
46
47
else
{
Feb 21, 2014
Feb 21, 2014
48
49
50
printf("%s\n", best);
retval = 0; // success.
MOJOSHADER_glDestroyContext(ctx);
Jun 29, 2008
Jun 29, 2008
51
52
53
} // else
} // else
Feb 21, 2014
Feb 21, 2014
54
SDL_Quit();
Jun 29, 2008
Jun 29, 2008
55
56
57
58
return retval;
} // main
// end of bestprofile.c ...