将 DirectX 移植到 OpenGL ES (iPhone)

发布于 2024-10-01 15:28:49 字数 260 浏览 3 评论 0原文

我被要求调查将 10 年前的 Direct X (v7-9) 游戏移植到 OpenGL ES,最初是针对 iPhone

我以前从未进行过这样的游戏移植(并将雇用某人来做这件事),但我会喜欢了解过程。

  1. 是否有任何资源/书籍/博客可以帮助我理解该过程?
  2. 有没有像 Mono 这样的项目可以实现这一点?

I have been asked to investigate porting 10 year old Direct X (v7-9) games to OpenGL ES, initially for the iPhone

I have never undertaken a game port like this before (and will be hiring someone to do it) but I'd like to understand the process.

  1. Are there any resources/books/blogs that will help me in understanding the process?
  2. Are there any projects like Mono that can accomplish this?

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

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

发布评论

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

评论(2

暮年慕年 2024-10-08 15:28:49

说实话,像这样的移植工作很复杂,但相当简单。

首先,您首先用“存根”(即空函数)替换所有 DirectX 调用。这样做直到可以编译软件为止。一旦编译完成,您就可以开始实现所有存根函数。一路上会遇到很多问题,但值得一做。

如果您需要移植并支持 iPhone 3GS 之前的手机,您的任务会更加复杂,因为硬件仅支持固定功能的 GLES 1。您必须以某种方式“模拟”这些着色器。过去,我在移动平台上编写了直接在顶点数据上执行“顶点着色”的汇编代码。像素着色通常更复杂,但您通常可以通过“顶点着色”提供足够的信息来实现这一点。您可能必须放弃某些图形功能。

更高版本的 iPhone 使用 GLES 2,因此您可以访问 GLSL ...ATI 编写的、Unity3D 名声大噪的 Aras P 已扩展的软件将移植 HLSL 代码到 GLSL

完成所有这些后,您就进入了优化阶段。您可能会发现您的第一次传递效率不高。这是完全正常的。此时,您可以从更高的级别查看代码,并了解如何移动代码并以不同的方式执行操作以获得最佳性能。

总之:您的第一步是在不使用 DirectX 的情况下编译代码。下一步是将 DirectX 调用实际移植到 OpenGL ES 调用。最后,您将需要重构剩余的代码以获得最佳性能。

(PS:我很乐意为您做移植工作。请通过我的个人资料中的 linkedin 页面与我联系;))。

TBH A porting job like this is involved but fairly easy.

First you start by replacing all the DirectX calls with "stubs" (ie empty functions). You do this until you can get the software to compile. Once it has compiled then you start implementing all the stub functions. There will be a number of gotchas along the way but its worth doing.

If you need to port to and support phones before iPhone 3GS you have a more complex task as the hardware only supports GLES 1 which is fixed-function only. You will have to "emulate" these shaders somehow. On mobile platforms I have written, in the past, assembler code that performs "vertex shading" directly on the vertex data. Pixel shading is often more complicated but you can usually provide enough information through the "vertex shading" to get this going. Some graphical features you may just have to drop.

Later versions of the iPhone use GLES 2 so you have access to GLSL ... ATI have written, and Aras P of Unity3D fame has extended, software that will port HLSL code to GLSL.

Once you have done all this you get on to the optimisation stage. You will probably find that your first pass isn't very efficient. This is perfectly normal. At this point you can look at the code from a higher level and see how you can move code around and do things differently to get best performance.

In summary: Your first step will be to get the code to compile without DirectX. Your next step will be the actual porting of DirectX calls to OpenGL ES calls. Finally you will want to refactor the remaining code for best performance.

(P.S: I'd be happy to do the porting work for you. Contact me through my linkedin page in my profile ;)).

不一样的天空 2024-10-08 15:28:49

不是一个完整的答案,但希望能有所帮助...

我不知道有任何专门针对 OpenGL ES 的内容,但 Cadega、Cider 和 VirtualBox(除其他外)提供了 DirectX 调用到 OpenGL 调用的转换,以及 OpenGL ES从广义上讲,OpenGL 删除了许多很少使用的位,并删除了一些速度较慢和冗余的部分。因此,至少研究这些产品可能是值得的;至少 VirtualBox 是开源的。

iPhone 3GS 以后的 SGX 部分具有完全可编程的管道,使其相当于 DirectX 10 部分,因此硬件就在那里。旧的 MBX 是带有 dot3 扩展的固定管道,但没有立方体贴图,只有两个纹理单元。它还具有矩阵调色板扩展,因此如果可以接受多次通过,您可以制作良好的动画和相当好的照明。

Not a complete answer, but in the hope of helping a little...

I'm not aware of anything targeting OpenGL ES specifically, but Cadega, Cider and VirtualBox — amongst others — provide translation of DirectX calls to OpenGL calls, and OpenGL ES is, broadly speaking, OpenGL with a lot of very rarely used bits and some slower and redundant parts removed. So it would probably be worth at least investigating those products; at least VirtualBox is open source.

The SGX part in the iPhone 3GS onwards has a fully programmable pipeline, making it equivalent to a DirectX 10 part, so the hardware is there. The older MBX is fixed pipeline with the dot3 extension but no cube maps and only two texture units. It also has the matrix palette extension, so you can do good animation and pretty good lighting if multiple passes is acceptable.

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