views:

151

answers:

3

Hi,

Rather new to trying to get OpenGL ES working on the iPhone, but I've created a working demo from an OpenGL template and wanted to add it to another App which is a standard UIViewController App. After searching around it seems that I can't addSubview a CAEAGLLayer to a CALayer aka UIView. How would I go about doing this? Or am I completely wrong in what I'm doing.

Cheers for any help

A: 

I believe you are looking for CALayer's insertSublayer methods or the addSublayer method.

charlie hwang
Pretty sure I've tried that but I'll give it another shot
Rudiger
+1  A: 

Simply use a UIView and add:

+ (Class)layerClass {
    return [CAEAGLLayer class];
}

That UIView is now a CAEAGLLayer, so you can add that view as a subview of another UIView like normal.

redshift5
A: 

What I actually had to do was change in the EAGLView -initWithCoder to -initWithFrame and make the appropriate changes to the method to handle the frame. Once I did that and initialised the view with initWithFrame it worked.

Rudiger