Jump to content
  • Advertisement


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


DirectDraw in a window

This topic is 5927 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 was wondering if anyone had an example of what I''m looking for. I want a window in directdraw that you can resize, and when resized, it doesn''t stretch or narrow the drawing, it just clips over it, like in the starcraft map editor. If you resize the window or the map, it doesn''t scrunch it up, it just draws less of it. My code scrunches my surfaces up. does anyone have some code of how to draw and setup the surface. Also, if i wanted to have a big map, say like a starcraft map or something, would i make the map on one huge surface? or make one viewing surface, or what? Thanks.

Share this post

Link to post
Share on other sites
I am in the middle of doing a windowed DirectDraw utility (and I have another problem, as my thread indicates) but I can help you with this.

The image is scaled because you are blitting the entire source surface to the client area of your window. What you need to do is blit only the portion of the source surface that would fit in the client area.


RECT rcRectSrc; //source rectangle

RECT rcRectDest; //destination rectangle

POINT org = {0, 0}; //origin of client area

//what is the coordinate of the origin relative to the top left corner of the screen?

ClientToScreen(m_hwnd, &org);

//obtain the location of the client area in client coordinates

GetClientRect(m_hwnd, &rcRectDest);

//copy client rect to source rect

CopyRect(&rcRectSrc, &rcRectDest);

//translate the client rectangle by org

OffsetRect(&rcRectDest, org.x, org.y);

//do the blt

lpPrim->Blt( &rcRectDest, lpBack, &rcRectSrc, DDBLT_WAIT, NULL);

That is the code that works for me. If you copy the whole back buffer into a reduced window everything is going to be scaled. Only blt a region the size of the client area.

Share this post

Link to post
Share on other sites
Thanks it worked! But it only displays teh surface if the window is the same size or smaller, is that correct?

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!