コード例 #1
0
ファイル: Main.cpp プロジェクト: Ali-il/gamekit
void android_main(android_app* state) 
{
	app_dummy();

	OgreKitAndroidGlue::init(state);
	OgreKitAndroidGlue::go(state);
}
コード例 #2
0
void android_main(android_app* state) {
	app_dummy();

	engine e;
	state->userData = &e;
	state->onAppCmd = [](android_app* app, int32_t cmd) {
		auto e = static_cast<engine*>(app->userData);
		switch (cmd) {
			case APP_CMD_INIT_WINDOW:
				init(e);
				draw(e);
				break;
		}
	};
	e.app = state;

	while (1) {
		int ident, events;
		android_poll_source* source;
		while ((ident=ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0) {
			if (source != NULL) {
				source->process(state, source);
			}
			if (state->destroyRequested != 0) {
				return;
			}
		}
	}
}
コード例 #3
0
ファイル: main.cpp プロジェクト: garudaxc/AndroidGL
void android_main(struct android_app* state) {
    struct engine engine;

    // Make sure glue isn't stripped.
    app_dummy();

    memset(&engine, 0, sizeof(engine));
    state->userData = &engine;
    state->onAppCmd = engine_handle_cmd;
    state->onInputEvent = engine_handle_input;
    engine.app = state;
	PlatfromInit();

	//_InitSensor();
	//InitSensor();
	
	ANativeActivity_setWindowFlags(state->activity, AWINDOW_FLAG_KEEP_SCREEN_ON, 0);

    if (state->savedState != NULL) {
        // We are starting with a previous saved state; restore from it.
        engine.state = *(struct saved_state*)state->savedState;
    }

    // loop waiting for stuff to do.

    while (1) {
        // Read all pending events.
        int ident;
        int events;
        struct android_poll_source* source;

        // If not animating, we will block forever waiting for events.
        // If animating, we loop until all events are read, then continue
        // to draw the next frame of animation.
        while ((ident = ALooper_pollAll(engine.animating ? 0 : -1, 
			NULL, &events,  (void**)&source)) >= 0) {

            // Process this event.
            if (source != NULL) {
                source->process(state, source);
            }

			//_ProcessSensorData(ident);

            // Check if we are exiting.
            if (state->destroyRequested != 0) {
                engine_term_display(&engine);
				PlatfromShutDown();
                return;
            }
        }

        if (engine.animating) {

            // Drawing is throttled to the screen update rate, so there
            // is no need to do timing here.
            engine_draw_frame(&engine);
        }
    }
}
コード例 #4
0
ファイル: engine_core.cpp プロジェクト: jiayu1016/dizzy
void EngineCore::mainLoop() {
    int ident;
    int events;
    struct android_poll_source* source;
    shared_ptr<EngineContext> engineContext(getEngineContext());
    app_dummy();

    while (true) {
        // If not animating, block forever waiting for events.
        // otherwise,  loop until all events are read, then continue
        // to draw the next frame of animation.
        while ((ident = ALooper_pollAll(
                    engineContext->isRendering() ? 0 : -1,
                    NULL, &events, (void**)&source)) >= 0) {
            if (ident == LOOPER_ID_MAIN || ident == LOOPER_ID_INPUT) {
                if (source != NULL) {
                    source->process(mApp, source);
                }
            }

            if (mApp->destroyRequested != 0) {
                DEBUG(Log::F_APP_CMD_EVENT, "destroy request received");
                return;
            }
        }

        // check needQuit() to give an early chance to stop drawing.
        if (engineContext->isRendering() && !engineContext->needQuit()) {
            // Drawing is throttled to the screen update rate, so there
            // is no need to do timing here.
            getEngineContext()->updateDisplay();
        }
    }

}
コード例 #5
0
ファイル: Main.c プロジェクト: rk126/FINS-Framework
void android_main(struct android_app *state) {
	app_dummy();

	//TODO-Have this update a variable, and use that to establish the pipes, sockets for improved compatibility with future android versions
	char *writeLocation = (char *) state->activity->internalDataPath;
	char *bootmsg = FINSBOOT_MSG;

	__android_log_print(ANDROID_LOG_INFO, "FINS", bootmsg);
	__android_log_print(ANDROID_LOG_INFO, "FINS", writeLocation);
	__android_log_print(ANDROID_LOG_INFO, "FINS", "Forking into capturermain() and main()");

	/*
	 int ret;
	 __android_log_print(ANDROID_LOG_INFO, "FINS", "Gaining su status");
	 if ((ret = system("su"))) {
	 __android_log_print(ANDROID_LOG_ERROR, "FINS", "SU failure: ret=%d, errno=%u, str='%s'", ret, errno, strerror(errno));
	 }
	 */
	if (0) {
		int i = 0;
		while (i < 1000) {
			__android_log_print(ANDROID_LOG_INFO, "FINS", "i=%d", i++);
			sleep(2);
		}
		return;
	}

	__android_log_print(ANDROID_LOG_INFO, "FINS", "Starting FINS: core_main()");
	core_dummy();
	core_main();
	while (1)
		;
	//sleep(1);
	__android_log_print(ANDROID_LOG_INFO, "FINS", "Exiting FINS: core_main()");
}
コード例 #6
0
/**
 * This is the main entry point of a native application that is using
 * android_native_app_glue.  It runs in its own thread, with its own
 * event loop for receiving input events and doing other things.
 */
void android_main(struct android_app* state)
{
    // Make sure glue isn't stripped.
    app_dummy();

    // create an instance of my sample
    ClusteredShadingSample *pSample = new ClusteredShadingSample();
    if (!pSample)
    {
        LOGI("Failed to allocate ClusteredShadingSample");
        return;
    }

     // Assign the sample back into the app state
    state->userData = pSample;
    state->onAppCmd = cput_handle_cmd;
    state->onInputEvent = CPUT_OGL::cput_handle_input;

	// Initialize the system and give it the base CPUT resource directory (location of GUI images/etc)
    // For now, we assume it's a relative directory from the executable directory.  Might make that resource
    // directory location an env variable/hardcoded later
    CPUTWindowAndroid::SetAppState(state);

    // start the main message loop
    pSample->CPUTMessageLoop();

    // cleanup resources
    SAFE_DELETE(pSample);
    pSample = NULL;

    state->userData = NULL;
}
コード例 #7
0
void android_main(android_app *app)
{
	int retval = 0;
	porting::app_global = app;

	Thread::setName("Main");

	try {
		app_dummy();
		char *argv[] = {strdup(PROJECT_NAME), NULL};
		main(ARRLEN(argv) - 1, argv);
		free(argv[0]);
#if !EXEPTION_DEBUG
	} catch (std::exception &e) {
		errorstream << "Uncaught exception in main thread: " << e.what() << std::endl;
		retval = -1;
	} catch (...) {
		errorstream << "Uncaught exception in main thread!" << std::endl;
		retval = -1;
#else
	} catch (int) { // impossible
#endif
	}

	porting::cleanupAndroid();
	infostream << "Shutting down." << std::endl;
	exit(retval);
}
コード例 #8
0
ファイル: android_main.cpp プロジェクト: AchimTuran/xbmc
extern void android_main(struct android_app* state)
{
  {
    // make sure that the linker doesn't strip out our glue
    app_dummy();

    // revector inputPollSource.process so we can shut up
    // its useless verbose logging on new events (see ouya)
    // and fix the error in handling multiple input events.
    // see https://code.google.com/p/android/issues/detail?id=41755
    state->inputPollSource.process = process_input;

    CEventLoop eventLoop(state);
    CXBMCApp xbmcApp(state->activity);
    if (xbmcApp.isValid())
    {
      start_logger("Kodi");

      IInputHandler inputHandler;
      eventLoop.run(xbmcApp, inputHandler);
    }
    else
      CXBMCApp::android_printf("android_main: setup failed");

    CXBMCApp::android_printf("android_main: Exiting");
    // We need to call exit() so that all loaded libraries are properly unloaded
    // otherwise on the next start of the Activity android will simple re-use
    // those loaded libs in the state they were in when we quit XBMC last time
    // which will lead to crashes because of global/static classes that haven't
    // been properly uninitialized
  }
  exit(0);
}
コード例 #9
0
ファイル: main.cpp プロジェクト: godfat/cubeat
int main(int argc, char *argv[])
#endif
{
#ifdef __APPLE__
    CFBundleRef mainBundle = CFBundleGetMainBundle();
    CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
    char path[PATH_MAX];
    if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
    {
        // error!
        std::cerr << "PATH ERROR " << __FILE__ << ": " << __LINE__ << std::endl;
    }
    CFRelease(resourcesURL);
    chdir(path); // cd in
    psc::Conf::i().init(path);
#elif _SHOOTING_CUBES_ANDROID_
    app_dummy();
    char buf[256] = {0};
    getcwd(buf, 256);
    chdir(app->activity->internalDataPath);
    LOGI("cwd: %s", buf);
    unpack_data(app);
    psc::Conf::i().init("", app->activity->internalDataPath, app->activity->externalDataPath);
    psc::App::i().init(app).launchOpening2().run();
    IrrDevice::i().~IrrDevice(); // manually destruct here, as IrrEx17 example?
#else
    psc::Conf::i().init(""); // doesn't need to find working_path on win32, not sure about linux though
    std::srand(std::time(0)^std::clock()); //  init srand for global rand...
    //return psc::App::i().init().launchOpening().run();
    return psc::App::i().init().launchOpening2().run();
#endif
}
コード例 #10
0
ファイル: porting_android.cpp プロジェクト: DaErHuo/minetest
void android_main(android_app *app)
{
	int retval = 0;
	porting::app_global = app;

	porting::setThreadName("MainThread");

	try {
		app_dummy();
		char *argv[] = { (char*) "minetest" };
		main(sizeof(argv) / sizeof(argv[0]), argv);
		}
	catch(BaseException e) {
		std::stringstream msg;
		msg << "Exception handled by main: " << e.what();
		const char* message = msg.str().c_str();
		__android_log_print(ANDROID_LOG_ERROR, PROJECT_NAME, "%s", message);
		errorstream << msg << std::endl;
		retval = -1;
	}
	catch(...) {
		__android_log_print(ANDROID_LOG_ERROR, PROJECT_NAME,
				"Some exception occured");
		errorstream << "Uncaught exception in main thread!" << std::endl;
		retval = -1;
	}

	porting::cleanupAndroid();
	errorstream << "Shutting down minetest." << std::endl;
	exit(retval);
}
コード例 #11
0
extern void android_main(struct android_app* state)
{
  // make sure that the linker doesn't strip out our glue
  app_dummy();

  setup_env(state);
  CEventLoop eventLoop(state);
  CXBMCApp xbmcApp(state->activity);
  if (xbmcApp.isValid())
  {
    g_xbmcapp = &xbmcApp;
    IInputHandler inputHandler;
    eventLoop.run(xbmcApp, inputHandler);
  }
  else
    CXBMCApp::android_printf("android_main: setup failed");

  CXBMCApp::android_printf("android_main: Exiting");
  // We need to call exit() so that all loaded libraries are properly unloaded
  // otherwise on the next start of the Activity android will simple re-use
  // those loaded libs in the state they were in when we quit XBMC last time
  // which will lead to crashes because of global/static classes that haven't
  // been properly uninitialized
  exit(0);
}
コード例 #12
0
ファイル: IndicoEngine.cpp プロジェクト: ralphmorton/Indico
	void Engine::run()
	{
		app_dummy();

		Timer timer;

		while (true)
		{
			int ident;
			int fdesc;
			int events;
			struct android_poll_source* source;

			while((ident = ALooper_pollAll(0, &fdesc, &events, (void**)&source)) >= 0)
			{
				if (source)
					source->process(mAndroidApp, source);
			}

			unsigned long long nanos = timer.nanos();
			timer.reset();

			if (mInited)
			{
				if (!mApp.update(nanos))
					break;

				mRender.frame();
			}
		}

		mApp.shutdown();
	}
コード例 #13
0
ファイル: displacement.cpp プロジェクト: 2007750219/Vulkan
// Linux entry point
int main(const int argc, const char *argv[])
#endif
{
#if defined(__ANDROID__)
	// Removing this may cause the compiler to omit the main entry point 
	// which would make the application crash at start
	app_dummy();
#endif
	vulkanExample = new VulkanExample();
#if defined(_WIN32)
	vulkanExample->setupWindow(hInstance, WndProc);
#elif defined(__ANDROID__)
	// Attach vulkan example to global android application state
	state->userData = vulkanExample;
	state->onAppCmd = VulkanExample::handleAppCommand;
	state->onInputEvent = VulkanExample::handleAppInput;
	vulkanExample->androidApp = state;
#elif defined(__linux__)
	vulkanExample->setupWindow();
#endif
#if !defined(__ANDROID__)
	vulkanExample->initSwapchain();
	vulkanExample->prepare();
#endif
	vulkanExample->renderLoop();
	delete(vulkanExample);
#if !defined(__ANDROID__)
	return 0;
#endif
}
コード例 #14
0
void android_main(struct android_app* state)
{
    app_dummy();
	state->userData = &app;

	// Prepare to monitor accelerometer
	app.sensorManager = ASensorManager_getInstance();
	app.sensorEventQueue = ASensorManager_createEventQueue(app.sensorManager, state->looper, LOOPER_ID_USER, NULL, NULL);

	if (state->savedState != NULL)
	{
		// We are starting with a previous saved state; restore from it.
		app.state = *(AppState*)state->savedState;
	}

	if(gRoot == NULL)
	{
		gRoot = new Ogre::Root();
		#ifdef OGRE_STATIC_LIB
			gStaticPluginLoader = new Ogre::StaticPluginLoader();
			gStaticPluginLoader->load();
		#endif
        gRoot->setRenderSystem(gRoot->getAvailableRenderers().at(0));
        gRoot->initialise(false);	
	}


    state->onAppCmd = &handleCmd;
    state->onInputEvent = &handleInput;

    int ident, events;
    struct android_poll_source* source;
    
    while (true)
    {
        while ((ident = ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0)
        {
            if (source != NULL)
            {
            	source->process(state, source);
            }
            
            if (state->destroyRequested != 0)
            {
            	return;
            }
        }
        
		if(gRenderWnd != NULL && gRenderWnd->isActive())
		{
			gRenderWnd->windowMovedOrResized();
			gRoot->renderOneFrame();

			InitGameScene();

		}
    }
}
コード例 #15
0
ファイル: main.c プロジェクト: LiberatorUSA/GUCEF
/**
 * This is the main entry point of a native application that is using
 * android_native_app_glue.  It runs in its own thread, with its own
 * event loop for receiving input events and doing other things.
 */
void
android_main( struct android_app* state )
{
    // Make sure glue isn't stripped.
    app_dummy();

    char packageDir[ 512 ];
    GetPackageDir( state, packageDir, 512 );

    // Check if we need to perform first time initialization
    int firstRun = IsFirstRun( packageDir );
    if ( 0 == firstRun )
    {
        LOGI( "Performing first run initialization" );

        // Extract to our private storage as desired
        if ( 0 == ExtractAssets( state, packageDir ) )
        {
            return;
        }

        LOGI( "Completed first run initialization" );
    }
    else
    {
        LOGI( "Detected previous run, skipping first run initialization" );
    }

    // Create the platform specific params
    char** platformArgv = NULLPTR;
    int platformArgc = 0;
    CreatePlatformParams( &platformArgv, &platformArgc, state );

    // Start the process of invoking the launch of the platform using the loader
    int appStatus = InvokeLoadAndRunGucefPlatformApp( "gucefPRODMAN", packageDir, platformArgc, platformArgv, 0, NULLPTR );

    // clean up our platform param data
    FreeStringMatrix( platformArgv, platformArgc );

    // Check if we had a successfull run
    if ( 0 != firstRun )
    {
        if ( 0 == appStatus )
        {
            LOGI( "Successfull completed first run, setting first run flag to false" );

            // Set the flag that we completed the first run
            SetFirstRunCompleted( packageDir );
        }
        else
        {
            // If the flag is already set, unset it
            UnSetFirstRunCompleted( packageDir );
        }
    }
    FLOGI( "exit status code: %i", appStatus );

}
コード例 #16
0
/**
 * This is the main entry point of a native application that is using
 * android_native_app_glue.  It runs in its own thread, with its own
 * event loop for receiving input events and doing other things.
 */
void android_main(struct android_app* state)
{
    // Make sure glue isn't stripped.
    app_dummy();

    LOGI("\n\n********************************");
    LOGI("      STARTING SAMPLE");
    LOGI("********************************\n\n");

    // create an instance of my sample
    MySample *pSample = new MySample();
    if (!pSample)
    {
        LOGI("Failed to allocate MySample");
        return;
    }

     // Assign the sample back into the app state
    state->userData = pSample;
    state->onAppCmd = cput_handle_cmd;
    state->onInputEvent = CPUT_OGL::cput_handle_input;


    // We make the assumption we are running from the executable's dir in
    // the CPUT SampleStart directory or it won't be able to use the relative paths to find the default
    // resources    
    cString ResourceDirectory;

    CPUTFileSystem::GetExecutableDirectory(&ResourceDirectory);

    // Different executable and assets locations on different OS'es.
    // Consistency should be maintained in all OS'es and API's.
    ResourceDirectory.append(GUI_LOCATION);

	// Initialize the system and give it the base CPUT resource directory (location of GUI images/etc)
    // For now, we assume it's a relative directory from the executable directory.  Might make that resource
    // directory location an env variable/hardcoded later
    CPUTWindowAndroid::SetAppState(state);
	pSample->CPUTInitialize(ResourceDirectory);

    CPUTFileSystem::GetExecutableDirectory(&ResourceDirectory);

    // Different executable and assets locations on different OS'es.
    // Consistency should be maintained in all OS'es and API's.
    ResourceDirectory.append(SYSTEM_LOCATION);
    CPUTAssetLibrary *pAssetLibrary = CPUTAssetLibrary::GetAssetLibrary();
    pAssetLibrary->SetSystemDirectoryName(ResourceDirectory);

    // start the main message loop
    pSample->CPUTMessageLoop();

    // cleanup resources
    SAFE_DELETE(pSample);
    pSample = NULL;

    state->userData = NULL;
}
コード例 #17
0
/**
 * This is the main entry point of a native application that is using
 * android_native_app_glue.  It runs in its own thread, with its own
 * event loop for receiving input events and doing other things.
 */
void android_main(struct android_app* state) {
    assert(state);

    // Make sure glue isn't stripped.
    app_dummy();

    gkAndroidApp app(state);
    app.run();
}
コード例 #18
0
ファイル: main.cpp プロジェクト: Acidburn0zzz/flatbuffers
void android_main(android_app *app) {
  app_dummy();

  flatbuffers::FlatBufferBuilder builder;
  auto name = builder.CreateString("Dog");
  auto sound = builder.CreateString("Bark");
  auto animal_buffer = sample::CreateAnimal(builder, name, sound);
  builder.Finish(animal_buffer);
}
コード例 #19
0
ファイル: main.cpp プロジェクト: jiayu1016/nativeactivity-es2
void android_main(struct android_app* state)
{
    struct engine engine;

    // Make sure glue isn't stripped.
    app_dummy();


    AndroidAssetManager::Inst(state->activity->assetManager);
    AndroidAssetManager::Inst()->openDir((char*)"");

    memset(&engine, 0, sizeof(engine));
    state->userData = &engine;
    state->onAppCmd = engine_handle_cmd;
    state->onInputEvent = engine_handle_input;
    engine.app = state;


    if (state->savedState != NULL)
    {
        // We are starting with a previous saved state; restore from it.
        engine.state = *(struct saved_state*)state->savedState;
    }

    // loop waiting for stuff to do.

    while (1) 
    {
        // Read all pending events.
        int ident;
        int events;
        struct android_poll_source* source;

        while ((ident=ALooper_pollAll(0, NULL, &events,
                (void**)&source)) >= 0) 
                {

            // Process this event.
            if (source != NULL) 
            {
                source->process(state, source);
            }

            // Check if we are exiting.
            if (state->destroyRequested != 0) 
            {
                engine_term_display(&engine);
                return;
            }
        }

        getDeltaTime();
        engine_draw_frame(&engine);

    }
}
コード例 #20
0
ファイル: AndroidEventLoop.cpp プロジェクト: mirceamt/MPACK
		ReturnValue AndroidEventLoop::Run(ActivityHandler* pActivityHandler)
		{
			int32_t result;
			int32_t events;
			android_poll_source* source;

			// Makes sure native glue is not stripped by the linker.
			app_dummy();
			m_pActivityHandler = pActivityHandler;

			// Global step loop.
			LOGI("Starting event loop");
			while (true)
			{
				Global::pContext->pTimeService->Update();
				Global::pContext->pInputService->Update();

				// Event processing loop.
				while ((result = ALooper_pollAll(m_enabled ? 0 : -1, NULL, &events, (void**) &source)) >= 0)
				{
					// An event has to be processed.
					if (source != NULL)
					{
						source->process(Global::pAndroidApp, source);
					}
					// Application is getting destroyed.
					if (Global::pAndroidApp->destroyRequested)
					{
						LOGI("Exiting event loop");
						return RETURN_VALUE_OK;
					}
				}

				//LOGD("m_enabled = %d",m_enabled);
				//LOGD("m_quit = %d", m_quit);
				//LOGD("context bound? = %d", m_window.IsContextBound());

				// Steps the application.
				if ((m_enabled) && (!m_quit) && (m_window.IsContextBound()))
				{
					//LOGD("TESTING");
					if (m_pActivityHandler->onStep() != RETURN_VALUE_OK)
					{
						m_quit = true;
						ANativeActivity_finish(Global::pAndroidApp->activity);
					}

					if(m_window.SwapBuffers() != RETURN_VALUE_OK)
					{
						m_quit = true;
						ANativeActivity_finish(Global::pAndroidApp->activity);
					}
				}
			}
			return RETURN_VALUE_OK;
		}
コード例 #21
0
/**
 * This is the main entry point of a native application that is using
 * android_native_app_glue.  It runs in its own thread, with its own
 * event loop for receiving input events and doing other things.
 */
void android_main( android_app* state )
{
    app_dummy();

    g_engine.SetState( state );

    //Init helper functions
    ndk_helper::JNIHelper::GetInstance()->Init( state->activity, HELPER_CLASS_NAME );

    state->userData = &g_engine;
    state->onAppCmd = Engine::HandleCmd;
    state->onInputEvent = Engine::HandleInput;

#ifdef USE_NDK_PROFILER
    monstartup("libMoreTeapotsNativeActivity.so");
#endif

    // Prepare to monitor accelerometer
    g_engine.InitSensors();

    // loop waiting for stuff to do.
    while( 1 )
    {
        // Read all pending events.
        int id;
        int events;
        android_poll_source* source;

        // If not animating, we will block forever waiting for events.
        // If animating, we loop until all events are read, then continue
        // to draw the next frame of animation.
        while( (id = ALooper_pollAll( g_engine.IsReady() ? 0 : -1, NULL, &events, (void**) &source ))
                >= 0 )
        {
            // Process this event.
            if( source != NULL )
                source->process( state, source );

            g_engine.ProcessSensors( id );

            // Check if we are exiting.
            if( state->destroyRequested != 0 )
            {
                g_engine.TermDisplay();
                return;
            }
        }

        if( g_engine.IsReady() )
        {
            // Drawing is throttled to the screen update rate, so there
            // is no need to do timing here.
            g_engine.DrawFrame();
        }
    }
}
コード例 #22
0
ファイル: fg_main_android.c プロジェクト: fatman2021/qb64
void fgPlatformMainLoopPreliminaryWork ( void )
{
  printf("fgPlatformMainLoopPreliminaryWork\n");

  key_init();

  /* Make sure glue isn't stripped. */
  /* JNI entry points need to be bundled even when linking statically */
  app_dummy();
}
コード例 #23
0
ファイル: AndroidMain.c プロジェクト: Gabriele91/Easy2D
/*********************************
Android MAIN
**********************************/
extern void android_main(struct android_app* state) {
    /////////////////////////////////
    // Make sure glue isn't stripped.
    app_dummy();
	//enable COUT 
	overloadSTDCOUT();
    /////////////////////////////////
    //Init state
    state->onAppCmd = __android_handle_cmd;
    state->onInputEvent = __android_handle_input;
    //save app
    app_state=state;
	//attach java thread
	attachToAndroidThreadJava();	
	//init sensors
	initSensors();
	createSensorsEventQueue();
	addAccelerometer();
	////////////////////////////
    int ident;
    int events;
    struct android_poll_source* source;
    //waiting to get window
    while (!getIsAndroidValidDevice()){
        while ((ident = ALooper_pollAll(0, NULL, &events,(void**)&source)) >= 0){
                if (source != NULL) source->process(state, source);
                if (state->destroyRequested != 0) return;
        }
        usleep( 16 );
    }
	////////////////////////////	
    //GET APK (ZIP FILE)
    ANativeActivity* activity = state->activity;
    jclass clazz = (*getEnv())->GetObjectClass(getEnv(), activity->clazz);
    jmethodID methodID = (*getEnv())->GetMethodID(getEnv(), clazz, "getPackageCodePath", "()Ljava/lang/String;");
	jobject result = (*getEnv())->CallObjectMethod(getEnv(), activity->clazz, methodID);
    jboolean isCopy;
    path_apk= (const char*) (*getEnv())->GetStringUTFChars(getEnv(), (jstring)result, &isCopy);
    ////////////////////////////
    //INIT openAL/backend
    JNI_OnLoad(activity->vm,0);
    //no in OpenSL ES backend
    ////////////////////////
	//call main
    char *argv[2];
    argv[0] = strdup("Easy2D");
    argv[1] = NULL;
    int out=main(1, argv);
    //call atexit
    callatexitANDROID();
	//deattach java thread
	deattachToAndroidThreadJava();
	//disable COUT 
	unoverloadSTDCOUT();
}
コード例 #24
0
ファイル: main.c プロジェクト: venkatarajasekhar/ssa
/**
 * 繧「繝励Μ繧ア繝シ繧キ繝ァ繝ウ髢句ァ� */
void android_main(struct android_app* state) {
    struct engine engine;

    // glue縺悟炎髯、縺輔l縺ェ縺�h縺�↓
    app_dummy();

    memset(&engine, 0, sizeof(engine));
    state->userData = &engine;
    state->onAppCmd = engine_handle_cmd;
    state->onInputEvent = engine_handle_input;
    engine.app = state;

    // 繧サ繝ウ繧オ繝シ縺九i縺ョ繝��繧ソ蜿門セ励↓蠢�ヲ√↑蛻晄悄蛹�    engine.sensorManager = ASensorManager_getInstance();
    engine.accelerometerSensor = ASensorManager_getDefaultSensor(
                                     engine.sensorManager, ASENSOR_TYPE_ACCELEROMETER);
    engine.sensorEventQueue = ASensorManager_createEventQueue(
                                  engine.sensorManager, state->looper, LOOPER_ID_USER, NULL,
                                  NULL);

    if (state->savedState != NULL) {
        // 莉・蜑阪�迥カ諷九↓謌サ縺�        engine.state = *(struct saved_state*) state->savedState;
    }

    while (1) {

        int ident;
        int events;
        struct android_poll_source* source;

        // 繧「繝励Μ繧ア繝シ繧キ繝ァ繝ウ縺悟虚菴懊☆繧九%縺ィ縺ォ縺ェ繧後�縲√%繧後i繧サ繝ウ繧オ繝シ縺ョ蛻カ蠕。繧定。後≧
        while ((ident = ALooper_pollAll(engine.animating ? 0 : -1, NULL,
                                        &events, (void**) &source)) >= 0) {

            // 繧、繝吶Φ繝医r蜃ヲ逅�☆繧�            if (source != NULL) {
            source->process(state, source);
        }

        // 繧サ繝ウ繧オ繝シ縺ォ菴輔°縺励i縺ョ繝��繧ソ縺悟ュ伜惠縺励◆繧牙�逅�☆繧�            if (ident == LOOPER_ID_USER) {
        if (engine.accelerometerSensor != NULL) {
            ASensorEvent event;
            while (ASensorEventQueue_getEvents(
                        engine.sensorEventQueue, &event, 1) > 0) {
                LOGI("accelerometer: x=%f y=%f z=%f",
                     event.acceleration.x, event.acceleration.y,
                     event.acceleration.z);
            }
        }
    }

    // 遐エ譽�ヲ∵アゅ′縺ゅ▲縺溘°
    if (state->destroyRequested != 0) {
        engine_term_display(&engine);
        return;
    }
}
コード例 #25
0
ShellAndroid::ShellAndroid(android_app &app, Game &game) : Shell(game), app_(app)
{
    instance_extensions_.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME);

    app_dummy();
    app_.userData = this;
    app_.onAppCmd = on_app_cmd;
    app_.onInputEvent = on_input_event;

    init_vk();
}
コード例 #26
0
ファイル: Main.cpp プロジェクト: GlenDC/StarEngine-downloads
void android_main(android_app* pApplication) 
{
	app_dummy();

	Game * pGame = new Game();

	star::EventLoop::GetInstance()->Initialize(pApplication, pGame);
	star::EventLoop::GetInstance()->Run();

	delete pGame;
}
コード例 #27
0
ファイル: glus_os_android_es.c プロジェクト: MaybeS/OpenGL
void android_main(struct android_app* app)
{
	// Make sure glue isn't stripped.
	app_dummy();

	if (!app)
	{
		return;
	}

	g_app = app;

	g_app->onAppCmd = onAppCmd;

	g_app->activity->callbacks->onConfigurationChanged = onConfigurationChanged;

	//

	GLUSboolean doInit = GLUS_TRUE;

	while(doInit)
	{
		int ident;
	    int events;
	    struct android_poll_source* androidPollSource;

	    while ((ident = ALooper_pollAll(0, NULL, &events, (void**)&androidPollSource)) >= 0)
	    {
	    	if (androidPollSource != NULL)
	        {
	    		androidPollSource->process(g_app, androidPollSource);
	        }
	    }

	    if (g_app->destroyRequested != 0)
	    {
	    	exit(0);
	    }

	    if (g_nativeWindow != 0)
	    {
	    	doInit = GLUS_FALSE;
	    }
	}

	//

	main(0, 0);

	//

	exit(0);
}
コード例 #28
0
ファイル: main.cpp プロジェクト: morsya/omim
void android_main(struct android_app * state) 
{
  // Make sure glue isn't stripped.
  app_dummy();
  
  integration_tests::test(state);
  indexer_tests::test(state);

  // @todo(vbykoianko) Take care of correctly leaving the activity after all tests have
  // finished. It's nice to show the result of the test on Android screen. Message box or
  // something like that.
}
コード例 #29
0
ファイル: main.c プロジェクト: seishuku/gauges
void android_main(struct android_app *state)
{
	system("su -c \"chmod 0777 /dev/ttyUSB0\"");

	app_dummy();

	state->userData=NULL;
	state->onAppCmd=engine_handle_cmd;
	state->onInputEvent=engine_handle_input;

	app=state;

	assetManager=state->activity->assetManager;

	SerialConnect("/dev/ttyUSB0");

	while(1)
	{
		int ident, events;
		struct android_poll_source *source;

		while((ident=ALooper_pollAll(0, NULL, &events, (void**)&source))>=0)
		{
			if(source!=NULL)
				source->process(state, source);

			if(state->destroyRequested!=0)
			{
				engine_term_display();
				return;
			}
		}

		memcpy(&StartTime, &EndTime, sizeof(struct timespec));
		clock_gettime(CLOCK_MONOTONIC, &EndTime);

		engine_draw_frame();

		fTimeStep=(float)timespecDiff(&EndTime, &StartTime)/1000000000.0f;

		fTime+=fTimeStep;
		FPSTemp+=1.0f/fTimeStep;

		if(Frames++>15)
		{
			FPS=FPSTemp/Frames;
			FPSTemp=0.0f;
			Frames=0;
		}
	}

	close(tty_fd);
}
コード例 #30
0
ファイル: main.cpp プロジェクト: ColinGilbert/noobEngine
void android_main(struct android_app* state)
{
	struct engine engine;
	// Make sure glue isn't stripped.
	app_dummy();
	memset(&engine, 0, sizeof(engine));
	state->userData = &engine;
	state->onAppCmd = engine_handle_command;
	state->onInputEvent = engine_handle_input;
	engine.app = state;
	engine.sensorManager = ASensorManager_getInstance();
	engine.accelerometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager, ASENSOR_TYPE_ACCELEROMETER);
	engine.sensorEventQueue = ASensorManager_createEventQueue(engine.sensorManager, state->looper, LOOPER_ID_USER, 0, 0);

	ANativeActivity* nativeActivity = state->activity;                              

	android_pre_init_filesystem(state);

	while (1)
	{
		int ident;
		int events;
		struct android_poll_source* source;
		while ((ident=ALooper_pollAll(engine.animating ? 0 : -1, 0, &events, (void**)&source)) >= 0)
		{
			if (source != nullptr)
			{
				source->process(state, source);
			}
			if (ident == LOOPER_ID_USER)
			{
				if (engine.accelerometerSensor != nullptr)
				{
					ASensorEvent event;
					while (ASensorEventQueue_getEvents(engine.sensorEventQueue, &event, 1) > 0)
					{
						accelerometer_input_callback(event.acceleration.x, event.acceleration.y, event.acceleration.z);
					}
				}
			}
			if (state->destroyRequested != 0)
			{
				engine_term_display(&engine);
				return;
			}
		}
		if (engine.animating)
		{
			engine_draw_frame(&engine);
		}
	}
}