Using Metal to Draw a View‘s Contents用Metal绘制视图内容

本文档介绍了如何使用MetalKit框架在iOS和macOS上创建一个视图,并利用Metal来绘制视图的内容。主要涉及MetalKit视图的配置、代理绘制职责、渲染通道描述符的创建以及命令缓冲的提交等步骤。
摘要由CSDN通过智能技术生成

Using Metal to Draw a View’s Contents

时间:2021-9-25
分类:Xcode,Metal开发,
针对人群:初学者,具备初级英语能力
来源:XCode帮助文件
Create a MetalKit view and a render pass to draw the view’s contents.
创建一个MetalKit视图和一个渲染通道来绘制视图内容。

Overview

In this sample, you’ll learn the basics of rendering graphics content with Metal.
You’ll use the MetalKit framework框架 to create a view that uses Metal to draw the contents of the view. Then, you’ll encode commands for a render pass that erases the view to a background color.
在这个例子中,你将学习用Metal渲染图形内容的基本操作。你会用MetalKit框架来创建一个视图,用Metal来绘制视图的内容。然后,你编码命令给一个渲染通道来“擦除”掉视图的背景颜色。

  • Note: MetalKit automates windowing system tasks, loads textures, and handles 3D model data. See [MetalKit][MetalKit] for more information.

Prepare a MetalKit View to Draw

MetalKit provides a class called [MTKView][MTKView], which is a subclass of [NSView][NSView] (in macOS) or [UIView][UIView] (in iOS and tvOS).
MTKView handles many of the details related相关联的细节 to getting the content you draw with Metal onto the screen.

An MTKView needs a reference引用(就是 C++中的指针) to a Metal device object in order to create resources internally, so your first step is to set the view’s device property to an existing [MTLDevice][MTLDevice].

_view.device = MTLCreateSystemDefaultDevice();

Other properties属性 on MTKView allow you to control its behavior行为. To erase the contents of the view to a solid background color, you set its

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值