Archived

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

cb007sax

DirectDraw in a window

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