Borland C++ 5.0 Setup For DirectX 5.0 By Bruce Veazie I've seen quite a few questions and answers with regard to compiling and running DirectX 5.0 samples with Borland C++ 5.0. It took me a while to get things running smoothly so I thought I'd share some lessons learned. It is, after all, an uphill battle to use Microsoft files and documentation with Borland compilers. First - you have to have the Borland compatible libraries to do anything. When you run dx5eng.exe to install dx5, it creates a dx5sdk directory with a bunch of subdirectories, etc. After you run the setup* in the dx5sdk directory, you'll have a dxsdk directory and subdirectories which looks very much like the dx5sdk directory and subdirectories. There's one very important difference! No Borland compatible lib files in the dxsdk. You need to create a subdirectory \dxsdk\sdk\lib\Borland and copy into it all the files from dx5sdk\sdk\lib\Borland. Must've been an oversight in Microsoft's setup. So, if don't have the Borland libs and you don't have the dx5sdk Borland lib directory any more, you need to run dx5eng.exe again and copy the lib files. Note: If you haven't run the setup program in the dx5sdk, you haven't completed installation of the dx5 SDK! Running the setup program in the dx5sdk directory will create another directory tree rooted at dxsdk (vs. dx5sdk) and expand and copy files from the dx5sdk directory into it. If you have some of your own stuff in the dx5sdk directories make sure you transfer whatever you want to use into the newly created dxsdk directory and subdirectories. For sure, copy the Borland compatible libraries as described above. Following the setup, you can delete the dx5sdk directory (and all its subdirectories) to avoid a lot of extra disk space taken up with duplicate files. BTW, I copied all the DirectX Borland libraries in dxsdk\sdk\lib\Borland to my \bc5\lib directory and all the files in \dxsdk\sdk\inc to my \bc5\include directory. Problem: DirectX 5.0 programs run OK when launched from the IDE but bomb on errors when run under Windows directly. Try adding a floating point error handler as recommended in the help documentation [see below] under D3D Immediate Mode/Troubleshooting/Borland Floating-Point Initialization. DirectX library error handlers and Borland default error handlers are apparently incompatible. The errors I encountered that occurred only outside the IDE disappeared when I added the error handler (actually an error disabler). Add code similar (or identical if you want) to that below to one of the modules in your project. Somewhere in the initialization (WinMain, before the message loop, is a good choice), before any DirectX functions are called, call initfp(). That's it. --- example from help documentation // Borland floating point initialization #include <MATH.H> #include <FLOAT.H> void initfp(void) { // disable floating point exceptions _control87(MCW_EM,MCW_EM); } int _matherr(struct _exception *e) { e; // dummy reference to catch the warning return 1; // error has been handled } --- end of example As a personal preference, I added the above to the rmmain.cpp file in samples\misc since that file is common to several of the samples. Problem: when a sample is compiled, link errors of the type "Unresolved external.." keep coming up. Not all the files (cpp, c, rc and lib) that need to be a part of the project have been added to the project. See the description below on how to setup a BC5 project for samples. I haven't tried compiling all the samples. But I've tried a lot of them and I'm consistently successful with compiles and runs using the guidelines below. My suggestions for setting up a BC5 project file for a dx5 sample from the SDK:
Copyright © 1997 Bruce J. Veazie
Discuss this article in the forums
See Also: © 1999-2011 Gamedev.net. All rights reserved. Terms of Use Privacy Policy
|