Mercurial > sdl-ios-xcode
diff src/video/wincommon/SDL_wingl.c @ 1656:96c2f89cc7e1 SDL-1.3
SDL-trunk-1.3-merge-1
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 27 Apr 2006 09:09:48 +0000 |
parents | ce84e28c2c07 |
children | 14717b52abc0 |
line wrap: on
line diff
--- a/src/video/wincommon/SDL_wingl.c Thu Apr 27 05:49:51 2006 +0000 +++ b/src/video/wincommon/SDL_wingl.c Thu Apr 27 09:09:48 2006 +0000 @@ -177,6 +177,7 @@ int iAttribs[64]; int *iAttr; float fAttribs[1] = { 0 }; + const char *wglext; /* load the gl driver from a default path */ if ( ! this->gl_config.driver_loaded ) { @@ -289,6 +290,11 @@ *iAttr++ = this->gl_config.multisamplesamples; } + if ( this->gl_config.accelerated >= 0 ) { + *iAttr++ = WGL_ACCELERATION_ARB; + *iAttr++ = (this->gl_config.accelerated ? WGL_GENERIC_ACCELERATION_ARB : WGL_NO_ACCELERATION_ARB); + } + *iAttr = 0; /* Choose and set the closest available pixel format */ @@ -323,7 +329,25 @@ SDL_SetError("Unable to create GL context"); return(-1); } + if ( WIN_GL_MakeCurrent(this) < 0 ) { + return(-1); + } gl_active = 1; + + /* Vsync control under Windows. Checking glGetString here is + * somewhat a documented and reliable hack - it was originally + * as a feature added by mistake, but since so many people rely + * on it, it will not be removed. strstr should be safe here.*/ + wglext = (const char *)this->glGetString(GL_EXTENSIONS); + if ( !SDL_strstr(wglext, "WGL_EXT_swap_control") ) { + this->gl_data->wglSwapIntervalEXT = NULL; + this->gl_data->wglGetSwapIntervalEXT = NULL; + } + if ( this->gl_config.swap_control >= 0 ) { + if ( this->gl_data->wglSwapIntervalEXT ) { + this->gl_data->wglSwapIntervalEXT(this->gl_config.swap_control); + } + } #else SDL_SetError("WIN driver not configured with OpenGL"); #endif @@ -423,6 +447,22 @@ case SDL_GL_MULTISAMPLESAMPLES: wgl_attrib = WGL_SAMPLES_ARB; break; + case SDL_GL_ACCELERATED_VISUAL: + wgl_attrib = WGL_ACCELERATION_ARB; + this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format, 0, 1, &wgl_attrib, value); + if ( *value == WGL_NO_ACCELERATION_ARB ) { + *value = SDL_FALSE; + } else { + *value = SDL_TRUE; + } + return 0; + break; + case SDL_GL_SWAP_CONTROL: + if ( this->gl_data->wglGetSwapIntervalEXT ) { + return this->gl_data->wglGetSwapIntervalEXT(); + } else { + return -1; + } default: return(-1); } @@ -509,6 +549,8 @@ this->gl_data->wglMakeCurrent = NULL; this->gl_data->wglChoosePixelFormatARB = NULL; this->gl_data->wglGetPixelFormatAttribivARB = NULL; + this->gl_data->wglSwapIntervalEXT = NULL; + this->gl_data->wglGetSwapIntervalEXT = NULL; this->gl_config.dll_handle = NULL; this->gl_config.driver_loaded = 0; @@ -547,6 +589,10 @@ GetProcAddress(handle, "wglDeleteContext"); this->gl_data->wglMakeCurrent = (BOOL (WINAPI *)(HDC, HGLRC)) GetProcAddress(handle, "wglMakeCurrent"); + this->gl_data->wglSwapIntervalEXT = (void (WINAPI *)(int)) + GetProcAddress(handle, "wglSwapIntervalEXT"); + this->gl_data->wglGetSwapIntervalEXT = (int (WINAPI *)(void)) + GetProcAddress(handle, "wglGetSwapIntervalEXT"); if ( (this->gl_data->wglGetProcAddress == NULL) || (this->gl_data->wglCreateContext == NULL) ||