utils/availableprofiles.c
changeset 588 ef3d2efa822d
parent 458 b91904879798
child 901 a9f799b93150
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/utils/availableprofiles.c	Thu Feb 12 17:29:24 2009 -0500
@@ -0,0 +1,67 @@
+/**
+ * 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"
+
+static int check_available(void)
+{
+    const char **avail = NULL;
+    int total = MOJOSHADER_glAvailableProfiles(SDL_GL_GetProcAddress, NULL, 0);
+    if (total > 0)
+    {
+        avail = (const char **) alloca(sizeof (const char *) * total);
+        total = MOJOSHADER_glAvailableProfiles(SDL_GL_GetProcAddress, avail, total);
+    } // if
+
+    if (total <= 0)
+        fprintf(stderr, "No profiles available.\n");
+    else
+    {
+        int i;
+        for (i = 0; i < total; i++)
+        {
+            printf("%s (Shader Model %d)\n", avail[i],
+                   MOJOSHADER_maxShaderModel(avail[i]));
+        } // for
+    } // else
+
+    return 0;
+} // check_available
+
+
+int main(int argc, char **argv)
+{
+    int retval = 1;
+
+    #if 0
+    printf("MojoShader availableprofile\n");
+    printf("Compiled against version %d\n", MOJOSHADER_VERSION);
+    printf("Linked against version %d\n", MOJOSHADER_version());
+    printf("\n");
+    #endif
+
+    if (SDL_Init(SDL_INIT_VIDEO) == -1)
+        fprintf(stderr, "SDL_Init(SDL_INIT_VIDEO) error: %s\n", SDL_GetError());
+    else
+    {
+        SDL_GL_LoadLibrary(NULL);
+        if (SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL)
+            fprintf(stderr, "SDL_SetVideoMode() error: %s\n", SDL_GetError());
+        else
+            retval = check_available();
+        SDL_Quit();
+    } // else
+
+    return retval;
+} // main
+
+// end of availableprofiles.c ...
+