Skip to main content
GameDev.net gamedev.net
🔒 Locked

IDirectDraw7::GetAvailableVidMem Question

Started by KuroKage Mar 22, 2005 at 4:10 AM 0 replies 2.7k views
Original Post
KuroKage
KuroKage
Hi, Is this function accurate? I've tried to remove/add surfaces just to see if its value is changing but it isn't. Why is that? am I doing it correctly. The SDK shows // For this example, the lpDD variable is a valid // pointer to an IDirectDraw interface. LPDIRECTDRAW7 lpDD; DDSCAPS2 ddsCaps2; DWORD dwTotal; DWORD dwFree; HRESULT hr; hr = lpDD->QueryInterface(IID_IDirectDraw7, &lpDD); if (FAILED(hr)) return hr; // Initialize the structure. ZeroMemory(&ddsCaps2, sizeof(ddsCaps2)); ddsCaps2.dwCaps = DDSCAPS_TEXTURE; hr = lpDD->GetAvailableVidMem(&ddsCaps2, &dwTotal, &dwFree); if (FAILED(hr)) return hr; and this is what I'm actually doing. I'll just have to get the value stored in dwFree right? Still not working! HELP! THANKS IN ADVANCE!!
Daerax
Daerax
I did not delve into 3D in less than DirectX 8 but a quick look here indicates that your code is correct. It seems the value returned is strongly correlated with how many textures you have loaded unto surfaces and how your card handles textures. It could be you are not doing enough to really illicit a change, especially on a more modern card. Try changing this line:
ddsCaps2.dwCaps = DDSCAPS_TEXTURE;

to
ddsCaps2.dwCaps = DDSCAPS_VIDEOMEMORY;

and see what happens. Chances are though, that this function is no longer supported by cards as those method of texture and surface management are dated. A better way to check how much memory you have that is not based around texture support of probably broken directdraw interfaces is to make a call to get the device caps.

        DDCAPS hel, hal;////////////////////////////////////////////////////////	memset(&hel,0,sizeof(hel));	hel.dwSize = sizeof(hel) ;	memset(&hal,0,sizeof(hal));	hal.dwSize = sizeof(hal) ;////////////////////////////////////////////////////////	lpdd->GetCaps(&hal, &hel);            char           txt[100];        int VidMemFree = hal.dwVidMemFree / 1024000, VidMemTot =  hal.dwVidMemTotal / 1024000;    	sprintf(txt, "Video Memory Free: %d MB,  Total Video Memory: %d MB",VidMemFree,VidMemTot);   	MessageBox(hwnd,txt,"PC Info", MB_OK | MB_ICONASTERISK);

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.