void GameWindow::EnableVerticalSync(bool aIsEnabled) { //Safety check that vertical sync is not already set if(m_IsVerticalSyncEnabled != aIsEnabled) { // m_IsVerticalSyncEnabled = aIsEnabled; //Ensure the v-sync function actually exists if(wglSwapIntervalEXT != nullptr) { if(m_IsVerticalSyncEnabled) { wglSwapIntervalEXT(1); } else { wglSwapIntervalEXT(0); } } else { // m_IsVerticalSyncEnabled = false; } } }
bool COpenGLControl::setVerticalSynchronization(bool bEnabled) { if(!wglSwapIntervalEXT)return false; if(bEnabled)wglSwapIntervalEXT(1); else wglSwapIntervalEXT(0); return true; }
//-------------------------------------- void ofSetVerticalSync(bool bSync){ //---------------------------- #ifdef TARGET_WIN32 //---------------------------- if (bSync) { if (GLEE_WGL_EXT_swap_control) wglSwapIntervalEXT (1); } else { if (GLEE_WGL_EXT_swap_control) wglSwapIntervalEXT (0); } //---------------------------- #endif //---------------------------- //-------------------------------------- #ifdef TARGET_OSX //-------------------------------------- long sync = bSync == true ? 1 : 0; CGLSetParameter (CGLGetCurrentContext(), kCGLCPSwapInterval, &sync); //-------------------------------------- #endif //-------------------------------------- // linux ofSetVerticalSync needed -- anyone want to help w/ this? // http://www.inb.uni-luebeck.de/~boehme/xvideo_sync.html // glXGetVideoSyncSGI(&count); // but needs to be at the end of every "draw? // also, see this: // glXWaitVideoSyncSGI(2,0,&count); }
//-------------------------------------- void ofSetVerticalSync(bool bSync){ //---------------------------- #ifdef TARGET_WIN32 //---------------------------- if (bSync) { if (GLEE_WGL_EXT_swap_control) wglSwapIntervalEXT (1); } else { if (GLEE_WGL_EXT_swap_control) wglSwapIntervalEXT (0); } //---------------------------- #endif //---------------------------- //-------------------------------------- #ifdef TARGET_OSX //-------------------------------------- GLint sync = bSync == true ? 1 : 0; CGLSetParameter (CGLGetCurrentContext(), kCGLCPSwapInterval, &sync); //-------------------------------------- #endif //-------------------------------------- //-------------------------------------- #ifdef TARGET_LINUX //-------------------------------------- if (GLEE_GLX_SGI_swap_control) glXSwapIntervalSGI(bSync ? 1 : 0); //-------------------------------------- #endif //-------------------------------------- }
/*void Window::InitPipeline(){ glGenProgramPipelines(1,&WindowPipeline); glBindProgramPipeline(WindowPipeline); }*/ void Window::VSyncState(bool st){ if(st){ ConsoleEcho("VSync:on\0"); wglSwapIntervalEXT(1); VSync=true; }else{ ConsoleEcho("VSync:off\0"); wglSwapIntervalEXT(0); VSync=false; } }
void oak::Window::setVSync(bool enable) { #ifdef Q_OS_WIN if (enable) wglSwapIntervalEXT(1); else wglSwapIntervalEXT(0); #endif #ifdef Q_OS_MAC GLint vsyncOn = enable ? 1 : 0; CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &vsyncOn); #endif }
xdl_int XdevLOpenGLWGL::setVSync(xdl_bool state) { if (wglSwapIntervalEXT) { if(state) wglSwapIntervalEXT(1); else wglSwapIntervalEXT(0); return ERR_OK; } else { XDEVL_MODULE_WARNING("VSync not supported.\n"); } return ERR_ERROR; }
bool spoutGLDXinterop::SetVerticalSync(bool bSync) { if(!bExtensionsLoaded) bExtensionsLoaded = LoadGLextensions(); if(bSWAPavailable) { if(bSync) { wglSwapIntervalEXT(1); // lock to monitor vsync } else { wglSwapIntervalEXT(0); // unlock from monitor vsync } return true; } return false; }
// initialize OpenGL void initGL(int *argc, char **argv) { glutInit(argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutInitWindowSize(width, height); glutCreateWindow("CUDA Particles"); glewInit(); if (!glewIsSupported("GL_VERSION_2_0 GL_VERSION_1_5 GL_ARB_multitexture GL_ARB_vertex_buffer_object")) { fprintf(stderr, "Required OpenGL extensions missing."); exit(EXIT_FAILURE); } #if defined (_WIN32) if (wglewIsSupported("WGL_EXT_swap_control")) { // disable vertical sync wglSwapIntervalEXT(0); } #endif glEnable(GL_DEPTH_TEST); glClearColor(0.25, 0.25, 0.25, 1.0); glutReportErrors(); }
void InitGLEW() { glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK) { std::cerr << "There was a problem initializing GLEW. Exiting..." << std::endl; exit(-1); } // Check for 3.3 support. // I've specified that a 3.3 forward-compatible context should be created. // so this parameter check should always pass if our context creation passed. // If we need access to deprecated features of OpenGL, we should check // the state of the GL_ARB_compatibility extension. if (!GLEW_VERSION_3_3) { std::cerr << "OpenGL 3.3 required version support not present." << std::endl; exit(-1); } #ifdef _WIN32 if (WGLEW_EXT_swap_control) { wglSwapIntervalEXT(0); // Disable vertical sync } #endif }
void TApp::ToggleWaitVsync() { wxStatusBar* status = frame->GetStatusBar(); waitVsync = !waitVsync; if (!waitVsync) status->SetFieldsCount(3, TFrame::StatusBarWidths); else status->SetFieldsCount(2, TFrame::StatusBarWidths); if (wglSwapIntervalEXT) { if (CapFps()) wglSwapIntervalEXT(1); else wglSwapIntervalEXT(0); } }
int Screen::InitializeGL() { /* Depth buffer setup */ glClearDepth( 1.0f ); /* Enables Depth Testing */ glEnable( GL_DEPTH_TEST ); /* The Type Of Depth Test To Do */ glDepthFunc( GL_LEQUAL ); glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST); InitExtensions(); #ifdef WIN32 if(WGLEW_EXT_swap_control) { wglSwapIntervalEXT(0); //turn off vsync } else { ENGINE_LOG(SORE_Logging::LVL_WARNING, "Vsync control not available"); } #endif PrintGLDiagnostics(); glViewport( 0, 0, ( GLsizei )screen.width, ( GLsizei )screen.height ); return 0; }
bool Initialise() { printf("Version GL : %s\n", glGetString(GL_VERSION)); printf("Pilotes GL : %s\n", glGetString(GL_RENDERER)); printf("Fabricant : %s\n", glGetString(GL_VENDOR)); printf("Version GLSL : %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION)); GLenum status = glewInit(); g_BasicShader.LoadVertexShader("basic.vs"); g_BasicShader.LoadFragmentShader("basic.fs"); g_BasicShader.Create(); static const float triangle[] = { -0.5f, -0.5f, 0.5f, -0.5f, 0.0f, 0.5f }; glGenBuffers(1, &g_Object.VBO); glBindBuffer(GL_ARRAY_BUFFER, g_Object.VBO); // glBufferData alloue et transfort 4 * 3 octets issus du tableau triangle[] glBufferData(GL_ARRAY_BUFFER, sizeof(triangle), triangle, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glUseProgram(0); #ifdef _WIN32 wglSwapIntervalEXT(1); #endif return true; }
void MFCOpenGLContext::setSwapInterval(int status) { if (GLAD_WGL_EXT_swap_control) { wglSwapIntervalEXT(status); } }
void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: glutLeaveMainLoop(); break; case 'r': translate_x = 0; translate_y = 0; scale_size = 1.0; break; case 's': pause = !pause; start_clock = std::clock(); fpsLimit = 5; fpsCount = 0; break; case 'd': pause = true; single = true; start_clock = std::clock(); fpsLimit = 1; fpsCount = 0; break; #if defined(_WIN32)||defined(_WIN64) case 'v': if(glewGetExtension("WGL_EXT_swap_control")) { vsync = 1 - vsync; wglSwapIntervalEXT(vsync); } break; #endif } }
/* ======================== GLimp_TestSwapBuffers ======================== */ void GLimp_TestSwapBuffers( const idCmdArgs &args ) { #if !NGD_USE_OPENGL_ES_2_0 idLib::Printf( "GLimp_TimeSwapBuffers\n" ); static const int MAX_FRAMES = 5; uint64 timestamps[MAX_FRAMES]; glDisable( GL_SCISSOR_TEST ); int frameMilliseconds = 16; for ( int swapInterval = 2 ; swapInterval >= -1 ; swapInterval-- ) { wglSwapIntervalEXT( swapInterval ); for ( int i = 0 ; i < MAX_FRAMES ; i++ ) { if ( swapInterval == -1 ) { Sys_Sleep( frameMilliseconds ); } if ( i & 1 ) { glClearColor( 0, 1, 0, 1 ); } else { glClearColor( 1, 0, 0, 1 ); } glClear( GL_COLOR_BUFFER_BIT ); ::SwapBuffers( win32.hDC ); glFinish(); timestamps[i] = Sys_Microseconds(); } idLib::Printf( "\nswapinterval %i\n", swapInterval ); for ( int i = 1 ; i < MAX_FRAMES ; i++ ) { idLib::Printf( "%i microseconds\n", (int)(timestamps[i] - timestamps[i-1]) ); } } #else NGD_MISSING_FUNCTIONALITY; #endif // !NGD_USE_OPENGL_ES_2_0 }
// Load configuration file void Manager::LoadConfig() { Config->Load("config.xml"); Engine::Window = WindowManager::NewWindow("Engine", Config->resolution, Config->position, true); RenderSys->Init(); //////////////////////////////////////// // TODO inspect if I can move these glewExperimental = true; glewInit(); /* Force Vertical Sync */ wglSwapIntervalEXT(1); //////////////////////////////////////// Debug->Init(); #ifdef PHYSICS_ENGINE Havok->Init(); #endif Texture->Init(); Audio->Init(); Font->Init(); Shader->Load(Config->GetResourceFileLoc("shaders")); Resource->Load(Config->GetResourceFileLoc("resource")); Menu->Load(Config->GetResourceFileLoc("menu")); Scene->LoadScene(Config->GetResourceFileLoc("scene")); AABB::Init(); }
void ContextGL_Win::set_use_vsync(bool p_use) { if (wglSwapIntervalEXT) { wglSwapIntervalEXT(p_use ? 1 : 0); } use_vsync = p_use; }
// Initialize GL //***************************************************************************** void InitGL(int* argc, char **argv) { // initialize GLUT glutInit(argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); glutInitWindowPosition (glutGet(GLUT_SCREEN_WIDTH)/2 - iGraphicsWinWidth/2, glutGet(GLUT_SCREEN_HEIGHT)/2 - iGraphicsWinHeight/2); glutInitWindowSize(iGraphicsWinWidth, iGraphicsWinHeight); iGLUTWindowHandle = glutCreateWindow("OpenCL for GPU RGB Sobel Filter Demo"); #if !(defined (__APPLE__) || defined(MACOSX)) glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); #endif // register glut callbacks glutKeyboardFunc(KeyboardGL); glutDisplayFunc(DisplayGL); glutReshapeFunc(Reshape); glutIdleFunc(Idle); glutTimerFunc(REFRESH_DELAY, timerEvent,0); // create GLUT menu iGLUTMenuHandle = glutCreateMenu(MenuGL); glutAddMenuEntry("Toggle Filter On/Off <spacebar>", ' '); glutAddMenuEntry("Toggle Processing between GPU and CPU [p]", 'p'); glutAddMenuEntry("Toggle between Full Screen and Windowed [f]", 'f'); glutAddMenuEntry("Increase Threshold [+]", '+'); glutAddMenuEntry("Decrease Threshold [-]", '-'); glutAddMenuEntry("Quit <esc>", '\033'); glutAttachMenu(GLUT_RIGHT_BUTTON); // Set clear color glClearColor(0.f, 0.f, 0.f, 0.f); // Zoom with fixed aspect ratio float fAspects[2] = {(float)glutGet(GLUT_WINDOW_WIDTH)/(float)uiImageWidth , (float)glutGet(GLUT_WINDOW_HEIGHT)/(float)uiImageHeight}; fZoom = fAspects[0] > fAspects[1] ? fAspects[1] : fAspects[0]; glPixelZoom(fZoom, fZoom); glewInit(); // Disable vertical sync, if supported #ifdef _WIN32 if (wglewIsSupported("WGL_EXT_swap_control")) { iVsyncState = wglGetSwapIntervalEXT(); wglSwapIntervalEXT(0); } #else #if defined (__APPLE__) || defined(MACOSX) GLint VBL = 0; CGLGetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &iVsyncState); CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &VBL); #else if(glxewIsSupported("GLX_SGI_swap_control")) { glXSwapIntervalSGI(0); } #endif #endif }
void setVSync(int interval) { if (WGL_EXT_swap_control) { wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress("wglSwapIntervalEXT"); wglSwapIntervalEXT(interval); } }
//-------------------------------------- void ofSetVerticalSync(bool bSync){ //---------------------------- #ifdef TARGET_WIN32 //---------------------------- if (bSync) { if (WGL_EXT_swap_control) wglSwapIntervalEXT (1); } else { if (WGL_EXT_swap_control) wglSwapIntervalEXT (0); } //---------------------------- #endif //---------------------------- //-------------------------------------- #ifdef TARGET_OSX //-------------------------------------- GLint sync = bSync == true ? 1 : 0; CGLSetParameter (CGLGetCurrentContext(), kCGLCPSwapInterval, &sync); //-------------------------------------- #endif //-------------------------------------- //-------------------------------------- #ifdef TARGET_LINUX //-------------------------------------- void (*swapIntervalExt)(Display *,GLXDrawable, int) = (void (*)(Display *,GLXDrawable, int)) glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT"); if(swapIntervalExt){ Display *dpy = glXGetCurrentDisplay(); GLXDrawable drawable = glXGetCurrentDrawable(); if (drawable) { swapIntervalExt(dpy, drawable, bSync ? 1 : 0); return; } } void (*swapInterval)(int) = (void (*)(int)) glXGetProcAddress((const GLubyte*) "glXSwapIntervalSGI"); if(!swapInterval) swapInterval = (void (*)(int)) glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA"); if(swapInterval) swapInterval(bSync ? 1 : 0); //-------------------------------------- #endif //-------------------------------------- }
// ------------------------------------------------------------------------------------------ //! Function would be called on the global initialization step. //! @returns Non-negative value if the operation succeeded. GDAPI IResult IGraphicsOpenGLWindows::OnRuntimeInitialize() { _CheckNotInitialized(); ConsoleDevice->Log(GD_DLOG_CAT ": going to initialize graphics devices..."); IResult const _BaseResult = IGraphicsPlatform::OnRuntimeInitialize(); if (IFailed(_BaseResult)) return _BaseResult; // Loading the device context of the window.. HGLRCDeviceContext = GetDC(hwndMain); GD_ASSERT(HGLRCDeviceContext != nullptr , "'GetDC' error: failed to retrieve the device context of the main window."); // Choosing the pixel format.. PIXELFORMATDESCRIPTOR glPixelFormatDescriptor = {}; glPixelFormatDescriptor.nSize = sizeof(glPixelFormatDescriptor); glPixelFormatDescriptor.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW; glPixelFormatDescriptor.iLayerType = PFD_MAIN_PLANE; glPixelFormatDescriptor.iPixelType = PFD_TYPE_RGBA; glPixelFormatDescriptor.cColorBits = 32; glPixelFormatDescriptor.cDepthBits = 32; int const _OglPixelFormat = ChoosePixelFormat(HGLRCDeviceContext, &glPixelFormatDescriptor); SetPixelFormat(HGLRCDeviceContext, _OglPixelFormat, &glPixelFormatDescriptor); GD_ASSERT(_OglPixelFormat != 0 , "'ChoosePixelFormat' error: failed to select correct pixel format."); // Creating temporary OpenGL 2.1 context.. // We need it to load a function, that helps us to create an advanced context with // the support of the OpenGL 3.0 and above. HGLRC const HGLRCContextTemp = wglCreateContext(HGLRCDeviceContext); wglMakeCurrent(HGLRCDeviceContext, HGLRCContextTemp); auto const wglCreateContextAttribsARB = reinterpret_cast<HGLRC(*)(HDC hDC, HGLRC hGLRC , int const* Attributes)>(wglGetProcAddress("wglCreateContextAttribsARB")); GD_ASSERT(wglCreateContextAttribsARB != nullptr , "'wglGetProcAddress' error: failed to retrieve the address of the 'wglCreateContextAttribsARB' routine."); wglMakeCurrent(nullptr, nullptr); wglDeleteContext(HGLRCContextTemp); // Creating the full-featured OpenGL 4.3++ context.. int static const HGLRCContextVersionAttributes[] = { WGL_CONTEXT_MAJOR_VERSION_ARB, 4, WGL_CONTEXT_MINOR_VERSION_ARB, 3, #if GD_DEBUG WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB | WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, #endif // if GD_DEBUG 0 }; HGLRCContext = wglCreateContextAttribsARB(HGLRCDeviceContext, nullptr, HGLRCContextVersionAttributes); wglMakeCurrent(HGLRCDeviceContext, HGLRCContext); if (WGLEW_EXT_swap_control) wglSwapIntervalEXT(0); ConsoleDevice->Log(GD_DLOG_CAT ": ... initialized."); return IResult::Ok; }
void GLApp::SetVsync() { if (WGLExtSupported("WGL_EXT_swap_control")) { wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress("wglGetSwapIntervalEXT"); wglSwapIntervalEXT(vSync); } }
void GL_Main::Init(int window_width, int window_height, bool fullscreen,void (*display_func)(void)) { screen.window_width = window_width; screen.window_height = window_height; // Create GL context char* headline="CUDA Voxel Demo";int nop=1; glutInit( &nop, &headline ); glutInitDisplayMode( GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize( window_width, window_height); glutCreateWindow( headline ); this->fullscreen = fullscreen; if(fullscreen) { glutFullScreen() ; } glewInit(); wglSwapIntervalEXT(false); // default initialization glClearColor( 0.5, 0.5, 0.5, 1.0); glDisable( GL_DEPTH_TEST); // viewport glViewport( 0, 0, window_width, window_height); // projection glMatrixMode( GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, (GLfloat)window_width / (GLfloat) window_height, 0.1, 10.0); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_LIGHT0); float red[] = { 1.0, 0.1, 0.1, 1.0 }; float white[] = { 1.0, 1.0, 1.0, 1.0 }; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, red); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 60.0); // register callbacks glutDisplayFunc( display_func); glutReshapeFunc( &reshape_static); glutIdleFunc( &idle_static ); glutSpecialFunc(&keyDown1Static); glutSpecialUpFunc(&keyUp1Static); glutKeyboardFunc(&keyDown2Static); glutKeyboardUpFunc(&keyUp2Static); glutMotionFunc(&MouseMotionStatic); glutPassiveMotionFunc(&MouseMotionStatic); glutMouseFunc (&MouseButtonStatic); get_error(); }
/* Enable/disable syncing of buffer-swaps to vertical retrace. */ void PsychOSSetVBLSyncLevel(PsychWindowRecordType *windowRecord, int swapInterval) { // Enable rendering context of window: PsychSetGLContext(windowRecord); // Try to set requested swapInterval if swap-control extension is supported on // this windows machine. Otherwise this will be a no-op... if (wglSwapIntervalEXT) wglSwapIntervalEXT(swapInterval); return; }
virtual ULONG execute() { if(WGLEW_EXT_swap_control) { if(!wglSwapIntervalEXT(mInterval)) ERR("Failed to set swap interval %d, error 0x%lx\n", mInterval, GetLastError()); } return sizeof(*this); }
void zl_glx_vsync(zl_glx *x, bool sync) { #ifdef TARGET_WIN32 if (sync) { if (GLEE_WGL_EXT_swap_control) wglSwapIntervalEXT (1); } else { if (GLEE_WGL_EXT_swap_control) wglSwapIntervalEXT (0); } #endif #ifdef TARGET_OSX long sync = sync ? 1 : 0; CGLSetParameter (CGLGetCurrentContext(), kCGLCPSwapInterval, &sync); #endif #ifdef TARGET_LINUX int interval = sync ? 2 : 0; glXSwapIntervalSGIFunc glXSwapIntervalSGI = 0; glXSwapIntervalMESAFunc glXSwapIntervalMESA = 0; if (GLXExtensionSupported(x->xdpy->dpy, "GLX_MESA_swap_control")) { glXSwapIntervalMESA = (glXSwapIntervalMESAFunc) glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalMESA"); if (glXSwapIntervalMESA) { ZL_LOG("glXSwapIntervalMESA(%d)", interval); glXSwapIntervalMESA (interval); } else { ZL_LOG("Could not get glXSwapIntervalMESA()\n"); } } else if (GLXExtensionSupported(x->xdpy->dpy, "GLX_SGI_swap_control")) { glXSwapIntervalSGI = (glXSwapIntervalSGIFunc) glXGetProcAddressARB((const GLubyte *)"glXSwapIntervalSGI"); if (glXSwapIntervalSGI) { ZL_LOG("glXSwapIntervalSGI(%d)", interval, glXSwapIntervalSGI); glXSwapIntervalSGI (interval); } else { ZL_LOG("Could not get glXSwapIntervalSGI()\n"); } } else { ZL_LOG("can't change vblank settings"); } #endif }
int main(int argc, char** argv){ glutInit(&argc, argv); #if defined(OS_MAC) { char* p = strrchr(argv[0], '/'); *p = 0; chdir(argv[0]); //puts(getcwd(NULL, 0)); } #endif #if defined(OS_WIN) OutputDebugString(TEXT("Boot up!\n")); #endif glutInitWindowPosition(0, 0); glutInitWindowSize(1280, 720); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); #if defined(OS_WIN) glutCreateWindow_ATEXIT_HACK("ICG SSAO"); #else glutCreateWindow("ICG SSAO"); #endif glutDisplayFunc(onDisplay); glutIdleFunc(onIdle); glutReshapeFunc(onReshape); glutKeyboardFunc(onKeyDown); glutSpecialFunc(onSpecialDown); glutMotionFunc(onMouseMotion); glutPassiveMotionFunc(onMousePassiveMotion); glewInit(); /* ENABLE V-SYNC */ int vsync = 1; #if defined(OS_MAC) CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &vsync); #elif defined(OS_WIN) if(WGLEW_EXT_swap_control) wglSwapIntervalEXT(vsync); #else if(GLXEW_EXT_swap_control) glXSwapIntervalEXT(glXGetCurrentDisplay(), glXGetCurrentDrawable(), vsync); #endif onInitialization(); #if !defined(__MINGW32__) atexit(onShutdown); #endif /* NO RETURN */ glutMainLoop(); return 0; }
NE_API void set_vsync(bool enable) { vsync_state = enable; BOOL(APIENTRY *wglSwapIntervalEXT)(int) = (BOOL(APIENTRY*)(int)) wglGetProcAddress("wglSwapIntervalEXT"); if (wglSwapIntervalEXT) { DEBUG(0, NE_MESSAGE, (enable ? "Enabled" : "Disabled") << " VSync."); wglSwapIntervalEXT(vsync_state); } else { DEBUG(0, NE_WARNING, "Failed to " << (enable ? "enable" : "disable") << " VSync. wglSwapIntervalEXT not found."); } }
void DemoEntityManager::InitGraphicsSystem() { wxGLCanvas::SetCurrent(*m_context); GLenum err = glewInit(); // if Glew doesn't initialize correctly. if (err != GLEW_OK) { //wxMessageBox(wxString(_("GLEW Error: ")) + wxString(_((char*)glewGetErrorString(err))), _("ERROR"), wxOK | wxICON_EXCLAMATION); } #if defined (_MSC_VER) if (wglSwapIntervalEXT) { wglSwapIntervalEXT(0); } #elif (defined (_POSIX_VER) || defined (_POSIX_VER_64)) if (glXSwapIntervalSGI) { glXSwapIntervalSGI(0); //NOTE check for GLX_SGI_swap_control extension : http://www.opengl.org/wiki/Swap_Interval#In_Linux_.2F_GLXw } #elif defined(_MACOSX_VER) //wglSwapIntervalEXT (GetContext()->GetWXGLContext()); wglSwapIntervalEXT (m_context->GetWXGLContext()); #endif // initialize free type library CreateOpenGlFont(); }