Click here to Skip to main content
15,894,251 members
Home / Discussions / C#
   

C#

 
AnswerDumb attempt to bump post. Pin
Pete O'Hanlon4-Nov-09 2:41
mvePete O'Hanlon4-Nov-09 2:41 
AnswerRe: Glass Effect using dwmapi.dll in windows xp on C# Pin
Dave Kreskowiak4-Nov-09 5:20
mveDave Kreskowiak4-Nov-09 5:20 
Question[Windows Form with visual C#] - Problem with data conversion Pin
_ASPAle_4-Nov-09 1:12
_ASPAle_4-Nov-09 1:12 
AnswerRe: [Windows Form with visual C#] - Problem with data conversion Pin
OriginalGriff4-Nov-09 1:16
mveOriginalGriff4-Nov-09 1:16 
GeneralRe: [Windows Form with visual C#] - Problem with data conversion Pin
_ASPAle_4-Nov-09 2:17
_ASPAle_4-Nov-09 2:17 
AnswerRe: [Windows Form with visual C#] - Problem with data conversion Pin
Giorgi Dalakishvili4-Nov-09 1:19
mentorGiorgi Dalakishvili4-Nov-09 1:19 
AnswerRe: [Windows Form with visual C#] - Problem with data conversion Pin
Luc Pattyn4-Nov-09 2:37
sitebuilderLuc Pattyn4-Nov-09 2:37 
QuestionXNA: Game updating slowly Pin
jdneul4-Nov-09 1:06
jdneul4-Nov-09 1:06 
Hello there I am hoping that someone might be able to help me optimize my code for an XNA Program I have made, basically I have made my own custom interface in XNA, now my interface works pretty similar to the ways that windows does, however if you nest too many controls inside each other, then the game really starts to run at a slow rate (fps wise), as it obviously the draw method for the controls are taking too long.

I have tried doing a background draw (using an event via BeginInvoke and EndInvoke), but I get lots of flashing and sometimes it even crashes, as it tries to access the Sprite Batch sometimes when it is still is use

Is there another way to optimize my code that will allow me to get my performance back again??

Here is a sample of the draw code for a container object:

if (m_pTexture != null)
{
    graphicsManager.Begin();
    if (bSetupClientArea)
        graphicsManager.SetupClientRect(TranslatedArea);
    if (Image_States == 0 || Image_States == 1)
        graphicsManager.Draw(m_pTexture, TranslatedArea, new Color(255, 255, 255, (byte)Alpha));
    else
    {
        int nSubHeight = m_pTexture.Height / Image_States;
        Rectangle src = new Rectangle(0, (int)Current_State * nSubHeight, m_pTexture.Width, nSubHeight);
        graphicsManager.Draw(m_pTexture, TranslatedArea, src, new Color(255, 255, 255, (byte)Alpha));
    }
    graphicsManager.End();
    DrawBorder(graphicsManager);
}
for (int i = 0; i < m_pComponents.Count; ++i)
{
    Component component = m_pComponents[i];
    if (component.Visible)
        component.Draw(gameTime, graphicsManager, true);
}


As you can see each container has its own Rectangular Area, and it will basically use the graphics manager (which contains the sprite batch object for my XNA Program) to setup it's clip area and draw all of the contents to it, of course using this method means every container has to use begin and end from the graphics manager, to make sure that the objects are drawn correctly

Does calling the SpriteBatch.Begin and End function numerous times cause it to slow down considerably??
Or do you think something else is causing it to slow down??
AnswerRe: XNA: Game updating slowly Pin
harold aptroot4-Nov-09 5:49
harold aptroot4-Nov-09 5:49 
GeneralRe: XNA: Game updating slowly Pin
jdneul4-Nov-09 6:54
jdneul4-Nov-09 6:54 
GeneralRe: XNA: Game updating slowly Pin
harold aptroot4-Nov-09 6:58
harold aptroot4-Nov-09 6:58 
GeneralRe: XNA: Game updating slowly Pin
jdneul4-Nov-09 7:46
jdneul4-Nov-09 7:46 
GeneralRe: XNA: Game updating slowly Pin
harold aptroot4-Nov-09 9:19
harold aptroot4-Nov-09 9:19 
GeneralRe: XNA: Game updating slowly Pin
jdneul5-Nov-09 1:23
jdneul5-Nov-09 1:23 
GeneralRe: XNA: Game updating slowly Pin
harold aptroot5-Nov-09 1:27
harold aptroot5-Nov-09 1:27 
QuestionPaper Setting Problem in Dot Matrix Printer using Crystal Report. Pin
sharad Pyakurel4-Nov-09 1:00
sharad Pyakurel4-Nov-09 1:00 
QuestionUsing StreamWriter twice Pin
Trollslayer4-Nov-09 0:56
mentorTrollslayer4-Nov-09 0:56 
AnswerRe: Using StreamWriter twice Pin
Covean4-Nov-09 1:15
Covean4-Nov-09 1:15 
GeneralRe: Using StreamWriter twice Pin
Trollslayer4-Nov-09 4:01
mentorTrollslayer4-Nov-09 4:01 
GeneralRe: Using StreamWriter twice Pin
Covean4-Nov-09 5:12
Covean4-Nov-09 5:12 
AnswerRe: Using StreamWriter twice Pin
Pete O'Hanlon4-Nov-09 4:22
mvePete O'Hanlon4-Nov-09 4:22 
GeneralRe: Using StreamWriter twice Pin
Trollslayer4-Nov-09 5:40
mentorTrollslayer4-Nov-09 5:40 
GeneralRe: Using StreamWriter twice Pin
Pete O'Hanlon4-Nov-09 6:39
mvePete O'Hanlon4-Nov-09 6:39 
Questionsending receiving sms Pin
sahoo.fm4-Nov-09 0:33
sahoo.fm4-Nov-09 0:33 
AnswerRe: sending receiving sms Pin
King Julien4-Nov-09 0:46
King Julien4-Nov-09 0:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.