# Surface doesn't draw after Restoring it

This topic is 4724 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, everyone! I have a little problem with DirectX: After creating a Surface that is stored on video memory ( DDSCAPS_VIDEOMEMORY ), the surface draws well on full-screen. But when I minimize the application and come back to it, I see nothing ( I did include restoring the Surface if it is lost ). I tried storing the Surface on system memory ( DDSCAPS_SYSTEMMEMORY ). That way it fully works, but I think that it would be better to store them in video memory when possible. Here is my code:
//-----------------------------------------------------------------------------
// Func: cSprite(int FrameNumber, int width, int height, LPCSTR szBitmap,
//					 LPDIRECTDRAW lpdd, COLORREF rgb, int SkipFrame)
// Desc: Create the bitmaps and surfaces from a bitmap file.
//-----------------------------------------------------------------------------
cSprite::cSprite(int FrameNumber, int width, int height, LPCSTR szBitmap,
LPDIRECTDRAW lpdd, COLORREF rgb, int SkipFrame)
{
FrameSkip=SkipFrame; // play speed ( 1 = fastest, 10 = very slow )
NumFrames*=FrameSkip;
CurrFrame=0;
rect.bottom=height;	rect.right=width;
rect.left=0;		rect.top=0;
frames=new LPDIRECTDRAWSURFACE[NumFrames];

DDSURFACEDESC ddsd;
ddsd.dwSize=sizeof(ddsd);
ddsd.dwFlags=DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH;
ddsd.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;
ddsd.dwHeight=height;
ddsd.dwWidth=width;

for(int i=0; i&lt; NumFrames; i++)
{
lpdd-&gt;CreateSurface(&ddsd,&frames,NULL);
DDSetColorKey(frames,rgb);
}
}



##### Share on other sites
I haven't touched DirectDraw in a very long time, so this may be completely wrong. I seem to recall that restoring a video memory surface simply enables the surface for reuse, it does not restore the contents of the surface, so you would need to reload the data.

Or I could be completely wrong. It's been years...

##### Share on other sites
That's right -- you're responsible for recreating the contents of the surface in this case. If you were dealing with vertex buffers, you'd be reponsible for recreating the vertex data.

##### Share on other sites
Drunken Hyena is correct all it does is restore the surface, you will need to reload the image back into the surface. So here is a rule of thumb, for big images store them in system memory so you do not have to load them again, just in case you get a lost device, and for small images have them in video memory since they can be loaded very fast, if you get a lost device.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 10
• 9
• 9
• 11
• 11
• ### Forum Statistics

• Total Topics
633685
• Total Posts
3013323
×