게임을 시작하면 배경에서 리소스를로드하는 동안 화면에로드하는 이미지가 표시됩니다. 간단한 UIImageView 구성 요소를로드하고 장치에 백그라운드에서 무언가를로드하는 사용자 피드백을 제공하기 위해 "회 전자"를 추가하여이 작업을 수행합니다.화면을 게임 전환으로 로딩
이 이미지가 표시되는 동안 내 이미지와 텍스처를 모두로드하고 OpenGL보기를 설정하고 렌더링을 허용합니다. 두 번째 프레임이 렌더링되면 ImageView를 숨기고 OpenGL보기 만 표시하려고합니다. OpenGL 뷰를 렌더링하는 데 시간이 많이 걸리기 때문에 첫 번째 프레임에 OpenGL 뷰를 표시하고 싶지 않습니다.
그러나 모든 리소스를로드하고 DisplayLink를 OpenGL보기로 설정하여 렌더링 루프를 새 스레드에 입력 한 다음로드가 완료되면 OpenGL보기를 표시 할 때 몇 가지 문제가 있습니다. 렌더링 루프가 시작되지 않는 것 같습니다. 여기
는- (void)loadView
{
CGRect mainScreenFrame = [[UIScreen mainScreen] applicationFrame];
// Set up the image view
UIImage *img = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"Startscreen" ofType:@"png"]];
_imageView = [[UIImageView alloc] initWithFrame:mainScreenFrame];
_imageView.image = img;
// Set up the spinner
_spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[_spinner setCenter:CGPointMake(mainScreenFrame.size.height/3.0*1.85, mainScreenFrame.size.width/10.0*7.55)];
[_imageView addSubview:_spinner];
[_spinner startAnimating];
// Show the loading image
self.view = _imageView;
/* Load resources in a new thread -- this shows the spinner during loading */
[NSThread detachNewThreadSelector:@selector(loadGLView) toTarget:self withObject:nil];
}
loadGLView는 다음과 같은 작업을 수행하고, OpenGL을보기를 초기화하고로드 프로세스를 시작하는 내보기 컨트롤러의에는 loadView 방법입니다.
_glView = [[JungleOpenGLView alloc] initWithFrame:mainScreenFrame];
이렇게하면 OpenGL보기에서 DisplayLink를 설정하는 방법입니다. 제 2 프레임이 내가 알림과의 ViewController를 보내 렌더링됩니다
CADisplayLink* displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(setupRender:)];
[displayLink setFrameInterval:2];
[displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
은 내 실수를 발견
self.view = _glView;