在“ViewController *”类型的对象上找不到属性“层”,其中 ViewController 的类型为 GLKView,而且我正在我的 opengl 项目中导入以下文件
QuartzCore/QuartzCore.h
OpenGLES/ES2/gl.h
OpenGLES/ES2/gext.h
ViewController.h 的代码
@interface ViewController : GLKViewController
{
CAEAGLLayer* eaglLayer;
}
@结尾
视图控制器.m
@interface ViewController ()
@property (nonatomic, strong) EAGLContext *context;
@property (nonatomic, strong) GLKBaseEffect *baseEffect;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES2];
GLKView *view = (GLKView *) self.view;
view.context = self.context;
[EAGLContext setCurrentContext:self.context];
}
+ (Class)layerClass
{
return [CAEAGLLayer class];
}
- (void)createLayer
{
eaglLayer = (CAEAGLLayer *) self.layer;
eaglLayer.opaque = YES;
}
请告诉我我做错了什么?