Loader and Saver plug-ins are implemented as dynamic link libraries (DLLs). DLLs are object code libraries that let multiple programs share code, data, and resources. Dynamic linking allows an executable module to include only the information needed at run time to locate the executable code for a DLL function. This type of linking differs from the more familiar static linking, which requires a copy of a library function's executable code in the executable module of each application using it.
The development tool for creating these DLLs is Microsoft Visual C++. For a description of how to create a new plug-in see Creating a New Plug-in Project.
// NBFLoaderSaver.cpp #include "nvsg/PlugInterfaceID.h" // definition of UPITID_VERSION, // UPITID_SCENE_LOADER, and // UPITID_SCENE_SAVER // unique plug-in types const UPITID PITID_SCENE_LOADER(UPITID_SCENE_LOADER, UPITID_VERSION); const UPITID PITID_SCENE_SAVER(UPITID_SCENE_SAVER, UPITID_VERSION); bool queryPlugInterfaceType(const UPITID& pitid, vector<UPIID>& piids) { piids.clear(); if ( pitid==PITID_SCENE_LOADER ) { piids.push_back(UPIID(".NBF", PITID_SCENE_LOADER)); } else if ( pitid==PITID_SCENE_SAVER ) { piids.push_back(UPIID(".NBF", PITID_SCENE_LOADER)); } return !piids.empty(); }
bool getPlugInterface(const UPIID& piid, PlugIn *& pi) { const UPIID PIID_NBF_SCENE_LOADER = UPIID(".NBF", PITID_SCENE_LOADER)); const UPIID PIID_NBF_SCENE_SAVER = UPIID(".NBF", PITID_SCENE_SAVER)); if ( piid==PIID_NBF_SCENE_LOADER ) { return !!(pi=new NBFLoader()); } else if ( piid==PIID_NBF_SCENE_SAVER ) { return !!(pi=new NBFSaver()); } return false; }
Back to Working With NVSG Classes