Archived

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

v3ct0rm4yh3m

Direct Draw Surface Trouble

Recommended Posts

// I''m running into a slight problem while adding a new surface to an already // working method. The new Surface is used for a menu image but will not render // properly. // Here is the chunk of good code that presently works as expected. I''ve got an // entity class that holds the position on the screen and it''s current frame in // a large image of animation sets. Works great. backSurface.DrawFast(entityPosition.X, entityPosition.Y, entitySurface, entity.CurrentFrame, DrawFastFlags.SourceColorKey); frontSurface.Flip(backSurface, FlipFlags.DoNotWait); // I now need to draw an image at the top of the screen. I created menuSurface // and loaded it up with the menu image. I used the backSurface drawfast, like // i used for the entity. backSurface.DrawFast(entityPosition.X, entityPosition.Y, entitySurface, entity.CurrentFrame, DrawFastFlags.SourceColorKey); backSurface.DrawFast(0, 0, menuSurface, Menu.Region, DrawFastFlags.SourceColorKey); frontSurface.Flip(backSurface, FlipFlags.DoNotWait); // The result of this is a big fat error. It seems that my rectangle is out of // the blt region, not sure if the region in question is from the backSurface // or the frontSurface. In an attempt to track down the problem, I changed the // menu draw to the following. // Leaving out the srcRegion parameter. backSurface.DrawFast(0, 0, menuSurface, DrawFastFlags.SourceColorKey); // The app runs now, but my menu does not size properly, it''s all shrunk up. // I really have no clue as to what''s going on, is one of my surfaces being resized? // Any help will be greatly appriciated.

Share this post


Link to post
Share on other sites
// Thanks for everyone who responded, helped me find the problem.
// The culprit was in my initialization of the surface itself.

description.Clear();
m_StandardShipSurface = new Surface(m_Game.ResourceDirectory + "StandardShipSurface.bmp", description, m_Device);
m_MenuSurface = new Surface(m_Game.ResourceDirectory + "MenuBackground.bmp", description, m_Device);
m_ReticuleSurface = new Surface(m_Game.ResourceDirectory + "Reticule.bmp", description, m_Device);

// I was reusing the description and didn''t realize that it was being modified by the previous surfaces
// My menu surface was the same size as my entity surface. The following fixed it.

description.Clear();
m_StandardShipSurface = new Surface(m_Game.ResourceDirectory + "StandardShipSurface.bmp", description, m_Device);
description.Clear();
m_MenuSurface = new Surface(m_Game.ResourceDirectory + "MenuBackground.bmp", description, m_Device);
description.Clear();
m_ReticuleSurface = new Surface(m_Game.ResourceDirectory + "Reticule.bmp", description, m_Device);

Share this post


Link to post
Share on other sites