Advertisement

LPDIRECTDRAW7...

Started by February 05, 2000 04:08 PM
8 comments, last by Rah 25 years, 1 month ago
Hi For the past few months whilst learning DDraw, I have always used an LPDIRECTDRAW object for my program, as well as DDSURFACEDESC with no problems. What I want to know is, what are the differences between the above and LPDIRECTDRAW7/DDSURFACEDESC2 respectively. I''m guessing that what I''ve actually been using is the original interfaces from an older DDraw revision (I''m currently using DX7). What are the implications of this if I''m right? Would I get a speed improvement upgrading my DDraw object etc. Also, I''m not exactly sure how to convert to the new interfaces. Adding a ''7'' and ''2'' to each respective object didn''t seem to work Anyway, thanks for any help... -- Rah
The LPDIRECDRAW7 and DDSURFACEDESC2 are the 7th revision of the original LPDIRECDRAW and the 2nd of DDSURFACEDESC that was in the first version of DirectX.

That you''ll get by upgrading you''re directdraw object is more options.

so heres how to initialise DirecDraw with the directdraw 6 interface interface, I guess is the same way to do it with diredraw 7 interface:

// DirectDraw globals
LPDIRECTDRAW lpdd_temp = NULL; // standart DirectDraw 1.0
LPDIRECTDRAW4 lpdd = NULL; // DirectDraw 6.0 interface 4
LPDIRECTDRAWSURFACE4 lpddsprimary = NULL;

int DD_Init(int Screen_Width, int Screen_Height, int Depth)
{



// create base IDirectDraw interface
if(FAILED(DirectDrawCreate(NULL, &lpdd_temp, NULL)))
return(0);

// query for IDirecDraw4
if(FAILED(lpdd_temp->QueryInterface(IID_IDirectDraw4,(LPVOID *)&lpdd)))
return(0);

// set the cooperative level to fullscreen and allow rebooting
if(FAILED(lpdd->SetCooperativeLevel(main_window_handle,DDSCL_FULLSCREEN / DDSCL_EXCLUSIVE / DDSCL_ALLOWREBOOT)))
return(0);

// release the old interface since we don''t need it
if(lpdd_temp!=NULL)
lpdd_temp->Release();

// set the display mode to the passed parameters
if(FAILED(lpdd->SetDisplayMode(Screen_Width, Screen_Height, Depth,0,0)))
return(0);
return(1)
}

Advertisement
Check out QueryInterface. That should point you in the right direction. Then you can use Dx7. Or you can just use DirectDrawCreateEx and skip using the old interface.



Still Learning...
Still Learning...
One interesting note on Directx 7. I''ve been using the directx 6 interface without any problems for a while now, but when I switched to using directX7 there was a serious problem with the interface calculating the pitch on my video card, it made the screen look smashed. I was wondering, how can you ensure that an older game that was written to take andvantage of earlier directx versions will run properly under any new versions of directx that may come out so you that you can avoid these types of problems??? I mean, the game will run under directX 6, but not version 7?
Anonymous:
The "squished" effect you described could very well be a driver problem. I had backbuffer problems (they kept getting lost) until I finally got the latest references driver from the chip manufatcurer''s website (nvidia in this case -- and the first reference I downloaded didn''t solve the problem).

Rah:

The major differences between IDirectDraw7 objects and previous versions are improved surface management and "improved compliance with com rules" in relation to the lifetime of an object. This comes from the DX7 help file.

As to which version you should use, I''m of the opinion you should always use the latest version. Any game you release can include the redistributables of the latest DX .dlls for installation on the user''s machine. The only time this is an issue is with WindowsNT.
Right, thanks a lot for your replies... most helpful. My problem was that I thought the old LPDIRECTDRAW interface was no longer necessary, and was trying to just use LPDIRECTDRAW7 to create the base interface.

Anyway, thanks for all the help guys...

--
Rah
Advertisement
What does CreateDirectDrawEx have that the CreateDirectDraw method doesn''t? Or is it just that the older method is depreciated and soon to be removed?
DirectDrawCreateEx lets you get create an IDirectDraw7 interface pointer without having to use the QueryInterface method. To get older interfaces, you''d still need to use DirectDrawCreate (to get an IDirectDraw interface) and then QueryInterface (to get a newer version).

- Dave
CreateDirectDraw will never be removed because itneeds to remain to maintain backwards compatibility.
I''m not even sure that you can get a DirectDraw7 (or a directAnything7) interface by querying the older interfaces. I thought I read somewhere that the DX7 interfaces were not actually newer interfaces of the old stuff and were not available through a DirectDraw4->QueryInterface call.

Dr_S
Dr_S
I was wondering is the pitch of a surface just for byte alignment? Or would it be stored in the image header?
Where is your faith now?

This topic is closed to new replies.

Advertisement