Archived

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

DirectDrawCreate Error....

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

Recommended Posts

I get this error now that I''ve converted all the LPDIRECTDRAW''s to LPDIRECTDRAW7''s. But now its complaining saying that it wants a LPDIRECTDRAW pointer and not a 7 one? I''ve put the DirectX 7 include and lib files in every include and lib file of my compiler. The directorory of the headers and libraries is at top (the dx ones) and I''m almost sure I''m using 7 because in ddraw.h I see this: typedef struct IDirectDraw7 FAR *LPDIRECTDRAW7; also in the readme: Microsoft(R) DirectX(R) 7 Software Development Kit // error and line it points to below ----\/ error C2664: ''DirectDrawCreate'' : cannot convert parameter 2 from ''struct IDirectDraw7 ** '' to ''struct IDirectDraw ** '' if(DirectDrawCreate(NULL,&lpdd,NULL) != DD_OK) What could be causing this? Thanks, Viri-

Share on other sites
Try inserting (void**) before &lpdd

Share on other sites
Use DirectDrawCreateEx with DD7

Share on other sites
quote:
Original post by A. Buza

Try inserting (void**) before &lpdd

if(DirectDrawCreate(NULL,(void**)&lpdd,NULL) != DD_OK)
still gives me the error as I had before. I looked at the IDirectDraw vs. IDD7 post earlier and it told me to use DDCreateEx( etc) That still doesnt'' work for me. I''ve got:
LPDIRECTDRAW7 lpdd = NULL; // dd object
as it declared that way. And am using it to create the surfaces. Also having the same problems with the SetDisplayMode as the other person was too. Whats causing this? I tried to cast them like the other person did too and that didn''t work....

Thanks,
Viri-

Share on other sites
This is some of my older Lamothe inspired code:

  // Setup DirectDraw 1 interface if(FAILED(DirectDrawCreate(NULL, &lpddtemp, NULL))) { MsgBox("Error in DirectDrawCreate"); return 1; } // Query for DirectDraw7 if(FAILED(lpddtemp->QueryInterface(IID_IDirectDraw7, (LPVOID*)&lpdd))) { MsgBox("Error in lpddtemp->QueryInterface"); return 1; } // Delete old DirectDraw1 interface if(lpddtemp) { lpddtemp->Release(); lpddtemp = NULL; }

You need to create a ddraw1 object first i think, and then query it for dd7

_____________________________
My Site: HERE

Share on other sites
Try this -Viri..

#include
//********************************************
//put this in your code initialization

HRESULT hRet;
LPDIRECTDRAW7 g_pDD = NULL;
LPDIRECTDRAWSURFACE7 g_pDDSFront = NULL;
LPDIRECTDRAWSURFACE7 g_pDDSBack = NULL;

hRet = DirectDrawCreateEx(NULL,
(VOID**)&g_pDD,
IID_IDirectDraw7,
NULL);
if(FAILED(hRet)){
//do error message here
}

//otherwise we''ve succeeded..
//now set cooperative level
hRet = g_pDD->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE |
DDSCL_FULLSCREEN);
if(FAILED(hRet)){
//another error message
}

//now set the display mode
//set the display mode to 800x600 with 16 bit depth
hRet = g_pDD->SetDisplayMode(800, 600, 16, 0, 0);
if(FAILED(hr)){
//error
}

// Create the primary surface with one back buffer.
DDSURFACEDESC2 ddsd;
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP |
DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;

hRet = g_pDD->CreateSurface(&ddsd, &g_pDDSFront, NULL);
if(FAILED(hRet)){
//error creating primary surface
}

DDSCAPS2 ddscaps;
ZeroMemory(&ddscaps, sizeof(ddscaps));
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
hRet = g_pDDSFront->GetAttachedSurface(&ddscaps, &g_pDDSBack);
if(FAILED(hRet)){
//error getting back buffer
}

//now we are DONE the initialization
//YAY!!!

THIS HAS GOT TO WORK!

Share on other sites
ZomeonE, I don''t think you can do it your way if you want to take advantage of the new Direct3D stuff, as MS sort of broke the COM chain with DirectDrawCreateEx...you CANNOT use a LPDIRECTDRAW object and query it for an LPDIRECTDRAW7 object (LaMothe uses it to create an LPDIRECTDRAW6 object NOT a 7 one)..
MS suggests this method to be "unpredictable"...

straight from the MSDN:

"DirectX 7.0 has a new function to create an IDirectDraw7 interface, DirectDrawCreateEx. This function is the only way to create the newest iteration of this DirectDraw object which supports the new features of DirectDraw and Direct3D. The IDirectDraw7 interface supersedes the IDirectDraw4 interface."

Wazoo

Share on other sites
wazoo69
aha..thnx, I didn''t know that. I has worked just fine for me though.
I''ve never read the msdn for dx stuff

_____________________________
My Site: HERE

Share on other sites
Wazoo thanks a lot for the code. I see a couple things I could be and am now doing different. Everything worked just fine except now I get this error. Its talking about the flag in IID_IDirectDraw7. I am also going to post this error as a new post to see if anyone has heard of it. So if ya know anything let me know alright? Thanks to everyone for their help, valid or not.
Thanks,
Viri-

izzy.obj : error LNK2001: unresolved external symbol _IID_IDirectDraw7
Debug/aproj.exe : fatal error LNK1120: 1 unresolved externals

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

Share on other sites
Viri, no problem with that one...

go to your menu bar at the top, and under "Project" hit
"settings"

you''ll see a bunch of tabs on the right hand side of the dialog box...select the one that says "link"...there''ll be a line right near the bottom which lists a whole bunch of libraries the compiler is linking to..(ie. gui32.lib, etc..) just go to the end of the line, and (making sure you have a space between libraries), enter "ddraw.lib"....

oh and just to be funky, at the very top of your main.cpp file (or whereever you have your winmain function),

//put this at the top of the file
#define INITGUID

This initializes some behind-the-scenes GUID''s in DX...(OR you can link your project with dxguid.lib putting it after ddraw.lib as above)

did I make any sense??? It''s almost nappy time..

take it easy, and post if this works or not..

wazoo

• 48
• 12
• 10
• 10
• 9
• Forum Statistics

• Total Topics
631379
• Total Posts
2999666
×