编程与软件工程blog.wolfire.com
为什么你应该用 OpenGL 而不是 DirectX
Why you should use OpenGL and not DirectX
2010 — 2013,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
Wolfire Games(Overgrowth 游戏开发商)2010 年的博文,主张游戏开发者应选择 OpenGL 而非 DirectX,理由包括跨平台移植性、开放生态以及微软曾通过营销手段推动 DirectX 的历史。文章在 2010 和 2013 两次登上 HN 首页,评论区对文中观点褒贬不一。
为什么经久不衰:它是 OpenGL 与 DirectX 之争的经典论战文,评论区的多方反驳恰好完整呈现了这场争论的两面,至今仍是理解图形 API 选型权衡的好材料。
HN 评论精选
客观指出文章偏向性:OpenGL 胜在跨平台和灵活性,Direct3D 胜在统一的功能集和效果管线,选择取决于具体需求。
这篇文章有倾向性,略过了 DirectX 的优点。(我是 OpenGL 开发者,但曾在 OpenGL 之上实现 D3D10,也用过 DX7+ 多年。)首先,应该比较的是 OpenGL 和 Direct3D 而非 DirectX——OpenGL 只与 Direct3D 的一小部分竞争,还需要 SDL、OpenAL 等多个库才能覆盖 DX 的功能广度。其次,OpenGL 各厂商扩展实现时间不一,你得为不同扩展写特殊路径;Direct3D 则有统一保证的功能集。用着色器还得自建效果系统或用 Cg,而 D3D 的效果管线省很多时间。最终选择取决于:你多在乎跨平台?有多少时间投入引擎?想要多大的渲染管线灵活性?重引擎技术的公司几乎总该选 OpenGL,而只是做游戏的话……
daeken查看英文原文
This is sort of a loaded article, since it glances over the benefits of DirectX. (Note: I'm an OpenGL developer, but I worked on implementing D3D10 on top of OpenGL, and I've worked with DX7+ over the years. I'm not a fan, but leaving these things out is misleading.) First and foremost, it's wrong to compare OpenGL and DirectX, rather than OpenGL and Direct3D. OpenGL directly competes with a small portion of Direct3D, and requires several libraries (I'm a big fan of SDL, OpenAL, etc myself) to begin to touch the breadth of DX. Second, with OpenGL you have many vendors producing extensions and implementing them at different times. With Direct3D, you have a single set of features you write for which are guaranteed to be there (in a given version). This means that when you write code for OpenGL, you have to special-case paths for many different available extensions and duplicate many pieces of functionality. If you want to use shaders, you have to either make your own effects system on top of GLSL/ARB shaders or use something like Cg. The Direct3D effects pipeline saves a lot of time, but of course reduces flexibility. In the end, the call on OGL vs DX really comes down to these things: How much do you care about cross-platform compatibility? How much time do you have to put into your engine? Do you want complete flexibility w.r.t. your rendering pipeline? If you're an engine-tech-heavy firm, OpenGL will almost always be the right choice. If you're just making a game, DirectX will almost definitely save you time. Again, I'm not a DX fan, but it has its place, and this sort of article is woefully misleading.
移动和 Web 时代几乎所有平台都基于 OpenGL 系,跨平台优势让 OpenGL 的论点更有说服力。
如今移动端和网页才是决定因素吧?文章写于 2010 年,但看看这些平台的 3D 开发:iOS、Android 用 OpenGL ES,Mac、Linux 用 OpenGL,HTML5 用 WebGL(基于 OpenGL ES),连 IE 都支持。新兴平台如 Tizen、Firefox OS 也是 OpenGL ES/WebGL。DirectX 只属于 Windows 和 Windows Phone。Windows 不再像过去那样举足轻重,DirectX 的封闭会不会反过来成为微软的劣势?
AshleysBrain查看英文原文
Isn't mobile and the web the decider these days? Article is from 2010, but consider if you want to develop 3D on any of these platforms: iOS - OpenGL ES Android - OpenGL ES Mac - OpenGL Linux - OpenGL HTML5 - WebGL (based on OpenGL ES) - even in IE! Emerging platforms like Tizen, Firefox OS - OpenGL ES/WebGL DirectX is just for Windows and Windows Phone. Isn't it getting to the point where the bother of having to write a DirectX port might cause developers to skip the Windows platforms, or stick to OpenGL on Windows desktop? Windows isn't as overwhelmingly important as it used to be, and couldn't the fact that DirectX is different start to work against MS? Imagine if Blackberry came out with their own custom 3D API - wouldn't that only serve to hurt them?
反驳文章的 FUD 论:DirectX 胜出更多是因为当时 OpenGL 自身 API 陈旧混乱。
我以为原因其实是:当时的 OpenGL API 很糟糕。到 OpenGL 2.1 时它积累了大量历史包袱,API 不再易用,做同一件事有五种方式,却不知道哪种最快。博文作者(David Rosen,2010 年 1 月 8 日)写这篇文章时本该知道这一点——OpenGL 2.1 在 2006 年就发布了。
taspeotis查看英文原文
API use was shifted in favor of DirectX by Microsoft's two-pronged DirectX campaign around the launch of XBox 360 and Windows Vista, including the spread of FUD (fear, uncertainty and doubt) about the future of OpenGL, and wild exaggeration of the merits of DirectX. I thought it was because that, at the time, the OpenGL API was shit [1]. By the time of OpenGL 2.1, OpenGL was running into a problem. It had a lot of legacy cruft. The API wasn't easy to use anymore. There were 5 ways to do things, and no idea which was the fastest. And really, the author of the blog post should have known this when the blog post was written... By David Rosen on January 8th, 2010 OpenGL 2.1 came out in 2006 [2]. [1] http://programmers.stackexchange.com/a/88055/7067 [2] http://en.wikipedia.org/wiki/OpenGL#OpenGL_2.1
游戏引擎的普及让 API 之争变得无关紧要,开发者已很少直接面对图形 API。
这难道不已经是个过时的问题了吗?如今有 Unity3d、UDK、CryEngine、Shiva、MonoGame 等工具,开发者基本不用再操心底层的 OpenGL/DirectX。这些引擎强大且便宜,如今自己造引擎需要非常充分的理由。等它们都支持 WebGL/HTML5 后,那些简陋的 WebGL 引擎也会被淘汰。而如果你确实在做自己的引擎,为了覆盖所有主流平台反正也得同时支持两者。
kayoone查看英文原文
Isn't this more or less a problem of the past? Today with tools like Unity3d, UDK, CryEngine, Shiva Engine, MonoGame etc, game developers are at a point where they can pretty much stop worrying about the OpenGL/DirectX layer beneath their engines. Those Engines have become so powerful and affordable that it hardly makes any sense to roll your own. In fact, imo you would need a very strong reason to build your own engine these days instead of focusing on your product. Soon all of these will support WebGL/HTML5 as a target and even render most of the (still very basic) WebGL engines obsolete. Now if you were in the business of creating your own tools or engine, you would need to support both of OpenGL and DirectX to be able to support all the major platforms anyway.
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选