Google cardBoard Android API (十六):两个接口中的CardboardView.StereoRenderer

20 篇文章 0 订阅
18 篇文章 0 订阅

CardboardView.StereoRenderer

public static interface  CardboardView.StereoRenderer

Interface for renderers that delegate all stereoscopic rendering details to the view.

Implementors should simply render a view as they would normally do using the provided transformation parameters. All stereoscopic rendering and distortion correction details are abstracted from the renderer and managed internally by the view.

Public Methods

abstract void
onDrawEye(Eye eye)
abstract void
onFinishFrame(Viewport viewport)
abstract void
onNewFrame(HeadTransform headTransform)
abstract void
abstract void
onSurfaceChanged(int width, int height)
abstract void
onSurfaceCreated(EGLConfig config)

Public Methods

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.

If VR mode is disabled the onDrawEye method will be called only once with parameters to draw a monocular system and distortion correction will not take place. For monocular rendering, the implementor should feel free to ignore the FieldOfView and instead create a perspective matrix with whatever field of view is desired (ScreenParams.getWidth()/ScreenParams.getHeight() can provide the aspect ratio). See thesetVRModeEnabled method for details.

Parameters
eye The eye to render, including the transformations to be applied.
public abstract void onFinishFrame (Viewport viewport)

Called before a frame is finished.

By the time of this call, the frame contents have been already drawn and, if enabled, distortion correction has been applied.

This method allows to perform additional overlay rendering over the frame results. For example, it could be used to draw markers that help users to properly center their device screens in their Cardboards.

Any rendering in this step is relative to the full surface, not to any single eye view. Aviewport object describing the bounds of the full surface is provided and automatically set in the current GL context.

Parameters
viewport Viewport of the full GL surface. Automatically set before this call.
public abstract void onNewFrame (HeadTransform headTransform)

Called when a new frame is about to be drawn.

Allows to differenciate between rendering eye views and different frames. Any per-frame operations not specific to a single view should happen here.

Parameters
headTransform The head transformation in the new frame.
public abstract void onRendererShutdown ()

Called on the renderer thread when the thread is shutting down.

Allows releasing GL resources and performing shutdown operations in the renderer thread. Called only if there was a previous call to onSurfaceCreated.

public abstract void onSurfaceChanged (int width, int height)

Called when there is a change in the surface dimensions.

All values are relative to the size required to render a single eye. If VR mode is enabled this will be the size to render one of the eyes. If VR mode is disabled this will be the size of the full surface.

Viewport, field of view and projection details are automatically updated.

Note that the eye parameters passed to onDrawEye(Eye) are computed under the assumption that the surface dimensions correspond to a fullscreen landscape view. Any other configuration is likely to lead to convergence problems.

Note that for stereo renderers the reported surface size corresponds to a single eye, which has half the width of the full view surface when VR mode is enabled.

Parameters
width New width of the surface for a single eye in pixels.
height New height of the surface for a single eye in pixels.
public abstract void onSurfaceCreated (EGLConfig config)

Called when the surface is created or recreated.

Parameters
config The EGL configuration used when creating the surface.
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值