mirror of https://github.com/axmolengine/axmol.git
issue #1190: Updated HelloLua.java and Cocos2dxGLSurfaceView.java, make HelloLua app support opengles2.0.
This commit is contained in:
parent
8d63e9f1bd
commit
394622f538
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue