Game Development Reference
In-Depth Information
How to do it
To create three-dimensional textures in our app, perform the following steps:
1. Open the
Main.storyboard
file and select the view controller. You will see a
view already added in the view controller.
2. Select the view, open the Identity inspector, and set the view's class to
GLKView
,
as shown in the following screenshot:
3. Open
ViewController.h
, import
GLKit
/
GLKit.h
, and change the
ViewController's parent class from
UIViewController
to
GLKViewCon-
troller
.
GLKViewController
provides the OpenGL render loop in addition
to all native view controller functionalities. The code will be as follows:
#import"GLKit/GLKit.h"
@interface ViewController : GLKViewController
4. Modify
viewController.m
. Add the following code to
viewDidLoad
:
GLKView* view = (GLKView*)self.view;
view.context = [[EAGLContext alloc]
initWithAPI:kEAGLRenderingAPIOpenGLES2];
5. Add the following methods: