Home | History | Annotate | Download | only in wincommon
      1 /*
      2     SDL - Simple DirectMedia Layer
      3     Copyright (C) 1997-2012 Sam Lantinga
      4 
      5     This library is free software; you can redistribute it and/or
      6     modify it under the terms of the GNU Lesser General Public
      7     License as published by the Free Software Foundation; either
      8     version 2.1 of the License, or (at your option) any later version.
      9 
     10     This library is distributed in the hope that it will be useful,
     11     but WITHOUT ANY WARRANTY; without even the implied warranty of
     12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13     Lesser General Public License for more details.
     14 
     15     You should have received a copy of the GNU Lesser General Public
     16     License along with this library; if not, write to the Free Software
     17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     18 
     19     Sam Lantinga
     20     slouken (at) libsdl.org
     21 */
     22 #include "SDL_config.h"
     23 
     24 /* WGL implementation of SDL OpenGL support */
     25 
     26 #include "../SDL_sysvideo.h"
     27 
     28 
     29 struct SDL_PrivateGLData {
     30     int gl_active; /* to stop switching drivers while we have a valid context */
     31 
     32 #if SDL_VIDEO_OPENGL
     33     PIXELFORMATDESCRIPTOR GL_pfd;
     34     HDC GL_hdc;
     35     HGLRC GL_hrc;
     36     int pixel_format;
     37     int WGL_ARB_pixel_format;
     38 
     39     void * (WINAPI *wglGetProcAddress)(const char *proc);
     40 
     41     HGLRC (WINAPI *wglCreateContext)(HDC hdc);
     42 
     43     BOOL (WINAPI *wglDeleteContext)(HGLRC hglrc);
     44 
     45     BOOL (WINAPI *wglMakeCurrent)(HDC hdc, HGLRC hglrc);
     46 
     47     BOOL (WINAPI *wglGetPixelFormatAttribivARB)(HDC hdc, int iPixelFormat,
     48                                                 int iLayerPlane,
     49                                                 UINT nAttributes,
     50                                                 const int *piAttributes,
     51                                                 int *piValues);
     52     void (WINAPI *wglSwapIntervalEXT)(int interval);
     53     int (WINAPI *wglGetSwapIntervalEXT)(void);
     54 #endif /* SDL_VIDEO_OPENGL */
     55 };
     56 
     57 /* Old variable names */
     58 #define gl_active	(this->gl_data->gl_active)
     59 #define GL_pfd		(this->gl_data->GL_pfd)
     60 #define GL_hdc		(this->gl_data->GL_hdc)
     61 #define GL_hrc		(this->gl_data->GL_hrc)
     62 #define pixel_format	(this->gl_data->pixel_format)
     63 
     64 /* OpenGL functions */
     65 extern int WIN_GL_SetupWindow(_THIS);
     66 extern void WIN_GL_ShutDown(_THIS);
     67 #if SDL_VIDEO_OPENGL
     68 extern int WIN_GL_MakeCurrent(_THIS);
     69 extern int WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
     70 extern void WIN_GL_SwapBuffers(_THIS);
     71 extern void WIN_GL_UnloadLibrary(_THIS);
     72 extern int WIN_GL_LoadLibrary(_THIS, const char* path);
     73 extern void *WIN_GL_GetProcAddress(_THIS, const char* proc);
     74 #endif
     75 
     76 #if SDL_VIDEO_OPENGL
     77 
     78 #ifndef WGL_ARB_pixel_format
     79 #define WGL_NUMBER_PIXEL_FORMATS_ARB   0x2000
     80 #define WGL_DRAW_TO_WINDOW_ARB         0x2001
     81 #define WGL_DRAW_TO_BITMAP_ARB         0x2002
     82 #define WGL_ACCELERATION_ARB           0x2003
     83 #define WGL_NEED_PALETTE_ARB           0x2004
     84 #define WGL_NEED_SYSTEM_PALETTE_ARB    0x2005
     85 #define WGL_SWAP_LAYER_BUFFERS_ARB     0x2006
     86 #define WGL_SWAP_METHOD_ARB            0x2007
     87 #define WGL_NUMBER_OVERLAYS_ARB        0x2008
     88 #define WGL_NUMBER_UNDERLAYS_ARB       0x2009
     89 #define WGL_TRANSPARENT_ARB            0x200A
     90 #define WGL_TRANSPARENT_RED_VALUE_ARB  0x2037
     91 #define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
     92 #define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
     93 #define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
     94 #define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
     95 #define WGL_SHARE_DEPTH_ARB            0x200C
     96 #define WGL_SHARE_STENCIL_ARB          0x200D
     97 #define WGL_SHARE_ACCUM_ARB            0x200E
     98 #define WGL_SUPPORT_GDI_ARB            0x200F
     99 #define WGL_SUPPORT_OPENGL_ARB         0x2010
    100 #define WGL_DOUBLE_BUFFER_ARB          0x2011
    101 #define WGL_STEREO_ARB                 0x2012
    102 #define WGL_PIXEL_TYPE_ARB             0x2013
    103 #define WGL_COLOR_BITS_ARB             0x2014
    104 #define WGL_RED_BITS_ARB               0x2015
    105 #define WGL_RED_SHIFT_ARB              0x2016
    106 #define WGL_GREEN_BITS_ARB             0x2017
    107 #define WGL_GREEN_SHIFT_ARB            0x2018
    108 #define WGL_BLUE_BITS_ARB              0x2019
    109 #define WGL_BLUE_SHIFT_ARB             0x201A
    110 #define WGL_ALPHA_BITS_ARB             0x201B
    111 #define WGL_ALPHA_SHIFT_ARB            0x201C
    112 #define WGL_ACCUM_BITS_ARB             0x201D
    113 #define WGL_ACCUM_RED_BITS_ARB         0x201E
    114 #define WGL_ACCUM_GREEN_BITS_ARB       0x201F
    115 #define WGL_ACCUM_BLUE_BITS_ARB        0x2020
    116 #define WGL_ACCUM_ALPHA_BITS_ARB       0x2021
    117 #define WGL_DEPTH_BITS_ARB             0x2022
    118 #define WGL_STENCIL_BITS_ARB           0x2023
    119 #define WGL_AUX_BUFFERS_ARB            0x2024
    120 #define WGL_NO_ACCELERATION_ARB        0x2025
    121 #define WGL_GENERIC_ACCELERATION_ARB   0x2026
    122 #define WGL_FULL_ACCELERATION_ARB      0x2027
    123 #define WGL_SWAP_EXCHANGE_ARB          0x2028
    124 #define WGL_SWAP_COPY_ARB              0x2029
    125 #define WGL_SWAP_UNDEFINED_ARB         0x202A
    126 #define WGL_TYPE_RGBA_ARB              0x202B
    127 #define WGL_TYPE_COLORINDEX_ARB        0x202C
    128 #endif
    129 
    130 #ifndef WGL_ARB_multisample
    131 #define WGL_SAMPLE_BUFFERS_ARB         0x2041
    132 #define WGL_SAMPLES_ARB                0x2042
    133 #endif
    134 
    135 #endif
    136