Пример #1
0
static void custom_handle_cmd(struct android_app* _application, int32_t _command)
{
    switch(_command)
    {
       case APP_CMD_INIT_WINDOW:
       {
    	   IGraphicsContext::Set_AWindow(_application->window);
    	   CResourceAccessor::Set_AAssetManager(_application->activity->assetManager);
    	   CGameViewController_ndk* controller = new CGameViewController_ndk();
    	   Run();
       }
       break;

       case APP_CMD_TERM_WINDOW:
       {
    	   ANativeActivity_finish(_application->activity);
    	   exit(0);
       }
       break;

       case APP_CMD_GAINED_FOCUS:
       {
    	   g_animating = 1;
       }
       break;

       case APP_CMD_LOST_FOCUS:
       {
    	   ANativeActivity_finish(_application->activity);
    	   exit(0);
       }
       break;
    }
}
Пример #2
0
		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;
		}
Пример #3
0
    Status AndroidEventLoop::Run(ActivityHandler* pActivityHandler)
    {
        int32_t lResult;
        int32_t lEvents;
        android_poll_source* lSource;

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

        // Global step loop.
        LOGI("Starting event loop");
        while (true)
        {
            // Event processing loop.
            while ((lResult = ALooper_pollAll(mEnabled ? 0 : -1, NULL, &lEvents, (void**) &lSource)) >= 0)
            {
                // An event has to be processed.
                if (lSource != NULL)
                {
                	LOGI("Processing an event");
                    lSource->process(Global::pAndroidApp, lSource);
                }
                // Application is getting destroyed.
                if (Global::pAndroidApp->destroyRequested)
                {
                	LOGI("Exiting event loop");
                    return STATUS_OK;
                }
            }

            // Steps the application.
            if ((mEnabled) && (!mQuit))
            {
                if (m_pActivityHandler->onStep() != STATUS_OK)
                {
                    mQuit = true;
                    ANativeActivity_finish(Global::pAndroidApp->activity);
                }
                if(eglSwapBuffers(mDisplay, mSurface)!=EGL_TRUE)
				{
					LOGE("Error %d swapping buffers.",eglGetError());
					mQuit = true;
					ANativeActivity_finish(Global::pAndroidApp->activity);
				}
            }
        }
        return STATUS_OK;
    }
Пример #4
0
void EventLoop::activate()
{
	if ((!enabled_) && (application_->window != 0))
	{
		sensorPollSource_.id = LOOPER_ID_USER;
		sensorPollSource_.app = application_;
		sensorPollSource_.process = callback_sensor;
		sensorManager_ = ASensorManager_getInstance();
		if (sensorManager_ != 0)
		{
			sensorEventQueue_ =
					ASensorManager_createEventQueue(sensorManager_,
													application_->looper,
													LOOPER_ID_USER,
													0,
													&sensorPollSource_);
			if (sensorEventQueue_ == 0) return;
		}

		quit_ = false;
		enabled_ = true;
		if (activity_->onActivate() != 0)
		{
			quit_ = true;
			deactivate();
			ANativeActivity_finish(application_->activity);
		}
	}
	return;
}
Пример #5
0
bool Engine::checkUIHandledMotion(int iX, int iY, int action)
{
	if (mCurrentMode == MODE_GAMEPLAY)
		return false;

	if (mCurrentMode == MODE_STARTUP_SCREEN)
	{
		int response = getUIClickResponse(iX, iY, action);
		if (response != UI_NO_HIT)
			setAppUIMode(MODE_GAMEPLAY);
	} 
	else if (mCurrentMode == MODE_AUTOPAUSE) 
	{
		int response = getUIClickResponse(iX, iY, action);
		if (response == UI_HIT_LEFT)
			setAppUIMode(MODE_GAMEPLAY);
		else if (response == UI_HIT_RIGHT)
			setAppUIMode(MODE_QUIT_CONFIRM);
	}
	else if (mCurrentMode == MODE_QUIT_CONFIRM) 
	{
		int response = getUIClickResponse(iX, iY, action);
		if (response == UI_HIT_LEFT)
			setAppUIMode(MODE_AUTOPAUSE);
		else if (response == UI_HIT_RIGHT)
			ANativeActivity_finish(mApp->activity);
	}

	return true;
}
Пример #6
0
void gtk_android_exit(struct android_app *state)
{
    int ident;
    int events;
    struct android_poll_source* source;

    // replace onDestroy handler to terminate the process AFTER everything is unloaded
    if (!defaultActivityDestroyHandler)
    {
        defaultActivityDestroyHandler = state->activity->callbacks->onDestroy;
        state->activity->callbacks->onDestroy = onActivityDestroy;
    }

    ANativeActivity_finish(state->activity);

    while (!state->destroyRequested)
    {
        // Read all pending events.
        while ((ident = ALooper_pollAll(0, NULL, &events, (void**)&source)) >= 0)
        {
            // Process this event.
            if (source != NULL)
                source->process(state, source);
        }
    }
}
Пример #7
0
	int destroyView(view_t vid)
	{
		if (is_valid(vid) == false)
			return Failed;

		ANativeActivity_finish(vid->activity);

		return Success;
	}
