Archived

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

Obtaining a DirectDraw4 Interface

This topic is 5402 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 dunno if this should go in the DirectX forum or not, but since it's such a newbie question, I decided to put it here I'm trying to get back into DirectDraw after a long break from it, but now I have a new problem -- I can't request a DirectDraw4 interface. Using the code (noting the fact that there were some errors) from TOWGPG, I tried to make myself a class (a wrapper?) to make DDraw init painless. Upon compiling, I got 7 errors, all related to DirectDraw4:
    
c:\developer\directdrawbeginningtest\ddrawclass.h(15) : error C2146: syntax error : missing ';' before identifier 'lpdd4'
c:\developer\directdrawbeginningtest\ddrawclass.h(15) : error C2501: 'LPDIRECTDRAW4' : missing storage-class or type specifiers
c:\developer\directdrawbeginningtest\ddrawclass.h(15) : error C2501: 'lpdd4' : missing storage-class or type specifiers
c:\developer\directdrawbeginningtest\ddrawclass.h(23) : error C2065: 'lpdd4' : undeclared identifier
c:\developer\directdrawbeginningtest\ddrawclass.h(36) : error C2065: 'IID_IDirectDraw4' : undeclared identifier
c:\developer\directdrawbeginningtest\ddrawclass.h(41) : error C2227: left of '->SetCooperativeLevel' must point to class/struct/union
c:\developer\directdrawbeginningtest\ddrawclass.h(46) : error C2227: left of '->SetDisplayMode' must point to class/struct/union
     
I even tried code that worked on my other computer a while back and tried to compile on this one (including ddraw.lib and dxguid.lib), but no luck. I can think of only three possiblities: 1. This is a fairly new computer, and never had earlier versions of DirectX. Might I need to download an older SDK? 2. I'm running WinXP. Any compatability problems here with DirectDraw? 3. DirectDraw is no longer supported (ie: it won't work anymore, since the new version is out) I'm pretty sure this isn't it though. Anyone else have some insight into why this is happening? Peon [edited by - Peon on March 2, 2003 9:46:15 PM] [edited by - Peon on March 2, 2003 9:47:05 PM]

Share this post


Link to post
Share on other sites
most of the time (from my knowledge) DirectX SDK''s are backwards compatiable for development using older technologies. This isn''t the case all the time though, considering that in newer versions some functions or methods are replaced with more functional counterparts. im not extremely familiar with directdraw4, i would consider 7, it may be old(er) than Direct X Graphics, but any computer that is worth its money has that version. Is it possible that you forgot to #include <ddraw.h>,.... ive done that before. if its possible, set up your IDE so you can search for definitions of those interfaces. when ive got those errors concerning directdraw7, it was a link error of some kind. it is possible that despite backwards compatabilty, the SDK you are using no longer uses DirectDraw4 interfaces, and therefore cant identify it. i suggest browsing through the files you are including and looking for said interface declarations. and if possible, move to a (more) recent techonolgy that is directdraw7. i find direct3d overkill, although not too complicated due to the ID3DXSprite interface. so maybe directx 8 is right for you too. but either way, its more than likely a link error.

----------------------
i code therefore i am.

Aero DX - Coming to a bored Monitor near you!

Share this post


Link to post
Share on other sites
The DirectDraw4 Interface is from DirectX6 I believe (TOTWGPG is a dated book ) Why MS decided not to name the interface according to the version of DirectX is beyond me, but whatever

is definetly included.

I looked @ the actual ddraw.h source and noticed in it there is no DirectDraw4 interface... I saw just a plain DirectDraw (LPDIRECTDRAW), and a DirectDraw2 (LPDIRECTDRAW2), but no DirectDraw4. Strange. I know it worked in the past, at least on my older computer. I'll have to take a look at my old version of ddraw.h and see how it compares.

I'm tempted to just go ahead and jump into 3D, but I think I'm really lacking in some of the concepts.

EDIT: Bingo. Found this in my old DDraw.h--
DEFINE_GUID( IID_IDirectDrawSurface4, 0x0B2B8630,0xAD35,0x11D0,0x8E,0xA6,0x00,0x60,0x97,0x97,0xEA,0x5B );

