00001 #ifndef VRS_OPENGL_VSYNCGL_H
00002 #define VRS_OPENGL_VSYNCGL_H
00003
00004 #include <vrs/opengl/openglconfig.h>
00005 #ifdef WIN32
00006 # include "../../../3rd-party/glew-1.5.1/include/GL/wglew.h"
00007 #endif
00008
00009 namespace VRS
00010 {
00011
00012
00013
00014
00015 class VSyncGL
00016 {
00017
00018 public:
00020 static inline bool enabled()
00021 {
00022 #ifdef WIN32
00023 bool hasExtension = wglewIsSupported("WGL_EXT_swap_control");
00024 VRS_Warning(hasExtension, "extension WGL_EXT_swap_control not supported");
00025 return (hasExtension ? wglGetSwapIntervalEXT() > 0 : true);
00026 #else
00027 VRS_Warning(false, "VSyncGL is currently only supported on WIN32 plattforms.");
00028 return true;
00029 #endif
00030 }
00031
00032
00034 static inline void setState(bool enabled)
00035 {
00036 #ifdef WIN32
00037 bool hasExtension = wglewIsSupported("WGL_EXT_swap_control");
00038 VRS_Warning(hasExtension, "extension WGL_EXT_swap_control not supported");
00039 if (hasExtension)
00040 {
00041
00042
00043 wglSwapIntervalEXT(enabled ? 1 : 0);
00044 }
00045 #else
00046 VRS_Warning(false, "VSyncGL is currently only supported on WIN32 plattforms.");
00047 #endif
00048 }
00049
00050 };
00051
00052 }
00053
00054 #endif // VRS_OPENGL_VSYNCGL_H