HOOPS Exchange Documentation

< Home

< Reference Manual

< File Formats

PROGRAMMING GUIDE

Contents

1.0 Introduction

2.0 Getting started

3.0 Product occurrence

4.0 Reading geometry

5.0 Entity attributes

6.0 Views and PMI

7.0 Advanced functions

Implementing external linking

  1. Call the LoadLibrary function (or a similar function) to load the DLL and obtain a module handle.
  2. Call the GetProcAddress function to obtain a function pointer to each exported function that your plugin calls. Because applications are calling the DLLs functions through a pointer, the compiler does not generate external references, so there is no need to link with an import library.

Example: Main code segment that loads the Acrobat 3D library and defines function pointers

HMODULE hModuleA3DPRCSDK = A3DPRCLoadLibrary();
if (!hModuleA3DPRCSDK) {
AVAlertNote("Failed to load A3DLIB.dll!");
_unlink(prcName);
_unlink(jsName);
return;
}
A3DPRCFunctionPointersInitialize(hModuleA3DPRCSDK);
//------------------------------------
// Your plug-in initializes its relationship with the Acrobat 3D Library
// and then it parses or creates PRC content.
//------------------------------------
A3DPRCUnloadLibrary(hModuleA3DPRCSDK);
} else {
char strMsg[128];
sprintf(strMsg, "A3DDllInitialize returned %d\n", iRet);
AVAlertNote(strMsg);
_unlink(prcName);
_unlink(jsName);
A3DPRCUnloadLibrary(hModuleA3DPRCSDK);
}
Example: Loading the DLL and obtaining a module handle
HMODULE A3DPRCLoadLibrary()
{
HMODULE hModuleA3DPRCSDK;
wchar_t acFilePath[MAX_PATH];
GetModuleFileNameW(NULL, acFilePath, MAX_PATH);
wchar_t* backslash = wcsrchr(acFilePath, L'\\');
if (backslash)
acFilePath[backslash - acFilePath] = 0;
wcscat(acFilePath, L"\\A3DLIB.dll");
#ifdef UNICODE
hModuleA3DPRCSDK = LoadLibraryExW(acFilePath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
#else
hModuleA3DPRCSDK = LoadLibraryExA(acFilePath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
#endif
if (hModuleA3DPRCSDK)
return hModuleA3DPRCSDK;
return NULL;
}

Example: Setting up the function pointers

void A3DPRCFunctionPointersInitialize(HMODULE hModule)
{
#define A3D_API(returntype,name,params) st_PF##name = (PF##name)GetProcAddress(hModule,#name);
#include <A3DSDK.h>
#include <A3DSDKTypes.h>
#include <A3DSDKBase.h>
#include <A3DSDKGeometry.h>
#include <A3DSDKGraphics.h>
#include <A3DSDKRepItems.h>
#include <A3DSDKMarkup.h>
#include <A3DSDKTexture.h>
#include <A3DSDKMisc.h>
#include <A3DSDKTopology.h>
#undef A3D_API
}

Example: Declaring the macro that resolves to the function pointer

#define A3DCALL(name,params) st_PF##name params

Example: Using the macro to invoke an Acrobat 3D API function

if(iErr == A3D_SUCCESS) {
A3DInt32 iRet = A3DCALL(A3DDllInitialize,(iMajorVersion, iMinorVersion));
if(iRet == A3D_SUCCESS) {
...
}
}