upgrade SDL to version 2.0.8
[platform/upstream/SDL.git] / test / testshader.c
index 807be1b..222d323 100755 (executable)
@@ -1,5 +1,9 @@
 /*
+<<<<<<< HEAD
   Copyright (r) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+=======
+  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
+>>>>>>> upstream
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
 #include "SDL_test_common.h"
 #define WINDOW_WIDTH 720
 #define WINDOW_HEIGHT 1280
-#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__NACL__) || defined(__TIZEN__)
+#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__NACL__) \
+    || defined(__WINDOWS__) || defined(__LINUX__) || defined(__TIZEN__)
 #define HAVE_OPENGLES2
 #endif
 
-#define HAVE_OPENGLES2
 
 #ifdef HAVE_OPENGLES2
 
@@ -61,7 +65,7 @@ static int LoadContext(GLES2_Context * data)
     do { \
         data->func = SDL_GL_GetProcAddress(#func); \
         if ( ! data->func ) { \
-            return SDL_SetError("Couldn't load GLES2 function %s: %s\n", #func, SDL_GetError()); \
+            return SDL_SetError("Couldn't load GLES2 function %s: %s", #func, SDL_GetError()); \
         } \
     } while ( 0 );
 #endif /* __SDL_NOGETPROCADDR__ */
@@ -96,7 +100,7 @@ quit(int rc)
         { \
           GLenum glError = ctx.glGetError(); \
           if(glError != GL_NO_ERROR) { \
-            SDLTest_Log("glGetError() = %i (0x%.8x) at line %i\n", glError, glError, __LINE__); \
+            SDL_Log("glGetError() = %i (0x%.8x) at line %i\n", glError, glError, __LINE__); \
             quit(1); \
           } \
         }
@@ -223,7 +227,7 @@ process_shader(GLuint *shader, const char * source, GLint shader_type)
     if(status != GL_TRUE) {
         ctx.glGetProgramInfoLog(*shader, sizeof(buffer), &length, &buffer[0]);
         buffer[length] = '\0';
-        SDLTest_Log("Shader compilation failed: %s", buffer);fflush(stderr);
+        SDL_Log("Shader compilation failed: %s", buffer);fflush(stderr);
         quit(-1);
     }
 }
@@ -466,7 +470,7 @@ void loop()
       for (i = 0; i < state->num_windows; ++i) {
           status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
           if (status) {
-              SDLTest_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+              SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
 
               /* Continue for next window */
               continue;
@@ -482,7 +486,7 @@ void loop()
 #endif
 }
 int
-SDL_main(int argc, char *argv[])
+main(int argc, char *argv[])
 {
     int fsaa, accel;
     int value;
@@ -527,7 +531,7 @@ SDL_main(int argc, char *argv[])
             }
         }
         if (consumed < 0) {
-            SDLTest_Log ("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
+            SDL_Log ("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0],
                     SDLTest_CommonUsage(state));
             quit(1);
         }
@@ -556,9 +560,9 @@ SDL_main(int argc, char *argv[])
         return 0;
     }
 
-    context = SDL_calloc(state->num_windows, sizeof(context));
+    context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(context));
     if (context == NULL) {
-        SDLTest_Log("Out of memory!\n");
+        SDL_Log("Out of memory!\n");
         quit(2);
     }
     
@@ -566,14 +570,14 @@ SDL_main(int argc, char *argv[])
     for (i = 0; i < state->num_windows; i++) {
         context[i] = SDL_GL_CreateContext(state->windows[i]);
         if (!context[i]) {
-            SDLTest_Log("SDL_GL_CreateContext(): %s\n", SDL_GetError());
+            SDL_Log("SDL_GL_CreateContext(): %s\n", SDL_GetError());
             quit(2);
         }
     }
 
     /* Important: call this *after* creating the context */
     if (LoadContext(&ctx) < 0) {
-        SDLTest_Log("Could not load GLES2 functions\n");
+        SDL_Log("Could not load GLES2 functions\n");
         quit(2);
         return 0;
     }
@@ -587,70 +591,70 @@ SDL_main(int argc, char *argv[])
     }
 
     SDL_GetCurrentDisplayMode(0, &mode);
