Android的GLSurfaceView没有setZOrderonTop透明背景 [英] Android GLSurfaceView transparent background without setZOrderonTop

查看:4024
本文介绍了Android的GLSurfaceView没有setZOrderonTop透明背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不起,我的英语水平。

Sorry for my English.

我的工作是基于 https://github.com/harism/android_page_curl/

多小时的研究后,我已经找到了一些解决方案,但不是所有的东西我在我的应用程序中的问题。 我曾与一个GLSurfaceView一些麻烦。 我有一个RelativeLayout的,一个GLSurfaceView,并在上面覆盖一个背景。

After many hours of research, I have found a few solutions, but not for all the issues what I have in my application. I've some trouble with a GLSurfaceView. I've got a background with a relativeLayout, a GLSurfaceView, and an overlay on top.

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/background"
    android:layout_width="match_parent"
    android:background="@layout/backgroundrepeat"
    android:layout_height="match_parent">
<com.m2y.foxprez.view.CurlView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/openglview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
<RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/overlay"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
</RelativeLayout>

当我初始化我的看法:

setEGLConfigChooser(8,8,8,8,16,0);
setRenderer(renderer);
getHolder().setFormat(PixelFormat.TRANSLUCENT);
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
setZOrderMediaOverlay(true);

在我的渲染器:

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    gl.glClearColor(0f, 0f, 0f, 0f);
    gl.glShadeModel(GL10.GL_SMOOTH);
    gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
    gl.glHint(GL10.GL_LINE_SMOOTH_HINT, GL10.GL_NICEST);
    gl.glHint(GL10.GL_POLYGON_SMOOTH_HINT, GL10.GL_NICEST);
    gl.glEnable(GL10.GL_LINE_SMOOTH);
    gl.glDisable(GL10.GL_DEPTH_TEST);
    gl.glDisable(GL10.GL_CULL_FACE);
}

public synchronized void onDrawFrame(GL10 gl) {
    gl.glClearColor(0f,0f,0f,0f);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    gl.glLoadIdentity();
}

多的研究之后,我目前阻止这个结果:
与setZOrderOnTop,我有背景,但覆盖的视野下。
与setZOrderMediaOverlay,我已经得到了覆盖,但背景是黑色的。

After multiple research, I am currently blocked with this result:
with setZOrderOnTop, i've got background, but the overlay is under the view.
with setZOrderMediaOverlay, i've got the overlay, but the background is black.

有人能帮助我吗?

推荐答案

这为我工作:

final GLSurfaceView glView = (GLSurfaceView) findViewById(R.id.glView);

glView.setZOrderOnTop(true);
glView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
glView.getHolder().setFormat(PixelFormat.RGBA_8888);
glView.setRenderer(new MyRenderer());
glView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

在这里找到:<一href="http://andrewhague.word$p$pss.com/2011/05/24/how-to-set-a-transparent-glsurfaceview/">http://andrewhague.word$p$pss.com/2011/05/24/how-to-set-a-transparent-glsurfaceview/

这篇关于Android的GLSurfaceView没有setZOrderonTop透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