Archived

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

wannabe H4x0r

inexplicable directinput lag... figure this out

Recommended Posts

wannabe H4x0r    122
my program is experiencing some bad input lag (the mouse cursor displays smoothly for a second or so and then the mouse stops for a split second and jumps to its new location a moment later, these jumps are anywhere from barely noticeable to perhaps almost a second delay) and i was wondering if anyone can diagnose the problem. the program is set up like this: i''m running directx8.1 both keyboard and mouse are foreground and nonexclusive i used to have keyboard and mouse on buffered data but in an effort to solve the problem i changed the mouse to immediate, but no solution the program goes into its own loop without ever going into the windows event loop the only thing the program does in an iteration is get input and display output. so far all the program displays is a screen-covering bitmap and a mouse cursor (the mousecursor is drawn with d3dx sprite as showcursor is turned off) the program runs at a consistent 75-77 fps according to queryperformancecounter but for some bizarre reason, the mouse still jumps even though this program is about as simple as you could get! when i turn off rendering and turn on the showcursor, the mouse is responsive, but at 75fps i cant believe the graphics is causing the lag and even if it did i have no idea how to fix that. what am i supposed to do? turn on the directX showcursor() ? multithread my program?? and even if the input was on another thread, there''s no way i can display it constantly because graphics is on the other thread! (assuming graphics is causing the lag) commercial directx titles don''t seem to suffer from such problems, the mouse cursors in those programs always keep up with input even though sometimes moving over a button theres a lag before the button lights up, etc. so obviously there''s some way to achieve a reasonable degree of input independence. any of you experts care to share?? i am stuck

Share this post


Link to post
Share on other sites
bergfald    122
I got this problem a while ago.. don''t remember exactly what I did, but I believe it was some nasty peaks in the m_fElapsedTime which caused the problem. At least that problem made the fullscreen view very jaggy (because every other m_fElapsedTime was 10 times larger that the one before).

I made the hax in d3dApp.cpp to smooth things out (DX8)CD3DApplication::Render3DEnvironment()
{

///blabla

// FrameMove (animate) the scene
if( m_bFrameMoving || m_bSingleStep )
{


if(!m_bWindowed)
{

static float fLastTime = 0.0f;
static float fLastElapsed = 0.0f;

static float fAppTime = DXUtil_Timer( TIMER_GETAPPTIME );

// static bool bAnnenhverFrame = true;


m_fElapsedTime = (fElapsedAppTime + fLastElapsed)/2.0f;
fLastElapsed = fElapsedAppTime;

fAppTime += m_fElapsedTime;

m_fTime = fAppTime;

}
else
{
m_fTime = fAppTime;
m_fElapsedTime = fElapsedAppTime;


}

// Store the time for the app
// m_fTime = fAppTime;
// m_fElapsedTime = fElapsedAppTime;

// Frame move the scene
if( FAILED( hr = FrameMove() ) )
return hr;

m_bSingleStep = FALSE;
}

//blablabla....
}


MenTaL

Share this post


Link to post
Share on other sites
wannabe H4x0r    122
i''m not using the d3dapp wrappers or anything, just plain native win32 program here; i turned on the direct3d hardware cursor and it works fine now, i still don''t know why the input lags so much

Share this post


Link to post
Share on other sites
Osc    122
This may be your problem:

"the program goes into its own loop without ever going into the windows event loop"

Try pumping the windows message queue until it''s empty, at the start of every frame.

Share this post


Link to post
Share on other sites