Archived

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

getting caps

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

Im trying to get the caps of my video card. LPDDCAPS HALcaps, HELcaps; lpdd->GetCaps(HALcaps, HELcaps); scanf(cbuffer, "free mem: %d", HALcaps.dwVidMemFree); lpdds->GetDC(hdc); TextOut(hdc,10,10, cbuffer, strlen(cbuffer)); I keep on getting 0 as a result. But when I use the the DirectX utility to look at caps, I see that I have 45mb. What is the a good way to get caps?

Share this post


Link to post
Share on other sites


1) "LPDDCAPS HALcaps, HELcaps;": umm, that''s a Long Pointer to a DDCAPS structure...
...but it doesn''t point to anything

2) If you read the docs you''ll see that the dwSize member needs to be initialised

3) Because the above two things aren''t done, I''m almost certain that the GetCaps call is failing. It will be returning an error code (which you don''t check for!) AND will be reported to the debug output stream (which you don''t seem to have looked at).

4) "scanf()"? - If look at the documentation for scanf() it says "Read formatted data from the standard input stream.", I don''t think you want the user of your program to enter the total memory size do you

5) IDirectDrawSurface*::GetDC() takes a pointer to a HDC structure, I''ve got a sneaky feeling you''ve done the same as you did with the DDCAPS (i.e. changed the type to make the compilation errors go away rather than setting up the correct object).

6) I''ll assume you are releasing the DC you got (if you don''t the machine will slowly grind to a halt!)

7) Since you''re only using the HAL caps you can pass NULL for the HEL caps pointer.

8)

//
// an object, not a pointer to an object!
DDCAPS caps;

//
// clear the whole structure
memset( &caps, 0, sizeof(DDCAPS) );

//
// set the size member as documented
caps.dwSize = sizeof(DDCAPS);

//
// get HAL caps AND error return code
HRESULT hr = lpDD->GetCaps( &caps, NULL );
if (FAILED(hr))
{
// perform appropriate error handling here
return false;
}

//
// A device context handle, not a pointer a device context handle
HDC hdc;
hr = lpDDS->GetDC( &hdc );
if (FAILED(hr))
{
// perform appropriate error handling here
return false;
}

//
// create a temporary 64 character buffer
char cbuffer[64];

//
// String PRINT Formatted
sprintf( cbuffer, "free mem: %d", caps.dwVidMemFree );

//
// output the text
TextOut( hdc, 10, 10, cbuffer, strlen(cbuffer) );

//
// release the DC
lpDDS->ReleaseDC( hdc );




Personally I think you need a bit more practice at C and C++ programming before trying to tackle DirectX!

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

Share this post


Link to post
Share on other sites