I'm tempted to just save the old one over the new, but I'm a little worried (I'll probably just back up just in case) Could the difference be do to the fact that this machine never had anything less than DirectDraw 8?

Peon

[edited by - Peon on March 2, 2003 11:05:05 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Although the RUNTIME for directx is backward compatible, the SDKs are usually not.

Meaning that you will have to hunt down the appropriate SDK and install it.

I think the first edition of the Windows Gurus book has that sdk on the cd.

Share this post


Link to post
Share on other sites
quote:

I''m tempted to just save the old one over the new, but I''m a little worried (I''ll probably just back up just in case) Could the difference be do to the fact that this machine never had anything less than DirectDraw 8?



i think you meant DirectX 8. there is no such thing as directdraw8, only direct x graphics. as far as writing over your ddraw.h.... be careful... the ddraw.ccp would not be compatable because of the different functions and whatnot. it may be hard to find, but you can get the directx7 sdk on microsoft.com, i know i did a couple of weeks ago.

----------------------
i code therefore i am.

Aero DX - Coming to a bored Monitor near you!

Share this post


Link to post
Share on other sites
I''m sure I have the ddraw.cpp too (that goes with my old ddraw.h) but yeah, like I said, I need to make sure to back it up. I''ll probably end up looking for the SDK instead. Would it interfere with an existing DirectX8 SDK (I think I did install the DX8 SDK, at some point)

Share this post


Link to post
Share on other sites
i''m a bit of a n00b but can''t you just define the directx version to be something else? AFAIK the SDKs are backwards compatible (you can still use the DDraw7 in DX8 if you define the SDK version to be 7).

maybe someone knows about this..

__________________________________________
you just think i''m here. i''m really not.

Share this post


Link to post
Share on other sites
it wont conflict, just make sure you unlink the DX 8 sdk before linking your compiler to another version. keep the sdks in seperate folders.

----------------------
i code therefore i am.

Aero DX - Coming to a bored Monitor near you!

Share this post


Link to post
Share on other sites
Mmm... well, I downloaded the DirectX 9 SDK (after trying to do the DX6 one) and it does work now... but I still have problems; this time it is with SetDisplayMode (currently returning DDERR_UNSUPPORTED). I will post my code just once to see if anyone has an idea of what''s wrong, otherwise I may just give up and just start anew with DirectX9


  class cDirectDraw
{
public:
cDirectDraw(HWND hwnd); //default constructor


void init(); //initalization procedure


private:

HWND myWindow; //handle to the main window

LPDIRECTDRAW lpdd; //used to hold initial interface

LPDIRECTDRAW4 lpdd4; //use d to hold the interface we will use


};

cDirectDraw::cDirectDraw(HWND hwnd)
{
//set all the initial objects to NULL

lpdd = NULL;
lpdd4 = NULL;

//grab the handle to the window and copy it

myWindow = hwnd;
};

void cDirectDraw::init()
{
if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL)))
{
MessageBox(NULL, "Direct Draw Interface cannot be retrieved!", "DirectDraw error", MB_OK);
}//endif


if (FAILED(lpdd->QueryInterface(IID_IDirectDraw4, (LPVOID *)&lpdd4)))
{
MessageBox(NULL, "Cannot obtain DirectDraw 4 object!", "DirectDraw Error", MB_OK);
}//end of


if (FAILED(lpdd4->SetCooperativeLevel(myWindow, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE)))
{
MessageBox(NULL, "Cannot set cooperative level!", "DirectDraw Error", MB_OK);
}//endif


//if (FAILED(lpdd4->SetDisplayMode(1024, 780, 8, 0, 0)))

if ((lpdd4->SetDisplayMode(800,640,32,0,0)) == DDERR_UNSUPPORTED)//I tried a bunch of errors returned from this function, and found out that it was returning DDERR_UNSUPPORTED

{
MessageBox(NULL, "Cannot set display mode!", "display Error", MB_OK);
}

//MessageBox(NULL, "success!", "success", MB_OK);h


};

Share this post


Link to post
Share on other sites
quote:

...this time it is with SetDisplayMode (currently returning DDERR_UNSUPPORTED...



That would more than likely be because your video driver doesn't know how to build the requested mode and DirectDraw is telling you it's unsupported. 800x640 isn't a standard video mode.

I'd suggest trying 800x600

i.e. SetDisplayMode(800,600,32,0,0)

[edited by - Fingolfin on March 5, 2003 9:24:59 AM]

Share this post


Link to post
Share on other sites
BTW, of course

LPDIRECTDRAW4 lpdd4;

works with the DirectX 9.0 SDK. Right in ddraw.h you can find:


typedef struct IDirectDraw FAR *LPDIRECTDRAW;
typedef struct IDirectDraw2 FAR *LPDIRECTDRAW2;
typedef struct IDirectDraw4 FAR *LPDIRECTDRAW4;
typedef struct IDirectDraw7 FAR *LPDIRECTDRAW7;


Why not use LPDIRECTDRAW7 lpdd7. That''s been around since DirectX 7.

Share this post


Link to post
Share on other sites
Fingolfin: Well, I have been using iDirectDraw4 simply because LaMothe does in the version of the book I have, and it makes it easier to follow if I do the same. I''m not really familiar with DirectX, so I figure I need to understand why his code works, before I can write my own, original code.

And yep, that did it alright; I had a weird video size I think what happened is that I got mixed up with the _40x480 mode. In my original test, I put 780, instead of 768, the _80 part coming from the smaller 480 mode. Wheeee, how stupid of me Not only did I use a weird size, but I did it TWICE. Thanks a bunch!

Peon

Share this post


Link to post
Share on other sites