⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glview.java

📁 android 下学习openGL的一个不错demo
💻 JAVA
字号:
/*** * Excerpted from "Hello, Android!", * published by The Pragmatic Bookshelf. * Copyrights apply to this code. It may not be used to create training material,  * courses, books, articles, and the like. Contact us if you are in doubt. * We make no guarantees that this code is fit for any purpose.  * Visit http://www.pragmaticprogrammer.com/titles/eband for more book information.***/
package com.mot.opengl;

import android.content.Context;
import android.util.Log;import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.Toast;
class GLView extends SurfaceView implements SurfaceHolder.Callback {
   
   private final String TAG = "GLView";
   private GLThread glThread;   private int type;
   
   GLView(Context context, int type) {
      super(context);      this.type = type;

      // Install a SurfaceHolder.Callback so we get notified when
      // the underlying surface is created and destroyed
      getHolder().addCallback(this);
      
      // Use hardware acceleration if available
      getHolder().setType(SurfaceHolder.SURFACE_TYPE_NORMAL);
   }

   
   public void surfaceCreated(SurfaceHolder holder) {
      
      // The Surface has been created so start our drawing thread	   Log.e(TAG,"surfaceCreated");
      glThread = new GLThread(this,type);      glThread.setRunning(true);
      glThread.start();
      
   }

   public void surfaceDestroyed(SurfaceHolder holder) {
	   Log.e(TAG,"surfaceDestroyed");
      // Stop our drawing thread. The Surface will be destroyed
      // when we return	   glThread.setRunning(false);
      glThread.requestExitAndWait();
      glThread = null;
      
   }
   

   public void surfaceChanged(SurfaceHolder holder, int format,
         int w, int h) {	   Log.e(TAG,"surfaceChanged");
      // TODO: handle window size changes
   }   public GLThread getThread() {       return glThread;   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -