标签:android style blog http io color os ar java
(2)接着经典的牛出现了:)
3.自带的example太多的代码,这样的代码无论对于NDK的初学者或OSG很不直观,所以本人重写了一个HelloWolrd for osg的例子。例子很简单,就是简单加载一个四边形并附上颜色。
(1)Java 代码:
(1)Java 代码:
package com.example.helloosg;
import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
public class MainActivity extends Activity {
private GLSurfaceView mGLSurfaceView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGLSurfaceView = new GLSurfaceView(this);
mGLSurfaceView.setEGLContextClientVersion(2);
NDKRenderer renderer = new NDKRenderer();
this.mGLSurfaceView.setRenderer(renderer);
this.setContentView(mGLSurfaceView);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
mGLSurfaceView.onResume();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
mGLSurfaceView.onPause();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
osg for android (一) 简单几何物体的加载与显示
标签:android style blog http io color os ar java
原文地址:http://www.cnblogs.com/hacksong/p/4055617.html