Jump to content
  • Advertisement
Sign in to follow this  
tadobie

scrolling

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

Can anyone explain to me how to display part of a surface that is larger than the full screen size using direct draw? I want to scroll a large background and place a backdrop on the screen that is clipped from a large image. Thanks

Share this post


Link to post
Share on other sites
Advertisement
When you call the surface's Blt() / BltFast() function, you can pass in a RECT which gives the region of the surface to transfer, so you can select which part of your backdrop to show on the screen at any one time.

From the MSDN docs:

HRESULT Blt(
LPRECT lpDestRect,
LPDIRECTDRAWSURFACE lpDDSrcSurface,
LPRECT lpSrcRect,
DWORD dwFlags,
LPDDBLTFX lpDDBltFX
);

lpSrcRect
Points to a RECT structure that defines the upper left and lower right points of the rectangle on the source surface which is to be blted from.

So, for example:


// Define the backdrop offset
int backdropX = 240;
int backdropY = 200;
// Create a rectangle
RECT rcSrc = {backdropX, backdropY, backdropX + screenX, backdropY + screenY};
// Blit to the screen using the source rectangle
m_pSurface->Blt(... &rcSrc ...);

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!