字号:    

Android 3D Demo 分析

1.         The analysis of 3D Demo example:

 

l         The 3D Demo must use a class extends SurfaceView which provides a dedicated drawing surface embedded inside of a view hierarchy, and it must implements SurfaceHolder.Callback to receive information about changes to the surface.

l         Install a SurfaceHolder.Callback so we get notified when the underlying surface is created and destroyed. It happened in the constructor.

l         The life cycle:

                                 i.              surfaceCreated (): The Surface has been created.

                               ii.              surfaceDestroyed (): The Surface will be destroyed.

                              iii.              surfaceChanged (): Surface size or format has changed.

l         Use a thread to control drawing.

l         Initialize the OpenGL object in the thread’s run().

l         Use the OpenGL API to draw 3D graphics in the thread’s loop which goes until asked to quit.

l         Use a class extends Activity to create an application, and use the setContentView() to load the new SurfaceView class.

l         Use a special class to seal the 3D graphics and provide the API to control it.

 

2.         The conclusion of the analysis:

 

l         Use OpenGL API to draw 3D graphics.

l         Use a special class to seal it.

l         Use Android API to initialize the OpenGL object and control the special class.

 

3.         The basal knowledge of making 3D graphics on Android:

 

l         Android API

l         OpenGL API (Maybe not, we could use tools to make the 3D models)

l         Matrix mathematical operation

 

4.         The analysis of relational API

 

l         SurfaceHolder android.view.SurfaceView.getHolder():Return the SurfaceHolder providing access and control over this SurfaceView's underlying surface.

l         void android.view.SurfaceHolder.addCallback(Callback callback): Add a Callback interface for this holder. There can several Callback interfaces associated to a holder.

l         void com.google.android.samples.graphics.GLSurfaceView.surfaceCreated(SurfaceHolder holder): This is called immediately after the surface is first created.
l         void com.google.android.samples.graphics.GLSurfaceView.surfaceDestroyed(SurfaceHolder holder): This is called immediately after the surface is destroyed.
l         void com.google.android.samples.graphics.GLSurfaceView.surfaceChanged(SurfaceHolder holder, int format, int w, int h): This is called immediately after any structural changes (format or size) have been made to the surface.
l         void android.graphics.OpenGLContext.makeCurrent(SurfaceHolder target): Bind this OpenGL ES context to the current thread and attach the specified rendering target to it.
l         GL android.graphics.OpenGLContext.getGL(): Returns the GL interface to this OpenGL ES context.
分类:Android
?次阅读
 2008-03-14 16:51