Frequently Asked Questions

Q: How do I turn off texture mapping?
A: You can turn off texture mapping with N3DTOP_DISABLE.
N3DDEVICE device;

// set texture
device.SetTexture(0, 128, 128, N3DFMT_A1B5G5R5);

// disable texture mapping
device.SetTextureState(N3DTST_COLOROP, N3DTOP_DISABLE);
TransformAndDrawGeometry ...

// enable texture mapping again
device.SetTextureState(N3DTST_COLOROP, N3DTOP_MODULATE);
TransformAndDrawGeometry ...

Q: Why do you use classes, they are very expensive?!
A: Classes are not expensive by nature, but virtual function calls usually are. The N3DDEVICE interface has no virtual member function at all. Actually, a non-virtual member function is nothing more than a regular function where the this pointer is passed as first parameter, to express it code-wise:

void N3DDEVICE::LightEnable(const unsigned _index, const N3DBOOL _enable)
compiles to:
void N3DDEVICE_LightEnable(N3DDEVICE* _pThis, const unsigned _index, const N3DBOOL _enable)
One thing that holds true is the this pointer is passed to every method. But I don't see a problem there. Most of the N3DDEVICE member functions have less than 4 parameters, so parameters can still exhanged through registers. To resolve the address of an incoming parmeter or from a global variable is not so different either. I'm also pretty sure using a class is way more productive than a bunch of functions. Thanks to code-completion, which provides a fantatic overview of all class members. Take a look at the following link to for more info about virtual and non-virtual member functions: http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.3

Q: Why do you use floats everywhere?
A: I use float's to initialize some N3DFLOAT variables. All of these floats are known at compile time, which means the compiler converts the float to the N3DFLOAT type at compile-time and this does not produce any overhead or slowdowns. Note that the N3DFLOAT type is a representation of a float using fixed point arithmetic and not a real float itself. I already wrote this in the detailed description of N3DFLOAT, but it seems the name confuses some people or they don't read carefully.


Generated on Wed Aug 29 19:48:04 2007 for N3D by  doxygen 1.5.3