我想为屏幕外渲染创建一个NSOpenGLPixelBuffer.现在,我甚至无法初始化它.这是代码:
NSOpenGLPixelFormatAttribute attribs[] = {
NSOpenGLPFAPixelBuffer,
NSOpenGLPFANoRecovery,
NSOpenGLPFAAccelerated,
NSOpenGLPFADepthSize, 24,
(NSOpenGLPixelFormatAttribute) 0
};
NSOpenGLPixelFormat* format = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attribs] autorelease];
NSOpenGLPixelBuffer* pixBuf = [[NSOpenGLPixelBuffer alloc]
initWithTextureTarget: GL_TEXTURE_2D
textureInternalFormat: GL_RGBA
textureMaxMipMapLevel: 0
pixelsWide: 32
pixelsHigh: 32];
NSLog(@"pbuf address: %p", pixBuf);
Run Code Online (Sandbox Code Playgroud)
我试图摆弄像素格式和宽度,高度,但似乎没有任何作用.我一再为pixBuf得到零.我在MacOS 10.13上使用Xcode 9.它说NSOpenGLPixelBuffer已被弃用,但它应该仍然有效,对吗?
我试图使用atof并接收模糊输出将字符数组转换为c中的double.
printf("%lf\n",atof("5"));
Run Code Online (Sandbox Code Playgroud)
版画
262144.000000
Run Code Online (Sandbox Code Playgroud)
我惊呆了.有人可以解释我哪里出错了吗?
我无法运行这段将pid写入文件的代码。
NSString *text = [NSString stringWithFormat:@"%d\n", getpid()];
NSError *error = nil;
if (![text writeToFile:@"/tmp/Frontend.pid" atomically:YES encoding:NSUTF8StringEncoding error:&error]) {
NSLog(@"Cannot write PID file %@: %@", @"/tmp/Frontend.pid", error);
return NO;
}
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误。
2017-11-13 20:19:18.742171 + 0530 TestThread [7648:273326]无法写入PID文件/tmp/Frontend.pid:错误域= NSCocoaErrorDomain代码= 513“您无权保存文件” Frontend。 pid”放在“ tmp”文件夹中。” UserInfo = {NSFilePath = / tmp / Frontend.pid,NSUnderlyingError = 0x6040000432a0 {Error Domain = NSPOSIXErrorDomain Code = 1“不允许操作”}}
我已将目录的权限更改为777,但仍然没有足够的权限。请帮忙。