Sign in to follow this  
jdub

[SlimDX]Program seems to jump

Recommended Posts

I am running on a fairly new system (Duo T3700 with Geforce 8600GS) and I am using a tight rendering loop like the following: while No Messages in Que Clear() RenderGame() Present() endWhile I have noticed that my program seems to jump every few frames and I am wondering what this could be due to. Any Ideas on how to fix this problem?

Share this post


Link to post
Share on other sites
how about this:


//Main rendering function
private void Render(long ellapsed, long total)
{
graphicsDevice.Clear ( ClearFlags.Target | ClearFlags.ZBuffer, System.Drawing.Color.Black.ToArgb(), 1.0f, 0 );
graphicsDevice.BeginScene ();

humanView.VRender ( ellapsed, total );

graphicsDevice.EndScene ();
graphicsDevice.Present();
}




//Human View VRender()
public virtual void VRender(long ellapsed, long total)
{
//Draw the elements in reverse order NOTE: there are no screen elements in this list now
foreach (IScreenElement se in screenElements)
{
se.VRender ( ellapsed, total );
}

drawSprite.Begin ( SpriteFlags.AlphaBlend);
drawFont.DrawString ( drawSprite, "Hello World", x, y, System.Drawing.Color.Red.ToArgb () );
drawSprite.End ();

y++;
x++;
}




The program doesn't get really choppy, like a lagging game would. It just slows down from 60fps to about 15fps every second or so. I don't know why.

and also, how do I profile my application? I have never done this before.

EDIT: I tried rendering 100 fonts and still got about the same FPS rate so I don't think it has to do with my computer being slow.

Share this post


Link to post
Share on other sites
Quote:
Original post by jdub
how about this:

*** Source Snippet Removed ***

The program doesn't get really choppy, like a lagging game would. It just slows down from 60fps to about 15fps every second or so. I don't know why.

and also, how do I profile my application? I have never done this before.

EDIT: I tried rendering 100 fonts and still got about the same FPS rate so I don't think it has to do with my computer being slow.


Yeah. That's about as useful as posting no code at all. Honestly, profile first.

Share this post


Link to post
Share on other sites
What do set your device's present parameters too? I've seen PresentInterval.Default falling back to 30fps or 15fps at times and it may be a better idea to use PresentInterval.One

Another thing may be if all your screen elements use Sprite.Begin and Sprite.End as well. Given what little source you have shown, there is a strong chance you could reuse the same Sprite for all your screen elements having a single Begin and End pair.

Showing your render loop itself may also help.

Regards,
ViLiO

Share this post


Link to post
Share on other sites
Some other thoughts: if you're debugging inside Visual Studio, you could see a significant slow down, especially if you have unmanaged debugging turned on.

Are you using the recommended application message loop, or trying to do your drawing inside of OnPaint or similar?

If you're using the sample framework, you should know that by default it has a fixed time step so you won't be able to exceed it until you disable it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this