int main(int argc, char *argv[]) { memset(&_esContext, 0, sizeof(ESContext)); _esContext.height = 600; _esContext.width = 800; if (esMain(&_esContext) != GL_TRUE) { return 1; } WinLoop(&_esContext); if (_esContext.shutdownFunc != NULL) { _esContext.shutdownFunc(&_esContext); } if (_esContext.userData != NULL) { free(_esContext.userData); } return 0; }
/// // main() // // Main entrypoint for application // int main ( int argc, char *argv[] ) { ESContext esContext; memset ( &esContext, 0, sizeof ( ESContext ) ); if ( esMain ( &esContext ) != GL_TRUE ) { return 1; } WinLoop ( &esContext ); if ( esContext.shutdownFunc != NULL ) { esContext.shutdownFunc ( &esContext ); } if ( esContext.userData != NULL ) { free ( esContext.userData ); } return 0; }
/// // HandleCommand() // // Android callback for onAppCmd // static void HandleCommand ( struct android_app *pApp, int32_t cmd ) { ESContext *esContext = ( ESContext * ) pApp->userData; switch ( cmd ) { case APP_CMD_SAVE_STATE: // the OS asked us to save the state of the app break; case APP_CMD_INIT_WINDOW: esContext->eglNativeDisplay = EGL_DEFAULT_DISPLAY; esContext->eglNativeWindow = pApp->window; /* // Call the main entrypoint for the app if ( esMain ( esContext ) != GL_TRUE ) { exit ( 0 ); //@TEMP better way to exit? } */ break; case APP_CMD_TERM_WINDOW: // Cleanup on shutdown if ( esContext->shutdownFunc != NULL ) { esContext->shutdownFunc ( esContext ); } if ( esContext->userData != NULL ) { free ( esContext->userData ); } memset ( esContext, 0, sizeof ( ESContext ) ); break; case APP_CMD_LOST_FOCUS: // if the app lost focus, avoid unnecessary processing (like monitoring the accelerometer) break; case APP_CMD_GAINED_FOCUS: // bring back a certain functionality, like monitoring the accelerometer break; } }