Google Cardboard Interfaces


Library Cardboard Api - com.google.vrtoolkit.cardboard
A- CardboardView.Renderer -  Interface for renderers who need to handle all the stereo rendering details by themselves. They are following methods-
  • onDrawFrame(HeadTransform headTransform, Eye leftEye, Eye rightEye) - Requests to draw a new frame. The implementor is assumed to handle all stereoscopic details by itself by making use of the provided head transformation and eye parameters. 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. If an implementor needs to change the current framebuffer, it must be reset back afterwards to the one obtained via glGetIntegerv(GL_FRAMEBUFFER_BINDING, ...) at the beginning of this call. If VR mode is disabled, instead of providing the parameters of two eyes, the left eye will contain monocular rendering parameters and the right eye will be null. No distortion correction will take place in that case. 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 for monocular rendering (ScreenParams.getWidth()/ScreenParams.getHeight() can provide the aspect ratio). This method will not be called if the view is not a fullscreen landscape view.
    Parameters
    headTransform -The head transformation for this frame, independent to any eyes.
    leftEye -Parameters of the left eye, or a single eye if VR mode is disabled. 
    rightEye- Parameters of the right eye, or null if VR mode is disabled.
  • onFinishFrame (Viewport viewport) - onFinishFrame is 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. A viewport object describing the bounds of the full surface is provided, but not set in the GL context. Renderer implementors are responsible of setting the viewport if needed. This method will not be called if the view is not a fullscreen landscape view.
  • Parameters- 
    Viewport - Viewport of the full GL surface. To be set by renderers if needed.
  • 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.
  • onSurfaceChanged (int width, int height) - Called when there is a change in the surface dimensions. Viewport, field of view and projection details are automatically updated. By default, rendering will be disabled if the view is not a fullscreen landscape view. This is determined by comparing the full-view surface dimensions against the screen size expectations defined in ScreenParams. Although discouraged, these expectations can be changed by calling the updateScreenParams method.
  • Parameters - 
    Width -New width of the surface in pixels. 
    Height- New height of the surface in pixels

  • onSurfaceCreated (EGLConfig config) - Called when the surface is created or recreated.
  • Parameters- 
    Config -The EGL configuration used when creating the surface.
B- 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.

  • 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 the setVRModeEnabled method for details. This method will not be called if the view is not a fullscreen landscape view. See onSurfaceChanged for details.
  • Parameters- 
    eye -The eye to render, including the transformations to be applied.
  • 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. A viewport object describing the bounds of the full surface is provided and automatically set in the current GL context. This method will not be called if the view is not a fullscreen landscape view. See onSurfaceChanged for details.
  • Parameters -
    Viewport- Viewport of full GL surface. Automatically set before this call.
  • 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.
  • 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.
  •  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. By default, rendering will be disabled if the view is not a fullscreen landscape view. This is determined by comparing the full-view surface dimensions against the screen size expectations defined in ScreenParams. Although discouraged, these expectations can be changed by calling the updateScreenParams method. 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. 
  • onSurfaceCreated (EGLConfig config) - Called when the surface is created or recreated.
  • Parameters- 
    Config- The EGL configuration used when creating the surface.

Delhi, INDIA

0 comments: