CreateSurface Not Setting lPitch Correctly
I am loading a bitmap onto a DirectDraw surface.
The call to CreateSurface()is not setting the lPitch parameter correctly for one of the bitmap files. I am calling CreateSurface() in the following manner:
ZeroMemory( &ddsd, sizeof(ddsd) );
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = bmp.bmWidth;
ddsd.dwHeight = bmp.bmHeight;
if(FAILED(hr = pDD->CreateSurface(pddsd, &m_pdds, NULL)))
return hr;
The surface created for most of the bitmaps has an lPitch of 8192, but one of the bitmaps has a bmWidthBytes of 8196. Depending on the order with which I load the bitmaps the call to CreateSurface() either 1) creates a surface with an lPitch of 8192 (which is obviously too small) or 2) creates a surface with an lPitch of 10928 (in which case everything is fine).
Thanks
Todd
Not that it will really help me solve your problem, but I''m curious which version of DD you are using?
I am using DirectX 8.1b.
I have figured out a work-around but I don''t understand why this was happening.
If I force the surface to be in System Memory the bitmap loads fine, if I either force it into Video Memory or don''t specify then the lPitch is set incorrectly.
I believe that the program works when I change the order in which the bitmaps are loaded because I run out of Video Memory and it ends up in System Memory.
What is scary here, is that I am not getting an error message when the CreateSurface() function is called. So right now my program is putting all bitmaps into System Memory which is very inefficient.
Thanks for the help
Todd
I have figured out a work-around but I don''t understand why this was happening.
If I force the surface to be in System Memory the bitmap loads fine, if I either force it into Video Memory or don''t specify then the lPitch is set incorrectly.
I believe that the program works when I change the order in which the bitmaps are loaded because I run out of Video Memory and it ends up in System Memory.
What is scary here, is that I am not getting an error message when the CreateSurface() function is called. So right now my program is putting all bitmaps into System Memory which is very inefficient.
Thanks for the help
Todd
This is a driver bug. If you don''t specify the memory type for the surface, the video driver gets first crack at trying to create it. If it fails, then the DDraw will allocate the surface in system memory. From what you''ve described, the video driver isn''t failing the creation of the surface, even though it''s unable to create an offscreen plain surface with a pitch greater than 8K bytes.
What display hardware exhibits this problem? I''m assuming you''ve got the latest driver from the manufacturer''s website?
Does the driver report DDCAPS2_WIDESURFACES support?
What display hardware exhibits this problem? I''m assuming you''ve got the latest driver from the manufacturer''s website?
Does the driver report DDCAPS2_WIDESURFACES support?
I am getting the error on an IBM T20 laptop.
I will check the WIDESURFACES flag. I scanned through the emails on this web site and someone else (addressing a similiar problem) pointed out that some older video cards aren''table to generate offscreen surfaces that were larger than the primary surface.
I will check for the newest drivers and in the future will check this flag in my code!
Thanks alot for helping me with this. Its taken me a some time to get to the heart of this one!
Todd
I will check the WIDESURFACES flag. I scanned through the emails on this web site and someone else (addressing a similiar problem) pointed out that some older video cards aren''table to generate offscreen surfaces that were larger than the primary surface.
I will check for the newest drivers and in the future will check this flag in my code!
Thanks alot for helping me with this. Its taken me a some time to get to the heart of this one!
Todd
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement