PageRenderTime 106ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/sources/engine/src/ogfpscounter.cpp

https://gitlab.com/seikosta/orange-grass
C++ | 49 lines | 25 code | 6 blank | 18 comment | 1 complexity | 1bd90390fa017e058443aed4245120b3 MD5 | raw file
  1. /*
  2. * OrangeGrass
  3. * Copyright (C) 2009 Vyacheslav Bogdanov.
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License version 3
  7. * as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this program. If not, see
  16. * <http://www.gnu.org/licenses/lgpl-3.0-standalone.html>.
  17. */
  18. #ifdef WIN32
  19. #include <windows.h>
  20. #endif
  21. #include "ogfpscounter.h"
  22. COGFPSCounter::COGFPSCounter()
  23. {
  24. #ifdef WIN32
  25. QueryPerformanceCounter (&framedelay);
  26. QueryPerformanceFrequency (&tickspersecond);
  27. #endif
  28. }
  29. COGFPSCounter::~COGFPSCounter()
  30. {
  31. }
  32. // updating FPS COUNTER
  33. void COGFPSCounter::Update ()
  34. {
  35. #ifdef WIN32
  36. QueryPerformanceCounter (&currentticks);
  37. speedfactor = (float)(currentticks.QuadPart - framedelay.QuadPart) / ((float)tickspersecond.QuadPart );
  38. fps = 1 / speedfactor;
  39. if (speedfactor <= 0)
  40. speedfactor = 1;
  41. framedelay = currentticks;
  42. #endif
  43. }