Inherits from UIView
Conforms to NGLCoreTimer
NGLViewDelegate
Declared in NGLView.h

Overview

The NinevehGL view to work with OpenGL. This class must be the first to be initialized when working with NinevehGL.

NGLView is the first class to introduce you in the NinevehGL Engine’s API. It’s reponsible for constructing and managing a view based on UIView class. When you want to use NinevehGL you must create a NGLView instance rather than an UIView. As a subclass of UIView You can use NGLView to build your layout with Interface Builder Tool.

The NGLView class is responsible for creating and managing the OpenGL buffers. At runtime, it is responsible for the render looping and drawing the content on it.

Usually you will create a subclass of NGLView and override its draw method to create your own render. Just as some Cocoa Classes, NGLView offers a delegate API to you work with the way that is most comfortable to you, so you could create an UIViewController conforming with NGLViewDelegate protocol and set the delegate.

Despite NinevehGL was created to work with OpenGL programmable pipeline, it is OpenGL version free, so every new OpenGL release does not change your implementation of NinevehGL. Although by default, NinevehGL starts using the lastest OpenGL version, you can choose what OpenGL version you want and NGLView will make all the necessary changes on its core. You make this change by calling a NinevehGL Global function.

Tasks

Other Methods

  •   paused

    Pauses or resumes the render loop.

    property
  •   delegate

    Indicates the delegation target. The target must implement the NGLViewDelegate protocol. If the target is nil or not implement the protocol, this instance of NGLView will be set as the delegate target.

    property
  •   antialias

    Specifies if this View will use the Multisample Filter provided by Apple. This filter produces more smooth images. The NGLAntialiasNone means no anti-aliasing filter will be placed in. NGLAntialias4X indicates the OpenGL buffer will be recreated and using 4 samples per pixel.

    property
  •   useDepthBuffer

    Specifies if this View will use the Depth Render Buffer. Depth Render Buffer is used to store depth information and it’s necessary to make 3D graphics. The depth buffer is necessary to place the objects in front of each other.

    property
  •   useStencilBuffer

    Specifies if this View will use the Stencil Render Buffer. Stencil Render Buffer is used to store information about how and when a pixel will be updated or not. In simple words, it’s like a mask to defining which pixels can be displayed.

    property
  •   framebuffer

    Gets the current OpenGL framebuffer for this NGLView. It’s useful to work with third party libraries that ask you for the framebuffer reference.

    property
  •   renderbuffer

    Gets the current OpenGL renderbuffer (color) for this NGLView. It’s useful to work with third party libraries that ask you for the renderbuffer reference.

    property
  • – compileCoreEngine

    Compiles the final engine and constructs the OpenGL’s buffers. This method is called automatically when the NGLView is initialized.

  • + updateAllViews

    (Internal only) You should not call this one manually.

  • + emptyAllViews

    (Internal only) You should not call this one manually.

  • + allViews

    (Internal only) You should not set this property manually.

NGLViewInteractive Methods

Properties

antialias

Specifies if this View will use the Multisample Filter provided by Apple. This filter produces more smooth images. The NGLAntialiasNone means no anti-aliasing filter will be placed in. NGLAntialias4X indicates the OpenGL buffer will be recreated and using 4 samples per pixel.

@property (nonatomic) NGLAntialias antialias

Discussion

Specifies if this View will use the Multisample Filter provided by Apple. This filter produces more smooth images. The NGLAntialiasNone means no anti-aliasing filter will be placed in. NGLAntialias4X indicates the OpenGL buffer will be recreated and using 4 samples per pixel.

The default value is NGLAntialiasNone.

Declared In

NGLView.h

delegate

Indicates the delegation target. The target must implement the NGLViewDelegate protocol. If the target is nil or not implement the protocol, this instance of NGLView will be set as the delegate target.

@property (nonatomic, assign) IBOutlet id<> delegate

Discussion

Indicates the delegation target. The target must implement the NGLViewDelegate protocol. If the target is nil or not implement the protocol, this instance of NGLView will be set as the delegate target.

If you are using Interface Builder tool, you can set the delegate as an Outlet to the view.

See Also

Declared In

NGLView.h

framebuffer

Gets the current OpenGL framebuffer for this NGLView. It’s useful to work with third party libraries that ask you for the framebuffer reference.

@property (nonatomic, readonly) unsigned int framebuffer

Discussion

Gets the current OpenGL framebuffer for this NGLView. It’s useful to work with third party libraries that ask you for the framebuffer reference.

Declared In

NGLView.h

paused

Pauses or resumes the render loop.

