Jump to content
  • Advertisement

Archived

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

uncleben

enumeration of ddraw

This topic is 6054 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 some problems with the enumeration of ddraw devices. when i get the ddraw device with null as guid it works fine, but if i get it with a enumerated GUID, it doesn''t. AVATAN RPG ENGINE http://www.avatan.de.vu

Share this post


Link to post
Share on other sites
Advertisement
Make sure you copy the *whole* GUID, - *do not* copy just the pointer which is passed to the enumeration function because what the pointer points to is temporary for the enum call and will be invalid later on.

Here''s some pseudo code based on the engine of the last DX7 based game I worked on (Pac-Man:AIT for Hasbro):


  
typedef struct
{
GUID ddGuid;
GUID ddDriverGuid;
}
gfxDEVICEINFO;


gfxDEVICEINFO g_deviceInfo;


BOOL WINAPI gfxDDEnumCallbackEx( GUID* lpGUID, LPSTR lpszDesc, LPSTR lpszName, LPVOID lpContext, HMONITOR hm )
{
...

if (lpGUID)
{
// if GUID is non-NULL, copy to dev structure

memcpy( &g_deviceInfo.ddGuid, lpGUID, sizeof(GUID) );
}


LPDIRECTDRAW7 lpDD;
hr = _DirectDrawCreateEx( lpGUID, (LPVOID *)&lpDD, IID_IDirectDraw7, NULL );
if (FAILED(hr))
{
// can''t create a DD interface, skip this device

return TRUE;
}

...
DDDEVICEIDENTIFIER2 dddi[2];
hr = lpDD->GetDeviceIdentifier( &(dddi[0]), 0 );
if (SUCCEEDED(hr))
{
memcpy( &dev.ddDriverGuid, &dddi.guidDeviceIdentifier, sizeof(GUID) );
}
...

lpDD->Release();

...
}


We used the DD device to do things like get the device identifier, get the available modes, enumerate D3D devices etc.

Since you''re doing enumeration stuff, something you''ll probably come across is a bug in GetDeviceIdentifier() which trashes a few past the end of the structure you pass it. You''ll note that I make an array of device identifiers to prevent any trashing problems.

In a real world app you''d collect all the validly enumerated devices in an array and present a list to the user.

BTW: the DirectX 7 SDK has sample code which handles multiple device enumeration correctly.


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
Actually - another thought - is it the DirectDrawCreate call which is failing or something later ?

The reason I ask is because needing a GUID to create a device implies the use of a secondary card such as a 3Dfx Voodoo2. If it fails later on, it could also be a result of trying to do stuff which the card doesn''t support, such as 32bit screen modes or large surfaces.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
the problem is that on some computers, my game runs very slow, and on others it runs perfectly. thats why i wanted to try enumeration to make sure that the right device is used

AVATAN RPG ENGINE
http://www.avatan.de.vu

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!