OSG for Android (i) loading and displaying of simple geometric objects

Source: Internet
Author: User

  • 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.