initial commit
[andemo] / src / android / main.c
1 #include <EGL/egl.h>
2 #include <GLES2/gl2.h>
3
4 #include "demo.h"
5 #include "android_native_app_glue.h"
6
7 static struct android_app *app;
8 static EGLDisplay dpy;
9 static EGLSurface surf;
10 static EGLContext ctx;
11
12 void android_main(struct android_app *app_ptr)
13 {
14         app_dummy();
15         app = app_ptr;
16
17         app->onAppCmd = handle_command;
18         app->onInputEvent = handle_input;
19
20         for(;;) {
21                 int num_events;
22                 struct android_poll_source *pollsrc;
23
24                 while(ALooper_pollAll(0, 0, &num_events, (void**)&pollsrc) >= 0) {
25                         if(pollsrc) {
26                                 pollsrc->process(ap, pollsrc);
27                         }
28                 }
29
30                 if(app->destroyRequested) {
31                         return;
32                 }
33                 if(!paused) {
34                         demo_display();
35                         eglSwapBuffers(dpy, surf);
36                 }
37         }
38 }