Initializing and terminating a session
HOOPS Publish is using two different libraries that need to be initialized separately.
A3DLIBS DLL
A3DLIBS DLL shares the code for the whole HOOPS Publish and HOOPS Exchange APIs.
Loading library and accessing functions
A3DLIBS uses explicit linking to access the functions in the API. With explicit linking, the executable using the DLL must make function calls to explicitly load and unload the DLL, and to access the DLL exported functions through a function pointer. HOOPS Publish is delivered with a unique top-level header file A3DSDKIncludes.h to help access the API. Only this header should be included in the customer application. Depending on the level of the product purchased, a specific macro should be defined before including this header:
-
HOOPS_PRODUCT_PUBLISH: for a HOOPS Publish level
-
HOOPS_PRODUCT_PUBLISHPLUSEXCHANGE: for a mixed use of HOOPS Publish + HOOPS Exchange
-
No #DEFINE means a HOOPS Exchange level
This top-level header defines two functions to initialize and terminate a session with the A3DLIBS DLL, as well as a macro that automates the definitions of function pointers for the whole API:
-
bool A3DSDKLoadLibrary(const TCHAR *pSDKDirectory = NULL);: The argument specifies the path where the A3DLIBS DLL is located. An empty string specifies that the library is loaded in the current directory, or with any other path search strategy used with the Windows API function LoadLibraryEx.
-
void A3DSDKUnloadLibrary();: The function to call on the end of the process to unload the library.
-
A3D_API: This macro defines function pointers accordingly to the platform used. Its use should be transparent to customers.
In your main code segment, define INITIALIZE_A3D_API before including A3DSDKIncludes.h, then a call to A3DSDKLoadLibrary will automatically load the DLL (A3DLIBS.DLL) and call GetProcAddress on each function. At the end just call A3DSDKUnloadLibrary.
#define INITIALIZE_A3D_API
#define HOOPS_PRODUCT_PUBLISH
#include "A3DSDKIncludes.h"
if (!A3DSDKLoadLibrary(_T("")))
{
printf("Cannot load library\n");
exit(-1);
}
Initializing the A3DLIBS DLL
-
Verify that your application is compatible with a particular A3DLIBS library by comparing the version of the A3DLIBS DLL against which you compiled and the version of the A3DLIBS DLL available to your application. Obtain the version identifiers for the currently installed A3DLIBS Library by invoking the A3DDllGetVersion function. Evaluate the returned values as follows:
-
Ensure that the value of the piMajorVersion argument matches the A3D_DLL_MAJORVERSION enumeration.
-
Ensure that the value of the piMinorVersion argument is equal to or greater than the A3D_DLL_MINORVERSION enumeration. A3DLIBS provides backward compatibility for earlier releases of the API that have the same major version identifier.
-
Initialize the A3DLIBS DLL using these version identifiers.
A3DInt32 iMajorVersion = 0, iMinorVersion = 0;
if(iRet == A3D_SUCCESS) { ... };
if(iRet == A3D_SUCCESS) { ... };
Terminating the A3DLIBS DLL
Terminate the A3DLIBS DLL by invoking the A3DDllTerminate function, as follows: