2

I don't understand why MTKView doesn't use device's scale.

I have a retina device: 2x scale, MTKView.bounds of 400x200, and CIImage size of 800x400, but it draws only left bottom quarter of the image.

Strangely drawableSize returns bounds size (400x200).

Here's the code I use:

id<MTLTexture> targetTexture = self.currentDrawable.texture;
id<MTLCommandBuffer> commandBuffer = [commandQueue commandBuffer];

[ctx render:coreImage toMTLTexture:targetTexture commandBuffer:commandBuffer bounds:self.bounds colorSpace:colorSpace];

[commandBuffer presentDrawable:self.currentDrawable];
[commandBuffer commit];
4

1 回答 1

1

Found it. I just need to use MTKView's method setDrawableSize to the scaled size I want:

[self setDrawableSize:coreImage.extent.size];
于 2019-05-28T03:40:51.377 回答