src/video/windows/SDL_windowsopengl.c
changeset 11839 971881e55d61
parent 11811 5d94cb6b24d3
child 11872 e917e911dab6
equal deleted inserted replaced
11838:5ef6e4e70103 11839:971881e55d61
   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     _this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *))
   122     *(void**)&_this->gl_data->wglGetProcAddress =
   123         SDL_LoadFunction(handle, "wglGetProcAddress");
   123         SDL_LoadFunction(handle, "wglGetProcAddress");
   124     _this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC))
   124     *(void**)&_this->gl_data->wglCreateContext =
   125         SDL_LoadFunction(handle, "wglCreateContext");
   125         SDL_LoadFunction(handle, "wglCreateContext");
   126     _this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC))
   126     *(void**)&_this->gl_data->wglDeleteContext =
   127         SDL_LoadFunction(handle, "wglDeleteContext");
   127         SDL_LoadFunction(handle, "wglDeleteContext");
   128     _this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC))
   128     *(void**)&_this->gl_data->wglMakeCurrent =
   129         SDL_LoadFunction(handle, "wglMakeCurrent");
   129         SDL_LoadFunction(handle, "wglMakeCurrent");
   130     _this->gl_data->wglShareLists = (BOOL(WINAPI *) (HGLRC, HGLRC))
   130     *(void**)&_this->gl_data->wglShareLists =
   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     wglGetExtensionsStringARB = (const char *(WINAPI *) (HDC))
   412     *(void**)&wglGetExtensionsStringARB =
   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         _this->gl_data->wglChoosePixelFormatARB = (BOOL(WINAPI *)
   423         *(void**)&_this->gl_data->wglChoosePixelFormatARB =
   424                                                    (HDC, const int *,
       
   425                                                     const FLOAT *, UINT,
       
   426                                                     int *, UINT *))
       
   427             WIN_GL_GetProcAddress(_this, "wglChoosePixelFormatARB");
   424             WIN_GL_GetProcAddress(_this, "wglChoosePixelFormatARB");
   428         _this->gl_data->wglGetPixelFormatAttribivARB =
   425         *(void**)&_this->gl_data->wglGetPixelFormatAttribivARB =
   429             (BOOL(WINAPI *) (HDC, int, int, UINT, const int *, int *))
       
   430             WIN_GL_GetProcAddress(_this, "wglGetPixelFormatAttribivARB");
   426             WIN_GL_GetProcAddress(_this, "wglGetPixelFormatAttribivARB");
   431 
   427 
   432         if ((_this->gl_data->wglChoosePixelFormatARB != NULL) &&
   428         if ((_this->gl_data->wglChoosePixelFormatARB != NULL) &&
   433             (_this->gl_data->wglGetPixelFormatAttribivARB != NULL)) {
   429             (_this->gl_data->wglGetPixelFormatAttribivARB != NULL)) {
   434             _this->gl_data->HAS_WGL_ARB_pixel_format = SDL_TRUE;
   430             _this->gl_data->HAS_WGL_ARB_pixel_format = SDL_TRUE;
   436     }
   432     }
   437 
   433 
   438     /* Check for WGL_EXT_swap_control */
   434     /* Check for WGL_EXT_swap_control */
   439     _this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_FALSE;
   435     _this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_FALSE;
   440     if (HasExtension("WGL_EXT_swap_control", extensions)) {
   436     if (HasExtension("WGL_EXT_swap_control", extensions)) {
   441         _this->gl_data->wglSwapIntervalEXT =
   437         *(void**)&_this->gl_data->wglSwapIntervalEXT =
   442             WIN_GL_GetProcAddress(_this, "wglSwapIntervalEXT");
   438             WIN_GL_GetProcAddress(_this, "wglSwapIntervalEXT");
   443         _this->gl_data->wglGetSwapIntervalEXT =
   439         *(void**)&_this->gl_data->wglGetSwapIntervalEXT =
   444             WIN_GL_GetProcAddress(_this, "wglGetSwapIntervalEXT");
   440             WIN_GL_GetProcAddress(_this, "wglGetSwapIntervalEXT");
   445         if (HasExtension("WGL_EXT_swap_control_tear", extensions)) {
   441         if (HasExtension("WGL_EXT_swap_control_tear", extensions)) {
   446             _this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_TRUE;
   442             _this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_TRUE;
   447         }
   443         }
   448     } else {
   444     } else {
   719         if (WIN_GL_MakeCurrent(_this, window, temp_context) < 0) {
   715         if (WIN_GL_MakeCurrent(_this, window, temp_context) < 0) {
   720             WIN_GL_DeleteContext(_this, temp_context);
   716             WIN_GL_DeleteContext(_this, temp_context);
   721             return NULL;
   717             return NULL;
   722         }
   718         }
   723 
   719 
   724         wglCreateContextAttribsARB =
   720         *(void**)&wglCreateContextAttribsARB =
   725             (PFNWGLCREATECONTEXTATTRIBSARBPROC) _this->gl_data->
   721             _this->gl_data->wglGetProcAddress("wglCreateContextAttribsARB");
   726             wglGetProcAddress("wglCreateContextAttribsARB");
       
   727         if (!wglCreateContextAttribsARB) {
   722         if (!wglCreateContextAttribsARB) {
   728             SDL_SetError("GL 3.x is not supported");
   723             SDL_SetError("GL 3.x is not supported");
   729             context = temp_context;
   724             context = temp_context;
   730         } else {
   725         } else {
   731             int attribs[15];  /* max 14 attributes plus terminator */
   726             int attribs[15];  /* max 14 attributes plus terminator */