Skip to main content
GameDev.net gamedev.net

PRO Tired of ads? Read GameDev.net ad-free and help keep the community independent with GameDev Pro — $3/month.

Beautiful code part 3 - bottom up design

Beautiful code part 3 - bottom up design

Norman Barrows
Gamedev info · · 1 min read
2,357 0
Beautiful code part 3 - bottom up design

an example of beautiful code using bottom up design.

with this method, you start with the lowest level stuff, then add higher level layers until you have a sufficiently high level API.

so you go from ugly low level stuff to a beautiful high level API.

This example uses the directx 9 skinned mesh code from tiny.cpp and DXUT.h macros at the low level:

https://www.gamedev.net/blog/1729/entry-2261223-skinned-mesh-code-part-1-low-level-microsoft-code/

probably not what most folks would call beautiful code. but that's the low level API i had to start with.

first step was a wrapper layer API to "beautify" things a bit:

https://www.gamedev.net/blog/1729/entry-2261224-skinned-mesh-code-part-2-rockland-skinned-mesh-api/

a little better, but still kind of ugly, given all the various routines for the different skinning methods. it should really be split up into separate API's, one for each skinning method.

mesh and controller pools were required. being new APIs, they turned out to be relatively simple and beautiful:

https://www.gamedev.net/blog/1729/entry-2261225-skinned-mesh-code-part-3-mesh-and-controller-memory-pools/

and finally, one routine to rule them all: draw_skinmesh_caveman

https://www.gamedev.net/blog/1729/entry-2261227-skinned-mesh-code-part-4-implementation-example/

https://www.gamedev.net/blog/1729/entry-2261228-skinned-mesh-code-part-5-implementation-example-2/

so all that ugly code has been beautified into the single API call draw_skinmesh_caveman

Discussion

Loading comments...