RRGLRenderView

Objective-C

@interface RRGLRenderView : UIView

Swift

class RRGLRenderView : UIView

An OpenGL view used to display renderables together with layouts. For all common purposes there are layout classes (RRUserPhotoLayout, RRSceneLayout) that do the job of updating the transformations of all renderables the layout knows. This means that it is not necessary to call addRenderable: when using a a layout.

  • Initializes the RenderView for offscreen rendering. This means that it renders cyclic and rendered content can be obtained by calling renderToImage: only.

    Declaration

    Objective-C

    - (instancetype _Nullable)initForOffscreenRendering;

    Swift

    init?(forOffscreenRendering: ())
  • Defines the syncing intervall between the displays refresh rate and the render loop. Setting it to 1 means that the rendered frames per second equal the displays refresh rate. The default value is 1.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger frameSyncInterval;

    Swift

    var frameSyncInterval: UInt { get set }
  • Defines the multisampling level used during rendering. Increasing this factor leads to significantly higher memory and time consumption. A multisampling level > 2 is normaly not necessary. The default value is 1. Currently the values 1 and 2 are supported.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger multisamplingFactor;

    Swift

    var multisamplingFactor: UInt { get set }
  • This property defines if double-sided rendering is activated. If this property is NO, backfacing triangles of the rendered geometry are not rendered. Setting this flag to YES can impact rendering runtime performance in a negative way.

    Declaration

    Objective-C

    @property (nonatomic) BOOL doubleSidedRendering;

    Swift

    var doubleSidedRendering: Bool { get set }
  • Defines the layout for the renderview. A layout manages the appearance and positioning of different renderables. For all common purposes there exist layout classes (e.g. RRUserPhotoLayout, RRSceneLayout). All renderables managed by the layout are automatically added to the renderview when setting the layout.

    Declaration

    Objective-C

    @property (nonatomic, strong) RRAbstractLayout *_Nullable layout;

    Swift

    var layout: RRAbstractLayout? { get set }
  • This property defines the virtual camera that is used for rendering including all its relevant properties like intrinsics, extrinsics and background color.

    See

    RRCamera

    Declaration

    Objective-C

    @property (nonatomic, strong) RRCamera *_Nonnull camera;

    Swift

    var camera: RRCamera { get set }
  • Render the content of the view to an image with the defined size. It should be considered that the defined targetSize also defines the viewport size for rendering. This is important for layouts that rely on absolute positions/sizes like RRSlotLayout.

    Declaration

    Objective-C

    - (RRImage *_Nonnull)renderToImage:(CGSize)targetSize;

    Swift

    func render(toImage targetSize: CGSize) -> RRImage

    Parameters

    targetSize

    Target size of the image

    Return Value

    An image with the content of the renderview.

  • Force a cleanup of removed renderables. This usualy happens within the next render call. In case the render loop has stopped (view is not attached) cleanup can be forced using this method.

    Declaration

    Objective-C

    - (void)cleanup;

    Swift

    func cleanup()
  • Add a renderable to the rendering engine’s root node.

    Declaration

    Objective-C

    - (BOOL)addRenderable:(RRRenderable *_Nonnull)renderable
         didFailWithError:(NSError *_Nullable *_Nullable)error;

    Swift

    func add(_ renderable: RRRenderable) throws

    Parameters

    renderable

    The renderable instance to add

    error

    An optional pointer to an NSError pointer. When this method fails, it will set an NSError instance to this pointer if provided.

    Return Value

    YES if successful, NO otherwise.

  • Remove a renderable from the rendering engine’s root node.

    Declaration

    Objective-C

    - (void)removeRenderable:(RRRenderable *_Nonnull)renderable;

    Swift

    func remove(_ renderable: RRRenderable)

    Parameters

    renderable

    The renderable instance to remove

  • Remove all renderables from the renderview. This method should never be used for renderables managed by a layout that is currently attached to the renderview!

    Declaration

    Objective-C

    - (void)removeAllRenderables;

    Swift

    func removeAllRenderables()
  • Returns a list of all currently added renderables.

    Declaration

    Objective-C

    - (NSArray<RRRenderable *> *_Nonnull)getAllRenderables;

    Swift

    func getAllRenderables() -> [RRRenderable]

    Return Value

    An array of all renderables added to this RRGLRenderView instance

  • Evaluates all intersections based on colliders attached to renderables given a ray in world coordinates.

    Declaration

    Objective-C

    - (NSArray<RRIntersection *> *_Nonnull)getIntersections:(RRRay *_Nonnull)ray;

    Swift

    func getIntersections(_ ray: RRRay) -> [RRIntersection]

    Parameters

    ray

    The world space ray to intersect with

    Return Value

    An array of all intersections ordered by distance. The first entry corresponds to the closest intersection.

  • Creates a world space ray based on a screen position.

    Declaration

    Objective-C

    - (RRRay *_Nonnull)rayFromViewPosition:(CGPoint)viewPosition;

    Swift

    func ray(fromViewPosition viewPosition: CGPoint) -> RRRay

    Parameters

    viewPosition

    The position in view coordinates.

    Return Value

    A world space ray

OptimalMultisamplingFactor

  • This class function provides an estimation of the optimal multisampling factor that should be used for the current hardware when rendering using RRGLRenderView

    Declaration

    Objective-C

    + (NSUInteger)optimalMultisamplingFactor;

    Swift

    class func optimalMultisamplingFactor() -> UInt