Archived

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

DirectX question

This topic is 6359 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

Ive been using LaMothe''s "Tricks" book to learn how to use DirectX. When I try to compile my own program or his using his setup I get a few errors I can''t resolve. here are my includes #include #include #include #include #include #include #include // I also included ddraw.lib to my project manually according to the book the errors occur in this section of code LPDIRECTDRAW lpdd = NULL; // dd object LPDIRECTDRAW4 lpdd4 = NULL; // dd4 object // errors in line above LPDIRECTDRAWSURFACE4 lpddsprimary = NULL; // dd primary surfac LPDIRECTDRAWSURFACE4 lpddsback = NULL; // dd back surface LPDIRECTDRAWPALETTE lpddpal = NULL; // a pointer to LPDIRECTDRAWCLIPPER lpddclipper = NULL; // dd clipper PALETTEENTRY palette[256]; // color palette PALETTEENTRY save_palette[256]; // used to save DDSURFACEDESC2 ddsd; // a direct draw DDBLTFX ddbltfx; // used to fill DDSCAPS2 ddscaps; // a direct draw HRESULT ddrval; // result back from DWORD start_clock_count = 0; // used for timing errors: D:\prog\source.cpp(55) : error C2146: syntax error : missing '';'' before identifier ''lpdd4'' D:\prog\source.cpp(55) : error C2501: ''LPDIRECTDRAW4'' : missing storage-class or type specifiers D:\prog\source.cpp(55) : fatal error C1004: unexpected end of file found I have no clue to get rid of the errors, could it have anything to do with my having DirectX 7.0a on my computer and the book using DX 6? I dont know, but any help would be greatly appreciated. Thanks

Share this post


Link to post
Share on other sites
It seems like this question comes up quite often. I think you need to make sure you have done the following things:

1] Make sure to physically include the DirectX .lib files you are using in your workspace.

2] Make sure you have your include/library directory set up right. They should be pointing to where ever you put the DirectX SDK. I believe you need to make them the first path in the list. (Above any of the other the default C++ paths)

Hope that helps,
-> Briar LoDeran <-

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You have to copy all the include files from the DirectX directory
( most of the time c:\mssdk\include ) to the include directory located in your compiler.
also copy the *.lib files from c:\mssdk\lib to the lib directory.

*Take a look at the DirectX SDK help to learn the differences among DirectX 6.x and 7.x.

Share this post


Link to post
Share on other sites
If you''re using MS''s DevStudio you can ''point'' to where you installed your DX include''s and libraries so that it will look there for the files. Then once you do that make sure to include the libraries in project->settings->link(tab). The directories tab is in the options menu.
~S''Greth

Got Code?

Share this post


Link to post
Share on other sites
Also, if you are using Visual C++ 6, and you used the Wizard to start a new Win32 project, you have to place the following line at the top of every C++ source file:

#include "stdafx.h"

That may be what''s causing the errors you''re getting ... maybe not.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What''s happening here, is that his compiler has the old version of DirectX in his include directory. If he''d be writing an API using DirectDraw; there would be no problem at all, but he''s trying to use a newer version of DirectX and the compiler is not aware that DirectX has been updated.
So what you have to do is get your compiler to use the new code that comes with the SDK.

and that new code is in c:\mssdk

also don''t forget to link ddraw.lib and dxguid.lib from the new version.

and if you have DirectX 7 installed, then use DirectX 7.

and don''t inlcude "stdafx.h" cause this is only for MFC. sure unless you''re working with MFC.

Share this post


Link to post
Share on other sites
Well, I''ve never included dxguids.lib I use
#define INITGUID
and all is fine
Actually I have no idea what INITGUID does, maybe it links dxguids.lib?

All I know is when i start something new i always forget it and sit around pondering over the guid errors i get


Martin Björklund

Share this post


Link to post
Share on other sites
Just to clarify something a little, "stdafx.h" is not just for MFC, you need to include it whenever you are using precompiled headers.
Well actually, you could name the precompiled header file anything, but "stdafx.h" is the name given to it by the Win32 Application Wizard in VC 6.

Share this post


Link to post
Share on other sites
#define''ing INITGUID before including the dx headers accomplishes the same thing as linking to dxguid.lib (though it doesn''t link).
INITGUID makes the DEFINEGUID macro actually initialize the guids it declares, instead of simply declaring them as external data.

Share this post


Link to post
Share on other sites
The best way I found to read through LaMothe''s book was NOT to use his code. Its not bad code-its just dated a little, go step by step read a section, look at his code, and write your own. Statr with creating a DD Object, then move on to initializing it, creating a surface, setting the video display ect... Thats how I learned it anyway. I find it very hard to understand someone elses code, so its easier to re-write your own.


Not really on topic at all am I-MUAHAHAHAHAHA

Share this post


Link to post
Share on other sites