Closed JeppeSRC closed 8 years ago
Thanks for doing this. Couple of things that need to be addressed:
swapchain->Present(m_Vsync, 0)
should take in a uint as the first parameter not a boolean. That bool isn't guaranteed to be 1 if true, it could be any non-zero value, so please change that to something like swapchain->Present(m_Vsync ? 1 : 0, 0)
. You can also do better and store the SyncInterval
parameter as a uint field in D3DContext if you like, to avoid the branch.Window::SetVsync
please use a switch statement rather than an if/else if statement. This will be cleaner in the future when more APIs get added.wglSwapIntervalEXT(m_Vsync)
should be called in graphics::API::GLContext::SetVsync()
, just like it is for DX. In fact, since every context needs to support vsync toggling, there should be a pure virtual SetVsync()
method in Context
. That would avoid the need for that switch statement entirely.That makes sense. Seems like Xeryko has fixed it so I'll leave it to him.
Window::SetVsync now enables/disables vsync for both opengl and direct3d. The direct3d implementation is maybe not the best, but it's the best I could come up with without rewriting anything. I'm open for any suggestions on improvement.