Archived

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

Woody FX

DirectX7 code not workin with SDK 8!!

Recommended Posts

Woody FX    169
Trying to recompile some code that was written for DirectX 7 but i''ve got DirectX 8 SDK installed and i''m gettin some errors I put the ole #define DIRECTDRAW_VERSION 0x0700 before #include ddraw.h But i''m still getting these some errors These are the defines and includes from the file that the errors appear to be from //include guard #ifndef DDFUNCS_H #define DDFUNCS_H #include <windows.h> #define DIRECTDRAW_VERSION 0x0700 #include "ddraw.h" #include "GDICanvas.h" This is the code the the error messages seems to point to /////////////////////////////////////////////////////////////////////////////// //Direct Draw Initialization/Cleanup functions /////////////////////////////////////////////////////////////////////////////// //create direct draw interface LPDIRECTDRAW7 LPDD_Create(HWND hWnd,DWORD dwCoopLevel); And here are the actual error messages!!! Deleting intermediate files and output files for project ''Littlerunningman - Win32 Debug''. --------------------Configuration: Littlerunningman - Win32 Debug-------------------- Compiling... DDFuncs.cpp c:\windows\desktop\gamedev\sourceiso\source\chapter10\isohex10_2\ddfuncs.h(65) : error C2146: syntax error : missing '';'' before identifier ''LPDD_Create'' c:\windows\desktop\gamedev\sourceiso\source\chapter10\isohex10_2\ddfuncs.h(65) : error C2501: ''LPDIRECTDRAW7'' : missing storage-class or type specifiers c:\windows\desktop\gamedev\sourceiso\source\chapter10\isohex10_2\ddfuncs.h(65) : fatal error C1004: unexpected end of file found GDICanvas.cpp IsoHex10_2.cpp c:\windows\desktop\gamedev\sourceiso\source\chapter10\isohex10_2\ddfuncs.h(65) : error C2146: syntax error : missing '';'' before identifier ''LPDD_Create'' c:\windows\desktop\gamedev\sourceiso\source\chapter10\isohex10_2\ddfuncs.h(65) : error C2501: ''LPDIRECTDRAW7'' : missing storage-class or type specifiers c:\windows\desktop\gamedev\sourceiso\source\chapter10\isohex10_2\ddfuncs.h(65) : fatal error C1004: unexpected end of file found TileSet.cpp c:\windows\desktop\gamedev\sourceiso\source\chapter10\isohex10_2\ddfuncs.h(65) : error C2146: syntax error : missing '';'' before identifier ''LPDD_Create'' c:\windows\desktop\gamedev\sourceiso\source\chapter10\isohex10_2\ddfuncs.h(65) : error C2501: ''LPDIRECTDRAW7'' : missing storage-class or type specifiers c:\windows\desktop\gamedev\sourceiso\source\chapter10\isohex10_2\ddfuncs.h(65) : fatal error C1004: unexpected end of file found Error executing cl.exe. Littlerunningman.exe - 9 error(s), 0 warning(s) Thanks Brain

Share this post


Link to post
Share on other sites
MindWipe    940
it works fine. My current engine uses ddraw from dx7 and audio & input from dx8

here's the error:

#include "ddraw.h" should be #include <ddraw.h>

/MindWipe

"If it doesn't fit, force it; if it breaks, it needed replacement anyway."

[EDIT]Damn I hate typos [/EDIT]

Edited by - MindWipe on February 8, 2002 7:18:34 AM

Share this post


Link to post
Share on other sites
Woody FX    169
No did not work!!!!!!

I will put the code for a program what throws up the error!!


//////////////////////////////////////////////////////////////////////////////
//INCLUDES
//////////////////////////////////////////////////////////////////////////////
#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include "ddraw.h"

//////////////////////////////////////////////////////////////////////////////
//DEFINES
//////////////////////////////////////////////////////////////////////////////
//name for our window class
#define WINDOWCLASS "ISOHEX5"
//title of the application
#define WINDOWTITLE "IsoHex 5-1"

//////////////////////////////////////////////////////////////////////////////
//PROTOTYPES
//////////////////////////////////////////////////////////////////////////////
bool Prog_Init();//game data initalizer
void Prog_Loop();//main game loop
void Prog_Done();//game clean up

//enumeration functions
HRESULT WINAPI EnumModesCallbackCount(LPDDSURFACEDESC2 lpDDSurfaceDesc, LPVOID lpContext);
HRESULT WINAPI EnumModesCallbackList(LPDDSURFACEDESC2 lpDDSurfaceDesc,LPVOID lpContext);


