用于水渲染的谷歌VR帧缓冲

问题描述 投票:0回答:1

在此处输入代码

我正在尝试使用最后一个谷歌GVR sdk在Android上的GvrView.StereoRenderer上实现水渲染。为此,我需要将反射和折射图像检索到帧缓冲区中。

所以我尝试了不同的méthode来获得结果。

1)我不能将任何这些中的水帧缓冲区绑定到方法“onNewFrame”和“onDrawEye”。渲染时我总是得到黑屏(我已经测试了没有GVR的帧缓冲器并且它运行良好)。所以我试图使用GLES20.glGetIntegerv(GLES20.GL_FRAMEBUFFER_BINDING,...)来切换帧缓冲区,但是我收到了这个错误:

JNI DETECTED ERROR IN APPLICATION: obj == null
 in call to GetIntField
 from void android.opengl.GLES20.glGetIntegerv(int, java.nio.IntBuffer)

"GLThread 46371" prio=5 tid=20 Runnable
| group="main" sCount=0 dsCount=0 obj=0x12c66640 self=0x7b690b9600
| sysTid=4963 nice=0 cgrp=default sched=0/0 handle=0x7b65bff450
| state=R schedstat=( 10115620317 57382805 1227 ) utm=923 stm=88 core=5 HZ=100
| stack=0x7b65afd000-0x7b65aff000 stackSize=1037KB
| held mutexes= "mutator lock"(shared held)
at android.opengl.GLES20.glGetIntegerv(Native method)
at com.example.user.googleVR.MyGLRenderer.onFinishFrame(MyGLRenderer.java:608)

enter code here

2)所以我试图在“onFinishFrame”方法中测试水帧缓冲区。可以执行帧缓冲区,但渲染错误的原因有很多:

  - I need to reorganize the drawing for the farest mesh to the closer mesh.
    if i render my skybox last i only see the sky. 
    So i need to draws it first and after the other mesh. 
    But at the end i got the transparency color on preview drawed mesh. 
    Even enabling GL_DEPTH_TEST and disabling GL_BLEND do not change nothing.  

enter code here

所以我想知道在stréoréoscopic渲染“onNewFrame”和“onDrawEye”期间是否可以使用其他帧缓冲区。我怎么能设法做到这一点,因为谷歌vr文档说它可以做到:

public abstract void onDrawEye (Eye eye)

Requests to draw the contents from the point of view of an eye.

If distortion correction is enabled the GL context will be set to draw into a framebuffer
backed by a texture at the time of this call, 
so if an implementor need to change the framebuffer for some rendering stage 
then the implementor must reset the framebuffer to the one obtained via 
glGetIntegerv(GL_FRAMEBUFFER_BINDING, ...) afterwards.
android google-vr
1个回答
0
投票

在此处输入代码

我找到了解决方案。问题来自使用GLES20.glGetIntegerv。事实上,GLES20中有两个GLES20.glGetIntegerv。

public static native void glGetIntegerv(
    int pname,
    java.nio.IntBuffer params
);

AND

public static native void glGetIntegerv(
    int pname,
    int[] params,
    int offset
);
enter code here

所以,如果我使用第二个glGetIntegerv一切正常。然后可以在onDrawEye(Eye eye)中使用帧缓冲区。

所以!对不起该帖子。但是对另一个开发者来说,了解它可能会有所帮助。

问候

© www.soinside.com 2019 - 2024. All rights reserved.