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

This should fix the white texture bug. #29

Closed dustinanon closed 13 years ago

dustinanon commented 13 years ago

Added some synchronization to force gl updates to actually run on the GL thread...

It turns out that GLResourceHelper.update() doesn't necessarily always run on the GLThread... this code forces the update method to actually run on the GLThread, but is a little hackish.

This might point you guys in the right direction to a fix, but for now it works without any noticeable performance impact.

shashachu commented 13 years ago

Locally, I fixed the problem by replacing the if (inUpdate) check in perform() with if (Thread.currentThread() == CCDirector.sharedDirector().getOpenGLView().getGLThread()). (I had to add an accessor to GLSurfaceView to return the GL thread.

This means if we're running in the GL thread, we'll go ahead and perform the resource load. Otherwise, it will be added to the task queue, to be performed at the next update.

This seems like a less hacky way, in my opinion. But maybe opengenius should decide, as I believe he's the one who built the whole resource loading queue.

ZhouWeikuan commented 13 years ago

Thanks very much:-)

dustinanon commented 13 years ago

I agree that the issue should be decided upon by the architect, but at least the issue is known, and a workaround is provided :)