Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualJeZ-l-Lee

Posted 31 October 2013 - 03:26 PM

Hi,

 

I'm developing a DirectX 9.0c 2D game engine now code named: "X-Caliber Engine"...

 

What is the best method to limit Frames Per Second?

 

I am currently doing this but I don't like it:

#include <mmsystem.h>
//...
static DWORD LastFrameTime = 0;
DWORD FPSLimit = 60;
//...

//-MAIN-LOOP--------------------------------------------------------------------
{
    render();

    DWORD currentTime = timeGetTime();
    if ( (currentTime - LastFrameTime) < (1000 / FPSLimit) )
    {
        Sleep(currentTime - LastFrameTime);
    }
    LastFrameTime = currentTime;
}

//--------------------------------------------------------------------MAIN-LOOP-

Above code adds an additional LIB dependency: "winmm.lib" which I don't like.

Any suggestions would be appreciated, thanks!

 

JeZ+Lee


#2JeZ-l-Lee

Posted 31 October 2013 - 03:21 PM

Hi,

 

I'm developing a DirectX 9.0c 2D game engine now code named: "X-Caliber Engine"...

 

What is the best method to limit Frames Per Second?

 

I am currently doing this but I don't like it:

#include <mmsystem.h>
//...
static DWORD LastFrameTime = 0;
DWORD FPSLimit = 60;
//...

//-MAIN-LOOP--------------------------------------------------------------------
{
    render();

    DWORD currentTime = timeGetTime();
    if ( (currentTime - LastFrameTime) < (1000 / FPSLimit) )
    {
        Sleep(currentTime - LastFrameTime);
    }
    LastFrameTime = currentTime;
}

//--------------------------------------------------------------------MAIN-LOOP-

Above code adds an additional DLL dependency: "winmm.lib" which I don't like.

Any suggestions would be appreciated, thanks!

 

JeZ+Lee


#1JeZ-l-Lee

Posted 31 October 2013 - 03:20 PM

Hi,

 

I'm developing a DirectX 9.0c 2D game engine now code named: "X-Caliber Engine"...

 

What is the best method to limit Frames Per Second?

 

I am currently doing this but I don't like it:

#include <mmsystem.h>
//...
static DWORD LastFrameTime = 0;
DWORD FPSLimit = 60;
//...

//-MAIN-LOOP--------------------------------------------------------------------
{
    render();

    DWORD currentTime = timeGetTime();
    if ( (currentTime - LastFrameTime) < (1000 / FPSLimit) )
    {
        Sleep(currentTime - LastFrameTime);
    }
    LastFrameTime = currentTime;
}

//--------------------------------------------------------------------MAIN-LOOP-

Above code adds an additional DLL dependency: "winmm.lib" which I don't like.

Any suggestions would be appreciated, thanks!

 

JeZ+Lee


PARTNERS