난 그냥 개인적인 관심에서의 OpenGL 책을 시도하기 시작하고 다음 코드에 부딪쳤다 :는 OpenGL : 슈퍼에 대한 질문/자기
@implementation GLView
+(Class) layerClass {
// This method returns the CALayer class object by default. Subclasses can override this method and return a different layer class as needed. For example, if you use OpenGL ES to do your drawing, you would override this method and return the class object for the CAEAGLLayer class.
return [CAEAGLLayer class];
}
-(id) initWithFrame: (CGRect) frame {
if(self = [super initWithFrame:frame]) {
CAEAGLLayer* eaglLayer = (CAEAGLLayer*) super.layer;
eaglLayer.opaque = YES;
m_context = [[EAGLContext alloc]initWithAPI:kEAGLRenderingAPIOpenGLES1];
if(!m_context || ![EAGLContext setCurrentContext:m_context]) {
[self release];
return nil;
}
}
return 0;
}
내가 길을 따라 모든 단계를 이해하려고 노력하고 내가 두가 이미이 코드 조각의 주요 질문. 여기서 "super.layer"대신 "self.layer"를 사용하면 어떻게됩니까? 현재 클래스 (예 : "GLView")는 UIView에서 상속받습니다. 왜 우리는 슈퍼를 부르며 실제로 어떤 차이를 만들 수 있습니까?
둘째, 나는 왜 여기에 "m_context"대신 "self"를 릴리스해야하는지 이해하지 못합니다. 왜냐하면 메모리가 할당 된 컨텍스트이기 때문입니다. 답장을 보내 주셔서 감사 드리며 바보 같은 질문에 사과드립니다.
내가 코드를 어디서 얻었는지에 관심이 있다면. 확인 : O'reilly iPhone 3D 프로그래밍. www.wowebook.com에서 다운로드 할 수 있습니다. – Trace
이것은 OpenGL과 직접 관련이 없지만 OpenGL을 사용하는 Objective-C 언어와 관련이 있습니다. – Macmade
즉,이 코드를 이해하려면 Objective-C를 배워야합니다. OpenGL은 다른 언어와 함께 사용할 수 있습니다. 가장 좋은 방법은 C 예제를 찾는 것이므로 기본 사항을 이해하고 다른 언어 또는 수퍼 세트에 적용 할 수 있습니다. – Macmade