Hello,
I have a big problem with my application. I have written a little direct3d framework to encapsulate common tasks like the renderloop and so an (basically its like the directx common framework). I've also implemented a camera class to move around, but now I've noticed that the movement is really jumpy. But even without any camera movement and with just a single spinning triangle the application moves "jumpy". The triangle doesnt rotate smooth, it seems like that every few seconds the rotation goes a little bit faster and then again it rotates normal.
I have tried to figure out the problem for days but I just dont know why it moves so laggy. It cant be the framerate, since my app is running with 300-1000 fps.
The most important parts of my code which (I guess) could relate to the problem are:
the render loop:
while(true) {
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
if(msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
onMove();
onRender(fpsCounter);
passedTime = timer.GetElapsedTime();
passedTimeTotal = timer.GetTime();
passedTimeWithinFrame += passedTime;
if(passedTimeWithinFrame >= 1.0f) {
passedTimeWithinFrame = 0;
fps = fpsCounter;
fpsCounter = 0;
}
}
Really nothing special. onMove() calls Move() and onRender() calls the Render() Method. passedTime is the time between 2 frames, passedTimeTotal is the total time the app is running. The rest is just the calulation of the framerate.
the render method:
virtual void render() {
if(FAILED(d3d9Device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(100, 100, 200), 1.0, 0)))
MessageBox(NULL, "FehlerA", "Fehler", MB_OK);
d3d9Device->BeginScene();
D3DXMATRIX world;
D3DXMatrixRotationY(&world, 3.14f*0.25f * passedTimeTotal);
d3d9Device->SetTransform(D3DTS_WORLD, &world);
d3d9Device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 1, data, sizeof(Vertex));
d3d9Device->EndScene();
d3d9Device->Present(NULL, NULL, NULL, NULL);
}
Again nothing special. Im just drawing one rotating triangle.
Since the movement of the triangle depends on passedTimeTotal I checked the values of passedTime (time between 2 frames. passedTimeTotal is just the sum of all passedTime) and got these results:
0.000276851
0.000193041
0.000183543
0.000190248
0.000267632
0.00379741
0.000319873
0.000199467
0.000185219
0.000190527
0.000390832
0.0013552
0.00018913
0.000358146
0.000302832
0.000185219
0.000192483
0.000298921
0.000438044
0.000410667
0.000423238
0.000419606
0.000430781
0.000421283
0.000436648
0.000526045
0.000340825
0.000400889
0.000432178
0.000419886
0.000424635
0.0028526
Most of the time passedTime has values like 0.000X, but sometimes the value gets bigger (for example 0.0028) which means more time passed between two frames.
Could these "jumpy" times between two frames be the problem? but even if: what can I do against it?
I hope someone was faced with the same problem or has an idea! This drives me cracy:((
thanks!
PS: I have uploaded the VS Project Files and the exe file: http://uploaded.to/?id=cn684d (I compiled with august 07 SDK)
[Edited by - schupf on September 15, 2007 11:19:07 AM]