Opengl1
Android簡介使用方法開發工具開始寫程式視覺化介面視覺元件對話元件核心物件事件處理資料儲存查詢功能影音功能繪圖功能網路功能衛星地圖特殊功能資源管理裝置管理系統核心問題與回答刷機升級常用軟體Eclipse教學錄影訊息相關網站參考文獻最新修改簡體版English |
專案下載:OpenGL1.zip 執行結果![]() 程式範例:OpenGL1.javapackage ccc.android; import android.app.Activity; import android.os.Bundle; import android.content.Context; import android.opengl.GLSurfaceView; import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.opengles.GL10; public class OpenGL1 extends Activity { private GlView mGlView; public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); mGlView = new GlView(this); setContentView(mGlView); } } class GlView extends GLSurfaceView{ private GlRender mGlRender; public GlView(Context context){ super(context); mGlRender = new GlRender(); setRenderer(mGlRender); } } class GlRender implements GLSurfaceView.Renderer{ @Override public void onSurfaceCreated(GL10 gl,EGLConfig config){ gl.glClearColor( 0.0f, 1.0f, 0.0f, 1.0f);// 3D背景色rgba } @Override public void onSurfaceChanged(GL10 gl,int w,int h){ gl.glViewport( 0, 0, w, h ); gl.glMatrixMode( GL10.GL_PROJECTION); gl.glLoadIdentity(); float ratio; ratio = (float)w/h; gl.glFrustumf(-ratio,ratio,-1,1,1,500); } @Override public void onDrawFrame(GL10 gl){ gl.glClear(GL10.GL_COLOR_BUFFER_BIT); gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); } } 參考文獻
|
page revision: 2, last edited: 06 Dec 2010 03:02
Post preview:
Close preview