Removed global variable from test program.
On Android starting the application after a previous quit did not always work.
Android keeps VM processes for a faster restart and therefore the loaded *.so.
--- a/test/testgesture.c Thu Dec 11 23:38:02 2014 +0100
+++ b/test/testgesture.c Fri Dec 12 21:00:25 2014 +0100
@@ -33,7 +33,6 @@
#define VERBOSE 0
-static SDL_Window *window;
static SDL_Event events[EVENT_BUF_SIZE];
static int eventWrite;
@@ -123,7 +122,7 @@
(k.p.y+k.r/2*SDL_sinf(k.ang))*screen->h,k.r/4*screen->w,0);
}
-void DrawScreen(SDL_Surface* screen)
+void DrawScreen(SDL_Surface* screen, SDL_Window* window)
{
int i;
#if 1
@@ -165,7 +164,8 @@
SDL_UpdateWindowSurface(window);
}
-SDL_Surface* initScreen(int width,int height)
+/* Returns a new SDL_Window if window is NULL or window if not. */
+SDL_Window* initWindow(SDL_Window *window, int width,int height)
{
if (!window) {
window = SDL_CreateWindow("Gesture Test",
@@ -175,11 +175,12 @@
if (!window) {
return NULL;
}
- return SDL_GetWindowSurface(window);
+ return window;
}
int main(int argc, char* argv[])
{
+ SDL_Window *window = NULL;
SDL_Surface *screen;
SDL_Event event;
SDL_bool quitting = SDL_FALSE;
@@ -194,7 +195,8 @@
if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1;
- if (!(screen = initScreen(WIDTH,HEIGHT)))
+ if (!(window = initWindow(window, WIDTH, HEIGHT)) ||
+ !(screen = SDL_GetWindowSurface(window)))
{
SDL_Quit();
return 1;
@@ -244,7 +246,8 @@
break;
case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
- if (!(screen = initScreen(event.window.data1, event.window.data2)))
+ if (!(window = initWindow(window, event.window.data1, event.window.data2)) ||
+ !(screen = SDL_GetWindowSurface(window)))
{
SDL_Quit();
return 1;
@@ -293,7 +296,7 @@
break;
}
}
- DrawScreen(screen);
+ DrawScreen(screen, window);
}
SDL_Quit();
return 0;