• Advertisement

Archived

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

Strange new problem

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

Hi all, I have been writing a game for a while now in DX9. I had got to a pretty decent stage when things have now gone t*ts up. Basically my game used to run nice and smoothly. Now all of a sudden when the camera rotates its jerking around instead of doing a nice smooth movement. The FPS is around 47 so that shouldn''t be causing it. Movement of the camera is based on the elapsed time
VOID TimeInterval(void)
{

   // Get the time in milliseconds (we convert to second by * 0.001).
   float currentTime = timeGetTime() * 0.0001f;


   // Calculate the frame interval by the current time minus the last frame''s time.
   g_fFrameInterval = currentTime - g_flastFrameTime;
   g_flastFrameTime = currentTime;
}
 
and then move things like this
		//move the object forward

		g_MainCharacter.MoveMesh(Direction,1.0f,g_fFrameInterval);
		//rotate the object

		g_MainCharacter.CalculateMeshRotation(g_Camera.m_CamPos);
		//move the camera forward

		g_Camera.MoveCamera(1.0f,g_fFrameInterval);
		//check for collisions

		collisionResult = MainCharacterCollisions();
I know this sounds really stupid but i''m convinced its something outside of my programming. I''ve even cut down the rendering to just draw the main character and display the frame rate, basically skipping over everything else in the code, and the framerate does not get any better. Has anyone had any similar experiences or can suggest what is going wrong! I''m compiling with /clr and multi-thread if thats any extra use. Cheers DRb2k2

Share this post


Link to post
Share on other sites
Advertisement
I had the same problem that just started happening after I got a new LCD monitor. Every 4 or 5 frames I would get a 4x frame time resulting in jerky camera movements.

The first thing I tried was to use QueryPerformanceCounter instead of timeGetTime. It seemed to instantly fix the problem. The next day the problem happened again for no apparent reason. I killed everything else running in the background and stripped my scene down to almost nothing. Still really bad hiccups.

I then tried running it fullscreen (I usually run in a window for debugging) and the frame rate totally smoothed out.
So maybe it has something to do with the LCD monitor running in a window. I have no idea. But fullscreen is fine.

Using QueryPerformanceCounter is a good idea to do though even if that doesn''t fix the problem completely. This problem sounds minor but it ate up way too much of my time.

Share this post


Link to post
Share on other sites
I had similar problems in my game too - some objects where lagging while rest was moving smoothly.

First thing is to run app in fullscreen mode as netrion mentioned. I suppose windows gives more cpu time to fullscreen dx apps.

In my case it reduced lags but they were still there.

I figured out that problem was with counting amount of movement in current frame.
Solution is somehow drastic but final - limit FPS. Make it smth about 40 FPS. Simply count time between Render calls and make sure intervals are > 0.020s

Share this post


Link to post
Share on other sites
Does it jerk only when rotating, or when moving around aswell?
I had something similar happen only when moving the mouse - the problem was I was centering the mouse every frame. Only centering it when it approached the edges of the screen cured it.
I''m not sure how things work with direct input, so this might be irrelevent.

Share this post


Link to post
Share on other sites
I printed out my time deltas between frames and I was getting something like 15 15 15 47 15 15 ...
So the jumps were a global problem that messed up movement as well. I was trying to get my collision system working at the time and the jumps made it almost impossible.

Share this post


Link to post
Share on other sites
quote:
Original post by netrion
I printed out my time deltas between frames and I was getting something like 15 15 15 47 15 15 ...



Same here. Only solution i came up was limiting frame count. And its not connected with LCD - it happens on all machines. I tested my app on w2k, xp pro with both CRT and LCD and full range of CPU and GPU. Always there were lags every 5-7 frames.
(Only on Barton 2.6Ghz, 512 ram and fx5950 lags were close to zero )

Share this post


Link to post
Share on other sites
At one time I encountered issues when I was running Microsoft Netmeeting at the same time as trying to run my game code w/graphics being horribly slow. Just thought I''d throw that out there...

Regards,
Jeff


[ CodeDread ]

Share this post


Link to post
Share on other sites

  • Advertisement