Jump to content
  • Advertisement

Archived

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

aprill

windowed direct draw problem

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

I''m working on a simple ddraw program that draws a bitmap from a file in a windowed display. the image draws in the right place, but is a garbled mess(or not the image at all). I think the problem lies in the code below. The only thing i do outside this routine is standard windows stuff and initialization of the primary surface. I blt the ddbg surface, created below, to the primary surface in my winmain after displaying the window but before entering the message loop. Any help would be greatly appreciated. HRESULT MakeDDSFromBmp(){ HBITMAP hbmp = NULL; BITMAP bmp; HRESULT hr; DDSURFACEDESC ddsd; HDC hdcbmp = NULL; HDC hdcdd = NULL; hbmp = (HBITMAP) LoadImage(NULL, "animate.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION); if(hbmp == NULL) return E_FAIL; GetObject(hbmp, sizeof(bmp), &bmp); 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; //ddobject is Global LPDIRECTDRAW //ddbg is Global LPDIRECTDRAWSURFACE if(FAILED(hr = ddobject->CreateSurface(&ddsd, &ddbg, NULL))) return hr; if(FAILED(hr = ddbg->Restore())) return hr; if(FAILED(hr = ddbg->GetDC(&hdcdd))) return hr; hdcbmp = CreateCompatibleDC(hdcdd); if(hdcbmp = NULL) return E_FAIL; SelectObject(hdcbmp, hbmp); //StretchBlt(hdcdd, 0, 0, ddsd.dwWidth, ddsd.dwHeight, hdcbmp, 0, 0, bmp.bmWidth, //bmp.bmHeight, SRCCOPY); BitBlt(hdcdd, 0, 0, bmp.bmWidth, bmp.bmHeight, hdcbmp, 0, 0, SRCCOPY); ddbg->ReleaseDC(hdcdd); DeleteDC(hdcbmp); return S_OK; }

Share this post


Link to post
Share on other sites
Advertisement
Please forgive my utter incompetence as a programmer. After re-tooling this code for several hours in several different ways I noticed that I was setting my device context to NULL in an if statement.... You can''t imagine my embarrassment. I''ve thoroughly slapped myself, and am preparing to copy and paste this lesson in humility on other the message boards where I hopefully haven''t wasted too much of anyone elses time.... Sincerest apologies

Share this post


Link to post
Share on other sites

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