Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDLActivity MUST be initiated in the right order. #85

Open
aquawicket opened this issue Jan 27, 2017 · 0 comments
Open

SDLActivity MUST be initiated in the right order. #85

aquawicket opened this issue Jan 27, 2017 · 0 comments

Comments

@aquawicket
Copy link
Owner

aquawicket commented Jan 27, 2017

SDLActivity MUST be initiated in the right order to work.
Let's take a look at DK.java. We can call OpenActivity("SplashActivity"); and it works.
If we try to call CallJavaFunction("OpenActivity","SDLActivity"); inside of DKSDLWindow. The native side will crash. The reason is DKCreate("DKSDLWindow") will happen before SDLActivity get's to call initSDL(mSingleton.getArguments());

We can't call DK.CallCppFunction("DKAndroid_init"); before initSDL(mSingleton.getArguments());
When we call "DKAndroid_init", it will eventually run User.js.. and if User.js has a DKCreate("DKWindow") in it.... BAM!, we just tried to initialize DKSDLWindow before initSDL(mSingleton.getArguments());

So at this point.. SDLActivity is always called first... it does the work in this function.

///////////////////////////
    @Override public void run()
	{
		Log.d("SDLActivity.java", "SDLActivity.run()");
		instance = this; 
		
        initSDL(mSingleton.getArguments());
    	DK.CallCppFunction("DKAndroid_init");
    	DK.CallCppFunction("DKAndroid_onResize,"+Integer.toString(width)+","+Integer.toString(height)+","+Integer.toString(format)+","+Float.toString(refresh));
    	DK.CallCppFunction("DKAndroid_loop");
        Log.v("SDL", "SDL thread terminated");
    }

Notice how initSDL(mSingleton.getArguments()); is called first to create an available context.
Then DK.CallCppFunction("DKAndroid_init"); that will eventually call DKCreate("DKSDLWindow");
DKSDLWindow will successfully join to SDLActivity.

If you didn't get it in the right order, you crash right here

Later we Call "DKAndroid_onResize" and "DKAndroid_loop"

Trying to get C++ to play well with Android Java is key.
We will eventually be asking Android to do what our desktops do, via javascript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant