使用现有的 C++ iPhone 上的引擎

发布于 2024-07-30 20:15:18 字数 381 浏览 3 评论 0原文

我有 C/C++ 背景,最近接触过 flash。 无论如何,我在 AS3 中编写了一个 2D 引擎,并希望让它在 iPhone 上运行。 首先,我将其转换为 C++。 作为测试,我编写了一个非常简单的 C++ 引擎,并将文件添加到 XCode 中基于标准视图的应用程序中。 然后我添加了一个覆盖整个 iPhone 屏幕的 UIImageView。

我的测试引擎目前设置的方式是,每一帧都会将结果渲染到图像,然后使用该图像更新每一帧的 UIImageView。 假设我可以将输入从 iPhone 传递到 C++ 引擎,这似乎是一个相当独立于平台的解决方案。 由于我为 iPhone/Mac 编码的时间还不到 1 天,我想知道这是否是在 iPhone 上运行现有 C++ 引擎的标准方法,如果不是,那是什么?

I come from a C/C++ background and more recently flash. Anyway I wrote a 2D engine in AS3 and would like to get it running on the iPhone. To start with I converted it to C++. As a test I wrote a very simple C++ engine and added the files to a standard view-based application in XCode. I then added a UIImageView that covered the whole iPhone screen.

The way my test engine is set up at the moment is that each frame it renders the result to an image which is then used to update the UIImageView every frame. Assuming I can pass input from the iPhone to the C++ engine this seems like a fairly platform-independent solution. Since I have been coding for iPhone/Mac for less than 1 day I was wondering whether this is the standard approach to getting an existing C++ engine running on the iPhone and if not, what is?

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

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

发布评论

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

评论(2

初雪 2024-08-06 20:15:18

渲染图像并刷新该图像没有问题,但使用此技术无法从 GPU 获得加速。 因此,您会消耗大量 CPU 周期,从而消耗电池。

如果您正在渲染的对象可以用普通图形基元来描述,请务必使用针对平台优化的绘图 API,并且可以将工作委托给 GPU。

另一种方法是使用 OpenGLES,但这有一个学习曲线

There's no problem in you rendering into an image and refreshing that image, but you get no acceleration from the GPU using this technique. So you'd be burning a lot of CPU cycles, which in turns eats battery.

If the objects you are rendering can be described in normal graphics primitives, be sure to use the drawing APIs which are optimised for the platform and can delegate work to the GPU.

An alternative approach is to make use of OpenGLES, but this has a learning curve

月亮邮递员 2024-08-06 20:15:18

是的,这是一种相当正常的处理方式。 一般来说,您要么使用小型 Objective C 存根来处理事件和推出帧之类的事情,要么设置一个 OpenGL 上下文,然后将其传递给 C++ 代码。

Yes, that is a fairly normal way to handle it. Generally you would either use small Objective C stubs for your events and things like pushing out the frame, or you would setup an OpenGL context and then pass it to your C++ code.

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