Are you sure you are calculating the frame rate correctly? Maybe you''re just off by a factor of ten in the calculation. I doubt the problem is vsync, since 25Hz would be a rather uncommon refresh rate
Framerate to low..why??
Yeah but technically it was a problem so I pointed it out. But you're right; the framerate counter could be wrong. However if you count a number of frames and take the time elapsed, that will minimize the effect of unprecise timers... if that is the problem.
~CGameProgrammer( );
[edited by - CGameProgrammer on May 7, 2003 7:01:09 PM]
~CGameProgrammer( );
[edited by - CGameProgrammer on May 7, 2003 7:01:09 PM]
why is fr a char*?
You should be returning an int and then sprintf to store the result in a string which is then outputted instead of using 2 TextOuts.
char fr[256];
sprintf (fr,"FPS: %i",GetFrameRate());
TextOut(fr);
Also, how is your framerate being calculated? It''s probably wrong. An empty render loop should get you thousands of frames per second since you''re not drawing anything and therefor not limited by VSYNC.
45 is also not a valid VSYNC. He should be getting at least 60fps if that were the bottleneck.
Ben
You should be returning an int and then sprintf to store the result in a string which is then outputted instead of using 2 TextOuts.
char fr[256];
sprintf (fr,"FPS: %i",GetFrameRate());
TextOut(fr);
Also, how is your framerate being calculated? It''s probably wrong. An empty render loop should get you thousands of frames per second since you''re not drawing anything and therefor not limited by VSYNC.
45 is also not a valid VSYNC. He should be getting at least 60fps if that were the bottleneck.
Ben
True, but if he did fix the bottleneck then he''d wonder why it only added 15 fps, so I''m just mentioning the vsync thing now
~CGameProgrammer( );
~CGameProgrammer( );
Hi..its me again. :-) I dont think the calculated framerates are wrong. You SEE it..nearly a slide-show. Maybe the GeForce2 100 cant get any more fps. I changed the D3D Init Method a little bit. Original copy from a tutorial. But no result. Still only 100 fps in an empty scene.
Here are the code-snippets for the FrameCounter and the GameLoop Methods:
Here are the code-snippets for the FrameCounter and the GameLoop Methods:
//calculate the frameratechar* GetFrameRate(){ CurrentTime = timeGetTime(); TimeElapsed = (int)(CurrentTime - LastTime); FrameCount++; if(TimeElapsed > 1000) { Frames = (int)(FrameCount / TimeElapsed); LastTime = CurrentTime; infoFrame = FrameCount; FrameCount = 0; } sprintf(fps,"%d",infoFrame); return fps;}//starts the gameloopINT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT){ //registry windows class WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, WinProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, "Axel1", NULL}; RegisterClassEx(&wc); //create window int width = GetSystemMetrics(SM_CXFULLSCREEN); int height = GetSystemMetrics(SM_CXFULLSCREEN); HWND hWnd; hWnd= CreateWindow("Axel1", "Axels 3D Engine V0.1a", WS_OVERLAPPEDWINDOW, 0,0,resx,resy, GetDesktopWindow(), NULL, wc.hInstance, NULL); //Direct Input dInput.InitDirectInput(hWnd); //D3D Init if(ddo.InitialiseD3D(hWnd)) { //show window ShowWindow(hWnd, SW_SHOWDEFAULT); UpdateWindow(hWnd); //start gameloop initObjects(); GameLoop(); } else { error("Error"); } deInit(); UnregisterClass("Axel1", wc.hInstance); return 0;}//the gameloopvoid GameLoop(){ //Gameloop MSG msg; BOOL fMessage; PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE); while(msg.message != WM_QUIT) { fMessage = PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE); if(fMessage) { //WinAPI Nachrichten abfangen TranslateMessage(&msg); DispatchMessage(&msg); } else { //Rendern Render(); } }}
OK, the first step is to find a Direct3D tutorial which, when compiled, runs fast. Now modify it to make it more and more like your original code and find out what causes the sudden slowdown.
~CGameProgrammer( );
~CGameProgrammer( );
All, right. Now we may be looking at vsync. 100 fps for an empty scene. 100-ish Hz is fairly common. Originally, only 45 fps was reported for the empty scene. In your D3DPRESENT_PARAMETERS you have PRESENT_INTERVAL_ONE, which is once per vsync. Try PRESENT_INTERVAL_IMMEDIATE and see if your empty scene fps goes up.
CGameProgrammer: "Mr.Saavik, you go right on quoting regulations."
<
[edited by - Dave Hunt on May 8, 2003 10:31:06 AM]
CGameProgrammer: "Mr.Saavik, you go right on quoting regulations."
<
[edited by - Dave Hunt on May 8, 2003 10:31:06 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement