TrueVision3D:Delphi
From GPWiki
The wiki is now hosted by GameDev.NET at wiki.gamedev.net. All gpwiki.org content has been moved to the new server. However, the GPWiki forums are still active! Come say hello. Using Delphi to interact with the TrueVision3D library is a simple task. Similar to other languages Delphi uses the COM interface. This page will have tips specific to Delphi and will give you needed instructions for making sense of setup and common problems. [edit] SetupOpen Delphi (this works for Delphi versions 5-7 but may work for other versions) Open the menu "Project" and click on "Import Type Library". The dialog will contain a list of all type libraries on your system. Browse for "TV3D SDK 6.5 - Delphi/COM Release" Select a directory in your library and browse path and click the "Create Unit" button. This will generate a header for the dll that can be included in the uses of your delphi units. [edit] Tips and Tricks1) There are some cases where DirectX will generate Floating Point errors. It is important to disable these errors in Delphi or they can cause spurious problems. To disable these add the following code to your initialization code (usually your main forms .OnCreate function.) Set8087CW($133f); 2) There may be cases where there is more than one TrueVision3D application is using the COM object dll. If this is true different versions may be registered that could have a different interface and cause failures in your application. The suggested solution is to have a local copy of the specific dll you want to use and register it in your program. The following code snippet allows you to register or unregister a dll. It's also suggested you unregister the dll first, before registering it. This, to make sure the registry is cleared of existing entries. function RegisterServer(const aDllFileName: string; aRegister: Boolean): Boolean; type TRegProc = function: HResult; stdcall; const cRegFuncNameArr: array [Boolean] of PChar = ('DllUnregisterServer', 'DllRegisterServer'); var vLibHandle: THandle; vRegProc: TRegProc; begin Result := False; vLibHandle := LoadLibrary(PChar(aDllFileName)); if vLibHandle = 0 then Exit; @vRegProc := GetProcAddress(vLibHandle, cRegFuncNameArr[aRegister]); if @vRegProc <> nil then Result := vRegProc = S_OK; FreeLibrary(vLibHandle); end; |


