From 3c8f8f55d7fa4ca899ebd26afcb5626fc8fb8b53 Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Sat, 6 Mar 2010 19:37:38 +0000 Subject: [PATCH] add vsync for Mac OSX to avoid tearing artifacts --- Demos/OpenGL/GlutStuff.cpp | 10 ++++++++++ Demos/OpenGL/GlutStuff.h | 1 + 2 files changed, 11 insertions(+) diff --git a/Demos/OpenGL/GlutStuff.cpp b/Demos/OpenGL/GlutStuff.cpp index 867e1e150..d8de3e726 100644 --- a/Demos/OpenGL/GlutStuff.cpp +++ b/Demos/OpenGL/GlutStuff.cpp @@ -101,6 +101,16 @@ int glutmain(int argc, char **argv,int width,int height,const char* title,DemoAp glutDisplayFunc( glutDisplayCallback ); glutMoveAndDisplayCallback(); + +//enable vsync to avoid tearing on Apple (todo: for Windows) + +#if defined(__APPLE__) && !defined (VMDMESA) +int swap_interval = 1; +CGLContextObj cgl_context = CGLGetCurrentContext(); +CGLSetParameter(cgl_context, kCGLCPSwapInterval, &swap_interval); +#endif + + glutMainLoop(); return 0; diff --git a/Demos/OpenGL/GlutStuff.h b/Demos/OpenGL/GlutStuff.h index c518bf208..10d357641 100644 --- a/Demos/OpenGL/GlutStuff.h +++ b/Demos/OpenGL/GlutStuff.h @@ -21,6 +21,7 @@ subject to the following restrictions: //think different #if defined(__APPLE__) && !defined (VMDMESA) +#include #include #include #include