[SlimDX]Program seems to jump

Started by
7 comments, last by Mike.Popoloski 15 years, 5 months ago
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?
J.W.
Advertisement
Profile and see. So far you have given us nothing to tell us what the problem could be.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

how about this:

//Main rendering functionprivate 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.
J.W.
It might be because of some other application that's running in the background.
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.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

which is why I asked: how do I profile?
J.W.
* Do any of the samples seem to jump?
* Do other, non SlimDX programs seem to jump?
* What D3D present interval are you using?
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
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
Richard 'ViLiO' Thomasv.net | Twitter | YouTube
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.
Mike Popoloski | Journal | SlimDX

This topic is closed to new replies.

Advertisement