- 1. First, a OSG for Android environment is required.
- (1). The NDK is now very friendly to the NDK, and does not require additional Cygwin to participate, but can refer to
- Android NDK Development Chapter (i): New NDK Environment (Cygwin, super fast)
- (2). OSG for Android compilation, reference OSG for Android Learning: Under Windows compilation (Pro test pass) it is recommended to compile the OpenGL ES2 version.
- 2. Then load the example:osgandroidexamplegles2 that OSG comes with
(1) Click the menu key to load the file path, enter/SDCARD/OSG/COW.OSG (must first create a folder to SDcard OSG and put COW.OSG into the folder inside)
(2) Then the classic Bull appeared:)
3. Example too much code, such code for the NDK beginner or osg very not intuitive, so I rewrote a hellowolrd for OSG example. The simple example is simply loading a quadrilateral and attaching a color.
(1) Java Code:
(1) Java Code: 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; @Overrideprotected 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);} @Overridepublic boolean Oncreateoptionsmenu (Menu menu) {//Inflate the menu; This adds items to the action bar if it is PR Esent.getmenuinflater (). Inflate (R.menu.main, menu); return true;} @Overrideprotected void Onresume () {//TODO auto-generated method Stubsuper.onresume (); Mglsurfaceview.onresume ();} @Overrideprotected void OnPause () {//TODO auto-generated method Stubsuper.onpause (); Mglsurfaceview.onPause ();} @Overridepublic 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 and RoidManifest.xml.int id = item.getitemid (); if (id = = r.id.action_settings) {return true;} return super.onoptionsitemselected (item);}}
OSG for Android (i) loading and displaying of simple geometric objects