DirectX question

10 views
Skip to first unread message

JoeC

unread,
Jan 5, 2006, 9:38:32 PM1/5/06
to C++ Game Programming
I have been trying to get the basics of DirectX and I coppied this
code:

#include<windows.h>
#include<windowsx.h>
#include<ddraw.h>
#include<d3d9.h>

HRESULT ddrval;
LPDIRECTDRAW7 lpdd = NULL;
HWND hwnd;

int APIENTRY WinMain(HINSTANCE hin, HINSTANCE hp, LPSTR lpCmd, int
CmdShow){

DirectDrawCreateEx(NULL, (void**) &lpdd, IID_IDirectDraw7, NULL);
ddrval = lpdd->SetCooperativeLevel( hwnd, DDSCL_ALLOWMODEX |
DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN);
ddrval = lpdd->SetDisplayMode( 800,600,16,0,0);
lpdd->Release();

return 0;
}

And it seems to be same as the books but I am getting this error:

Compiling...
Main.cpp
Linking...
Main.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw7
Debug/DDrawX.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

DDrawX.exe - 2 error(s), 0 warning(s)


with

DirectDrawCreateEx(NULL, (void**) &lpdd, IID_IDirectDraw7, NULL);

Why am I getting this error?

Hieu Le Trung

unread,
Jan 5, 2006, 9:48:08 PM1/5/06
to C-Game-Pr...@googlegroups.com
Hi,

Seem that you have forgot linking with dxguild.lib
Add following line to solve that error

#pragma comment(lib, "dxguid.lib")


Hieu Le

JoeC

unread,
Jan 5, 2006, 10:52:51 PM1/5/06
to C++ Game Programming
Thanks much, I now get this error:
Linking...
dxguid.lib(dxguid.obj) : fatal error LNK1103: debugging information
corrupt; recompile module
Error executing link.exe.

DDrawX.exe - 1 error(s), 0 warning(s)

Hieu Le Trung

unread,
Jan 5, 2006, 10:55:53 PM1/5/06
to C-Game-Pr...@googlegroups.com
Have you rebuild your project?


-----Original Message-----
From: C-Game-Pr...@googlegroups.com
[mailto:C-Game-Pr...@googlegroups.com] On Behalf Of JoeC
Sent: Friday, January 06, 2006 10:53 AM
To: C++ Game Programming

JoeC

unread,
Jan 5, 2006, 11:07:04 PM1/5/06
to C++ Game Programming
Yes.

swordlegend

unread,
Jan 5, 2006, 11:33:59 PM1/5/06
to C-Game-Pr...@googlegroups.com
you can try this method, add the #define INITGUID before 

jakob lin

unread,
Jan 6, 2006, 1:26:12 AM1/6/06
to C-Game-Pr...@googlegroups.com
i think it would be better if you tell us what version of direct x u r using .
--
Jakob Lin Mall

Hieu Le Trung

unread,
Jan 6, 2006, 1:50:52 AM1/6/06
to C-Game-Pr...@googlegroups.com

swordlegend

unread,
Jan 6, 2006, 2:03:56 AM1/6/06
to C-Game-Pr...@googlegroups.com
this is the define of  IID_IDirectDraw7 in dxsdk
DEFINE_GUID( IID_IDirectDraw7,             0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b );
 and the DEFINE_GUID is def as

#ifdef INITGUID
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
        EXTERN_C const GUID DECLSPEC_SELECTANY name \
                = { l, w1, w2, { b1, b2,  b3,  b4,  b5,  b6,  b7,  b8 } }
#else
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
    EXTERN_C const GUID FAR name
#endif // INITGUID

u can see , want to use the IID_IDirectDraw7 must first define the macro INITGUID

2006/1/6, Hieu Le Trung <hie...@cybersoft-vn.com>:

JoeC

unread,
Jan 6, 2006, 10:35:04 AM1/6/06
to C++ Game Programming
Thanks that worked, I didn't see that in amy of my books.

Reply all
Reply to author
Forward
0 new messages