Пример #8
0
static void terminateMain(ActivityStates* states)
{
    // Protect from concurrent access
    Lock lock(states->mutex);

    // The main thread has finished, we must explicitly ask the activity to finish
    states->mainOver = true;
    ANativeActivity_finish(states->activity);
}
Пример #9
0
void CEventLoop::activate()
{
  if (m_enabled || m_application->window == NULL)
    return;

  m_enabled = true;
  if (m_activityHandler->onActivate() != ActivityOK)
  {
    CXBMCApp::android_printf("CEventLoop: IActivityHandler::onActivate() failed");
    ANativeActivity_finish(m_application->activity);
  }
}
Пример #10
0
    void AndroidEventLoop::Activate()
    {
        // Enables activity only if a window is available.
        if ((!mEnabled) && (Global::pAndroidApp->window != NULL))
        {
            mQuit = false; mEnabled = true;
            if ( InitializeDisplay() != STATUS_OK )
            {
            	mQuit = true;
				Deactivate();
				ANativeActivity_finish(Global::pAndroidApp->activity);
				return;
            }
            if (m_pActivityHandler->onActivate() != STATUS_OK)
            {
                mQuit = true;
                Deactivate();
                ANativeActivity_finish(Global::pAndroidApp->activity);
            }
        }
    }
Пример #11
0
void android_main(android_app* const aApplication)
{
   app_dummy(); // Make sure glue isn't stripped
   Client::TAppPtr app = CreateApplication();
   native = std::make_shared<Client::CNativeAndroid>(aApplication->activity);
   LOG_INFO("MAIN START");
   engine = Client::IEngine::CreateEngine(native, app);

   // Init callbacks for the event loop
   android_poll_source* pSource;
   aApplication->onAppCmd = HandleCommand;
   aApplication->onInputEvent = HandleInput;

   // Main activity loop
   if (!engine->OnCreate(aApplication->savedState)) {
      ANativeActivity_finish(aApplication->activity);
   } else {
      while (!aApplication->destroyRequested)
      {
         // Process all pending events
         int result;
         int fileDescriptors;
         int events;
         android_poll_source* pSource;
         while ((result = ALooper_pollAll(0, &fileDescriptors, &events, (void**)&pSource)) >= 0)
         {
            if (pSource != NULL) { // Lifecycle or input event
               // Launch event app processing via aApplication->onAppCmd or aApplication->onInputEvent
               pSource->process(aApplication, pSource); 
            }

            // ... (check other data like sensors)

            // Check if we are exiting.
            if (aApplication->destroyRequested) {
               break;
            }
         }

         // Input handler is idle - so the app can draw a frame or do some stuff
         if (!aApplication->destroyRequested && native->IsReady()) {
            engine->OnIdle();
            engine->OnDrawFrame();
            native->Swap();
         }
      }
   }
   LOG_INFO("MAIN EXIT");
   engine.reset();
   native.reset();
   NLogging::FinishLogger();
}
Пример #12
0
void android_main(struct android_app* state) {
  app_dummy(); // Make sure glue isn't stripped

  namespace fs = boost::filesystem;

  __android_log_print(
      ANDROID_LOG_INFO,
      "BoostFilesystemExample",
      fs::current_path().c_str()
  );

  ANativeActivity_finish(state->activity);
}
Пример #13
0
void cleanupAndroid()
{

#ifdef GPROF
    errorstream << "Shutting down GPROF profiler" << std::endl;
    setenv("CPUPROFILE", (path_user + DIR_DELIM + "gmon.out").c_str(), 1);
    moncleanup();
#endif

    JavaVM *jvm = app_global->activity->vm;
    if (jvm)
        jvm->DetachCurrentThread();
    ANativeActivity_finish(app_global->activity);
}
Пример #14
0
bool Engine::renderFrame(bool allocateIfNeeded)
{
    if (!mEgl.isReadyToRender(allocateIfNeeded))
        return false;
	if (!initUI())
	{
		LOGW("Could not initialize UI - assets may be missing!");
		ANativeActivity_finish(mApp->activity);
		return false;
	}
	MyGlErrorTest();
	//resizeIfNeeded();
	mOrientation = nv_app_get_display_rotation(mApp);
	if( g_pAndroidTestApp )
	{
		int	l_iOrientation = nv_app_get_display_rotation(mApp);
		// (0=ROTATION_0, 1=ROTATION_90, 2=ROTATION_180, 3=ROTATION_180
		switch( l_iOrientation )
		{
			case 0:
				cGameApp::m_seDeviceDirection = eDD_PORTRAIT;
				break;
			case 1:
				cGameApp::m_seDeviceDirection = eDD_LANDSCAPE_LEFT;
				break;
			case 2:
				cGameApp::m_seDeviceDirection = eDD_UPSIDE_DOWN;
				break;
			case 3:
				cGameApp::m_seDeviceDirection = eDD_LANDSCAPE_LEFT;
				break;
		}
		MyGlErrorTest();
		
		if( g_bLostFocus )
		{
			Sleep(10);
			return true;
		}
		g_pAndroidTestApp->m_svAccelerometer.x = g_fSensorValue[0];
		g_pAndroidTestApp->m_svAccelerometer.y = g_fSensorValue[1];
		g_pAndroidTestApp->m_svAccelerometer.z = g_fSensorValue[2];
		g_pAndroidTestApp->m_sfForce = g_fForce;
		g_pAndroidTestApp->Run();
	}

    mEgl.swap();

    return true;
}
Пример #15
0
		void EventLoop::activate()
		{
			if(!m_enabled && m_application->window != NULL)
			{
				m_quit = false;
				m_enabled = true;

				if(m_activityHandler->onActivate() != STATUS_OK)
				{
					m_quit = true;
					ANativeActivity_finish(m_application->activity);
				}
			}
		}
