Archived

This topic is now archived and is closed to further replies.

Please help with problem

This topic is 6030 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I attempted to compile the program demo8_3.cpp from Tricks of the Windows Game Programming Gurus by André LaMothe, where there are asteroids bumipng around the edges of the screen. Unfortunately, i had a compilation error. I included ddraw.h and ddraw.lib, and I have DirectX8.0. I get the following errors: C:\Program Files\Microsoft Visual Studio\MyProjects\asteroids\demo8_1.cpp(50) : error C2065: ''LPDIRECTDRAWSURFACE4'' : undeclared identifier C:\Program Files\Microsoft Visual Studio\MyProjects\asteroids\demo8_1.cpp(50) : error C2146: syntax error : missing '')'' before identifier ''lpdds'' C:\Program Files\Microsoft Visual Studio\MyProjects\asteroids\demo8_1.cpp(50) : error C2059: syntax error : '')'' C:\Program Files\Microsoft Visual Studio\MyProjects\asteroids\demo8_1.cpp(71) : error C2146: syntax error : missing '';'' before identifier ''lpdd'' C:\Program Files\Microsoft Visual Studio\MyProjects\asteroids\demo8_1.cpp(71) : error C2501: ''LPDIRECTDRAW4'' : missing storage-class or type specifiers C:\Program Files\Microsoft Visual Studio\MyProjects\asteroids\demo8_1.cpp(71) : fatal error C1004: unexpected end of file found How can I fix these? These are straight from the book. I know there should be an LPDIRECTDRAWSURFACE4, but apparently, my compiler doesn''t recognize it. Thanks, Maneesh

Share this post


Link to post
Share on other sites
It sounds like you haven''t linked to the Direct Draw libraries. (I am at school so I don''t have my compiler handy, but I will post back on how to fix it when I get home).

Share this post


Link to post
Share on other sites
You havent included the *correct* directX headers.
You need to reconfigure your compiler to look in the correct place (where you installed the SDK) otherwise it will just use the default ones, which only go as far as DX3.

If you are using MSVC, go tools->options->directories, select include files from the dropdown box, add a new directory and make sure you shift it to the top of the search order. Do the same for library files or youll get a similar linker error later.

Share this post


Link to post
Share on other sites
I already did that, I have been able to compiile other DIretX progams. In MSVC++, i have it set to C:\Program FIles\Directx\SDK\include and lib. I even tried including every single DirectX library, but it still didn''t work. That isn''t the problem. By the way, it recognizes LPDIRECTDRAW SURACE, but it doesn''t recognize LPDIRECTDRAWSURFACE4


-Maneesh

Share this post


Link to post
Share on other sites
I had similar problems to this in the past but ran out of time so never came up with a solution. However, if I can be a bit constructive I think it is to do with the fact that the demos in the book are all created for directx version 6.1. Now, there is something that needs to be added to the dx6.1 source code to get dx8 to compile it correctly. I think it''s something to do with setting the version but I don''t know the exact details. Possibly somebody can help out here if I''m on the right track.

Hope this helps

henry

Share this post


Link to post
Share on other sites
Thanks a lot KVH, it fixed the problem. But now there are new errors and warnings. NOw there is 3 errors and 55 warnings. The erros are:


D:\Maneesh\GameProgrammingSource\T3dchap12\t3dlib2.cpp(83) : error C2065: ''DirectInputCreate'' : undeclared identifier
D:\Maneesh\GameProgrammingSource\T3dchap12\t3dlib2.cpp(110) : error C2065: ''DIDEVTYPE_JOYSTICK'' : undeclared identifier
d:\maneesh\gameprogrammingsource\t3dchap12\t3dlib3.h(64) : error C2065: ''DSBCAPS_CTRLDEFAULT'' : undeclared identifier

How do I fix these errors. I have included dinput.h and dinput.lib and ddraw.h and ddraw.lib

Share this post


Link to post
Share on other sites
In DX8, they changed a few things. DirectInputCreate became DirectInput8Create, I believe, and DIDEVTYPE_JOYSTICK became DI8DEVTYPE_JOYSTICK, but I''m not entirely sure about these. They also decided to no longer #define DSBCAPS_CTRLDEFAULT. Try this:
#define DSBCAPS_CTRLDEFAULT (DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN)

Share this post


Link to post
Share on other sites
(...I apologize in advance for the length of this message...)


Try these:

A) Make sure the new directories for DirectX are above the other directories as it includes the first one it runs into

B) got to your include directory. open up dinput.h in notepad. Search for 'DirectInputCreate'. If it doesn't find it you don't have valid headers. I use the DX8 sdk but directinput 5 so i KNOW this works. also there are still legacy versions of constants in dinput.h



(stripped from dinput.h)
    

#if DIRECTINPUT_VERSION <= 0x700

#define DIDEVTYPE_DEVICE 1

#define DIDEVTYPE_MOUSE 2

#define DIDEVTYPE_KEYBOARD 3

#define DIDEVTYPE_JOYSTICK 4

#else

#define DI8DEVCLASS_ALL 0

#define DI8DEVCLASS_DEVICE 1

#define DI8DEVCLASS_POINTER 2

#define DI8DEVCLASS_KEYBOARD 3

#define DI8DEVCLASS_GAMECTRL 4

#define DI8DEVTYPE_DEVICE 0x11

#define DI8DEVTYPE_MOUSE 0x12

#define DI8DEVTYPE_KEYBOARD 0x13

#define DI8DEVTYPE_JOYSTICK 0x14

..........

#endif /* DIRECTINPUT_VERSION <= 0x700 */



also

        
#if DIRECTINPUT_VERSION > 0x0700


extern HRESULT WINAPI DirectInput8Create(HINSTANCE hinst, DWORD dwVersion, REFIID riidltf, LPVOID *ppvOut, LPUNKNOWN punkOuter);


#else

extern HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter);

extern HRESULT WINAPI DirectInputCreateW(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTW *ppDI, LPUNKNOWN punkOuter);

#ifdef UNICODE

#define DirectInputCreate DirectInputCreateW

#else

#define DirectInputCreate DirectInputCreateA

#endif // !UNICODE






but aprosenf is correct about DSBCAPS_CTRLDEFAULT


Robert Warden
Lasershot Shooting Simulations



Edited by - KlePt0 on June 8, 2001 4:32:18 PM

Share this post


Link to post
Share on other sites
Well, all the directories are set up correctly, but it still doesn''t work. KlePt0 had exactly the same header as me, so that isn''t the problem. I even tried changing DirectDrawCreate to DirectInputCreateW and DirectInputCreateA, but it still doesn''t work. If anyone wants, I can send the files to them!

Thanks
-Maneesh

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Make totally abosutely sure that the directx include/lib directories are at te top of the search list. This is the kind of common sense error everyone makes.

Share this post


Link to post
Share on other sites