使用核心显卡的优点

发布于 2024-12-08 06:47:33 字数 268 浏览 2 评论 0原文

我想知道使用 Core Graphics 而不是 Open GL ES 可以获得什么样的优势。我的主要问题是基于此:

  • 创建简单的视图动画。
  • 创建一些视觉上吸引人的对象(例如核心图等图形、动画对象等)。
  • 耗时(学习和实施)
  • 简单 2D 游戏
  • 复杂 2D 游戏
  • 3D 游戏
  • 代码维护以及更清晰的代码。
  • 更轻松地与其他 UI 元素集成。

谢谢。

I would like to know what kind of advantages I get from using Core Graphics instead of Open GL ES. My main question is based on this:

  • Creating simple View animations.
  • Creating some visual appealing objects (Graphics like Core Plot for instance, Animated Objects, etc).
  • Time consuming (both learning and implementing)
  • Simple 2D Games
  • Complex 2D Games
  • 3D Games
  • Code maintenance ad also cleaner code.
  • Easier integration with other UI elements.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤城病女 2024-12-15 06:47:33

首先,我想澄清一些术语。当人们谈论 Core Graphics 时,他们通常指的是 Quartz 2D 绘图,这是一个基于 2-D 矢量的绘图 API。它用于将矢量元素绘制到屏幕或屏幕外上下文(例如 PDF)。 Core Animation 负责动画、布局和一些涉及矩形层和 UI 元素的有限 3D 效果。 OpenGL ES 是一个较低级别的 API,用于与 iOS 设备上的图形硬件进行交互以进行 2D 和 3D 绘图。

您在问题中提出了很多问题,并且对每种情况下最好的判断是主观的,完全取决于开发人员及其特定需求。不过,我可以提供一些一般性提示。

一般来说,您会在 Apple 的文档和工程师的演示文稿中看到的建议是,最好使用解决您的特定问题的最高级别的抽象。

如果您只需要绘制 2D 用户界面,那么您应该尝试的第一件事就是使用 Apple 提供的 UIKit 元素来实现。如果他们不具备您需要的功能,请制作自定义 UIView。如果您正在设计 Mac-iOS 跨平台代码(例如在 Core Plot 框架中),您可能会选择使用自定义 Core Animation CALayers。此过程中的每一步都需要您编写更多代码来处理上一级为您所做的事情。

您可以使用 Core Animation 做数量惊人的事情,并且性能相当不错。这不仅限于 2D 动画,还可以扩展到一些简单的 3D 作品。

OpenGL ES 位于 iOS 设备屏幕上所看到的所有内容的绘制之下,尽管它不会向您公开。因此,它为屏幕渲染提供了最少的抽象,并且需要您编写最多的代码来完成任务。然而,当您想要从 2D 显示中获取最大性能(例如,在动作游戏中)或渲染真正的 3D 对象和环境时,这可能是必要的。

再次,我倾向于建议人们在编写应用程序时从最高的抽象级别开始,只有当他们发现自己无法执行某些操作或性能不符合他们想要达到的规范时才下降。更少的代码行使应用程序更易于编写、调试和维护。

也就是说,有一些围绕抽象 OpenGL ES 开发的优秀框架,例如 cocos2D 和 Unity 3D,这可能会使在许多情况下使用 OpenGL ES 变得更容易。对于每种情况,您都需要评估什么对您的应用程序的特定需求有意义。

First, I want to clear up a little terminology here. When people talk about Core Graphics, they generally are referring to Quartz 2D drawing, which is a 2-D vector-based drawing API. It is used to draw out vector elements either to the screen or to offscreen contexts like PDFs. Core Animation is responsible for animation, layout, and some limited 3-D effects involving rectangular layers and UI elements. OpenGL ES is a lower-level API for talking with the graphics hardware on iOS devices for both 2-D and 3-D drawing.

You're asking a lot in your question, and the judgment on what's best in each scenario is subjective and completely up to the developer and their particular needs. I can, however, provide a few general tips.

In general, a recommendation you'll see in Apple's documentation and in presentations by engineers is that you're best off using the highest level of abstraction that solves your particular problem.

If you need to just draw a 2-D user interface, the first thing you should try is to implement this using Apple's provided UIKit elements. If they don't have the capability you need, make custom UIViews. If you are designing Mac-iOS cross-platform code (like in the Core Plot framework), you might drop down to using custom Core Animation CALayers. Each step down in this process requires you to write more code to handle things that the level above did for you.

You can do a surprising amount of stuff with Core Animation, with pretty good performance. This isn't just limited to 2-D animations, but can extend into some simple 3-D work as well.

OpenGL ES is underneath the drawing of everything you see on the screen for an iOS device, although this is not exposed to you. As such, it provides the least abstraction for onscreen rendering, and requires you to write the most code to get something done. However, it can be necessary in situations where you want to extract the most performance from 2-D display (say, in an action game) or to render true 3-D objects and environments.

Again, I tend to recommend that people start at the highest level of abstraction when writing an application, and only drop down when they find that they cannot do something or the performance is not within the specification they are trying to hit. Fewer lines of code makes applications easier to write, debug, and maintain.

That said, there are some nice frameworks that have developed around abstracting away OpenGL ES, such as cocos2D and Unity 3D, which might make working with OpenGL ES easier in many situations. For each case, you'll need to evaluate what makes sense for the particular needs of your application.

自我难过 2024-12-15 06:47:33

基本上,如果您正在制作游戏,请使用 OpenGL。否则,请使用 CoreGraphics。 CoreGraphics 允许您执行嵌入到普通 UI 代码中的简单操作。

创建简单的视图动画。
-> CG

创建一些视觉上吸引人的对象(例如核心图等图形、动画对象等)。
-> CG

耗时(学习和实施)
-> OpenGL 和 CG 一开始都有点困难。

简单的 2D 游戏
-> OpenGL

复杂 2D 游戏
-> OpenGL

3D 游戏
-> OpenGL

代码维护广告也更干净的代码。
->无关紧要

Basically, use OpenGL if you are making a game. Otherwise, use CoreGraphics. CoreGraphics lets you do simple things embedded in your normal UI code.

Creating simple View animations.
-> CG

Creating some visual appealing objects (Graphics like Core Plot for instance, Animated Objects, etc).
-> CG

Time consuming (both learning and implementing)
-> OpenGL and CG are both kind of tough at first.

Simple 2D Games
-> OpenGL

Complex 2D Games
-> OpenGL

3D Games
-> OpenGL

Code maintenance ad also cleaner code.
-> Irrelevant

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文