OSDN Git Service

backup
authornyatla <nyatla@users.sourceforge.jp>
Fri, 25 May 2012 16:00:18 +0000 (01:00 +0900)
committernyatla <nyatla@users.sourceforge.jp>
Fri, 25 May 2012 16:00:18 +0000 (01:00 +0900)
NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/CameraCapture.java [deleted file]
NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLBasicSprite.java [new file with mode: 0644]
NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLBitmapSprite.java [new file with mode: 0644]
NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLBox.java [new file with mode: 0644]
NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLHelper.java [new file with mode: 0644]
NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLTextLabel.java [new file with mode: 0644]
NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLView.java [new file with mode: 0644]

diff --git a/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/CameraCapture.java b/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/CameraCapture.java
deleted file mode 100644 (file)
index 0ebdd43..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package jp.androidgroup.nyartoolkit.utils;
-
-public class CameraCapture {
-
-}
diff --git a/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLBasicSprite.java b/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLBasicSprite.java
new file mode 100644 (file)
index 0000000..cfc4aaa
--- /dev/null
@@ -0,0 +1,221 @@
+package jp.androidgroup.nyartoolkit.utils.gl;
+
+import java.nio.FloatBuffer;
+
+import javax.microedition.khronos.opengles.GL10;
+
+import jp.androidgroup.nyartoolkit.sketch.AndSketch;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.opengl.GLU;
+import android.opengl.GLUtils;
+
+
+/**
+ * スプライトテクスチャ。
+ * http://pr0jectze10.blogspot.jp/2011/02/androidopengl.html
+ * を参考にしました。
+ */
+public class AndGLBasicSprite implements AndGLView.IGLViewEventListener
+{
+
+    private int[] _gl_state_holder=new int[10];
+       
+       public int index; // イメージバインドID
+       protected Bitmap _image; // ビットマップイメージ
+       protected Canvas _canvas;
+       private GL10 _ref_gl;
+       private boolean _is_attache;
+       protected AndSketch _context;
+
+       /**
+        * コンストラクタ
+        */
+       protected AndGLBasicSprite(AndGLView i_view)
+       {
+               i_view._evl.add(this);
+               //bitmapの生成
+               this._image =null;
+               this._is_attache=false;
+
+       }
+       /**
+        * ビットマップをセットします。
+        * @param i_bitmap
+        * @param i_is_attache
+        */
+       protected void setBitmap(Bitmap i_bitmap,boolean i_is_attache)
+       {
+               this._image=i_bitmap;
+               this._is_attache=i_is_attache;
+               this._canvas=new Canvas(this._image);
+       }
+       /**
+        * ビットマップをリサイズします。
+        * この関数を実行するには、ビットマップを所有している必要があります。
+        * @param i_w
+        * @param i_h
+        * @throws Exception
+        */
+       protected void resize(int i_w,int i_h) throws Exception
+       {
+               if(!this._is_attache){
+                       throw new Exception("can not resize no attached bitmap");
+               }
+               this._image.recycle();
+               this._image=Bitmap.createBitmap(i_w, i_h, Bitmap.Config.ARGB_8888);
+               this._canvas=new Canvas(this._image);
+       }
+
+       private int _screen_height;
+       private int _screen_width;
+
+       protected void sync()
+       {
+               GL10 gl=this._ref_gl;
+               //GLが未初期化なら何もしない
+               if(gl==null){
+                       return;
+               }
+               // ビットマップイメージの設定
+               gl.glActiveTexture(AndGLHelper.TEXTURE_CHANNEL);
+               gl.glBindTexture(GL10.GL_TEXTURE_2D,this.index);
+               GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0,this._image, 0);
+       }
+       private FloatBuffer _draw_tmp = AndGLHelper.makeFloatBuffer(3*4); //Vertex
+       private FloatBuffer _uv_tmp = AndGLHelper.makeFloatBuffer(2*4);// UVバッファ
+
+
+       /**
+        * This function changes the matrix mode to MODEL_VIEW , and changes some parameter.
+        * @param i_x
+        * @param i_y
+        * @param i_w
+        * @param i_h
+        * @param i_sx
+        * @param i_sy
+        */
+       protected void draw(int i_x, int i_y,int i_w,int i_h,int i_sx,int i_sy)
+       {
+               assert this._image!=null;
+               int[] st=this._gl_state_holder;
+               GL10 gl=this._ref_gl;
+//             {       //<SaveGLstatus>
+//                     gl.glGetIntegerv(GL10.GL_NORMALIZE,st,1);
+//                     gl.glGetIntegerv(GL10.GL_LIGHTING,st,2);
+//                     gl.glGetIntegerv(GL10.GL_VERTEX_ARRAY,st,3);
+//                     gl.glGetIntegerv(GL10.GL_TEXTURE_COORD_ARRAY,st,4);
+//                     gl.glGetIntegerv(GL10.GL_COLOR_ARRAY,st,5);
+//                     //gl.glGetIntegerv(GL10.GL_MATRIX_MODE,st,5); //なんでないんだよ!
+//             }
+               //set GL state
+               gl.glActiveTexture(AndGLHelper.TEXTURE_CHANNEL);
+       gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,GL10.GL_REPEAT);
+       gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,GL10.GL_REPEAT);
+       gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_LINEAR);
+       gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_LINEAR);
+               // ポリゴン色とテクスチャ色の合成方法
+       gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE,GL10.GL_MODULATE);
+               
+               gl.glEnable(GL10.GL_TEXTURE_2D);
+               gl.glDisable(GL10.GL_NORMALIZE);  
+               gl.glDisable(GL10.GL_LIGHTING);                         
+               gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
+               gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
+               gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
+               gl.glBindTexture(GL10.GL_TEXTURE_2D,this.index);        
+
+               
+               //平行投影へ。
+               gl.glMatrixMode(GL10.GL_PROJECTION);
+               gl.glPushMatrix();
+               gl.glLoadIdentity();
+               GLU.gluOrtho2D(gl,0,this._screen_width,0,this._screen_height);//平行投影            
+               gl.glMatrixMode(GL10.GL_MODELVIEW);
+               gl.glPushMatrix();
+               gl.glLoadIdentity();
+
+               // 描画
+               gl.glVertexPointer(3, GL10.GL_FLOAT, 0,getVertices(i_x,i_y,i_w,i_h,this._draw_tmp));
+
+               // UV座標
+               gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, getUv(0,0,i_w,i_h,this._uv_tmp));
+               gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
+               
+               gl.glPopMatrix();
+               gl.glMatrixMode(GL10.GL_PROJECTION);
+               gl.glPopMatrix();
+               
+
+//             {       //Restore
+//                     if(st[1]!=0){gl.glEnable(GL10.GL_NORMALIZE);}
+//                     if(st[2]!=0){gl.glEnable(GL10.GL_LIGHTING);}                    
+//                     if(st[3]==0){gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);}
+//                     if(st[4]==0){gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);}
+//                     if(st[5]!=0){gl.glEnableClientState(GL10.GL_COLOR_ARRAY);}
+//             }
+
+       }
+       private FloatBuffer getUv(int x, int y, int width,int height,FloatBuffer i_buf)
+       {
+               int bw=this._image.getWidth();
+               int bh=this._image.getHeight();
+               float l=((float)x)/((float)bw);
+               float t=((float)y)/((float)bh);
+               float r=((float)(width+x))/((float)bw);
+               float b=((float)(height+y))/((float)bh);
+               float[] vertices = {
+                               l,b,
+                               r,b,
+                               l,t,
+                               r,t};
+               i_buf.put(vertices);
+               i_buf.position(0);
+               return i_buf;           
+       }
+       private static FloatBuffer getVertices(int x, int y, int width,int height,FloatBuffer i_buf)
+       {
+               // 頂点バッファ
+               float[] vertices = {
+                       x, y, 0,
+                       x + width, y, 0,
+                       x, y + height, 0,
+                       x + width, y + height, 0};
+               i_buf.position(0);
+               i_buf.put(vertices);
+               i_buf.position(0);
+               return i_buf;
+       }
+
+       @Override
+       public void onGlChanged(GL10 i_gl, int i_width, int i_height)
+       {
+               if(this._ref_gl!=null){
+                       int[] textures = {this.index};
+                       this._ref_gl.glDeleteTextures(1, textures, 0);
+               }
+               this._ref_gl=i_gl;
+               this._screen_height=i_height;
+               this._screen_width=i_width;
+               
+               // テクスチャIDの設定
+               int[] ids={-1};
+               i_gl.glGenTextures(1, ids, 0);
+               this.index=ids[0];
+
+       //bitmap画あるときはここでsync
+       if(this._image!=null){
+               this.sync();
+       }
+       }
+       @Override
+       public void onGlMayBeStop() {
+               int[] textures = {this.index};
+               this._ref_gl.glDeleteTextures(1, textures, 0);
+               this._image = null;
+               this._image.recycle();
+               this._ref_gl=null;
+               
+       }
+}
+
diff --git a/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLBitmapSprite.java b/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLBitmapSprite.java
new file mode 100644 (file)
index 0000000..c88a01c
--- /dev/null
@@ -0,0 +1,41 @@
+package jp.androidgroup.nyartoolkit.utils.gl;
+
+import android.graphics.Bitmap;
+
+public class AndGLBitmapSprite extends AndGLBasicSprite
+{
+       private int _internal_w;
+       private int _internal_h;
+       public AndGLBitmapSprite(AndGLView i_view,int i_w,int i_h)
+       {
+               super(i_view);
+               //2^nサイズを求める。
+               int s=AndGLHelper.getPow2Size(i_w, i_h);
+               this.setBitmap(Bitmap.createBitmap(s,s, Bitmap.Config.ARGB_8888),true);
+               this._internal_w=i_w;
+               this._internal_h=i_h;
+       }
+       private boolean _locked=false;
+       public Bitmap lockBitmap()
+       {
+               assert this._locked==false;
+               this._locked=true;
+               return this._image;
+       }
+       public void unlockBitmap()
+       {
+               assert this._locked==true;
+               this._locked=false;
+               this.sync();
+       }
+
+       public void draw(int i_dx,int i_dy,int i_w,int i_h,int i_sx,int i_sy)
+       {
+               super.draw(i_dx, i_dy, i_w, i_h, i_sx, i_sy);
+       }
+       public void draw(int i_dx,int i_dy)
+       {
+               super.draw(i_dx, i_dy,this._internal_w, this._internal_h,0,0);
+       }
+}
+
diff --git a/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLBox.java b/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLBox.java
new file mode 100644 (file)
index 0000000..121d17b
--- /dev/null
@@ -0,0 +1,124 @@
+package jp.androidgroup.nyartoolkit.utils.gl;
+
+import java.nio.ByteBuffer;
+import java.nio.FloatBuffer;
+
+import javax.microedition.khronos.opengles.GL10;
+
+
+
+public class AndGLBox  implements AndGLView.IGLViewEventListener
+{
+       private GL10 _ref_gl;
+       
+       private FloatBuffer _vertex;
+       private FloatBuffer _color;
+       private ByteBuffer _index;
+       public AndGLBox(AndGLView i_context,float i_size)
+       {
+               i_context._evl.add(this);
+               float s=i_size/2;
+               float[] square = {
+                               -s, -s, -s, // 0(bottom)
+                               s, -s, -s, // 
+                               s,  s, -s, // 
+                               -s,  s, -s, // 3
+                               -s, -s,  s, // 4(top)
+                               s, -s,  s, // 
+                               s,  s,  s, // 
+                               -s,  s,  s};
+               this._vertex=AndGLHelper.makeFloatBuffer(square);
+               float[] colors = {
+                       0.0f, 0.0f, 0.0f, 1.0f,
+                       1.0f, 0.0f, 0.0f, 1.0f,
+                       1.0f, 1.0f, 0.0f, 1.0f,
+                       0.0f, 1.0f, 0.0f, 1.0f,
+                       0.0f, 0.0f, 1.0f, 1.0f,
+                       1.0f, 0.0f, 1.0f, 1.0f,
+                       1.0f, 1.0f, 1.0f, 1.0f,
+                       0.0f, 1.0f, 1.0f, 1.0f
+               };
+               this._color=AndGLHelper.makeFloatBuffer(colors);
+               // 面設定
+               byte[] indices = {
+                               0, 4, 5,        0, 5, 1,
+                               1, 5, 6,        1, 6, 2, 
+                               2, 6, 7,        2, 7, 3, 
+                               3, 7, 4,        3, 4, 0, 
+                               4, 7, 6,        4, 6, 5, 
+                               3, 0, 1,        3, 1, 2};
+               this._index=AndGLHelper.makeByteBuffer(indices);
+       }
+       /**
+        * This function changes the matrix mode to MODEL_VIEW , and change some parameter.
+        * @param i_x
+        * @param i_y
+        * @param i_z
+        */
+       public void draw(float i_x,float i_y,float i_z)
+       {
+               GL10 gl=this._ref_gl;
+               gl.glEnableClientState(GL10.GL_COLOR_ARRAY);
+               gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
+               gl.glDisable(GL10.GL_TEXTURE_2D);
+               gl.glDisable(GL10.GL_NORMALIZE);  
+               gl.glDisable(GL10.GL_LIGHTING);                         
+               
+               gl.glColorPointer( 4, GL10.GL_FLOAT, 0,this._color);
+               gl.glVertexPointer( 3, GL10.GL_FLOAT, 0,this._vertex);
+               
+               gl.glMatrixMode(GL10.GL_MODELVIEW);
+               gl.glPushMatrix();
+               gl.glTranslatef(i_x,i_y,i_z);
+               gl.glPushMatrix();
+               gl.glDrawElements(GL10.GL_TRIANGLES, 36, GL10.GL_UNSIGNED_BYTE,this._index);
+               gl.glPopMatrix();               
+//             gl.glEnable(GL10.GL_TEXTURE_2D);
+//             gl.glEnable(GL10.GL_NORMALIZE);  
+//             gl.glEnable(GL10.GL_LIGHTING);                  
+//             gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
+//             gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
+       }
+       @Override
+       public void onGlChanged(GL10 i_gl, int i_width, int i_height)
+       {
+               if(this._ref_gl!=null){
+               }
+               this._ref_gl=i_gl;
+       }
+       @Override
+       public void onGlMayBeStop()
+       {
+               this._ref_gl=null;
+       }
+}
+
+/* (non-Javadoc)
+ * @see jp.nyatla.nyartoolkit.android.renderer.DefaultRenderer#draw(javax.microedition.khronos.opengles.GL10)
+ *//*
+@Override
+public void draw(GL10 gl)
+{
+       Log.d(TAG, "draw");
+       gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
+       
+       gl.glMatrixMode(GL10.GL_PROJECTION);
+//     gl.glLoadIdentity();
+       gl.glLoadMatrixf(NyARToolKitWrapper.getInstance().getGlProjectionMatrix(), 0);
+       
+//     gl.glEnable(GL10.GL_CULL_FACE);
+//     gl.glShadeModel(GL10.GL_SMOOTH);
+//     gl.glEnable(GL10.GL_DEPTH_TEST);
+//     gl.glFrontFace(GL10.GL_CW);
+       
+       if (NyARToolKitWrapper.getInstance().queryMarkerVisible()) {
+               Log.d(TAG, "draw visible");
+               gl.glMatrixMode(GL10.GL_MODELVIEW);
+               gl.glLoadIdentity();
+               gl.glLoadMatrixf(NyARToolKitWrapper.getInstance().queryMarkerTransformation(), 0);
+               
+               Log.d(TAG, "draw model");
+               _drawModel(gl);
+       }
+}
+*/
\ No newline at end of file
diff --git a/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLHelper.java b/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLHelper.java
new file mode 100644 (file)
index 0000000..c1a5407
--- /dev/null
@@ -0,0 +1,46 @@
+package jp.androidgroup.nyartoolkit.utils.gl;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.FloatBuffer;
+
+import javax.microedition.khronos.opengles.GL10;
+
+public class AndGLHelper
+{
+       public static final int TEXTURE_CHANNEL=GL10.GL_TEXTURE0;
+       
+    public static FloatBuffer makeFloatBuffer(int i_len)
+    {
+        ByteBuffer bb = ByteBuffer.allocateDirect(i_len*4);
+        bb.order(ByteOrder.nativeOrder());
+        FloatBuffer fb = bb.asFloatBuffer();
+        fb.position(0);
+        return fb;
+    }  
+    public static FloatBuffer makeFloatBuffer(float[] i_arr)
+    {
+        ByteBuffer bb = ByteBuffer.allocateDirect(i_arr.length*4);
+        bb.order(ByteOrder.nativeOrder());
+        FloatBuffer fb = bb.asFloatBuffer();
+        fb.put(i_arr);
+        fb.position(0);
+        return fb;
+    }
+    public static ByteBuffer makeByteBuffer(byte[] i_arr)
+    {
+       ByteBuffer bb = ByteBuffer.allocateDirect(i_arr.length);
+       bb.put(i_arr);
+       bb.position(0);
+       return bb;
+    }    
+    public static int getPow2Size(int i_w,int i_h)
+    {
+       int c=i_w>i_h?i_w:i_h;
+       int s=0x1;
+       while(s<c){
+               s=s<<1;
+       }
+       return s;
+    }
+}
+
diff --git a/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLTextLabel.java b/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLTextLabel.java
new file mode 100644 (file)
index 0000000..dbda508
--- /dev/null
@@ -0,0 +1,69 @@
+package jp.androidgroup.nyartoolkit.utils.gl;
+
+import android.graphics.Bitmap;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Paint.Style;
+import android.graphics.Typeface;
+
+public class AndGLTextLabel extends AndGLBasicSprite
+{
+       protected final Paint fgpaint= new Paint();
+       protected final Paint bgpaint= new Paint();     
+       public AndGLTextLabel(AndGLView i_context)
+       {
+               super(i_context);
+               //2^nサイズを求める。
+               this.setBitmap(Bitmap.createBitmap(32,32, Bitmap.Config.ARGB_8888),true);
+       this.fgpaint.setColor(Color.WHITE);
+       this.fgpaint.setTypeface(Typeface.DEFAULT);
+       this.fgpaint.setTextSize(16.0f);
+       this.fgpaint.setAntiAlias(true);
+       this.bgpaint.setColor(Color.BLACK);
+       this.bgpaint.setStyle(Style.FILL);
+               
+       }
+       private int _last_str_w=1;
+       private int _last_str_h=1;
+       private String _last_str="";
+       public void draw(double i_s,int i_dx,int i_dy)
+       {
+               this.draw(String.valueOf(i_s),i_dx,i_dy);
+       }
+       public void draw(long i_s,int i_dx,int i_dy)
+       {
+               this.draw(String.valueOf(i_s),i_dx,i_dy);
+       }
+       public void draw(String i_s,int i_dx,int i_dy)
+       {
+       Paint.FontMetrics fontMetrics = this.fgpaint.getFontMetrics();
+       //文字列の内容が異なっていたら、テクスチャ/BMPの再構築
+       int lw=this._last_str_w;
+       int lh=this._last_str_h;
+//     if(i_s.compareTo(this._last_str)!=0){
+               //bitmapの再構築を試行
+               int w=(int)Math.ceil(this.fgpaint.measureText(i_s));
+               int h=(int)Math.ceil(Math.abs(fontMetrics.ascent) +Math.abs(fontMetrics.descent) + Math.abs(fontMetrics.leading));
+               //ビットマップのサイズをチェックしてリサイズ
+               int s=AndGLHelper.getPow2Size(w,h);
+               if(s> this._image.getWidth()|| s>this._image.getHeight()){
+                       try {
+                                       this.resize(s,s);
+                               } catch (Exception e) {
+                                       // TODO Auto-generated catch block
+                                       e.printStackTrace();
+                                       this._context._finish(e);
+                               }
+                       lw=lh=s;
+               }
+               this._last_str=i_s;
+//     }
+       //埋め戻し
+               this._canvas.drawRect(0, 0,lw,lh,this.bgpaint);
+               this._canvas.drawText(i_s,0, Math.abs(fontMetrics.ascent),this.fgpaint);
+       this.sync();
+               super.draw(i_dx, i_dy,w,h, 0,0);
+               this._last_str_w=w;
+               this._last_str_h=h;
+       }
+}
diff --git a/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLView.java b/NyARToolKit for Android -Utils/src/jp/androidgroup/nyartoolkit/utils/gl/AndGLView.java
new file mode 100644 (file)
index 0000000..25b0a32
--- /dev/null
@@ -0,0 +1,120 @@
+package jp.androidgroup.nyartoolkit.utils.gl;
+
+import java.util.ArrayList;
+
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL10;
+
+import jp.androidgroup.nyartoolkit.sketch.AndSketch;
+
+import android.graphics.PixelFormat;
+import android.opengl.GLSurfaceView;
+
+public class AndGLView extends GLSurfaceView implements AndSketch.IAndSketchEventListerner
+{
+       public interface IGLFunctionEvent
+       {
+               public void setupGL(GL10 i_gl);
+               public void drawGL(GL10 i_gl);
+       }
+       public interface IGLViewEventListener{
+               public void onGlChanged(GL10 i_gl,int i_width,int i_height);
+               public void onGlMayBeStop();
+               
+       }               
+       public ArrayList<IGLViewEventListener> _evl=new ArrayList<IGLViewEventListener>();
+       
+       public AndGLView(AndSketch i_context)
+       {
+               super(i_context);
+               i_context._evlistener.add(this);                
+               this.setEGLConfigChooser( 8, 8, 8, 8, 16, 0);
+               this.getHolder().setFormat(PixelFormat.TRANSLUCENT);
+               this.setRenderer(new GLRenderer(i_context,this));
+               
+       }
+
+       @Override
+       public void onAcResume()
+       {
+               super.onResume();
+       }
+       @Override
+       public void onAcPause()
+       {
+               super.onPause();
+       }
+
+       @Override
+       public void onAcDestroy() throws Exception
+       {
+       }
+
+       @Override
+       public void onAcStop() throws Exception
+       {
+               for(AndGLView.IGLViewEventListener i : this._evl) {
+                       i.onGlMayBeStop();
+               }               
+       }
+
+
+       
+}
+
+
+
+class GLRenderer implements GLSurfaceView.Renderer
+{
+       private AndGLView _view;
+       private AndSketch _context;
+       private AndGLView.IGLFunctionEvent _function_if;
+       public final static int AST_NULL=0;
+       public final static int AST_SETUP=1;
+       public final static int AST_RUN  =2;
+       private int _ast=AST_NULL;      
+       /**
+        * i_contextが{@link AndGLView.IGLFunctionEvent}を持つ場合
+        * @param i_context
+        * @param i_view
+        */
+       public GLRenderer(AndSketch i_context,AndGLView i_view)
+       {
+               this._view=i_view;
+               this._context=i_context;
+               if(!(i_context instanceof AndGLView.IGLFunctionEvent)){
+                       i_context._finish(new Exception());
+               }
+               this._function_if=(AndGLView.IGLFunctionEvent)i_context;
+       }
+       /**
+        * Logging Tag
+        */     
+       @Override
+       public void onSurfaceCreated(GL10 gl, EGLConfig config)
+       {
+               // Transparent background
+               gl.glClearColor(0.5f, 0.0f, 0.0f, 0.f);
+               gl.glEnable(GL10.GL_DEPTH_TEST);
+               this._ast=AST_SETUP;
+               this._function_if.setupGL(gl);
+               this._ast=AST_RUN;
+               
+       }
+       @Override
+       public void onSurfaceChanged(GL10 gl, int width, int height)
+       {
+               //Surfaceの再構築で、Sketchの所有しているGLサーフェイスの
+               for(AndGLView.IGLViewEventListener i : this._view._evl) {
+                       i.onGlChanged(gl,width,height);
+               }
+               gl.glViewport(0, 0, width, height);
+       }
+       @Override
+       public void onDrawFrame(GL10 gl)
+       {
+               if(this._ast==AST_RUN){
+                       this._function_if.drawGL(gl);
+               }
+       }
+}
\ No newline at end of file