Android 在背景中使用opengl和GestureImageView绘制透明三角形

Android 在背景中使用opengl和GestureImageView绘制透明三角形,android,imageview,Android,Imageview,我需要做一个三角形的框架。而GestureImageView将是该三角形框架的背景。只有实心边框的三角形。这样用户可以放大和缩小三角形内的图像。 有什么帮助吗 我已经做了手势。唯一需要的是三角形透明框架。请帮忙 下面是代码 public class TriangleActivity extends Activity implements android.opengl.GLSurfaceView.Renderer { private static final String TAG = Tr

我需要做一个三角形的框架。而GestureImageView将是该三角形框架的背景。只有实心边框的三角形。这样用户可以放大和缩小三角形内的图像。 有什么帮助吗

我已经做了手势。唯一需要的是三角形透明框架。请帮忙

下面是代码

public class TriangleActivity extends Activity implements android.opengl.GLSurfaceView.Renderer
{
    private static final String TAG = TriangleActivity.class.getSimpleName();

    private static final int Coordinates_In_A_Vertex = 2;
    private static final int Vertices_In_A_Triangle = 3;
    private static final int Bits_In_A_Byte = 8;
    private static final int Bits_In_A_Float = Float.SIZE;
    private static final int Bytes_In_A_Float = Bits_In_A_Float / Bits_In_A_Byte;

    private GLSurfaceView glSurfaceView;
    private FloatBuffer vertices;
    private int width;
    private int height;

    /*
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.triangle);
        glSurfaceView=(GLSurfaceView)findViewById(R.id.surfaceview);
        //glSurfaceView.setEGLConfigChooser(8,8,8,8,16,0);

        glSurfaceView.setRenderer(this);
//      glSurfaceView.getHolder().setFormat(PixelFormat.TRANSPARENT);
//      glSurfaceView.setZOrderOnTop(true);

    }

    /*
     * Called when the activity is resumed.
     * The activity is resumed whenever it is being presented to user (from the background).
     */
    @Override
    public void onResume()
    {
        super.onResume();
        glSurfaceView.onResume();
    }

    /*
     * Called when the activity is paused.
     * The activity is paused whenever it is placed into the background. Various things can cause this (pressing the home button, receiving a phone call, turning off the display, etc.).
     */
    @Override
    public void onPause()
    {
        glSurfaceView.onPause();
        super.onPause();
    }

    @Override
    public void onDrawFrame(GL10 gl)
    {
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
        gl.glColor4f(0.64313725490196f, 0.77647058823529f, 0.22352941176471f, 1);
        gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vertices);
        gl.glDrawArrays(GL10.GL_TRIANGLES, 0, 3);
    }

    @Override
    public void onSurfaceChanged(GL10 gl, int width, int height)
    {
        Log.d(TAG, "Surface changed! width = " + String.valueOf(width) + ", height = " + String.valueOf(height));
    }

    @Override
    public void onSurfaceCreated(GL10 gl, EGLConfig config)
    {
        Log.d(TAG, "Surface Created!");

        width = glSurfaceView.getWidth();
        height = glSurfaceView.getHeight();


        gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GL10.GL_PROJECTION);
        gl.glLoadIdentity();
        gl.glOrthof(0, 1, 0, 1, 1, -1);
        //New Changes
//      gl.glDisable(GL10.GL_DITHER);
//      gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,
//              GL10.GL_FASTEST);

         //gl.glClearColor(1, 1, 1, 1);
//       gl.glEnable(GL10.GL_CULL_FACE);
//       gl.glShadeModel(GL10.GL_SMOOTH);
//       gl.glEnable(GL10.GL_DEPTH_TEST);
         //End

        ByteBuffer byteBuffer = ByteBuffer.allocateDirect(Coordinates_In_A_Vertex * Vertices_In_A_Triangle * Bytes_In_A_Float);
        byteBuffer.order(ByteOrder.nativeOrder());

        vertices = byteBuffer.asFloatBuffer();

        vertices.put(new float[]
                { 
                    0.0f, 0.0f,
                    0.5f, 1.0f,
                    1.0f, 0.0f
                }
        );

        vertices.flip();

        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
    }
}

我有制作三角形的opengl代码。它覆盖了整个AVD。我尝试了使其透明的代码。但是结果变成空白。我需要这样的输出。检查以下链接