Archived

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

Newbie Question: having problems with directx

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

I have just recently been learing directx and I''m have a problem with the DDLoadBitmap funtion in the ddutil.cpp which comes with the sdk. I keep getting an error that says: "error C2664: ''DDLoadBitmap'' : cannot convert parameter 1 from ''struct IDirectDraw *'' to ''struct IDirectDraw7 *''" How do I change to IDirectDraw7? Right now I Query IDD_DIRECTDRAW2 with QueryInterface, should I do a different DIRECTDRAW, like 4 or something? I realize that there is probebly a simple solution, but being new to directx I have no idea what it is, I have a book on Directx 5.2 and I have directx 7.0a, did they change this funtion a bit in the new release, well that is what im thinking they did, but when I installed Directx 5.2 the SDK, I got a different error that said "DDLoadBitmap: does not take 4 parameters", I really dont know what im doing wrong, It is the exact same code as the books, and it still won''t work, can someone please help me. It would be greatly appreceated...

Share this post


Link to post
Share on other sites
well you have to set your objects that your using to the same thing like
lpdds1,lpdds2 have to equal LPDIRECTDRAW
u cant have one set to LPDIRECTDRAW7 and one to LPDIRECTDRAW

Share this post


Link to post
Share on other sites
you need to query a directdraw 7 interface (IDD_DIRECTDRAW7 or whatever)

or you can just create the DD object with

DirectDrawCreateEx(NULL,&lpdd7,IID_IDirectDraw7,NULL);

where lpdd7 is a LPDIRECTDRAW7 variable.

Share this post


Link to post
Share on other sites
Actually it needs to be like this:

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

The way fuzzyai said will give you an error.

-Snyper

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Although a book is a good thing, you should also look at the documentation that comes with the DirectX SDK. It''s actually very helpful, it seems many people tend to rely on books 100% and never look at the SDK documentation.

Also, I don''t think you can query for a DirectX 7 object, I believe you can only use the DirectDrawCreateEx function to create the object, but I may be wrong.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hey listen JSCFaith:

extern "C" IDirectDrawSurface7 *
DDLoadBitmap(IDirectDraw7 * pdd, LPCSTR szBitmap, int dx, int dy)

Notice that this function is using DirectDraw7 not DirectDraw, and when you call the function, the first parameter SHOULD be 7 too.

so...
LPDIRECTDRAW7 pDD7 = NULL;
LPDIRECTDRAWSURFACE7 pDDTempSurface = NULL;

// do all your initialization...
// *I''d recommend you to look at the DirectX 7.x and learn how
// to Inlitialize DirectDraw using the DirectDrawCreateEx
// function so that you don''t have to call QueryInterface ().

// and then load the bitmap to the surface. *should be 7 too.
pDDTempSurface = DDLoadBitmap ( pDD7, "filename.bmp", 0, 0 );

then do whatever you want with it...

Share this post


Link to post
Share on other sites