On Jan 10, 2012, at 12:39 AM, Richard wrote:
Depending on
what you're trying to do with it and how early you consider
portability issues, it can be relatively simple or d evilishly complex
to translate Direct3D operations to OpenGL;
For games, its not that hard to have it work on both. The parts that
don't map well between the two APIs (logical ops on pixels, indexed
color both come to mind) are not the areas that are used by games.
Indeed; I've certainly written code that ports between both. It's a lot harder to
port *existing* code which was exclusively designed for one or the other; a lot of
assumptions (like the ordering of matrices) have to be undone or worked around. If you
start from the ground up assuming you need to make allowances, it's not so bad.
Shaders are a little harder, but obviously there are options. I think Trinity uses Cg and
compiles that to native shaders, which isn't *terrible*, but I haven't worked with
it in a while, so I may not be remembering clearly.
lots of
developer s with cutting-edge engines just don't find it worth it
to try to support OpenGL as a "second-tier" solution, which necessarily
ties the games to Windows or X Box 360 (which, as I understand it,
runs a very modified NT kernel).
It's generally not that hard to have an engine that works well on both
D3D and OGL. Xbox 360 is more like D3D9, while the PC is using a much
more advanced shader model whether it's via D3D{10,11} or OGL.
For so-called "AAA" titles, console portability is more important to
them than reaching the Mac. That means Xbox 360 and PS3.
Well, yes. Which is why most PC games still exist at a D3D9 level of graphics. :-)
(notable exceptions are becoming more abundant, of course)
Both of
these have proprietary SDKs with details that are under NDA; I know
Xbox 360 looks like D3D9 with a few extra features and more direct
access to the GPU (you are, for intents and purposes, the only process
running and the hardware is fixed, not variable). I don't know what
the PS3 API looks like, if it's OpenGL or something more low-level and
you're on your own to build higher layers of abstraction on top of it.
IIRC, it's got a commodity GPU in there somewhere in addition to the
Cell BE.
It does, and I know folks who have done that directly (before their PS3s dropped the
"other OS" feature, UMBC used to use them for a Cell programming class, and some
people took it a bit further). They came to appreciate what the drivers did a great deal
more after that. I have no idea what the official SDK looks like, but it must not be that
different from DX9 or we'd see a lot fewer titles bridging the gap.
No idea what the Wii SDK looks like, either, but I've definitely seen way more of its
machine code than I care to have done. The existing homebrew efforts have produced some
interesting OGL-lite stuff that works pretty OK.
- Dave