-    SDLTest_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
-    SDLTest_Log("\n");
-    SDLTest_Log("Vendor     : %s\n", ctx.glGetString(GL_VENDOR));
-    SDLTest_Log("Renderer   : %s\n", ctx.glGetString(GL_RENDERER));
-    SDLTest_Log("Version    : %s\n", ctx.glGetString(GL_VERSION));
-    SDLTest_Log("Extensions : %s\n", ctx.glGetString(GL_EXTENSIONS));
-    SDLTest_Log("\n");
+    SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format));
+    SDL_Log("\n");
+    SDL_Log("Vendor     : %s\n", ctx.glGetString(GL_VENDOR));
+    SDL_Log("Renderer   : %s\n", ctx.glGetString(GL_RENDERER));
+    SDL_Log("Version    : %s\n", ctx.glGetString(GL_VERSION));
+    SDL_Log("Extensions : %s\n", ctx.glGetString(GL_EXTENSIONS));
+    SDL_Log("\n");
 
     status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value);
     if (!status) {
-        SDLTest_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
+        SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        SDLTest_Log( "Failed to get SDL_GL_RED_SIZE: %s\n",
+        SDL_Log( "Failed to get SDL_GL_RED_SIZE: %s\n",
                 SDL_GetError());
     }
     status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value);
     if (!status) {
-        SDLTest_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
+        SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        SDLTest_Log( "Failed to get SDL_GL_GREEN_SIZE: %s\n",
+        SDL_Log( "Failed to get SDL_GL_GREEN_SIZE: %s\n",
                 SDL_GetError());
     }
     status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value);
     if (!status) {
-        SDLTest_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
+        SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value);
     } else {
-        SDLTest_Log( "Failed to get SDL_GL_BLUE_SIZE: %s\n",
+        SDL_Log( "Failed to get SDL_GL_BLUE_SIZE: %s\n",
                 SDL_GetError());
     }
     status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value);
     if (!status) {
-        SDLTest_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
+        SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value);
     } else {
-        SDLTest_Log( "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
+        SDL_Log( "Failed to get SDL_GL_DEPTH_SIZE: %s\n",
                 SDL_GetError());
     }
     if (fsaa) {
         status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value);
         if (!status) {
-            SDLTest_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
+            SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);
         } else {
-            SDLTest_Log( "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
+            SDL_Log( "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n",
                     SDL_GetError());
         }
         status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value);
         if (!status) {
-            SDLTest_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
+            SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
                    value);
         } else {
-            SDLTest_Log( "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
+            SDL_Log( "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n",
                     SDL_GetError());
         }
     }
     if (accel) {
         status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
         if (!status) {
-            SDLTest_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
+            SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
         } else {
-            SDLTest_Log( "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
+            SDL_Log( "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
                     SDL_GetError());
         }
     }
 
-    datas = SDL_calloc(state->num_windows, sizeof(shader_data));
+    datas = (shader_data *)SDL_calloc(state->num_windows, sizeof(shader_data));
 
     /* Set rendering settings for each context */
     for (i = 0; i < state->num_windows; ++i) {
@@ -658,7 +662,7 @@ SDL_main(int argc, char *argv[])
         int w, h;
         status = SDL_GL_MakeCurrent(state->windows[i], context[i]);
         if (status) {
-            SDLTest_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
+            SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError());
 
             /* Continue for next window */
             continue;
@@ -718,7 +722,7 @@ SDL_main(int argc, char *argv[])
     /* Print out some timing information */
     now = SDL_GetTicks();
     if (now > then) {
-        SDLTest_Log("%2.2f frames per second\n",
+        SDL_Log("%2.2f frames per second\n",
                ((double) frames * 1000) / (now - then));
     }
 #if !defined(__ANDROID__) && !defined(__NACL__)  
@@ -732,7 +736,7 @@ SDL_main(int argc, char *argv[])
 int
 main(int argc, char *argv[])
 {
-    SDLTest_Log("No OpenGL ES support on this system\n");
+    SDL_Log("No OpenGL ES support on this system\n");
     return 1;
 }