@property (nonatomic, getter=isPaused) BOOL paused

Discussion

Pauses or resumes the render loop.

Set this property to YES if you want to pause the animation temporary. Set it to NO again to resume the render loop.

While this property is set to YES, no calls to drawView method will happen.

Its default value is NO.

Declared In

NGLView.h

renderbuffer

Gets the current OpenGL renderbuffer (color) for this NGLView. It’s useful to work with third party libraries that ask you for the renderbuffer reference.

@property (nonatomic, readonly) unsigned int renderbuffer

Discussion

Gets the current OpenGL renderbuffer (color) for this NGLView. It’s useful to work with third party libraries that ask you for the renderbuffer reference.

Declared In

NGLView.h

useDepthBuffer

Specifies if this View will use the Depth Render Buffer. Depth Render Buffer is used to store depth information and it’s necessary to make 3D graphics. The depth buffer is necessary to place the objects in front of each other.

@property (nonatomic) BOOL useDepthBuffer

Discussion

Specifies if this View will use the Depth Render Buffer. Depth Render Buffer is used to store depth information and it’s necessary to make 3D graphics. The depth buffer is necessary to place the objects in front of each other.

The default value is YES.

Declared In

NGLView.h

useStencilBuffer

Specifies if this View will use the Stencil Render Buffer. Stencil Render Buffer is used to store information about how and when a pixel will be updated or not. In simple words, it’s like a mask to defining which pixels can be displayed.

@property (nonatomic) BOOL useStencilBuffer

Discussion

Specifies if this View will use the Stencil Render Buffer. Stencil Render Buffer is used to store information about how and when a pixel will be updated or not. In simple words, it’s like a mask to defining which pixels can be displayed.

The default value is NO.

Declared In

NGLView.h

Class Methods

allViews

(Internal only) You should not set this property manually.

+ (NSArray *)allViews

Return Value

A NSArray containing all the views.

Discussion

(Internal only) You should not set this property manually.

Gets all the views currently in the application’s memory.

Declared In

NGLView.h

emptyAllViews

(Internal only) You should not call this one manually.

+ (void)emptyAllViews

Discussion

(Internal only) You should not call this one manually.

This method affects all NGLView in the memory. It’ll clean up all core engines.

Declared In

NGLView.h

updateAllViews

(Internal only) You should not call this one manually.

+ (void)updateAllViews

Discussion

(Internal only) You should not call this one manually.

This method affects all NGLView in the memory. It’ll update all core engines.

Declared In

NGLView.h

Instance Methods

compileCoreEngine

Compiles the final engine and constructs the OpenGL’s buffers. This method is called automatically when the NGLView is initialized.

- (void)compileCoreEngine

Discussion

Compiles the final engine and constructs the OpenGL’s buffers. This method is called automatically when the NGLView is initialized.

This method should be called only after a change in the properties that affect the view’s size, color or layer.

Calling this method will fire the render cycle, that means, if this NGLView was paused, it will be resumed.

Declared In

NGLView.h

drawToData:

Render to an off-screen surface.

- (NSData *)drawToData:(NGLImageFileType)type

Parameters

type

The type of binary format (NGLImageFileTypeJPG or NGLImageFileTypePNG).

Return Value

An autoreleased instance of NSData.

Discussion

Render to an off-screen surface.

This method works like an screen-shot or snapshot. It doesn’t produce new renders, it just draw the last rendered frame with this NGLView and converts it to a NSData. The data inside NSData can be:

  • JPG formated bytes;
  • PNG formated bytes.

To create and save an image file locally you can call writeToFile:atomically: method from the returned NSData.

So, if you have made changes until the last call to drawView method, those changes will not appear in the output of this method.

Declared In

NGLView.h

drawToImage

Render to an off-screen surface.

- (UIImage *)drawToImage

Return Value

An autoreleased instance of UIImage.

Discussion

Render to an off-screen surface.

This method works like an screen-shot or snapshot. It doesn’t produce new renders, it just draw the last rendered frame with this NGLView and converts it to an UIImage.

So, if you have made changes until the last call to drawView method, those changes will not appear in the output of this method.

Declared In

NGLView.h

drawToTexture

Render to an off-screen surface.

- (NGLTexture *)drawToTexture

Return Value

An autoreleased instance of NGLTexture.

Discussion

Render to an off-screen surface.

This method works like an screen-shot or snapshot. It doesn’t produce new renders, it just draw the last rendered frame with this NGLView and converts it to a NGLTexture.

So, if you have made changes until the last call to drawView method, those changes will not appear in the output of this method.

Declared In

NGLView.h