diff test/common.c @ 3194:c18c03927a77

Proper window resize handling in GLES test application.
author Mike Gorchak <lestat@i.com.ua>
date Thu, 11 Jun 2009 06:03:05 +0000
parents 51750b7a966f
children 3e0f51e60fa2
line wrap: on
line diff
--- a/test/common.c	Thu Jun 11 05:57:32 2009 +0000
+++ b/test/common.c	Thu Jun 11 06:03:05 2009 +0000
@@ -11,59 +11,56 @@
 #define AUDIO_USAGE \
 "[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]"
 
-struct pformat
-{
+struct pformat {
     Uint32 id;
-    const char *idstr;
-} pixel_format[] = {
-    {
-    SDL_PIXELFORMAT_INDEX1LSB, "SDL_PIXELFORMAT_INDEX1LSB"}, {
-    SDL_PIXELFORMAT_INDEX1MSB, "SDL_PIXELFORMAT_INDEX1MSB"}, {
-    SDL_PIXELFORMAT_INDEX4LSB, "SDL_PIXELFORMAT_INDEX4LSB"}, {
-    SDL_PIXELFORMAT_INDEX4MSB, "SDL_PIXELFORMAT_INDEX4MSB"}, {
-    SDL_PIXELFORMAT_INDEX8, "SDL_PIXELFORMAT_INDEX8"}, {
-    SDL_PIXELFORMAT_RGB332, "SDL_PIXELFORMAT_RGB332"}, {
-    SDL_PIXELFORMAT_RGB444, "SDL_PIXELFORMAT_RGB444"}, {
-    SDL_PIXELFORMAT_RGB555, "SDL_PIXELFORMAT_RGB555"}, {
-    SDL_PIXELFORMAT_BGR555, "SDL_PIXELFORMAT_BGR555"}, {
-    SDL_PIXELFORMAT_ARGB4444, "SDL_PIXELFORMAT_ARGB4444"}, {
-    SDL_PIXELFORMAT_ABGR4444, "SDL_PIXELFORMAT_ABGR4444"}, {
-    SDL_PIXELFORMAT_ARGB1555, "SDL_PIXELFORMAT_ARGB1555"}, {
-    SDL_PIXELFORMAT_ABGR1555, "SDL_PIXELFORMAT_ABGR1555"}, {
-    SDL_PIXELFORMAT_RGB565, "SDL_PIXELFORMAT_RGB565"}, {
-    SDL_PIXELFORMAT_BGR565, "SDL_PIXELFORMAT_BGR565"}, {
-    SDL_PIXELFORMAT_RGB24, "SDL_PIXELFORMAT_RGB24"}, {
-    SDL_PIXELFORMAT_BGR24, "SDL_PIXELFORMAT_BGR24"}, {
-    SDL_PIXELFORMAT_RGB888, "SDL_PIXELFORMAT_RGB888"}, {
-    SDL_PIXELFORMAT_BGR888, "SDL_PIXELFORMAT_BGR888"}, {
-    SDL_PIXELFORMAT_ARGB8888, "SDL_PIXELFORMAT_ARGB8888"}, {
-    SDL_PIXELFORMAT_RGBA8888, "SDL_PIXELFORMAT_RGBA8888"}, {
-    SDL_PIXELFORMAT_ABGR8888, "SDL_PIXELFORMAT_ABGR8888"}, {
-    SDL_PIXELFORMAT_BGRA8888, "SDL_PIXELFORMAT_BGRA8888"}, {
-    SDL_PIXELFORMAT_ARGB2101010, "SDL_PIXELFORMAT_ARGB2101010"}, {
-    SDL_PIXELFORMAT_YV12, "SDL_PIXELFORMAT_YV12"}, {
-    SDL_PIXELFORMAT_IYUV, "SDL_PIXELFORMAT_IYUV"}, {
-    SDL_PIXELFORMAT_YUY2, "SDL_PIXELFORMAT_YUY2"}, {
-    SDL_PIXELFORMAT_UYVY, "SDL_PIXELFORMAT_UYVY"}, {
-    SDL_PIXELFORMAT_YVYU, "SDL_PIXELFORMAT_YVYU"}
+    const char* idstr;
+} pixel_format[]={
+    {SDL_PIXELFORMAT_INDEX1LSB, "SDL_PIXELFORMAT_INDEX1LSB"},
+    {SDL_PIXELFORMAT_INDEX1MSB, "SDL_PIXELFORMAT_INDEX1MSB"},
+    {SDL_PIXELFORMAT_INDEX4LSB, "SDL_PIXELFORMAT_INDEX4LSB"},
+    {SDL_PIXELFORMAT_INDEX4MSB, "SDL_PIXELFORMAT_INDEX4MSB"},
+    {SDL_PIXELFORMAT_INDEX8, "SDL_PIXELFORMAT_INDEX8"},
+    {SDL_PIXELFORMAT_RGB332, "SDL_PIXELFORMAT_RGB332"},
+    {SDL_PIXELFORMAT_RGB444, "SDL_PIXELFORMAT_RGB444"},
+    {SDL_PIXELFORMAT_RGB555, "SDL_PIXELFORMAT_RGB555"},
+    {SDL_PIXELFORMAT_BGR555, "SDL_PIXELFORMAT_BGR555"},
+    {SDL_PIXELFORMAT_ARGB4444, "SDL_PIXELFORMAT_ARGB4444"},
+    {SDL_PIXELFORMAT_ABGR4444, "SDL_PIXELFORMAT_ABGR4444"},
+    {SDL_PIXELFORMAT_ARGB1555, "SDL_PIXELFORMAT_ARGB1555"},
+    {SDL_PIXELFORMAT_ABGR1555, "SDL_PIXELFORMAT_ABGR1555"},
+    {SDL_PIXELFORMAT_RGB565, "SDL_PIXELFORMAT_RGB565"},
+    {SDL_PIXELFORMAT_BGR565, "SDL_PIXELFORMAT_BGR565"},
+    {SDL_PIXELFORMAT_RGB24, "SDL_PIXELFORMAT_RGB24"},
+    {SDL_PIXELFORMAT_BGR24, "SDL_PIXELFORMAT_BGR24"},
+    {SDL_PIXELFORMAT_RGB888, "SDL_PIXELFORMAT_RGB888"},
+    {SDL_PIXELFORMAT_BGR888, "SDL_PIXELFORMAT_BGR888"},
+    {SDL_PIXELFORMAT_ARGB8888, "SDL_PIXELFORMAT_ARGB8888"},
+    {SDL_PIXELFORMAT_RGBA8888, "SDL_PIXELFORMAT_RGBA8888"},
+    {SDL_PIXELFORMAT_ABGR8888, "SDL_PIXELFORMAT_ABGR8888"},
+    {SDL_PIXELFORMAT_BGRA8888, "SDL_PIXELFORMAT_BGRA8888"},
+    {SDL_PIXELFORMAT_ARGB2101010, "SDL_PIXELFORMAT_ARGB2101010"},
+    {SDL_PIXELFORMAT_YV12, "SDL_PIXELFORMAT_YV12"},
+    {SDL_PIXELFORMAT_IYUV, "SDL_PIXELFORMAT_IYUV"},
+    {SDL_PIXELFORMAT_YUY2, "SDL_PIXELFORMAT_YUY2"},
+    {SDL_PIXELFORMAT_UYVY, "SDL_PIXELFORMAT_UYVY"},
+    {SDL_PIXELFORMAT_YVYU, "SDL_PIXELFORMAT_YVYU"}
 };
 
-const char *
-PixelFormatToString(Uint32 pformat)
+const char* PixelFormatToString(Uint32 pformat)
 {
-    Uint32 it = 0;
+   Uint32 it=0;
 
-    do {
-        if (pixel_format[it].idstr == NULL) {
-            break;
-        }
-        if (pixel_format[it].id == pformat) {
-            return pixel_format[it].idstr;
-        }
-        it++;
-    } while (1);
+   do {
+      if (pixel_format[it].idstr == NULL) {
+          break;
+      }
+      if (pixel_format[it].id == pformat) {
+          return pixel_format[it].idstr;
+      }
+      it++;
+   } while(1);
 
-    return "SDL_PIXELFORMAT_UNKNOWN";
+   return "SDL_PIXELFORMAT_UNKNOWN";
 }
 
 CommonState *
@@ -82,8 +79,8 @@
     state->window_flags = SDL_WINDOW_SHOWN;
     state->window_x = SDL_WINDOWPOS_UNDEFINED;
     state->window_y = SDL_WINDOWPOS_UNDEFINED;
-    state->window_w = 640;
-    state->window_h = 480;
+    state->window_w = DEFAULT_WINDOW_WIDTH;
+    state->window_h = DEFAULT_WINDOW_HEIGHT;
     state->num_windows = 1;
     state->audiospec.freq = 22050;
     state->audiospec.format = AUDIO_S16;
@@ -709,7 +706,7 @@
         fullscreen_mode.w = state->window_w;
         fullscreen_mode.h = state->window_h;
         fullscreen_mode.refresh_rate = state->refresh_rate;
-        if (SDL_SetFullscreenDisplayMode(&fullscreen_mode) < 0) {
+        if (SDL_SetFullscreenDisplayMode(&fullscreen_mode)<0) {
             fprintf(stderr, "Can't switch to fullscreen display mode: %s\n",
                     SDL_GetError());
             return SDL_FALSE;