Google cardBoard Android API (六):DistortionRenderer

20 篇文章 0 订阅
18 篇文章 0 订阅
public class  DistortionRenderer

Encapsulates the rendering operations to correct lens distortion.

This class is not thread-safe. For performance reasons, exposed public methods in this class are assumed to run in mutual exclusion (e.g. in the same or non-overlapping threads).

Public Constructors

Public Methods

void
void
boolean
void
onFovChanged(HeadMountedDisplay hmd, FieldOfView leftFov, FieldOfView rightFov, float virtualEyeToScreenDistance)
void
setRestoreGLStateEnabled(boolean enabled)
void
setVignetteEnabled(boolean enabled)
void
undistortTexture(int textureId)
void
updateViewports(Viewport leftViewport, Viewport rightViewport)

Inherited Methods

Public Constructors

public DistortionRenderer ()

Public Methods

public void afterDrawFrame ()

Performs distortion correction.

Must be called after drawing a frame to correct its distortion. Note that this method is only allowed to modify the parts of the OpenGL state machine which are backed up and restored using a GLStateBackup object.

public void beforeDrawFrame ()

Performs the required setup to correct distortion.

Must be called before drawing a frame that should be undistorted.

public boolean haveViewportsChanged ()

Checks if the distortion-corrected dimensions of the viewports have changed since the last call to updateViewports.

Returns
  • true if the dimensions have changed, false otherwise.
public void onFovChanged (HeadMountedDisplay hmd, FieldOfView leftFov,FieldOfView rightFov, float virtualEyeToScreenDistance)

To be called when a change in the field of view of any eye happens.

Must be called at least once prior to beforeDrawFrame(). Calling this method betweenbeforeDrawFrame() and afterDrawFrame() calls will raise an IllegalStateException.

This method might recompute the mesh used for distortion correction, but no changes involving GL calls will take place until beforeDrawFrame() is called.

Parameters
hmd The head mounted display.
leftFov The field of view of the left eye.
rightFov The field of view of the right eye.
virtualEyeToScreenDistance The virtual-eye-to-screen distance in meters.
public void setRestoreGLStateEnabled (boolean enabled)

Enables or disables restoration of the application's GL state after postprocessing.

If this flag is enabled, the framework ensures that the GL state at the beginning of the next frame is equivalent to the GL state at the end of the last frame.

Enabled by default.

Parameters
enabled true to enable GL state restoration, false to disable.
public void setVignetteEnabled (boolean enabled)

Enables or disables vignetting around frame edge.

If this flag is enabled, the distortion shader applies a darkening effect to the edges of the visible viewport, simulating vignetting.

Enabled by default.

Parameters
enabled true to enable vignette effect, false to disable.
public void undistortTexture (int textureId)

Undistorts the provided texture by rendering into the current output target.

This method should not be directly called when using the beforeDrawFrame() andafterDrawFrame() methods.

Parameters
textureId Texture to undistort.
public void updateViewports (Viewport leftViewport, Viewport rightViewport)

Updates the eye viewports to their effective dimensions after distortion correction.

Parameters
leftViewport Object updated with the viewport for the left eye.
rightViewport Object updated with the viewport for the right eye.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值