1
我正在研究图形框架的可可包装。在NSWindow中绘图
为了最后得出的东西,我这样做:
- (void)drawRect:(NSRect)rect
{
CGContextRef ctx = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
CGContextDrawImage(ctx, NSRectToCGRect(rect), image);
}
的NSView
一个子类中。
现在,我看着像古薮,Irrlicht的,等其他框架,我看到他们总是在做复杂NSOpenGL
东西,如:
// Settings, depending on fullscreen or not
NSOpenGLPixelFormatAttribute windowedAttrs[] =
{
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAScreenMask,
(NSOpenGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID()),
NSOpenGLPFADepthSize,
(NSOpenGLPixelFormatAttribute)16,
(NSOpenGLPixelFormatAttribute)0
};
NSOpenGLPixelFormatAttribute fullscreenAttrs[] =
{
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAScreenMask,
(NSOpenGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID()),
NSOpenGLPFAFullScreen,
NSOpenGLPFADepthSize,
(NSOpenGLPixelFormatAttribute)16,
(NSOpenGLPixelFormatAttribute)0
};
NSOpenGLPixelFormatAttribute* attrs = fullscreen ? fullscreenAttrs : windowedAttrs;
// Create pixel format and OpenGL context
ObjRef<NSOpenGLPixelFormat> fmt(
[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]);
::context = [[NSOpenGLContext alloc] initWithFormat: fmt.obj() shareContext:nil];
他们为什么所有的问题?我的“简单”方式好吗?
如果它可以工作,那没关系,_enn in meinem Plutarch lese vongroßenMenschen_! – ryyst 2011-05-01 19:28:24