DirectX SDK 3D Examples With Borland C++.
Author : Joop Vossers
Date : 29 January 1997
Draft : 1.0
Disclaimer: This document is created as an aid for those who are
experiencing difficulty using the DirectX SDK (version 2) with Borland C++.
Although I have taken care to ensure that this document will resolve the
technical issues at hand, I cannot be held responsible for losses or damages
resulting from the use of this document.
This document covers the egg, faces, flipcube, fly, globe, hier1, hier2, oct1,
oct2, rockem, shadow, sphere, tex1, tex3, tex4, tex5, trans, triangle, tunnel,
twist and uvis "3D" examples which are part of the DirectX 2 SDK. Follow
the next steps carefully to let the DirectX examples run with Borland C++.
The examples where tested with the DirextX 2 SDK and Borland C++ Version
4.52, but it should work with newer releases of the SDK or the compiler.
Implib
See the DirectX & Borland C++ 2D Examples document on how to create a import library.
Plpvtbl
To let the "3D" examples work with Borland C++ you have to compile them in "CPP" mode.
This is because of the anonymous unions in the header files.
To do this you have to remove the "lpVtbl->" and first argument from the function calls.
You can do this for every file using your editor, but you can also use the "PlpVtbl" utility.
This utility needs the "C" filename as input an produces a "CPP" file.
Click here to download this utility.(23K)
Project
!!! Don't include any of the ".def" files in your project !!!.
New Project
Win32 (Platform)
Gui (Target Model)
Browse (Edit Project Name)
Advanced (no .def file)
Add files in project
Add library file(s) to the project
Add include directory to your project. (Options)
\dxsdk\sdk\inc;..\misc
Add _WIN32 define to your project. (Options)(Compiler)(Define)
Example: e:\bc45\include;..\..\inc;..\misc
Build All
Floating Point Handling
Create following file in the "\dxsdk\sdk\inc" directory.
dx3dborl.cpp
-------------------------cut here-----------------------------
#include <float.h>
#include <math.h>
int _matherr(struct _exception *e)
{
return 1;
}
--------------------------cut here-----------------------------
Add following include in the "Main-file". (just behind the normal includes)
#include "dx3dborl.cpp"
In function WinMain(...,.....) (just behind the variables)
_control87(MCW_EM, MCW_EM);
3D Samples
First you have to convert and edit the files in the "misc" directory. The
files in this directory are used by most of the examples.
MISC
PLPVTBL d3dapp.c --> d3dapp.cpp
PLPVTBL d3dcalls.c --> d3dcalls.cpp
PLPVTBL d3dmath.c --> d3dmath.cpp
PLPVTBL d3dsphr.c --> d3dsphr.cpp
PLPVTBL ddcalls.c --> ddcalls.cpp
PLPVTBL dsutil.c --> dsutil.cpp
PLPVTBL lbprintf.c --> lbprintf.cpp
PLPVTBL lclib.c --> lclib.cpp
PLPVTBL misc.c --> misc.cpp
PLPVTBL rmerror.c --> rmerror.cpp
PLPVTBL texture.c --> texture.cpp
Add Floating Point Handling to rmmain.cpp
Add Floating Point Handling to rmfull.cpp
Add Floating Point Handling to d3dmain.cpp
Edit "d3dcalls.cpp"
Change line 29
&IID_IDirect3D, (LPVOID*)&d3dappi.lpD3D);
To
IIDirect3D, (LPVOID*)&d3dappi.lpD3D);
Change line 248
&d3dappi.Driver[driver].Guid,
To
d3dappi.Driver[driver].Guid,
Edit "d3dmath.cpp"
Append line 11
#ifdef __cplusplus
extern "C" {
#endif
Append line 179
#ifdef __cplusplus
};
#endif
Edit "d3dsphr.cpp"
Append line 11
#ifdef __cplusplus
extern "C" {
#endif
Append line 211
#ifdef __cplusplus
};
#endif
Edit "rmmain.cpp"
Change line 88
extern "C" void ReadMouse(int*, int*, int*);
To
void ReadMouse(int*, int*, int*);
Edit "texture.cpp"
Change line 64
&IID_IDirect3DTexture,
To
II_IDirect3DTexture,
Change line 120
&IID_IDirect3DTexture,
To
IID_IDirect3DTexture,
Change line 189
&IID_IDirect3DTexture,
To
IID_IDirect3DTexture,
EGG
PLPVTBL egg.c --> egg.cpp
Add following files in project:
egg.cpp
..\misc\rmerror.cpp
..\misc\rmmain.cpp
..\misc\rmmain.rc
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
FACES
PLPVTBL faces.c --> faces.cpp
Edit "faces.cpp"
Change line 59
normals, face_data, NULL)))
To
normals, (unsigned long *)face_data, NULL)))
Change line 87
normals, face_data, NULL)))
To
normals, (unsigned long *)face_data, NULL)))
Change line 136
face1_data, NULL)))
To
(unsigned long *)face1_data, NULL)))
Change line 169
face2_data, NULL)))
To
(unsigned long *) face2_data, NULL)))
Add following files in project:
faces.cpp
..\misc\rmerror.cpp
..\misc\rmmain.cpp
..\misc\rmmain.rc
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
FLIPCUBE
PLPVTBL flipcube.c --> flipcube.cpp
Add following files in project:
flipcube.cpp
..\misc\d3dmain.rc
..\misc\d3dapp.cpp
..\misc\d3dcalls.cpp
..\misc\d3dmath.cpp
..\misc\ddcalls.cpp
..\misc\lclib.cpp
..\misc\misc.cpp
..\misc\stats.cpp
..\misc\texture.cpp
..\misc\d3dmain.cpp
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib\
FLY
PLPVTBL fly.c --> fly.cpp
Edit "fly.cpp"
Change line 261
this_face->GetVertices( &vertex_count,
To
this_face->GetVertices( (unsigned long *)&vertex_count,
Add following files in project:
fly.cpp
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
..\misc\rmfull.rc
..\misc\d3dapp.cpp
..\misc\d3dcalls.cpp
..\misc\ddcalls.cpp
..\misc\lclib.cpp
..\misc\misc.cpp
..\misc\rmfull.cpp
..\misc\mstats.cpp
..\misc\texture.cpp
GLOBE
PLPVTBL globe.c --> globe.cpp
Add following files in project:
globe.cpp
..\misc\rmerror.cpp
..\misc\rmmain.cpp
..\misc\rmmain.rc
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
HIER1
PLPVTBL hier1.c --> hier1.cpp
Add following files in project:
hier1.cpp
..\misc\rmerror.cpp
..\misc\rmmain.cpp
..\misc\rmmain.rc
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
HIER2
PLPVTBL hier2.c --> hier2.cpp
Add following files in project:
hier2.cpp
..\misc\rmerror.cpp
..\misc\rmmain.cpp
..\misc\rmmain.rc
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
OCT1
PLPVTBL oct1.c --> oct1.cpp
Add following files in project:
oct1.cpp
..\..\blib\d3drm.lib\
..\..\blib\ddraw.lib\
..\misc\d3dmain.rc
..\misc\d3dapp.cpp
..\misc\d3dcalls.cpp
..\misc\d3dmain.cpp
..\misc\d3dmath.cpp
..\misc\ddcalls.cpp
..\misc\lclib.cpp
..\misc\misc.cpp
..\misc\stats.cpp
..\misc\texture.cpp
OCT2
PLPVTBL oct2.c --> oct2.cpp
Add following files in project:
oct2.cpp
..\misc\d3dmain.rc
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
..\misc\d3dapp.cpp
..\misc\d3dcalls.cpp
..\misc\d3dmain.cpp
..\misc\d3dmath.cpp
..\misc\ddcalls.cpp
..\misc\lclib.cpp
..\misc\misc.cpp
..\misc\stats.cpp
..\misc\texture.cpp
QUAT
PLPVTBL quat.c --> quat.cpp
Add following files in project:
quat.cpp
..\misc\rmerror.cpp
..\misc\rmmain.rc
..\misc\rmmain.cpp
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
ROCKEM
Add Floating Point Handling to winmain.cpp
Add following files in project:
..\..\blib\ddraw.lib
..\..\blib\d3drm.lib
..\..\blib\dsound.lib
rockem3d.rc
control.cpp
directx.cpp
midi.cpp
rm.cpp
winmain.cpp
SHADOW
PLPVTBL shadow.c --> shadow.cpp
Add following files in project:
shadow.cpp
..\misc\rmerror.cpp
..\misc\rmmain.cpp
..\misc\rmmain.rc
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
SPHERE
PLPVTBL sphere.c --> sphere.cpp
Add following files in project:
sphere.cpp
..\misc\d3dmain.rc
..\..\blib\d3drm.lib\
..\..\blib\ddraw.lib\
..\misc\d3dapp.cpp
..\misc\d3dcalls.cpp
..\misc\d3dmain.cpp
..\misc\d3dmath.cpp
..\misc\d3dsphr.cpp
..\misc\ddcalls.cpp
..\misc\lclib.cpp
..\misc\misc.cpp
..\misc\stats.cpp
..\misc\texture.cpp
TEX1
PLPVTBL tex1.c --> tex1.cpp
Add following files in project:
tex1.cpp
..\misc\rmerror.cpp
..\misc\rmmain.cpp
..\misc\rmmain.rc
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
TEX3
PLPVTBL tex3.c --> tex3.cpp
Edit "tex3.cpp"
Change line 31
if (SUCCEEDED(v->QueryInterface( &IID_IDirect3DRMMesh, .......)
To
if (SUCCEEDED(v->QueryInterface( IID_IDirect3DRMMesh, .......)
Add following files in project:
tex3.cpp
..\misc\rmerror.cpp
..\misc\rmmain.cpp
..\misc\rmmain.rc
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
TEX4
PLPVTBL tex4.c --> tex4.cpp
Edit "tex4.cpp"
Change line 31
if (SUCCEEDED(v->QueryInterface( &IID_IDirect3DRMMesh, .......)
To
if (SUCCEEDED(v->QueryInterface( IID_IDirect3DRMMesh, .......)
Add following files in project:
tex4.cpp
..\misc\rmerror.cpp
..\misc\rmmain.cpp
..\misc\rmmain.rc
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
TEX5
PLPVTBL tex5.c --> tex5.cpp
Add following files in project:
tex5.cpp
..\misc\rmerror.cpp
..\misc\rmmain.cpp
..\misc\rmmain.rc
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
TRANS
PLPVTBL trans.c --> trans.cpp
Add following files in project:
trans.cpp
..\misc\rmerror.cpp
..\misc\rmmain.cpp
..\misc\rmmain.rc
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
TRIANGLE
PLPVTBL triangle.c --> triangle.cpp
Add following files in project:
triangle.cpp
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
..\misc\d3dmain.rc
..\misc\d3dapp.cpp
..\misc\d3dcalls.cpp
..\misc\d3dmain.cpp
..\misc\ddcalls.cpp
..\misc\lclib.cpp
..\misc\misc.cpp
..\misc\stats.cpp
..\misc\texture.cpp
TUNNEL
PLPVTBL tunnel.c --> tunnel.cpp
Add following files in project:
tunnel.cpp
d3dmain.rc
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
..\misc\d3dcalls.cpp
..\misc\d3dmath.cpp
..\misc\lclib.cpp
..\misc\misc.cpp
..\misc\stats.cpp
..\misc\texture.cpp
..\misc\d3dapp.cpp
..\misc\d3dmain.cpp
..\misc\ddcalls.cpp
TWIST
PLPVTBL twist.c --> twist.cpp
Edit "twist.cpp"
Change line 423
lpTri = lpPointer;
To
lpTri = (D3DTRIANGLE *)lpPointer;
Add following files in project:
twist.cpp
..\..\blib\d3drm.lib\
..\..\blib\ddraw.lib\
..\misc\d3dmain.rc
..\misc\d3dapp.cpp
..\misc\d3dcalls.cpp
..\misc\d3dmain.cpp
..\misc\d3dmath.cpp
..\misc\d3dsphr.cpp
..\misc\ddcalls.cpp
..\misc\lclib.cpp
..\misc\misc.cpp
..\misc\stats.cpp
..\misc\texture.cpp
UVIS
Add following files in project:
uvis.cpp
..\misc\rmerror.cpp
..\misc\rmmain.cpp
..\misc\rmmain.rc
..\..\blib\d3drm.lib
..\..\blib\ddraw.lib
VIEWER
Add Floating Point Handling to viewer.cpp
Add following files in project:
color.cpp
file.cpp
rodcone.cpp
sel.cpp
viewer.cpp
viewer.rc
..\..\blib\ddraw.lib
..\..\blib\d3drm.lib
© 1997 jovo@hotmail.com