Cocos2d-x on android call to OpenGL es api with no current context

Source: Internet
Author: User

I. Problems:

The interface on the Cocos2d-x is spent on returning messages by calling C ++ (Cocos2d-x) functions from the Java (Android) side

Check the Log of Eclipse and see the call to OpenGL es api with no current context (logged once per thread) error.


Ii. solution:

After looking for information to understand this problem is because Android in the startup of the cocos2d-x Thread, the main Thread of the context is not used, but the use of OpenGL Thread,

Therefore, we cannot complete the work in the main Thread. This should be done in the OpenGL Thread of cocos2dx (that is, the work of the called function in Cocos2dx)
It must be completed using OpenGL Thread ︰

Java (Android)-Cocos2dxActivity. java

You should use runOnGLThread to complete the corresponding work in the Activity of Cocos2dxActivty.

Public static native void nativeCallback (String code, String params );
Public static void runNativeCallback (final String code, final String params)
{
Cocos2dxGLSurfaceView. getInstance (). queueEvent (new Runnable (){
@ Override
Public void run (){
NativeCallback (code, params );
}
});
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.