WinPlatformGL.cpp 802 B

1234567891011121314151617181920212223242526272829303132333435
  1. #if defined(TORQUE_OPENGL) && !defined(TORQUE_SDL)
  2. #include "platform/platformGL.h"
  3. #include "gfx/gl/tGL/tWGL.h"
  4. #include "gfx/gl/gfxGLUtils.h"
  5. void PlatformGL::setVSync(const int i)
  6. {
  7. if (gglHasWExtension(EXT_swap_control))
  8. {
  9. PRESERVE_FRAMEBUFFER();
  10. // NVidia needs to have the default framebuffer bound or the vsync calls fail
  11. glBindFramebuffer(GL_FRAMEBUFFER, 0);
  12. if (gglHasWExtension(EXT_swap_control_tear))
  13. {
  14. if (i == 1 || i == -1)
  15. {
  16. BOOL ret = wglSwapIntervalEXT(-1);
  17. if (!ret)
  18. wglSwapIntervalEXT(1);
  19. }
  20. else
  21. {
  22. wglSwapIntervalEXT(i);
  23. }
  24. return;
  25. }
  26. //fallback with no EXT_swap_control_tear
  27. wglSwapIntervalEXT(i);
  28. }
  29. }
  30. #endif