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;
|
package org.cocos2dx.hellolua;
|
||||||
import org.cocos2dx.lib.Cocos2dxActivity;
|
import org.cocos2dx.lib.Cocos2dxActivity;
|
||||||
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
|
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
|
||||||
|
import org.cocos2dx.lib.Cocos2dxRenderer;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.ConfigurationInfo;
|
||||||
import android.opengl.GLSurfaceView;
|
import android.opengl.GLSurfaceView;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
|
||||||
public class HelloLua extends Cocos2dxActivity{
|
public class HelloLua extends Cocos2dxActivity{
|
||||||
protected void onCreate(Bundle savedInstanceState){
|
protected void onCreate(Bundle savedInstanceState){
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// get the packageName,it's used to set the resource path
|
if (detectOpenGLES20()) {
|
||||||
String packageName = getApplication().getPackageName();
|
// get the packageName,it's used to set the resource path
|
||||||
super.setPackageName(packageName);
|
String packageName = getApplication().getPackageName();
|
||||||
|
super.setPackageName(packageName);
|
||||||
|
|
||||||
mGLView = new LuaGLSurfaceView(this);
|
mGLView = new LuaGLSurfaceView(this);
|
||||||
setContentView(mGLView);
|
setContentView(mGLView);
|
||||||
|
mGLView.setEGLContextClientVersion(2);
|
||||||
|
mGLView.setCocos2dxRenderer(new Cocos2dxRenderer());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log.d("activity", "don't support gles2.0");
|
||||||
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,7 +66,16 @@ public class HelloLua extends Cocos2dxActivity{
|
||||||
mGLView.onResume();
|
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 {
|
static {
|
||||||
System.loadLibrary("cocosdenshion");
|
System.loadLibrary("cocosdenshion");
|
||||||
|
|
|
@ -145,10 +145,13 @@ public class Cocos2dxGLSurfaceView extends GLSurfaceView {
|
||||||
initView();
|
initView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCocos2dxRenderer(Cocos2dxRenderer renderer){
|
||||||
|
mRenderer = renderer;
|
||||||
|
setRenderer(mRenderer);
|
||||||
|
}
|
||||||
|
|
||||||
protected void initView() {
|
protected void initView() {
|
||||||
mRenderer = new Cocos2dxRenderer();
|
|
||||||
setFocusableInTouchMode(true);
|
setFocusableInTouchMode(true);
|
||||||
setRenderer(mRenderer);
|
|
||||||
|
|
||||||
textInputWraper = new TextInputWraper(this);
|
textInputWraper = new TextInputWraper(this);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue