Original Post
Hi. This is a question of good programming practice.
I've just been working on a solution to a problem for a while and it seems to work. The problem was that my image class was being called to try to use the image libary i use before the critical initialisation funstions were called. You may ask why not just wait untill these were called. The answer was becuase it's rooted in the constructor to a class that is defined in the main game class.
So basicly it was trying to use a system that wasn't initialised yet (like trying to drive a car without any petrol).
I did this fix in the constructor:
CDevILImage::CDevILImage()
{
#ifndef DEVIL_DEFINED_
#define DEVIL_DEFINED_
ilInit(); //Initiate DevIL libary
iluInit(); //Initiate DevIL Utility liabary.
#endif
}
This looks simple, and believe me i was hitting my self woundering why it took me so long. Any way, is placing preprocessor commands in normal function bodies good coding practise? It works but it might not be up to standard. Should i go with just making a global or static var using normal if statements making its a little more complicated (when dealing with more includes)?
I might just be too worried about this..
Thanks,
-J
[edited by - jason2jason on June 1, 2003 6:46:21 PM]