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];
Borzh
  • 5,069
  • 2
  • 48
  • 64
  • It is very likely that you need to adjust the bounds argument to pixel as opposed to points. On a 2x device that will double the width and height which will fill the whole area as opposed to half of it. – MoDJ May 27 '19 at 22:45
  • Tried this, but now it's showing left upper quarter instead of lower. – Borzh May 27 '19 at 22:54

1 Answers1

1

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

[self setDrawableSize:coreImage.extent.size];
Borzh
  • 5,069
  • 2
  • 48
  • 64