This site has been permanently archived. The content on this site was last updated in 2019.
GVRCardboardView Class
Stay organized with collections
Save and categorize content based on your preferences.
Defines a view responsible for rendering graphics in VR mode.
It is designed to work in full screen mode with a landscape orientation. It provides all the transition between mono and stereo (VR) modes. The view switches to fullscreen VR mode when vrModeEnabled
property is set to YES. The developer should ensure UISupportedInterfaceOrientations
key in the application's plist file includes UIInterfaceOrientationPortrait
and UIRequiresFullscreen
is set to YES.
The users of this class provide an implementation of the GVRCardboardViewDelegate
protocol through the delegate
property. The methods in the protocol GVRCardboardViewDelegate
are called to perform the actual rendering of the graphics.
In order to drive the rendering, the users of this class should call the render
method from their render loop. The thread used to call the render
method is refered to as the GL thread. This thread, in turn, calls the method of the GVRCardboardViewDelegate
protocol.
Inherits UIView.
- (instancetype) initWithFrame: |
|
(CGRect) |
NS_DESIGNATED_INITIALIZER |
|
Drives the rendering of the cardboard view.
Call this from your app's render loop.
+ (void) setViewerParamsFromUrl: |
|
(NSURL *) |
url |
withCompletion: |
|
(void(^)(BOOL success, NSError *error)) |
completion |
|
|
| |
Sets the Cardboard viewer parameters from a Url.
This allows programmatically pairing a viewer without having the user go through the pairing flow. Calls the supplied completion handler with the result of pairing and the error if it fails.
Note: The viewer parameters can be set only if no other viewer pairing exists. In other words, this only works if the user hasn't already paired a viewer for the current application.
A valid viewer parameters URI can be generated from this page: https://www.google.com/get/cardboard/viewerprofilegenerator/
Delegate to be notified of cardboard view rendering.
The OpenGL context used for rendering.
Defaults to OpenGL ES3 context, if not set.
The vrModeEnabled property allows switching to and from VR mode.
When set to YES, the cardboard view transitions into a fullscreen view to allow the user to place the device into the Cardboard viewer. When set to NO, it transitions back to pre-VR (mono) mode.
- (BOOL) hidesTransitionView |
|
readwritenonatomicassign |
Flag to hide or show the transition view when in VR mode.
All rights reserved. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-09 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-09 UTC."],[[["\u003cp\u003e\u003ccode\u003eGVRCardboardView\u003c/code\u003e is a UIView subclass that renders graphics in VR mode, switching between mono and stereo (VR) modes using the \u003ccode\u003evrModeEnabled\u003c/code\u003e property.\u003c/p\u003e\n"],["\u003cp\u003eIt uses a delegate (\u003ccode\u003eGVRCardboardViewDelegate\u003c/code\u003e) to perform the actual rendering, triggered by the \u003ccode\u003erender\u003c/code\u003e method called from the developer's render loop.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can programmatically set Cardboard viewer parameters from a URL using the \u003ccode\u003esetViewerParamsFromUrl:withCompletion:\u003c/code\u003e class method.\u003c/p\u003e\n"],["\u003cp\u003eThe view utilizes an OpenGL context for rendering, defaults to OpenGL ES3, and offers properties to control VR mode, delegate, and transition view visibility.\u003c/p\u003e\n"]]],["The `GVRCardboardView` class renders graphics in VR mode, working in fullscreen with landscape orientation. It switches to VR mode when the `vrModeEnabled` property is set to YES. Users implement the `GVRCardboardViewDelegate` protocol for rendering, triggered by the `render` method, which should be called from the application's render loop. The class can also set viewer parameters via `setViewerParamsFromUrl:withCompletion:`. Key properties include `delegate`, `context`, `vrModeEnabled`, and `hidesTransitionView`, with methods to initialize and render.\n"],null,["# GVRCardboardView Class\n\n[Instance Methods](#pub-methods) \\| [Class Methods](#pub-static-methods) \\| [Properties](#properties) \nGVRCardboardView Class Reference \n\nOverview\n--------\n\nDefines a view responsible for rendering graphics in VR mode.\n\nIt is designed to work in full screen mode with a landscape orientation. It provides all the transition between mono and stereo (VR) modes. The view switches to fullscreen VR mode when [vrModeEnabled](/vr/ios/reference/interface_g_v_r_cardboard_view#a9d184749c1056438ed60c94b938c725c \"The vrModeEnabled property allows switching to and from VR mode. \") property is set to YES. The developer should ensure `UISupportedInterfaceOrientations` key in the application's plist file includes `UIInterfaceOrientationPortrait` and `UIRequiresFullscreen` is set to YES.\n\nThe users of this class provide an implementation of the [GVRCardboardViewDelegate](/vr/ios/reference/protocol_g_v_r_cardboard_view_delegate-p \"Defines a delegate protocol for GVRCardboardView. \") protocol through the `delegate` property. The methods in the protocol [GVRCardboardViewDelegate](/vr/ios/reference/protocol_g_v_r_cardboard_view_delegate-p \"Defines a delegate protocol for GVRCardboardView. \") are called to perform the actual rendering of the graphics.\n\nIn order to drive the rendering, the users of this class should call the `render` method from their render loop. The thread used to call the `render` method is refered to as the GL thread. This thread, in turn, calls the method of the [GVRCardboardViewDelegate](/vr/ios/reference/protocol_g_v_r_cardboard_view_delegate-p \"Defines a delegate protocol for GVRCardboardView. \") protocol.\n\nInherits UIView.\n\n|----------------|--------------------------------------------------------------------------------------------------------|\n| Instance Method Summary ----------------------- ||\n| (instancetype) | - [initWithFrame:](/vr/ios/reference/interface_g_v_r_cardboard_view#ab9d997e071c75cc004aba36df6334561) |\n| | Designated initializer. [More...](#ab9d997e071c75cc004aba36df6334561) |\n| ||\n| (void) | - [render](/vr/ios/reference/interface_g_v_r_cardboard_view#a772ea7d00ef72f128416da33d006c4ea) |\n| | Drives the rendering of the cardboard view. [More...](#a772ea7d00ef72f128416da33d006c4ea) |\n| ||\n\n|--------|--------------------------------------------------------------------------------------------------------------------------------|\n| Class Method Summary -------------------- ||\n| (void) | + [setViewerParamsFromUrl:withCompletion:](/vr/ios/reference/interface_g_v_r_cardboard_view#a053783e64400204a31340fe1a1da6303) |\n| | Sets the Cardboard viewer parameters from a Url. [More...](#a053783e64400204a31340fe1a1da6303) |\n| ||\n\n|------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|\n| Property Summary ---------------- ||\n| id\\\u003c [GVRCardboardViewDelegate](/vr/ios/reference/protocol_g_v_r_cardboard_view_delegate-p) \\\u003e | [delegate](/vr/ios/reference/interface_g_v_r_cardboard_view#a91b10566ba33a3c952730ade32ec8c1d) |\n| | Delegate to be notified of cardboard view rendering. [More...](#a91b10566ba33a3c952730ade32ec8c1d) |\n| ||\n| EAGLContext \\* | [context](/vr/ios/reference/interface_g_v_r_cardboard_view#afa901c9714cbe5271f8e487c16aa9afb) |\n| | The OpenGL context used for rendering. [More...](#afa901c9714cbe5271f8e487c16aa9afb) |\n| ||\n| BOOL | [vrModeEnabled](/vr/ios/reference/interface_g_v_r_cardboard_view#a9d184749c1056438ed60c94b938c725c) |\n| | The vrModeEnabled property allows switching to and from VR mode. [More...](#a9d184749c1056438ed60c94b938c725c) |\n| ||\n| BOOL | [hidesTransitionView](/vr/ios/reference/interface_g_v_r_cardboard_view#a00b1533f15dc4ab6ce634549ffee76b4) |\n| | Flag to hide or show the transition view when in VR mode. [More...](#a00b1533f15dc4ab6ce634549ffee76b4) |\n| ||\n\nMethod Detail\n-------------\n\n|---------------------------------|---|----------|-----------------------------|---|\n| - (instancetype) initWithFrame: | | (CGRect) | *NS_DESIGNATED_INITIALIZER* | |\n\nDesignated initializer. \n\n|-----------------|---|---|---|\n| - (void) render | | | |\n\nDrives the rendering of the cardboard view.\n\nCall this from your app's render loop. \n\n|----------------------------------|---|-------------------------------------------|--------------|\n| + (void) setViewerParamsFromUrl: | | (NSURL \\*) | *url* |\n| withCompletion: | | (void(\\^)(BOOL success, NSError \\*error)) | *completion* |\n| | | | |\n\nSets the Cardboard viewer parameters from a Url.\n\nThis allows programmatically pairing a viewer without having the user go through the pairing flow. Calls the supplied completion handler with the result of pairing and the error if it fails.\n\nNote: The viewer parameters can be set only if no other viewer pairing exists. In other words, this only works if the user hasn't already paired a viewer for the current application.\n\nA valid viewer parameters URI can be generated from this page: \u003chttps://www.google.com/get/cardboard/viewerprofilegenerator/\u003e\n\nProperty Detail\n---------------\n\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------|\n| |-----------------------------------------------------------------------------------------------------------| | - (id\\\u003c[GVRCardboardViewDelegate](/vr/ios/reference/protocol_g_v_r_cardboard_view_delegate-p)\\\u003e) delegate | | readwritenonatomicweak |\n\nDelegate to be notified of cardboard view rendering. \n\n|-------------------------------------------------------------|--------------------------|\n| |---------------------------| | - (EAGLContext\\*) context | | readwritenonatomicassign |\n\nThe OpenGL context used for rendering.\n\nDefaults to OpenGL ES3 context, if not set. \n\n|-------------------------------------------------------|--------------------------|\n| |------------------------| | - (BOOL) vrModeEnabled | | readwritenonatomicassign |\n\nThe vrModeEnabled property allows switching to and from VR mode.\n\nWhen set to YES, the cardboard view transitions into a fullscreen view to allow the user to place the device into the Cardboard viewer. When set to NO, it transitions back to pre-VR (mono) mode. \n\n|-------------------------------------------------------------------|--------------------------|\n| |------------------------------| | - (BOOL) hidesTransitionView | | readwritenonatomicassign |\n\nFlag to hide or show the transition view when in VR mode."]]