Jump to content
  • Advertisement
Sign in to follow this  
Guest cpp-guy

Need help with DIRECTDRAWSURFACE::Blt()

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

Guest cpp-guy
OK, so here's my problem. I've created an MFC CWnd class that wraps DirectDraw. I'm trying to use Blt to stick an image onto the surface used to draw the CWnd in its OnPaint handler Here's what I do (Note: I'm using LPDIRECTDRAWSURFACE, LPDIRECTDRAW, and DDSURFACEDESC... Not LPDIRECTDRAWSURFACE7, LPDIRECTDRAW7, and DDSURFACEDESC2... and my video card is incredibly bad) 1. I create the front surface for the CWnd using the following surface description: SurfDesc.dwSize = sizeof(SurfDesc); SurfDesc.dwFlags = DDSD_CAPS; SurfDesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; 2. I create a back surface for flipping using this description SurfDesc.dwSize = sizeof(SurfDesc); SurfDesc.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; SurfDesc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; SurfDesc.dwWidth = in_unWidth; SurfDesc.dwHeight = in_unHeight; 3. I create a 3rd surface that I want to use Blt to draw to the back surface. (in_bmp is the bitmap class that stores my image) Desc.dwSize = sizeof(Desc); Desc.dwWidth = in_bmp.GetWidth(); Desc.dwHeight = in_bmp.GetHeight(); Desc.dwFlags = DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT; Desc.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; Desc.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); Desc.ddpfPixelFormat.dwFlags = DDPF_RGB; Desc.ddpfPixelFormat.dwRGBBitCount = 32; Desc.ddpfPixelFormat.dwRBitMask = 0x000000FF; Desc.ddpfPixelFormat.dwGBitMask = 0x0000FF00; Desc.ddpfPixelFormat.dwBBitMask = 0x00FF0000; 4. I fill the 3rd surface with a test image and if I lock it, I can see in the mem view in Visual Studio that there is valid image data there. 5. The code works such that - the back surface is cleared m_pBack->Blt(rcClear, NULL, NULL, DDBLT_COLORFILL|DDBLT_WAIT, &BltFX); *WORKS!!!* - the back surface get's locked m_pBack->Lock(NULL, &SurfDesc, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT, NULL) *WORKS!!!* - some things get drawn to the back surface *Nothing right now but potentially there is something drawn* - the back surface get's unlocked *WORKS!!!* - the 3rd surface is Blted to the back surface using: m_pBack->Blt(&rcDst, in_pSrc, &rcSrc, DDBLT_WAIT, NULL); *works only if rcDst and rcSrc are the same width and height!!!* - the back is locked again - a few more things are drawn to the back surface - the back is unlocked a final time - the back is flipped to the front m_pFront->Blt(&rcDest, m_pBack, &rcSrc, DDBLT_WAIT, NULL); *WORKS!!!* Sorry for the long description... my question is why does Blt fail when I'm trying to scale? Blt succeeds everywhere else in the code. And even when I use different sized rects for the src and dst, the return code is S_OK. But instead of drawing a scaled version of the 3rd surface, it draws a dark blue-gray rectangle. Somebody please help. This is very frustrating!!! :)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!