Пример #16
0
// ==== デストラクタ
ANAS::Activity::~Activity()
{

	Log::i("Activity Destructor", "Start Destruction");

	// アクティビティの終了宣言
	ANativeActivity_finish(pActivity);

	AConfiguration_delete(pConfig);
	
	// Wait "onDestroy" Callback is called.
	DestroyFuture.get();

	Log::i("Activity Destructor", "End Destruction");
}
Пример #17
0
void Activity::run()
{
    androidApp->userData = this;
    androidApp->onAppCmd = handle_cmd;
    androidApp->onInputEvent = handle_input;

    // TODO: restore state

    // Main loop
    while (1)
    {
        int ident;
        int events;
        android_poll_source *source;

        // Process events
        while ((ident = ALooper_pollAll(0, nullptr, &events, (void **) &source)) >= 0)
        {
            if (source != nullptr)
            {
                source->process(androidApp, source);
            }

            //We are exiting
            if (androidApp->destroyRequested != 0)
            {
                LOGGER.logf(LOG_DEBUG, "Destroy requested, exiting...");
                app->destroy();
                window->destroy();

                ANativeActivity_finish(androidApp->activity);
                return;
            }
        }


        if (ready())
        {
            float frameTime = window->getFrameTime();

            app->render(frameTime);

            window->swapBuffers();
        }
    }
}
Пример #18
0
	void EventLoop::run(ActivityHandler* pActivityHandler, InputHandler* pInputHandler)
	{
		Pegas_log_info_loop("EventLoop::run [pActivityHandler: %X, pInputHandler: %X]", pActivityHandler, pInputHandler);

		int32_t lResult;
		int32_t lEvents;
		android_poll_source* lSource;

		app_dummy();

		mActivityHandler = pActivityHandler;
		mInputHandler = pInputHandler;

		Pegas_log_info("Starting event loop");
		while (true)
		{
			while ((lResult = ALooper_pollAll(mEnabled ? 0 : -1,
					NULL, &lEvents, (void**)&lSource)) >= 0)
			{
				if (lSource != NULL)
				{
					Pegas_log_info_loop("Processing an event");
					lSource->process(mApplication, lSource);
				}//if (lSource != NULL)

				if (mApplication->destroyRequested)
				{
					Pegas_log_info("Exiting event loop");
					return;
				}//if (mApplication->destroyRequested)
			}//while ((lResult = ALooper_pollAll(-1, NULL, &lEvents, (void**)&lSource)) >= 0)

			if(mEnabled && !mQuit)
			{
				if(mActivityHandler->onStep() != STATUS_OK)
				{
					Pegas_log_info("Application finish");
					mQuit = true;
					ANativeActivity_finish(mApplication->activity);
				}
			}
		}//while (true)
	}
Пример #19
0
	void EventLoop::activate()
	{
		Pegas_log_info("EventLoop::activate");

		if((!mEnabled) && (mApplication->window != NULL))
		{
			mSensorPollSource.id = LOOPER_ID_USER;
			mSensorPollSource.app = mApplication;
			mSensorPollSource.process = callback_sensor;
			mSensorManager = ASensorManager_getInstance();
			if (mSensorManager != NULL)
			{
				mSensorEventQueue = ASensorManager_createEventQueue(mSensorManager,
						mApplication->looper, LOOPER_ID_USER, NULL, &mSensorPollSource);
				if (mSensorEventQueue == NULL)
				{
					Pegas_log_warning("EventLoop::activate:");
					Pegas_log_warning("ASensorManager_createEventQueue == NULL");

					goto ERROR;
				}
			}
			mQuit = false;
			mEnabled = true;

			if(mActivityHandler->onActivate() != STATUS_OK)
			{
				Pegas_log_warning("EventLoop::activate:");
				Pegas_log_warning("mActivityHandler->onActivate() != STATUS_OK");

				goto ERROR;

			}
		}
		return;

		ERROR:

		Pegas_log_info("Application finish");
		mQuit = true;
		deactivate();
		ANativeActivity_finish(mApplication->activity);
	}
Пример #20
0
void ShellAndroid::on_app_cmd(int32_t cmd)
{
    switch (cmd) {
    case APP_CMD_INIT_WINDOW:
        create_context();
        resize_swapchain(0, 0);
        break;
    case APP_CMD_TERM_WINDOW:
        destroy_context();
        break;
    case APP_CMD_WINDOW_RESIZED:
        resize_swapchain(0, 0);
        break;
    case APP_CMD_STOP:
        ANativeActivity_finish(app_.activity);
        break;
    default:
        break;
    }
}
Пример #21
0
/*
    Force exit and wait for the events to work themselves out
*/
void nv_app_force_quit_no_cleanup(struct android_app* android_app)
{
    ANativeActivity_finish(android_app->activity);

    /* 
        we need to process all of the messages waiting for exit.
        This will cause trouble if the app has its own processor added
        We need the default _only_ here, so we null out the app's handlers (if any)
    */
    android_app->onAppCmd = NULL;
    android_app->onInputEvent = NULL;
    while (nv_app_status_running(android_app))
    {
        int events;
        struct android_poll_source* source;
        if (ALooper_pollAll(-1, NULL, &events, (void**)&source) < 0)
            return;
        if (source != NULL)
            source->process(android_app, source);
    }
}
void AndroidApplication::run()
{
	int ident;
	int events;
	struct android_poll_source* source;

	app_dummy();
	_gameEngine->setCurrentScript("scripts/interfaces/main.lua");
	if (!isIndependent())
		(*_gameEngine)();
	else
	{
		_run = true;
		while (_run)
		{

			while ((ident = ALooper_pollAll(_applicationEnabled ? 0 : -1, NULL, &events, (void**)&source)) >= 0)
			{


				if (source != NULL)
					source->process(_context, source);

				if (_context->destroyRequested != 0)
				{
					_run = false;
					break;
				}
			}

			//if (_context->window != NULL && _applicationEnabled)
			//	stepApplication();

		}
		Log::debug("Exit");
		_gameEngine->stop();
	}
	ANativeActivity_finish(_context->activity);
	::exit(0);
}
Пример #23
0
void CocoDeviceWrapper::StateHandler(android_app* app, int32_t state)
{
	CocoDeviceWrapper* t = (CocoDeviceWrapper*)app->userData;
	switch(state)
	{
		case APP_CMD_INIT_WINDOW:
		{
			t->glwrap = new CocoDeviceOpenGLContext(app->window, t);
			global = window = new HTMLWindow();
			window->innerWidth = t->glwrap->GetScreen().width;
			window->innerHeight = t->glwrap->GetScreen().height;
			window->devicePixelRatio = t->glwrap->GetScreen().pixelRatio;

			window->deviceRotation = 0.0f;
			document = new HTMLDocument();
			HTMLCanvasElement* canvas = document->createElement("canvas");
			gl = (WebGLRenderingContext*)canvas->getContext("webgl");
			gl->canvas->width = window->innerWidth;
			gl->canvas->height = window->innerHeight;
			engine = new GameEngine();
			break;
		}
		case APP_CMD_WINDOW_REDRAW_NEEDED:
			break;
		case APP_CMD_TERM_WINDOW:
			delete t->glwrap;
			t->glwrap = nullptr;
			break;
		case APP_CMD_GAINED_FOCUS:
			break;
		case APP_CMD_LOST_FOCUS:
			break;
		case APP_CMD_STOP:
			ANativeActivity_finish(app->activity);
			break;
		default:
			break;
	}
}
Пример #24
0
		void EventLoop::run(IActivityHandler* activityHandler, IInputHandler*  inputHandler)
		{
			int32_t result;
			int32_t events;
			android_poll_source* source;

			app_dummy();
			m_activityHandler = activityHandler;
			m_inputHandler = inputHandler;

			LOGI("starting event loop");

			while(true)
			{
				while((result = ALooper_pollAll(m_enabled ? 0 : -1, NULL, &events, (void**)&source)) >= 0)
				{
					if(source != NULL)
					{
						LOGI("processing an event");
						source->process(m_application, source);
					}

					if(m_application->destroyRequested)
					{
						LOGI("exiting event loop");
						return;
					}
				}

				if(m_enabled && !m_quit)
				{
					if(m_activityHandler->onStep() != STATUS_OK)
					{
						m_quit = true;
						ANativeActivity_finish(m_application->activity);
					}
				}
			}//while(true)
		}//EventLoop::run()
