The calling of the initialize() method for EffectI and ImportableI depends on which device drivers is used. For example OpenGL device dirver has far less calls to that methods compared to DirectX 8 driver since, the DX8 driver handles the device lost status via intialize() method.
But there are some ruler which applies to all devices.
Right after a new effect is created, the initialize() method is called with reason INIT_INTIAL_UPDATE.
Right after importable is created and the load_file() is called, the initialize() method is called with reason INIT_INTIAL_UPDATE.
When all the files and effects are loaded and all device drivers are created the initialize() method of all importables are called. The initialise method is the first called method where the devices are quaranteed to be valid. So you should not use any device specifid code in load() and load_file() methods!
When a device is changed (for example Graphics Device) the initialise method is called with reason INIT_DEVICE_CHANGED. The device which is about to be shut down, has set state DEVICE_STATE_SHUTTINGDOWN. After the device has chaged, a new call to the intialize() method is made with reason INIT_DEVICE_VALIDATE. Then the effect or importable should check the device context for available devices reinitialise device specific data (such as textures).
The Direct X driver has a state called lost device. This is D3D specific and it happens everytime the main surface changes (full screen change, window size change, etc.). This state is handled via the initialize() method. When ever a device is about to be lost, the initialize() method is called with reason INIT_DEVICE_INVALIDATE. If then the graphics device driver has DEVICE_STATE_LOST state set, the effect or importer should handle the device lost state. When the device is restored again, the intialize() method is called with reason INIT_DEVICE_VALIDATE.
Example:
void TestEffectC::initialize( uint32 ui32Reason, DeviceContextC* pContext, TimeContextC* pTimeContext ) { // Get the device and make sure it exists DX8DeviceC* pDevice = (DX8DeviceC*)pContext->query_interface( CLASS_DX8_DEVICEDRIVER ); if( !pDevice ) return; if( ui32Reason == INIT_INITIAL_UPDATE ) { // Do the initial update } else if( ui32Reason == INIT_DEVICE_CHANGED ) { if( pDevice->get_state() == DEVICE_STATE_SHUTTINGDOWN ) { // The device is being shut down... } } else if( ui32Reason == INIT_DEVICE_INVALIDATE ) { if( pDevice->get_state() == DEVICE_STATE_LOST ) { // The device is lost } } else if( ui32Reason == INIT_DEVICE_VALIDATE ) { if( pDevice->get_state() == DEVICE_STATE_OK ) { // The device is got back } } }