【发布时间】:2010-03-23 08:43:22
【问题描述】:
我想在普通的 2d ui 布局屏幕上显示一些 3d 对象。
2d ui 屏幕有背景图片,GLSurfaceView 是内容布局的子级。
我在 ApiDemos 示例中尝试了与半透明 GLSurfaceView 相同的技术,
但 GLSurfaceView 会清除所有内容并显示黑色背景。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/my_background_image"
>
...
<android.opengl.GLSurfaceView android:id="@+id/glview"
android:layout_width="fill_parent"
android:layout_height="300px"
android:windowIsTranslucent="true" (i'm not sure this is right)
/>
</LinearLayout>
setContentView(R.layout.main);
...
glview = (GLSurfaceView) findViewById(R.id.glview);
glview.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
glview.getHolder().setFormat(PixelFormat.TRANSLUCENT);
glview.setRenderer(this);
...
gl.glClearColor(0, 0, 0, 0);
...
在这种情况下我可以保留底层背景图片吗?
【问题讨论】:
标签: android opengl-es background transparent