Please save the Slave of DirectX, pals!!!!!!
Hi there, pals! Below is my code for the DirectDraw project that''s similar to the second demo in Chapter 6 of Andre LaMothe''s "Tricks of the Windows Game Programming Gurus" :
#include "stdafx.h"
#include
LPDIRECTDRAW lpdd = NULL;
LPDIRECTDRAW4 lpdd4 = NULL;
int GameInit()
{
//create the DirectDraw interface and fill lpdd with the IDirectDraw interface pointer.
if(FAILED(DirectDrawCreate(NULL,&lpdd,NULL)))
{
return 0;
}
//u can get there if u can get there from anywhere.
//thus, get IDirectDraw4 interface pointer from the
//newly retrieved IDirectDraw interface pointer!
if(FAILED(lpdd->QueryInterface(IID_IDirectDraw4,(LPVOID*)&lpdd4)))
{
return 0;
}
//set the cooperative level!!!!!
if(FAILED(lpdd4->SetCooperativeLevel(g_hWnd,DDSCL_FULLSCREEN + DDSCL_ALLOWREBOOT + DDSCL_EXCLUSIVE + DDSCL_ALLOWMODEX)))
{
return 0;
}
if(FAILED(lpdd4->SetDisplayMode(WINDOW_WIDTH,WINDOW_HEIGHT,16,0,0)))
{
return 0;
}
return 1;
}
Besides the code above, I also did the following steps like an old faithful darn DirectX Slave :
1) Copy the ddraw.lib files to my project''s directory and insert them into my project as well.
2) I went to Tools--->Options--->Directories tab and specified the full search path for the ddraw.h and ddraw.lib.(in this case, it''s "C:\mssdk\include" and "C:\mssdk\lib" respectively, under the Include section and Library section respectively. I put both of them as the first entry in both sections.
3) I also go to Project--->Settings--->Link tab and typed in "ddraw.lib" as the first library name in the Library text field.
And after doing these faithful duties as what a DirectX Slave should be doing to it''s Master, the Guardian of DirectX, the Visual C++ linker complained of the following Linker errors :
DirectDraw.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw4
Release/DirectDraw.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
(the name of my project is call DirectDraw)
I noticed that if I take out the line that has IID_IDirectDraw4, there will be NO errors, but when I put the line back in, the 2 errors appeared again!!!!!!!! Why is this????? But I''''ve already faithfully included the ddraw.lib and .h files, right?
Someone please help!!!!!!!!!!!!!!! (:-(
"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone''s watching in awe......."
"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone's watching in awe......."
quote:
Original post by Xeon_Boy
Hi there, pals! Below is my code for the DirectDraw project that''s similar to the second demo in Chapter 6 of Andre LaMothe''s "Tricks of the Windows Game Programming Gurus" :
#include "stdafx.h"
#include
LPDIRECTDRAW lpdd = NULL;
LPDIRECTDRAW4 lpdd4 = NULL;
int GameInit()
{
//create the DirectDraw interface and fill lpdd with the IDirectDraw interface pointer.
if(FAILED(DirectDrawCreate(NULL,&lpdd,NULL)))
{
return 0;
}
//u can get there if u can get there from anywhere.
//thus, get IDirectDraw4 interface pointer from the
//newly retrieved IDirectDraw interface pointer!
if(FAILED(lpdd->QueryInterface(IID_IDirectDraw4,(LPVOID*)&lpdd4)))
{
return 0;
}
//set the cooperative level!!!!!
if(FAILED(lpdd4->SetCooperativeLevel(g_hWnd,DDSCL_FULLSCREEN + DDSCL_ALLOWREBOOT + DDSCL_EXCLUSIVE + DDSCL_ALLOWMODEX)))
{
return 0;
}
if(FAILED(lpdd4->SetDisplayMode(WINDOW_WIDTH,WINDOW_HEIGHT,16,0,0)))
{
return 0;
}
return 1;
}
Besides the code above, I also did the following steps like an old faithful darn DirectX Slave :
1) Copy the ddraw.lib files to my project''s directory and insert them into my project as well.
This stemp is not necessary. Everybody that will run your program will have these files anyways...
quote:
2) I went to Tools--->Options--->Directories tab and specified the full search path for the ddraw.h and ddraw.lib.(in this case, it''s "C:\mssdk\include" and "C:\mssdk\lib" respectively, under the Include section and Library section respectively. I put both of them as the first entry in both sections.
So far so good.
quote:
3) I also go to Project--->Settings--->Link tab and typed in "ddraw.lib" as the first library name in the Library text field.
Not sure if that''s the problem but I usually put "ddraw.lib" & "dxguid.lib" at the end of the list and it works fine...
Now, with that said, if you''re running the DX8 SDK, these lines might not work as DX8 encapsulate DDraw and D3D together. Some people say that DDraw will be back in DX9 but I don''t think it will. People will have to get used to using D3D to do 2D stuff as in OGL...
Anyhow, hope these steps help.
BTW, there is a way to get access to the DDraw using DX8 but I don''t remember the #define needed in order to get it to work...
"And that''s the bottom line cause I said so!"
Cyberdrek
Headhunter Soft
A division of DLC Multimedia
Resist Windows XP''s Invasive Production Activation Technology!
"gitty up" -- Kramer
[Cyberdrek | ]
Heh heh heh! Got it! It''s "dxguid.lib". Honestly, folks who''re real new to COM might not know that there''s actually a GUID lib/file or most IIDs, that''s why, and I believe LaMothe didn''t even mentioned anything about "dxguid.lib" in his book.
Another thing is, pal......MUST WE PROGRAM IN 3D even if we don''t want to do so in DirectX 8.0 cos'' Direct3D and DirectDraw are fused together? Thanks!!!!!!!
"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone''s watching in awe......."
"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone's watching in awe......."
Heh heh heh! Got it! It''s "dxguid.lib". Honestly, folks who''re real new to COM might not know that there''s actually a GUID lib/file or most IIDs, that''s why, and I believe LaMothe didn''t even mentioned anything about "dxguid.lib" in his book.
Another thing is, pal......MUST WE PROGRAM IN 3D even if we don''t want to do so in DirectX 8.0 cos'' Direct3D and DirectDraw are fused together? Thanks!!!!!!!
And yes, yes. We must totally RESIST Windows XP''s Product Activitation Code stuff. What rubbish? We buy the software and we''ve to convince MS everytime through phone calls that we''re not pirates?????!!! What if we re-format the hard drive or upgrade to a new hard disk?????!!!!!!
"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone''s watching in awe......."
"The feeling of mastering and understanding hard stuff in Game Programming is just like the feeling u get when u perform an Air-Walk in the basketball court, soaring.....and everyone's watching in awe......."
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement