2D 게임을 그릴 때 OpenGL보기 (필요한 투영, 카메라 앵글 등)를 설정하는 데 필요한 최소한의 보일러 플레이트 코드는 무엇입니까?OpenGL 2D View의 최소 상용구 코드는 무엇입니까?
#import <Cocoa/Cocoa.h>
@interface MyView : NSView {
}
@end
= = =
#import "MyView.h"
@implementation MyView
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
return self;
}
- (void)drawRect:(NSRect)rect {
CGContextRef myContext = [[NSGraphicsContext currentContext] graphicsPort];
CGRect frame = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height);
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef url = CFBundleCopyResourceURL(mainBundle, CFSTR("background"), CFSTR("png"), NULL);
CGDataProviderRef provider = CGDataProviderCreateWithURL (url);
CGImageRef image = CGImageCreateWithPNGDataProvider (provider, NULL, true, kCGRenderingIntentDefault);
CGDataProviderRelease (provider);
CGContextDrawImage (myContext, frame, image);
CGImageRelease (image);
//rest of drawing code here...
}
@end
: 예를 들어
는 석영 2D는 (예를 들어, 배경 이미지를로드하고) 사용자 지정보기에 그리기 수행하는 데 필요한 최소는 다음과 보일러 코드의 내용이 Mac에서 Open GL을 사용하는 것과는 달리 iPhone에서 Open GS ES와 다를 수 있습니까?
아, 게임 라이브러리 권장 사항이 아닙니다. cocos2D 외. 나는 OpenGL만을 기반으로하는 대답을 원한다. – Hejazzman