Most of the 2D stuff is now done; I have yet to hit Draw_Fill (couldn't really be bothered at this stage) and Draw_TransPicTranslate. Otherwise, it's all rendering nicely in Direct 3D.
Lessons learned so far:
- You read a hell of a lot about Vertex Buffers in the documentation and examples, but they're not really suitable for a lot of data that's dynamically changing. Having to set up a vertex buffer for every possible screen element makes no sense. Locking and unlocking to just draw a single 8 x 8 character seems like a daft thing. There is a IDirect3DDevice9::DrawPrimitiveUP member which is hardly ever mentioned, and is just perfect for this.
- Carmack may have made a comparison between the amount of code required to get a triangle on screen in his OpenGL vs Direct 3D rant, but the point he missed (at the time) is that you're not really meant to use the API directly. Instead, you write wrappers for your common functionality around the API. You only need to write the wrapper once, and then Direct 3D actually requires substantially less code for the single triangle. It means a steeper initial learning curve, which I guess would put a lot of people off.
- Textures are truly horrible. I've figured that the best approach is to build a TGA format in memory around the texture in GL_Upload32, then use D3DXCreateTextureFromFileInMemory to create it. Must rank as one of the nastiest hacks ever, but I really see no reason to do it any different.
- After having been used to OpenGL for so long, Direct 3D matrices and co-ordinates seem slightly wacko. Even in pure 2D. Getting used to the differences is easily the biggest challenge.
0 comments:
Post a Comment