2016-08-15 5 views
0

MTLTextureオブジェクトを作成するために次のコードを使用しました(わかりやすくするため、コードの一部のみが表示されています)。MTLTextureオブジェクトの作成時に認識できないセレクタエラー

int tmpbuf[4096] 
id<MTLDevice> device = MTLCreateSystemDefaultDevice(); 
MTLTextureDescriptor* desc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat: MTLPixelFormatA8Unorm width: 64 height:64 mipmapped: NO]; 
id<MTLTexture> input_texture = [device newTextureWithDescpriptor:desc]; 

//memory for the texture 
MTLOrigin texture_origin = { 0, 0, 0}; 
MTLSize texture_size = {64, 64, 0}; 
MTLRegion texture_region = {texture_origin, texture_size}; 
[input_texture replaceRegion: texture_region mipmaplevel: 0 withBytes: tmpbuf bytesPerRow: 64 ]; 

コード実行している:

id<MTLTexture> input_texture = [device newTextureWithDescpriptor:desc]; 

このコードはコンパイルおよびOS Xシステム上で実行された[MTLIGAccelDevice newTextureWithDescpriptor:]: unrecognized selector sent to instance 0x7fd0a3012200 was reported.というエラーが。なぜこのエラーが起こったのか分かりません。

答えて

1

最初に;を最初の行の末尾に追加してから、3番目のMTLSize引数にNULL以外の値を追加してください。以下のコードスニペットは、OS X 10.11.6マシンで正常にコンパイルされます。

int tmpbuf[4096]; 
    id<MTLDevice> device = MTLCreateSystemDefaultDevice(); 
    MTLTextureDescriptor* desc = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat: MTLPixelFormatA8Unorm width: 64 height:64 mipmapped: NO]; 
    id<MTLTexture> input_texture = [device newTextureWithDescriptor:desc]; 
    MTLOrigin texture_origin = { 0, 0, 0}; 
    MTLSize texture_size = {64, 64, 1}; 
    MTLRegion texture_region = {texture_origin, texture_size}; 
    [input_texture replaceRegion:texture_region mipmapLevel:0 withBytes:tmpbuf bytesPerRow:64]; 
+0

マシンで正常に実行できますか? @Marius – Pony

+0

はい、これらの2つの修正を行い、それに続いてクリーンプロジェクトを行いましたか?今もあなたのもので動くはずです。 – Marius

+0

私は変更を加えましたが、うまくいかなかった。コードが実行されたときに同じエラーが報告されました。 – Pony

関連する問題