Porting simple materials code. |
26 August 2004 |
Porting from VisualC++.Net to Xcode.
Before our mantra of "Standards for everything" we used Direct3D8
for our graphics and DirectX for everything else. We were fairly carefull
not to mix DirectX/3D with anything that didn't need it.
Now we use OpenGL for our graphics so a lot of code needs to be ported
from Direct3D8 to OpenGL. We have a small amount of experience with OpenGL,
but it's been a while since we wrote anything with it.
Until recently we have been moving only our platform independent code
into Xcode, with some minor GCC strictness issues. Visual C really lets
you get away with quite a bit. So now we have event handlers,
scripts objects, resource loading, state machines and trigger systems
"ported". But, no graphics, no sound.
So we have started moving some of the graphics code across.
This looked like a daunting task, and it is, but not as nasty as
first thought. The first thing we have moved across are our menu
drawing code and simple materials code.
Simple materials.
Using Direct3D8 our materials code was spread over 3 simple files:
header, materials handling and DirectX common. The DirectX common code
file was elimintated and the header and materials handling were significantly
reduced in source code size.
Simple materials handling using OpenGL is much cleaner.
No device contexts to look after, no directx device checking,
just a few calls to glMaterialfv().
So, moving from proprietary to standard for this simple bit of
code allowed us to reduce the source code size for this class by about 40%!
Menu drawing.
This is where it gets fun. With Direct3D we were using simple
meshes to draw our menus with, now we use GLU quadrics.
Nothing more to be said, very simple, no mesh data hanging around,
and much cleaner source. When the menu code has been fully
ported and "prettied up" it will be released for free as a simple
illustration of circular menus (or menu discs, if you prefer).
|