Пример #25
0
bool Engine::renderFrame(bool allocateIfNeeded)
{
    if (!mEgl.isReadyToRender(allocateIfNeeded))
        return false;

	if (!initUI())
	{
		LOGW("Could not initialize UI - assets may be missing!");
		ANativeActivity_finish(mApp->activity);
		return false;
	}

	resizeIfNeeded();

	// set up viewport
	glViewport((GLint)0, (GLint)0, 
		(GLsizei)(mEgl.getWidth()), (GLsizei)(mEgl.getHeight()));

	// clear buffers as necessary
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// do some game rendering here
	// ...
	
	// start rendering bitfont text overlaid here.
	NVBFTextRenderPrep();

	m_ui->Render();

	// done rendering overlaid text.
	NVBFTextRenderDone();

	if (mForceRender > 0)
		mForceRender--;

    mEgl.swap();

    return true;
}
Пример #26
0
void EventLoop::run(Activity* activity, InputService* input)
{
	// Make sure native glue is not stripped by the linker.
	app_dummy();

	int result;
	int events;
	android_poll_source* source;

	activity_ = activity;
	input_ = input;

	// Global step loop.
	while (true)
	{
		// Event processing loop.
		while ((result = ALooper_pollAll(enabled_ ? 0 : -1, 0, &events,
				reinterpret_cast<void**>(&source))) >= 0)
		{
			if (source != 0)
			{
				source->process(application_, source);
			}
			if (application_->destroyRequested)
			{
				return;
			}
		}
		if ((enabled_) && (!quit_))
		{
			if (activity_->onStep() != 0)
			{
				quit_ = true;
				ANativeActivity_finish(application_->activity);
			}
		}
	}
}
Пример #27
0
void android_main(struct android_app* state)
{	
	LOG_INTRO();
	if (!envInitialized)
	{
		LOGE("ERROR! JAVA DID NOT INITIALIZE FIRST. Exiting!");
		return;
	}

	pthread_mutex_init(&incomingMutex,NULL);
	jniDataVector.clear();	

	Engine mainEngine = Engine();	
	AmplifyRunner myRunner = AmplifyRunner(&mainEngine);
	
	struct ARUserData myData;
	memset(&myData,0,sizeof(ARUserData));

	myData.engine = &mainEngine;
	myData.runner = &myRunner;
	state->userData = &myData;
		
	initializeEngine(state, &mainEngine);	


	bool running = true;
	while (running)
	{
		// 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(mainEngine.animating ? 0 : -1, NULL, &events, (void**) &source)) >= 0)
		{
			// Process this event.
			if (source != NULL)
			{
				source->process(state, source);
			}		

			//Process sensor events
			if (ident == LOOPER_ID_USER)
			{
				mainEngine.sensorCollector->ProcessSensorEvents();
			}

			// Check if we are exiting.
			if (state->destroyRequested != 0)
			{
				LOGI(LOGTAG_MAIN,"Engine thread destroy requested!");
				shutdownEngine(&mainEngine);
				return;
			}			
		}
		
		if (mainEngine.animating == 1)
		{	
			mainEngine.communicator->Update(javaVM);

			//Check for messages in JNI queue
			if ( pthread_mutex_trylock(&incomingMutex) == 0)
			{
				int count = 0;
				while (!jniDataVector.empty())
				{
					count++;
					mainEngine.communicator->AddIncomingMessage(jniDataVector.back());
					jniDataVector.pop_back();
				}
				if (count > 0)
					LOGD(LOGTAG_NETWORKING,"Got %d messages from JNI queue",count);
				pthread_mutex_unlock(&incomingMutex);
			}

			try
			{
				myRunner.DoFrame(&mainEngine);
			}
			catch (exception & e)
			{
				LOGE("Exiting due to caught exception. Message=%s",e.what());
				myRunner.Teardown(&mainEngine);
				shutdownEngine(&mainEngine);
			}
		}

		//Check if state has changed during animation loop
		if (mainEngine.animating == 0)
		{
			LOGW(LOGTAG_MAIN,"Exiting due to internal user command.");
			ANativeActivity_finish(state->activity);
		}
	}
	myRunner.~AmplifyRunner();
	shutdownEngine(&mainEngine);
	//ANativeActivity_finish(state->activity);
}
Пример #28
0
		void AndroidEventLoop::Activate()
		{
			LOGD("AndroidEventLoop::Activate()");

			if ((!m_enabled) && (Global::pAndroidApp->window != NULL))
			{
				bool haveToReload = false;

				m_quit = false;
				m_enabled = true;

				LOGD("CONTEXT BOUND = %d",m_window.IsContextBound());

				if (!m_window.IsContextBound())
				{
					LOGD("CONTEXT NOT BOUND");
					if (!m_window.IsSurfaceCreated())
					{
						LOGD("SURFACE NOT CREATED");
						if (!m_window.IsContextCreated())
						{
							LOGD("CONTEXT NOT CREATED");
							EGLBufferConfigManager *pConfigManager = NULL;
							EGLint format;
							EGLint redSize=0, greenSize=0, blueSize=0, depthSize=16;

							if(m_window.Init() != RETURN_VALUE_OK)
							{
								goto ERROR;
							}

							pConfigManager = new EGLBufferConfigManager(&m_window);
							LOGI("AndroidEventLoop::InitializeDisplay() info: number of configurations = %d",pConfigManager->GetCount());
							pConfigManager->PrintAll();
							pConfigManager->Match(redSize,greenSize,blueSize,depthSize);
							delete pConfigManager;

							LOGI("AndroidEventLoop::InitializeDisplay() info: matched configuration to: (R:%d G:%d B:%d depth:%d)",redSize,greenSize,blueSize,depthSize);

							if(m_window.ChooseConfig(redSize,greenSize,blueSize,depthSize) != RETURN_VALUE_OK)
							{
								goto ERROR;
							}

							if(m_window.GetFormat(format) != RETURN_VALUE_OK)
							{
								goto ERROR;
							}
							ANativeWindow_setBuffersGeometry(Global::pAndroidApp->window, 0, 0, format);

							if(m_window.CreateContext() != RETURN_VALUE_OK)
							{
								goto ERROR;
							}

							haveToReload = true;
						}

						if(m_window.CreateSurface(Global::pAndroidApp->window) != RETURN_VALUE_OK)
						{
							goto ERROR;
						}
					}

					if(m_window.Bind(m_width, m_height) != RETURN_VALUE_OK)
					{
						goto ERROR;
					}

					if(m_width<=0 || m_height<=0)
					{
						LOGE("AndroidEventLoop::InitializeDisplay() invalid width or height (%d x %d)", m_width, m_height);
						goto ERROR;
					}
				}

				// Displays information about OpenGL.
				LOGI("Starting GraphicsService");
				LOGI("Version  : %s", glGetString(GL_VERSION));
				LOGI("Vendor   : %s", glGetString(GL_VENDOR));
				LOGI("Renderer : %s", glGetString(GL_RENDERER));
				LOGI("Viewport : %d x %d", m_width, m_height);

				Graphics::Render::SetScreenSize(m_width,m_height);

				Global::pContext->pInputService->Update();
				Global::pContext->pInputService->Update();

				if(haveToReload)
				{
					if (m_pActivityHandler->onActivate() != RETURN_VALUE_OK)
					{
						m_quit = true;
						Deactivate();
						ANativeActivity_finish(Global::pAndroidApp->activity);
					}
				}

				//return RETURN_VALUE_OK;
			}

			return;
		ERROR:
			m_enabled = false;
			m_quit = true;
			Deactivate();
			ANativeActivity_finish(Global::pAndroidApp->activity);
		}
Пример #29
0
void platformExit()
{
	ANativeActivity_finish(gApp->activity);
}
Пример #30
0
void SfwCloseWindow()
{
	ANativeActivity_finish(state->activity);
	LOGI("Closing window\n");
}