issue #1190: Updated HelloLua.java and Cocos2dxGLSurfaceView.java, make HelloLua app support opengles2.0.

This commit is contained in:
James Chen 2012-04-26 12:06:51 +08:00
parent 8d63e9f1bd
commit 394622f538
2 changed files with 33 additions and 9 deletions

View File

@ -24,22 +24,34 @@ THE SOFTWARE.
package org.cocos2dx.hellolua;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
import org.cocos2dx.lib.Cocos2dxRenderer;
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
public class HelloLua extends Cocos2dxActivity{
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
// get the packageName,it's used to set the resource path
String packageName = getApplication().getPackageName();
super.setPackageName(packageName);
if (detectOpenGLES20()) {
// get the packageName,it's used to set the resource path
String packageName = getApplication().getPackageName();
super.setPackageName(packageName);
mGLView = new LuaGLSurfaceView(this);
setContentView(mGLView);
mGLView = new LuaGLSurfaceView(this);
setContentView(mGLView);
mGLView.setEGLContextClientVersion(2);
mGLView.setCocos2dxRenderer(new Cocos2dxRenderer());
}
else {
Log.d("activity", "don't support gles2.0");
finish();
}
}
@Override
@ -54,7 +66,16 @@ public class HelloLua extends Cocos2dxActivity{
mGLView.onResume();
}
private GLSurfaceView mGLView;
private boolean detectOpenGLES20()
{
ActivityManager am =
(ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
ConfigurationInfo info = am.getDeviceConfigurationInfo();
return (info.reqGlEsVersion >= 0x20000);
}
private LuaGLSurfaceView mGLView;
static {
System.loadLibrary("cocosdenshion");

View File

@ -144,11 +144,14 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
super(context, attrs);
initView();
}
public void setCocos2dxRenderer(Cocos2dxRenderer renderer){
mRenderer = renderer;
setRenderer(mRenderer);
}
protected void initView() {
mRenderer = new Cocos2dxRenderer();
protected void initView() {
setFocusableInTouchMode(true);
setRenderer(mRenderer);
textInputWraper = new TextInputWraper(this);