1 /*
2 
3 Boost Software License - Version 1.0 - August 17th, 2003
4 
5 Permission is hereby granted, free of charge, to any person or organization
6 obtaining a copy of the software and accompanying documentation covered by
7 this license (the "Software") to use, reproduce, display, distribute,
8 execute, and transmit the Software, and to prepare derivative works of the
9 Software, and to permit third-parties to whom the Software is furnished to
10 do so, all subject to the following:
11 
12 The copyright notices in the Software and this entire statement, including
13 the above license grant, this restriction and the following disclaimer,
14 must be included in all copies of the Software, in whole or in part, and
15 all derivative works of the Software, unless such copies or derivative
16 works are solely in the form of machine-executable object code generated by
17 a source language processor.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
22 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
23 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
24 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26 
27 */
28 module derelict.opengl.wgl;
29 
30 private
31 {
32     import derelict.util.wintypes;
33     import derelict.util.compat;
34 }
35 
36 version(Windows)
37 {
38     extern(Windows)
39     {
40         alias BOOL function(void*,void*) da_wglCopyContext;
41         alias void* function(void*) da_wglCreateContext;
42         alias void* function(void*,int) da_wglCreateLayerContext;
43         alias BOOL function(void*) da_wglDeleteContext;
44         alias BOOL function(void*,int,int,UINT,LAYERPLANEDESCRIPTOR*) da_wglDescribeLayerPlane;
45         alias void* function() da_wglGetCurrentContext;
46         alias void* function() da_wglGetCurrentDC;
47         alias int function(void*,int,int,int,COLORREF*) da_wglGetLayerPaletteEntries;
48         alias FARPROC function(LPCSTR) da_wglGetProcAddress;
49         alias BOOL function(void*,void*) da_wglMakeCurrent;
50         alias BOOL function(void*,int,BOOL) da_wglRealizeLayerPalette;
51         alias int function(void*,int,int,int,COLORREF*) da_wglSetLayerPaletteEntries;
52         alias BOOL function(void*,void*) da_wglShareLists;
53         alias BOOL function(void*,UINT) da_wglSwapLayerBuffers;
54         alias BOOL function(void*,DWORD,DWORD,DWORD) da_wglUseFontBitmapsA;
55         alias BOOL function(void*,DWORD,DWORD,DWORD,FLOAT,FLOAT,int,GLYPHMETRICSFLOAT*) da_wglUseFontOutlinesA;
56         alias BOOL function(void*,DWORD,DWORD,DWORD) da_wglUseFontBitmapsW;
57         alias BOOL function(void*,DWORD,DWORD,DWORD,FLOAT,FLOAT,int,GLYPHMETRICSFLOAT*) da_wglUseFontOutlinesW;
58 
59     }
60 
61     mixin(gsharedString!() ~
62     "
63     da_wglCopyContext wglCopyContext;
64     da_wglCreateContext wglCreateContext;
65     da_wglCreateLayerContext wglCreateLayerContext;
66     da_wglDeleteContext wglDeleteContext;
67     da_wglDescribeLayerPlane wglDescribeLayerPlane;
68     da_wglGetCurrentContext wglGetCurrentContext;
69     da_wglGetCurrentDC wglGetCurrentDC;
70     da_wglGetLayerPaletteEntries wglGetLayerPaletteEntries;
71     da_wglGetProcAddress wglGetProcAddress;
72     da_wglMakeCurrent wglMakeCurrent;
73     da_wglRealizeLayerPalette wglRealizeLayerPalette;
74     da_wglSetLayerPaletteEntries wglSetLayerPaletteEntries;
75     da_wglShareLists wglShareLists;
76     da_wglSwapLayerBuffers wglSwapLayerBuffers;
77     da_wglUseFontBitmapsA wglUseFontBitmapsA;
78     da_wglUseFontOutlinesA wglUseFontOutlinesA;
79     da_wglUseFontBitmapsW wglUseFontBitmapsW;
80     da_wglUseFontOutlinesW wglUseFontOutlinesW;
81 
82     alias wglUseFontBitmapsA    wglUseFontBitmaps;
83     alias wglUseFontOutlinesA   wglUseFontOutlines;
84     ");
85 
86 
87     package
88     {
89         void loadPlatformGL(void delegate(void**, string, bool doThrow = true) bindFunc)
90         {
91             bindFunc(cast(void**)&wglCopyContext, "wglCopyContext", false);
92             bindFunc(cast(void**)&wglCreateContext, "wglCreateContext", false);
93             bindFunc(cast(void**)&wglCreateLayerContext, "wglCreateLayerContext", false);
94             bindFunc(cast(void**)&wglDeleteContext, "wglDeleteContext", false);
95             bindFunc(cast(void**)&wglDescribeLayerPlane, "wglDescribeLayerPlane", false);
96             bindFunc(cast(void**)&wglGetCurrentContext, "wglGetCurrentContext", false);
97             bindFunc(cast(void**)&wglGetCurrentDC, "wglGetCurrentDC", false);
98             bindFunc(cast(void**)&wglGetLayerPaletteEntries, "wglGetLayerPaletteEntries", false);
99             bindFunc(cast(void**)&wglGetProcAddress, "wglGetProcAddress", false);
100             bindFunc(cast(void**)&wglMakeCurrent, "wglMakeCurrent", false);
101             bindFunc(cast(void**)&wglRealizeLayerPalette, "wglRealizeLayerPalette", false);
102             bindFunc(cast(void**)&wglSetLayerPaletteEntries, "wglSetLayerPaletteEntries", false);
103             bindFunc(cast(void**)&wglShareLists, "wglShareLists", false);
104             bindFunc(cast(void**)&wglSwapLayerBuffers, "wglSwapLayerBuffers", false);
105             bindFunc(cast(void**)&wglUseFontBitmapsA, "wglUseFontBitmapsA", false);
106             bindFunc(cast(void**)&wglUseFontOutlinesA, "wglUseFontOutlinesA", false);
107             bindFunc(cast(void**)&wglUseFontBitmapsW, "wglUseFontBitmapsW", false);
108             bindFunc(cast(void**)&wglUseFontOutlinesW, "wglUseFontOutlinesW", false);
109         }
110 
111         void* loadGLSymbol(string symName)
112         {
113             return cast(void*)wglGetProcAddress(toCString(symName));
114         }
115     }
116 }