| |
|
开发:
C++知识库
Java知识库
JavaScript
Python
PHP知识库
人工智能
区块链
大数据
移动开发
嵌入式
开发工具
数据结构与算法
开发测试
游戏开发
网络协议
系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程 数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁 |
-> 开发工具 -> Using Metal to Draw a View‘s Contents用Metal绘制视图内容 -> 正文阅读 |
|
[开发工具]Using Metal to Draw a View‘s Contents用Metal绘制视图内容 |
Using Metal to Draw a View’s Contents时间:2021-9-25 OverviewIn this sample, you’ll learn the basics of rendering graphics content with Metal.
Prepare a MetalKit View to DrawMetalKit provides a class called [ An
Other properties属性 on
Because you won’t be drawing animated content in this sample, configure the view so that it only draws when the contents need to be updated, such as when the view changes shape:
Delegate Drawing Responsibilities代理绘图职责
设置了视图的代理后,就可以在代理对象中来通知程序绘制窗口。
In this sample, a class called Create a Render Pass Descriptor建立一个渲染通道描述符When you draw, the GPU stores the results into textures, which are blocks of memory that contain image data and are accessible to the GPU. In this sample, the To draw, you create a render pass渲染通道, which is a sequence序列 of rendering commands that draw into a set of textures. When used in a render pass, textures are also called render targets. To create a render pass, you need a render pass descriptor, an instance of [
A render pass descriptor 描述了 the set of render targets, and how they should be processed at the start and end of the render pass. Render passes also define some other aspects面貌 of rendering that are not part of this sample. The view returns a render pass descriptor with a single color attachment附着 that points to one of the view’s textures, and otherwise configures the render pass based on the view’s properties. By default, this means that at the start of the render pass, the render target is erased to a solid color that matches the view’s Because a view’s render pass descriptor might be Create a Render Pass 建立一个渲染通道You create the render pass by encoding it into the command buffer using a [
In this sample, you don’t encode编码 any drawing commands, so the only thing the render pass does is erase the texture. Call the encoder’s
Present a Drawable to the Screen 准备一个“可绘制”到屏幕Drawing to a texture doesn’t automatically display the new contents onscreen. In fact, only some textures can be presented onscreen. In Metal, textures that can be displayed onscreen are managed by drawable objects, and to display the content, you present the drawable. 在Metal中,在屏幕能被显示的贴图由drawable对象管理、显示内容,你(负责)准备这个可绘制。
Call the
This method tells Metal that when the command buffer is scheduled for execution, Metal should coordinate协调配合 with Core Animation to display the texture after rendering completes. When Core Animation presents the texture, it becomes the view’s new contents. In this sample, this means that the erased texture becomes the new background for the view. The change happens alongside与…一起 any other visual updates that Core Animation makes for onscreen user interface elements. Commit the Command Buffer 提交命令缓冲Now that you’ve issued发布了 all the commands for the frame, commit the command buffer.
该程序运行后,仅仅显示一个窗口,如下: 【结束】Using Metal to Draw a View’s Contents用Metal绘制视图内容 |
|
|
上一篇文章 下一篇文章 查看所有文章 |
|
开发:
C++知识库
Java知识库
JavaScript
Python
PHP知识库
人工智能
区块链
大数据
移动开发
嵌入式
开发工具
数据结构与算法
开发测试
游戏开发
网络协议
系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程 数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁 |
360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年12日历 | -2024/12/23 9:08:21- |
|
网站联系: qq:121756557 email:121756557@qq.com IT数码 |
数据统计 |