Hello,
I am quite new to DirectX, using DirectX March 2008 with C++.
I have started on "2D" project first (actually it is 3D, but its plane with zero z-coordinates) - Arkanoid - using manually vertex (and index) buffer.
Now i have started 2nd project in 3D, using D3DXMesh (loaded from x-file).
Both projects have the same serious problems -
strange lags (on some pcs, on some the lags will appear if you start the application two times or more). Don't know what i have missed. Maybe some settings with D3D or wrong timing? I'll try to little describe my code (
I could upload whole VS solution, if it helps).
1) setting D3DPRESENT_PARAMETERS
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
2) setting Render-state
// Turn on the zbuffer
g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
// Turn on ambient lighting
g_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0xffffffff );
3) Arkanoid: Filling vertex and index buffer (few quads) / 2nd project: Loading 3 very basic models
4) Rendering:
a) timing (originally different, now from article on gamedev - didn't help):
do{
g_dwFrameEndTime = timeGetTime();
} while (g_dwFrameStartTime==g_dwFrameEndTime);
g_dwFrameTime = g_dwFrameEndTime - g_dwFrameStartTime;
g_dwFrameStartTime = g_dwFrameEndTime;
b) setting coords of objects (speed * g_dwFrameEndTime/1000.f)
c) cleaning buffers, starting scene
d) setting view and projection matrices
e) setting lights - only in 2nd project
f) drawing polygons (DrawIndexedPrimitive / DrawSubset)
g) ending scene, Present() method
Nothing moves smoothly, don't know what is wrong :-( Even if FPS is high (if not v-syncing), no smooth movement can be seen :-(
Thanks.
PS: Sorry for my english