src/video/windows/SDL_windowsopengl.c
changeset 11872 e917e911dab6
parent 11839 971881e55d61
child 12503 806492103856
equal deleted inserted replaced
11871:c207c3ab46ee 11872:e917e911dab6
   117         return SDL_OutOfMemory();
   117         return SDL_OutOfMemory();
   118     }
   118     }
   119 
   119 
   120     /* Load function pointers */
   120     /* Load function pointers */
   121     handle = _this->gl_config.dll_handle;
   121     handle = _this->gl_config.dll_handle;
   122     *(void**)&_this->gl_data->wglGetProcAddress =
   122     _this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *))
   123         SDL_LoadFunction(handle, "wglGetProcAddress");
   123         SDL_LoadFunction(handle, "wglGetProcAddress");
   124     *(void**)&_this->gl_data->wglCreateContext =
   124     _this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC))
   125         SDL_LoadFunction(handle, "wglCreateContext");
   125         SDL_LoadFunction(handle, "wglCreateContext");
   126     *(void**)&_this->gl_data->wglDeleteContext =
   126     _this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC))
   127         SDL_LoadFunction(handle, "wglDeleteContext");
   127         SDL_LoadFunction(handle, "wglDeleteContext");
   128     *(void**)&_this->gl_data->wglMakeCurrent =
   128     _this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC))
   129         SDL_LoadFunction(handle, "wglMakeCurrent");
   129         SDL_LoadFunction(handle, "wglMakeCurrent");
   130     *(void**)&_this->gl_data->wglShareLists =
   130     _this->gl_data->wglShareLists = (BOOL(WINAPI *) (HGLRC, HGLRC))
   131         SDL_LoadFunction(handle, "wglShareLists");
   131         SDL_LoadFunction(handle, "wglShareLists");
   132 
   132 
   133     if (!_this->gl_data->wglGetProcAddress ||
   133     if (!_this->gl_data->wglGetProcAddress ||
   134         !_this->gl_data->wglCreateContext ||
   134         !_this->gl_data->wglCreateContext ||
   135         !_this->gl_data->wglDeleteContext ||
   135         !_this->gl_data->wglDeleteContext ||
   407     if (!hglrc) {
   407     if (!hglrc) {
   408         return;
   408         return;
   409     }
   409     }
   410     _this->gl_data->wglMakeCurrent(hdc, hglrc);
   410     _this->gl_data->wglMakeCurrent(hdc, hglrc);
   411 
   411 
   412     *(void**)&wglGetExtensionsStringARB =
   412     wglGetExtensionsStringARB = (const char *(WINAPI *) (HDC))
   413         _this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB");
   413         _this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB");
   414     if (wglGetExtensionsStringARB) {
   414     if (wglGetExtensionsStringARB) {
   415         extensions = wglGetExtensionsStringARB(hdc);
   415         extensions = wglGetExtensionsStringARB(hdc);
   416     } else {
   416     } else {
   417         extensions = NULL;
   417         extensions = NULL;
   418     }
   418     }
   419 
   419 
   420     /* Check for WGL_ARB_pixel_format */
   420     /* Check for WGL_ARB_pixel_format */
   421     _this->gl_data->HAS_WGL_ARB_pixel_format = SDL_FALSE;
   421     _this->gl_data->HAS_WGL_ARB_pixel_format = SDL_FALSE;
   422     if (HasExtension("WGL_ARB_pixel_format", extensions)) {
   422     if (HasExtension("WGL_ARB_pixel_format", extensions)) {
   423         *(void**)&_this->gl_data->wglChoosePixelFormatARB =
   423         _this->gl_data->wglChoosePixelFormatARB = (BOOL(WINAPI *)
       
   424                                                    (HDC, const int *,
       
   425                                                     const FLOAT *, UINT,
       
   426                                                     int *, UINT *))
   424             WIN_GL_GetProcAddress(_this, "wglChoosePixelFormatARB");
   427             WIN_GL_GetProcAddress(_this, "wglChoosePixelFormatARB");
   425         *(void**)&_this->gl_data->wglGetPixelFormatAttribivARB =
   428         _this->gl_data->wglGetPixelFormatAttribivARB =
       
   429             (BOOL(WINAPI *) (HDC, int, int, UINT, const int *, int *))
   426             WIN_GL_GetProcAddress(_this, "wglGetPixelFormatAttribivARB");
   430             WIN_GL_GetProcAddress(_this, "wglGetPixelFormatAttribivARB");
   427 
   431 
   428         if ((_this->gl_data->wglChoosePixelFormatARB != NULL) &&
   432         if ((_this->gl_data->wglChoosePixelFormatARB != NULL) &&
   429             (_this->gl_data->wglGetPixelFormatAttribivARB != NULL)) {
   433             (_this->gl_data->wglGetPixelFormatAttribivARB != NULL)) {
   430             _this->gl_data->HAS_WGL_ARB_pixel_format = SDL_TRUE;
   434             _this->gl_data->HAS_WGL_ARB_pixel_format = SDL_TRUE;
   432     }
   436     }
   433 
   437 
   434     /* Check for WGL_EXT_swap_control */
   438     /* Check for WGL_EXT_swap_control */
   435     _this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_FALSE;
   439     _this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_FALSE;
   436     if (HasExtension("WGL_EXT_swap_control", extensions)) {
   440     if (HasExtension("WGL_EXT_swap_control", extensions)) {
   437         *(void**)&_this->gl_data->wglSwapIntervalEXT =
   441         _this->gl_data->wglSwapIntervalEXT =
   438             WIN_GL_GetProcAddress(_this, "wglSwapIntervalEXT");
   442             WIN_GL_GetProcAddress(_this, "wglSwapIntervalEXT");
   439         *(void**)&_this->gl_data->wglGetSwapIntervalEXT =
   443         _this->gl_data->wglGetSwapIntervalEXT =
   440             WIN_GL_GetProcAddress(_this, "wglGetSwapIntervalEXT");
   444             WIN_GL_GetProcAddress(_this, "wglGetSwapIntervalEXT");
   441         if (HasExtension("WGL_EXT_swap_control_tear", extensions)) {
   445         if (HasExtension("WGL_EXT_swap_control_tear", extensions)) {
   442             _this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_TRUE;
   446             _this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_TRUE;
   443         }
   447         }
   444     } else {
   448     } else {
   715         if (WIN_GL_MakeCurrent(_this, window, temp_context) < 0) {
   719         if (WIN_GL_MakeCurrent(_this, window, temp_context) < 0) {
   716             WIN_GL_DeleteContext(_this, temp_context);
   720             WIN_GL_DeleteContext(_this, temp_context);
   717             return NULL;
   721             return NULL;
   718         }
   722         }
   719 
   723 
   720         *(void**)&wglCreateContextAttribsARB =
   724         wglCreateContextAttribsARB =
   721             _this->gl_data->wglGetProcAddress("wglCreateContextAttribsARB");
   725             (PFNWGLCREATECONTEXTATTRIBSARBPROC) _this->gl_data->
       
   726             wglGetProcAddress("wglCreateContextAttribsARB");
   722         if (!wglCreateContextAttribsARB) {
   727         if (!wglCreateContextAttribsARB) {
   723             SDL_SetError("GL 3.x is not supported");
   728             SDL_SetError("GL 3.x is not supported");
   724             context = temp_context;
   729             context = temp_context;
   725         } else {
   730         } else {
   726             int attribs[15];  /* max 14 attributes plus terminator */
   731             int attribs[15];  /* max 14 attributes plus terminator */