//////////////////////////////////////////////////////////////////////////////
//GLOBALS
//////////////////////////////////////////////////////////////////////////////
HINSTANCE hInstMain=NULL;//main application handle
HWND hWndMain=NULL;//handle to our main window
//IDirectDraw7 Pointer
LPDIRECTDRAW7 lpdd=NULL;
//display mode structure
struct DisplayMode
{
DWORD dwWidth;
DWORD dwHeight;
DWORD dwBPP;
};
//display mode enumeration variables
DWORD dwDisplayModeCount=0;
DisplayMode* DisplayModeList=NULL;

//////////////////////////////////////////////////////////////////////////////
//WINDOWPROC
//////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK TheWindowProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
//which message did we get?
switch(uMsg)
{
case WM_KEYDOWN:
{
//check for escape key
if(wParam==VK_ESCAPE)
{
DestroyWindow(hWndMain);
}

return(0);//handled message
}break;
case WM_DESTROY://the window is being destroyed
{

//tell the application we are quitting
PostQuitMessage(0);

//handled message, so return 0
return(0);

}break;
case WM_PAINT://the window needs repainting
{
//a variable needed for painting information
PAINTSTRUCT ps;

//start painting
HDC hdc=BeginPaint(hwnd,&ps);

/////////////////////////////
//painting code would go here
/////////////////////////////

//end painting
EndPaint(hwnd,&ps);

//handled message, so return 0
return(0);
}break;
}

//pass along any other message to default message handler
return(DefWindowProc(hwnd,uMsg,wParam,lParam));
}


//////////////////////////////////////////////////////////////////////////////
//WINMAIN
//////////////////////////////////////////////////////////////////////////////
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
//assign instance to global variable
hInstMain=hInstance;

//create window class
WNDCLASSEX wcx;

//set the size of the structure
wcx.cbSize=sizeof(WNDCLASSEX);

//class style
wcx.nononostyle=CS_OWNDC | CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;

//window procedure
wcx.lpfnWndProc=TheWindowProc;

//class extra
wcx.cbClsExtra=0;

//window extra
wcx.cbWndExtra=0;

//application handle
wcx.hInstance=hInstMain;

//icon
wcx.hIcon=LoadIcon(NULL,IDI_APPLICATION);

//cursor
wcx.hCursor=LoadCursor(NULL,IDC_ARROW);

//background color
wcx.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);

//menu
wcx.lpszMenuName=NULL;

//class name
wcx.lpszClassName=WINDOWCLASS;

//small icon
wcx.hIconSm=NULL;

//register the window class, return 0 if not successful
if(!RegisterClassEx(&wcx)) return(0);

//create main window
hWndMain=CreateWindowEx(0,WINDOWCLASS,WINDOWTITLE, WS_POPUP | WS_VISIBLE,0,0,320,240,NULL,NULL,hInstMain,NULL);

//error check
if(!hWndMain) return(0);

//if program initialization failed, then return with 0
if(!Prog_Init()) return(0);

//message structure
MSG msg;

//message pump
for(;; )
{
//look for a message
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
//there is a message

//check that we arent quitting
if(msg.message==WM_QUIT) break;

//translate message
TranslateMessage(&msg);

//dispatch message
DispatchMessage(&msg);
}

//run main game loop
Prog_Loop();
}

//clean up program data
Prog_Done();

//return the wparam from the WM_QUIT message
return(msg.wParam);
}

//////////////////////////////////////////////////////////////////////////////
//INITIALIZATION
//////////////////////////////////////////////////////////////////////////////
bool Prog_Init()
{
//error code
HRESULT hr;

//initialize the dd pointer
hr=DirectDrawCreateEx(NULL,(void**)&lpdd,IID_IDirectDraw7,NULL);

//example for error handling
if(FAILED(hr))
{
//initialization failed
return(false);
}

//set the cooperative level
lpdd->SetCooperativeLevel(hWndMain,DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT);

//enumerate the displaymodes
dwDisplayModeCount=0;

lpdd->EnumDisplayModes(0,NULL,NULL,EnumModesCallbackCount);

DisplayModeList=new DisplayMode[dwDisplayModeCount];
dwDisplayModeCount=0;

lpdd->EnumDisplayModes(0,NULL,NULL,EnumModesCallbackList);

//pick a display mode
DisplayMode TestMode;
TestMode.dwWidth=0;
TestMode.dwHeight=0;
TestMode.dwBPP=0;
DWORD index;
bool found=false;

for(index=0;(index {
if(DisplayModeList[index].dwBPP==16)
{
if(DisplayModeList[index].dwWidth>TestMode.dwWidth)
{
TestMode.dwWidth=DisplayModeList[index].dwWidth;
TestMode.dwHeight=DisplayModeList[index].dwHeight;
TestMode.dwBPP=DisplayModeList[index].dwBPP;
found=true;
}
}
}

if(!found)
{
return(false);
}

//set the display mode
hr=lpdd->SetDisplayMode(TestMode.dwWidth,TestMode.dwHeight,TestMode.dwBPP,0,0);

return(true);//return success
}

//////////////////////////////////////////////////////////////////////////////
//CLEANUP
//////////////////////////////////////////////////////////////////////////////
void Prog_Done()
{
//clean up the dd pointer
if(lpdd)
{
lpdd->Release();
lpdd=NULL;
}

//get rid of enumeration stuff
delete [] DisplayModeList;
}

//////////////////////////////////////////////////////////////////////////////
//MAIN GAME LOOP
//////////////////////////////////////////////////////////////////////////////
void Prog_Loop()
{
///////////////////////////
//main game logic goes here
///////////////////////////
}

//enumeration-count
HRESULT WINAPI EnumModesCallbackCount(
LPDDSURFACEDESC2 lpDDSurfaceDesc,
LPVOID lpContext
)
{
//increment the count variable
dwDisplayModeCount++;

//continue the enumeration
return(DDENUMRET_OK);
}

//enumeration-list
HRESULT WINAPI EnumModesCallbackList(
LPDDSURFACEDESC2 lpDDSurfaceDesc,
LPVOID lpContext
)
{
//copy applicable information to the list
DisplayModeList[dwDisplayModeCount].dwWidth=lpDDSurfaceDesc->dwWidth;
DisplayModeList[dwDisplayModeCount].dwHeight=lpDDSurfaceDesc->dwHeight;
DisplayModeList[dwDisplayModeCount].dwBPP=lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount;

//increment the count variable
dwDisplayModeCount++;

//continue the enumeration
return(DDENUMRET_OK);
}


When i build it these are the erros it gives


Deleting intermediate files and output files for project 'IsoHex5_1 - Win32 Debug'.
--------------------Configuration: IsoHex5_1 - Win32 Debug--------------------
Compiling...
IsoHex5_1.cpp
c:\windows\desktop\gamedev\sourceiso\source\chapter5\isohex5_1\isohex5_1.cpp(43) : error C2146: syntax error : missing ';' before identifier 'lpdd'
c:\windows\desktop\gamedev\sourceiso\source\chapter5\isohex5_1\isohex5_1.cpp(43) : error C2501: 'LPDIRECTDRAW7' : missing storage-class or type specifiers
c:\windows\desktop\gamedev\sourceiso\source\chapter5\isohex5_1\isohex5_1.cpp(43) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

IsoHex5_1.exe - 3 error(s), 0 warning(s)


I Do everything that You need to do such as including the Librarys and includes

Using VC++ 6 and DirectX 8 sdk

Edited by - Woody FX on February 9, 2002 9:16:38 AM

Share this post


Link to post
Share on other sites
Colin Jeanne    1114
Please do not post the same topic in the same forum. Also, for us to better help you, please post your current edited code and not the old one (and only the part that is relevant to the problem, as you did in your first post).

Invader X
Invader''s Realm

Share this post


Link to post
Share on other sites
3dModelMan    204
I''ve managed to compile and run that sample with almost no trouble, using DX8.1 and VC++ 6.

Under "Project->Settings->Link->Object/Library Modules" add two new library names at the end of the existing list, they are ddraw.lib and dxguid.lib.

Try that. If it still won''t compile then email me for my project files.

Cheers

Matt



Share this post


Link to post
Share on other sites
Hyatus    122
I just reformatted this PC and tried the same thing.
It didn''t work, either.
Then I looked at the ddraw.h header in the MSVS directory.
It''s not the header it SHOULD be.(and yeah, dx81 sdk was
installed after service pack 5)

I''d copy the header files you need over to the MSVS directory,
or include them from the dxsdk directory.

You may need to move the .lib files as well(they may not be
dx81).

*sigh*

-Hyatus
"da da da"

Share this post


Link to post
Share on other sites
a person    118
this is why ppl should RTFM. the sdk install explcitly tells you how to set it up. it actually will set the directories up for you, assuming you pick that option (well the dx8 sdk did, so i assume the dx8.1 does as well). btw this question (about compiling dd7 apps with dx8.1 sdk) has been asked and answered a few times on the board already.

Share this post


Link to post
Share on other sites
3dModelMan    204
a person: RTFM is one thing, Understanding TFM and correctly following it is something all beginners fail to do at some point. That''s why these boards exist. Get down of your high horse and if you can''t add anything constructive to a thread, leave it alone.

Hyatus: Incidentally, I also reformatted and reinstalled everything just before I tried getting this to work, in fact it is one of the reasons I took the time to try it since I have a lot of DX7 code of my own and this was the first thing I tried to compile without the version 7 sdk on the hard drive. If you have to resort to moving libs and headers from their installed directory then you are not setting up your VC paths correctly. Moving these files around is a bad thing to do for all sorts of reasons.

Cheers

Matt



Share this post


Link to post
Share on other sites
Hyatus    122
Last time I installed the DXSDK, it asked me whether I wanted it
to have MSVC be configured for the pathnames and such.
I got no such dialog this time.

Seeing as how it was so damned long ago that I installed the SDK,
I had forgotten that it should''ve given me the option.

Still, yeah, I could''ve made it point to the dxsdk directories.
However, seeing as how MSVC already had DX5 installed in it''s
OWN include&lib directories, I don''t see the harm in copying over
the newest version.

-Hyatus
"da da da"

Share this post


Link to post
Share on other sites
3dModelMan    204
Well, Hyatus. If you think that is the right thing to do, then I really can''t help you (j/k). Whatever you do in life- especially in programming, someone will always poke you in the ribs and say "I know a better way to do that". This is just one of those times

- Matt

Share this post


Link to post
Share on other sites
a person    118
i did add something constructive. suggesting to look through the forum where other ppl had this SAME problem. this is helpful since he may not have realized this. i agree understanding and reading are different and most times ppl have trouble understanding what they are reading when the first start. i had problems before, but i would reread the docs. do research and TRY to understand what was going wrong. in the end i would figure it out, maybe not as fast as if i asked the question here, but then again i learned so much more about how things worked, this allowing me to better understand other similar problems. many ppl give up to earlier, they spend two hours and give up. they dont bother doing any research to see if previous ppl have had this problem. they resort to formating (?!??!) the harddrive to fix things. ppl today i notice are more interested in how to fix things and not why the fix works or what the problem was.

please dont be quick to judge. someone who posts the same code twice and says he changed things obviously is not paying attention to something.

Share this post


Link to post
Share on other sites
Woody FX    169
Did not post the same topic twice in the same forum!!

Posted Originally in The Programming Forum but told to post here on the DirectX Forum so i did and then later a mod moved my original post over Here as well!!

So it appears i''ve stupidy posted about the same thing Twice!!

Thanks for all that help i''ll try these fix''s and get back to ye!!

Brian

Share this post


Link to post
Share on other sites
Woody FX    169
OK i''ve got done everything like setting the libs and includes pointing to c:\mssdk\libs and c:c:\mssdk\includes and moved them to the top of the list...

Put dxguid.lib and ddraw.lib in the project settings links tab!!

Haytus::::SAID:::

Then I looked at the ddraw.h header in the MSVS directory.
It''s not the header it SHOULD be.(and yeah, dx81 sdk was
installed after service pack 5)

I''d copy the header files you need over to the MSVS directory,
or include them from the dxsdk directory.

You may need to move the .lib files as well(they may not be
dx81).

What does that mean!!! You reckon my problem is that i''m pointing to the DirectX version 5 ddraw.libs are something!!



Haytus::::SAID::

I could''ve made it point to the dxsdk directories.

So that is what ive to do then is it??

Thanks Brian


Share this post


Link to post
Share on other sites
Hyatus    122
"What does that mean!!! You reckon my problem is that i''m
pointing to the DirectX version 5 ddraw.libs are something!!"

Yeah...you see, MSVC has DX5 installed when you install MSVC.
DX81 SHOULD give you a dialog asking if you want to point your
directories to it''s header and lib folders. Mine didn''t ask and
I''m assuming yours didn''t either.

So, make sure that your DXSDK include and lib directories are set
BEFORE MSVC''s(at least I think they''re supposed to be set
before...it might not matter).

Then it should compile fine(provided there aren''t any other
errors in the code).

-Hyatus
"da da da"

Share this post


Link to post
Share on other sites