0


I'm using Windows 10 Professional high contrast mode for working at night.
I'm working in a Cocos2d-x 3.15 project, which using these following Win32 API:

UINT TARGET_RESOLUTION = 1; // 1 millisecond target resolution
TIMECAPS tc;
UINT wTimerRes = 0;
if (TIMERR_NOERROR == timeGetDevCaps(&tc, sizeof(TIMECAPS)))
{
    wTimerRes = std::min(std::max(tc.wPeriodMin, TARGET_RESOLUTION), tc.wPeriodMax);
    timeBeginPeriod(wTimerRes);// request minimum time resolution to 1
}

It's not truly these following code, just an example.

while(true)//main loop
{
    mainGameLoop();
    int workedTime= calculateWorkedTime();// miliseconds
    if(workedTime < 1000/60)// target 60fps
    {
        int remainingTime = 1000/60 - workedTime;
        Sleep(remainingTime);
    }
}

In normal state, my game will run at 60fps on Windows (nearly 60fps). But in high contrast, the game is limited to 30fps (feel very annoying when testing games).

I played many games that have 60fps fine. Can I do some trick in my project to bypass the 30fps limit (using Win32 API)?

p/s: This project uses OpenGL.

  • 1
    Are you using OpenGL? If so, read [this](https://jira.atlassian.com/browse/HCPUB-1214?focusedCommentId=992229&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-992229). I don't know what the _answer_ is, but at least it gives you a handle on the problem. – Paul Sanders Jun 14 '18 at 11:09
  • 1
    Emulating the legacy high contrast theme became expensive at Aero, enabled today on all recent Windows versions. So nothing particularly unusual, albeit that it is fishy that it exactly half. If you don't use timeBeginPeriod then the default rate is 64 FPS, if a render takes longer than 15.625 msec then you get 32 FPS. Universal advice applies, debug code with the minimum dataset required. – Hans Passant Jun 14 '18 at 11:12
  • I don't see any fps limiting when high contrast mode is enabled. Presentation seem to run at the exactly same rate. – user7860670 Jun 14 '18 at 19:53
  • @Paul Sanders yes, it is OpenGL. Thank You. – Khang Dinh Hoang Jun 15 '18 at 03:04
  • OK, so you could try the technique described [here](https://stackoverflow.com/questions/1122730/how-to-detect-hardware-acceleration-for-opengl-on-windows) to see if hardware acceleration is enabled (or not) when Windows is running in HC mode. If not (which would be my prediction), then I doubt there's anything you can do about it but at least you can display a sensible error message. And those other games? They're probably using other, more sophisticated techniques to draw all those polygons but I really know very little about this kind of thing so you'll have to do your own research, sorry. – Paul Sanders Jun 15 '18 at 04:17

0 Answers0