ZhouWeikuan / cocos2d

cocos2d for android, based on cocos2d-android-0.82, and now ported from cocos2d-iphone 0.99.4. The googlecode address is here: http://code.google.com/p/cocos2d-android-1/ . There are several demos to watch.
610 stars 291 forks source link

CCRenderTexture and emulator #58

Open Trurl101 opened 12 years ago

Trurl101 commented 12 years ago

If I use CCRendertexture I can not test the apps in the android-emulator. The following error appears (i replaced my app-name with XXX):

03-23 10:30:26.118: E/AndroidRuntime(896): FATAL EXCEPTION: GLThread 105 03-23 10:30:26.118: E/AndroidRuntime(896): java.lang.UnsupportedOperationException: glGenRenderbuffersOES 03-23 10:30:26.118: E/AndroidRuntime(896): at com.google.android.gles_jni.GLImpl.glGenRenderbuffersOES(Native Method) 03-23 10:30:26.118: E/AndroidRuntime(896): at org.cocos2d.opengl.CCRenderTexture.(CCRenderTexture.java:69) 03-23 10:30:26.118: E/AndroidRuntime(896): at org.cocos2d.opengl.CCRenderTexture.renderTexture(CCRenderTexture.java:43) 03-23 10:30:26.118: E/AndroidRuntime(896): at XXX.loadSprites(SplashScene.java:43) 03-23 10:30:26.118: E/AndroidRuntime(896): at XXX.SplashScene.onEnter(SplashScene.java:37) 03-23 10:30:26.118: E/AndroidRuntime(896): at org.cocos2d.nodes.CCDirector.setNextScene(CCDirector.java:1238) 03-23 10:30:26.118: E/AndroidRuntime(896): at org.cocos2d.nodes.CCDirector.drawCCScene(CCDirector.java:705) 03-23 10:30:26.118: E/AndroidRuntime(896): at org.cocos2d.nodes.CCDirector.onDrawFrame(CCDirector.java:665) 03-23 10:30:26.118: E/AndroidRuntime(896): at org.cocos2d.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1245) 03-23 10:30:26.118: E/AndroidRuntime(896): at org.cocos2d.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1056)

I think it is a bug in the emulator, but is it possible to use an other openGL-Function to replace glGenRenderbuffersOES?

lluismontero commented 12 years ago

I'm having the same error on my Galaxy Nexus device... Any workaround?

Trurl101 commented 12 years ago

This error appears on real devices too? Which Nexus do you use and which android version? I thought this is only appears on old devices and emulator.

I hope some guy with open-gl knowledge could help

lluismontero commented 12 years ago

Hi, exactly. In some cases happens on my Galaxy Nexus devices, with stock Android 4.0.2

Trurl101 commented 12 years ago

I recognize that you should only build a CCRendertexture in "onenter" or something like that otherwise the app crashes (I think because the openg-gl-scene is not fully initalized before?)

GlGenRenderbuffersOES is in android since API 4 should be no problem. I tested it on Samsung Galaxy S and Galaxy Note and it works fine. I experience only problems in the emulator.

Source: http://docs.go-mono.com/index.aspx?link=M%3AAndroid.Opengl.GLES11Ext.GlGenRenderbuffersOES(System.Int32%2CSystem.Int32%5B%5D%2CSystem.Int32)

lluismontero commented 12 years ago

You are completely right. Creating the CCRendertexture inside onEnter method works well. Thanks!