Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SettingsGL.cpp
1 // JW
2 
3 #include "SettingsGL.hh"
4 
5 #if defined(BIAS_HAVE_GLEW) && defined(WIN32)
6 // MS wgl extensions via GLEW
7 # include <GL/wglew.h>
8 # else
9 // Linux glx extensions via GLEW
10 //#include <GL/glxew.h>
11 #endif
12 
13 #include <Base/Debug/Error.hh>
14 #include <Base/Debug/DebugSimple.hh>
15 
16 
17 // ----------------------------------------------------------
18 // namespace stuff:
19 using namespace BIAS;
20 using namespace std;
21 // ----------------------------------------------------------
22 
23 /** @author Jan Woetzel 04/2005 */
24 
25 
26 /** set the vsync swap interval */
27 void SettingsGL::SetVSyncInterval( const int & interval )
28 {
29 #if defined(WIN32) && defined(BIAS_HAVE_GLEW)
30  if (WGLEW_EXT_swap_control) /* faster than wglewIsSupported(string) */
31  {
32  if (!wglSwapIntervalEXT(interval))
33  {
34  BIASERR("error on wglSwapIntervalEXT");
35  }
36  CHECK_GL_ERROR;
37  return;
38  } else {
39  BIASERR("WGLEW_EXT_swap_control not supported.");
40  };
41 #else // WIN32 and glew
42  BIASERR("Sorry, not implemented. Look at glXSwapInterval or AGL_SWAP_INTERVAL or enabled glew on win32 (JW)");
43  // possibly glewXGetVideoSyncSGI ???
44  //if (GLXEW_SGI_swap_control)
45  //{
46  //glXSwapIntervalSGI( interval);
47  // //or: glXWaitVideoSyncSGI(1,0,&interval)
48  // //glXSwapInterval( interval );
49  // CHECK_GL_ERROR;
50  // return;
51  //} else {
52  // BIASERR("GLXEW_SGI_swap_control not supported.");
53  //};
54 #endif // WIN32
55 }
56 
57 
58 
59 /** returns the swap control interval JW */
61 {
62  int interval = -2;
63 #if defined(WIN32) && defined(BIAS_HAVE_GLEW)
64  if(wglewIsSupported("WGL_EXT_swap_control"))
65  {
66  interval = wglGetSwapIntervalEXT();
67  CHECK_GL_ERROR;
68  } else {
69  BIASERR("WGLEW_EXT_swap_control not supported.");
70  };
71 #else // WIN32 and glew
72  BIASERR("Sorry, not implemented/tested. Enable glew on Window (JW)");
73  //if (GLXEW_SGI_swap_control)
74  //{
75  // interval=glXGetSwapIntervalSGI();
76  // CHECK_GL_ERROR;
77  //} else {
78  // string msg("Error: GLXEW_SGI_swap_control not supported.");
79  // BIASERR(msg);
80  // ::wxMessageBox(msg.c_str());
81  //};
82 #endif // WIN32
83  return interval;
84 }
85 
static int GetVSyncInterval()
query status of vsync/swap control interval=VSYNC JW
Definition: SettingsGL.cpp:60
static void SetVSyncInterval(const int &interval)
set the vsync/swap control interval JW
Definition: SettingsGL.cpp:27