Initialization and Termination of Framework (Java)
Updated: 01/26/2023
Launch
Set logging-related options in the CubismFramework.startUp function.
Without calling this function, the CubismFramework.initialize function to be performed later will not work.
// Java private LAppDelegate() { currentModel = ModelDir.values()[0]; // Set up Cubism SDK framework. cubismOption.logFunction = new LAppPal.PrintLogFunction(); cubismOption.loggingLevel = LAppDefine.cubismLoggingLevel; CubismFramework.cleanUp(); CubismFramework.startUp(cubismOption); } private final CubismFramework.Option cubismOption = new CubismFramework.Option();
The argument registers the level of debugging and the function to be debugged.
During initialization, Cubism Core version information is displayed via debugging functions, as shown below.
[CSM][I]Live2D Cubism Core Version: 04.02.0001 (67239937)
Initialization
After performing the CubismFramework.startUp function, call the CubismFramework.initialize function.
Always call it once before using the Framework in your application.
If it is never called, an error will occur when using the Framework.
If called in succession, the process is ignored.
However, after calling the CubismFramework.dispose function (described below) and exiting, the initialize function can be called again to initialize it.
// Java public void onSurfaceCreated() { // Texture sampling settings GLES20.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); GLES20.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Transparency settings GLES20.glEnable(GLES20.GL_BLEND); GLES20.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Initialize Cubism SDK framework CubismFramework.initialize(); // Initialize shaders. view.initializeShader(); }
Exit
Calling the CubismFramework.dispose function releases the common part resources allocated by the Framework.
Do not call this function before calling the CubismFramework.initialize function.
Typically, it is called when the application is terminated.
As an exception, in an environment with very little memory, you can call the function to release resources when not needed or when you want to completely detach the library, and then call the CubismFramework.initialize function again the next time you want to use it.
// Java public void onStop() { view = null; textureManager = null; LAppLive2DManager.releaseInstance(); CubismFramework.dispose(); }