Я посмотрел в документации, но я не знаю, как получить идентификатор текстуры.Я на самом деле получаю металлическую текстуру из SDK, и я хотел бы поделиться ею с Ogre Texture.Моя проблема Этот код компилируется, но я не знаю, как получить идентификатор текстуры, чтобы я мог использовать его для Ogre для его рендеринга.Код падает, и он не работает вообще.Я потратил много времени на его структурирование.Надеюсь, что кто-то сэкономит мое время.
Например, теперь происходит сбой в этой строке, однако инициализируется ioSurface
id<MTLTexture> metalTexture = [device newTextureWithDescriptor:textureDescriptor
ioSurface:surface
plane:0];
нераспознанный селектор, отправленный на экземпляр
-
void* texPtr = SixDegreesSDK_GetBackgroundTexture();
if (texPtr != nil) {
id<MTLTexture> mtlTexture = (__bridge id<MTLTexture>)texPtr;
id<MTLDevice> device = [mtlTexture device];
// !!! Not fond of creating a new command queue for every texture
id<MTLCommandQueue> commandQueue = [device newCommandQueue];
id<MTLCommandBuffer> commandBuffer = [commandQueue commandBuffer];
id<MTLBlitCommandEncoder> blitEncoder = [commandBuffer blitCommandEncoder];
NSUInteger textureWidth = mtlTexture.width;
NSUInteger textureHeight = mtlTexture.height;
NSUInteger rowbytes = mtlTexture.bufferBytesPerRow;
MTLPixelFormat pixFormat = mtlTexture.pixelFormat;
CVPixelBufferRef _CVPixelBuffer = NULL;
NSDictionary* cvBufferProperties = @{
(__bridge NSString*)kCVPixelBufferOpenGLCompatibilityKey : @YES,
(__bridge NSString*)kCVPixelBufferMetalCompatibilityKey : @YES,
};
CVReturn cvret = CVPixelBufferCreate(kCFAllocatorDefault,
textureWidth, textureHeight,
kCVPixelFormatType_32RGBA,
(__bridge CFDictionaryRef)cvBufferProperties,
&_CVPixelBuffer);
const IOSurfaceRef surface = CVPixelBufferGetIOSurface(_CVPixelBuffer); // available in ios11 sdk, ios4 runtime
MTLTextureDescriptor* textureDescriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:pixFormat
width:textureWidth
height:textureHeight
mipmapped:NO];
id<MTLTexture> metalTexture = [device newTextureWithDescriptor:textureDescriptor
ioSurface:surface
plane:0];
MTLRegion region = MTLRegionMake2D(0, 0, textureWidth, textureHeight);
[blitEncoder copyFromTexture:mtlTexture
sourceSlice:0
sourceLevel:0
sourceOrigin:region.origin
sourceSize:region.size
toTexture:metalTexture
destinationSlice:0
destinationLevel:0
destinationOrigin:region.origin];
[blitEncoder endEncoding];
[commandBuffer commit];
[self.mEAGLContext texImageIOSurface:surface target:GL_TEXTURE_2D internalFormat:GL_RGBA width:textureWidth height:textureHeight format:GL_RGBA type:GL_UNSIGNED_BYTE plane:0];