bunch more groundwork for ICD support - patch by blight
[reactos.git] / reactos / lib / opengl32 / wgl.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: lib/opengl32/wgl.c
5 * PURPOSE: OpenGL32 lib, wglXXX functions
6 * PROGRAMMER: Anich Gregor (blight)
7 * UPDATE HISTORY:
8 * Feb 2, 2004: Created
9 */
10
11 #define WIN32_LEAN_AND_MEAN
12 #include <windows.h>
13 #include <winreg.h>
14
15 #include "opengl32.h"
16
17
18 BOOL wglCopyContext( HGLRC src, HGLRC dst, UINT mask )
19 {
20 }
21
22
23 HGLRC wglCreateContext( HDC hdc )
24 {
25 return wglCreateLayerContext( hdc, 0 );
26 }
27
28
29 HGLRC wglCreateLayerContext( HDC hdc, int layer )
30 {
31 HKEY hKey;
32 WCHAR subKey[1024] = L"SOFTWARE\\Microsoft\\Windows NT\\"
33 "CurrentVersion\\OpenGLDrivers");
34 LONG ret;
35 WCHAR driver[256];
36 DWORD size;
37 DWORD dw;
38 FILETIME time;
39
40 GLDRIVERDATA *icd;
41 GLRC *hglrc, *drvHglrc = NULL;
42
43 if (GetObjectType( hdc ) != OBJ_DC)
44 {
45 DBGPRINT( "Wrong object type" );
46 return NULL;
47 }
48
49 /* find out which icd to load */
50 ret = RegOpenKeyExW( HKEY_LOCAL_MACHINE, subKey, 0, KEY_READ, &hKey );
51 if (ret != ERROR_SUCCESS)
52 {
53 DBGPRINT( "Error: Couldn't open registry key '%ws'\n", subKey );
54 return FALSE;
55 }
56
57 /* allocate our GLRC */
58 hglrc = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof (GLRC) );
59 if (!hglrc)
60 return NULL;
61
62 for (dw = 0; ; dw++)
63 {
64 size = 256;
65 ret = RegEnumKeyExW( hKey, dw, driver, &size, NULL, NULL, NULL, &time );
66 if (ret != ERROR_SUCCESS )
67 break;
68
69 icd = OPENGL32_LoadICDW( driver );
70 if (!icd)
71 continue;
72
73 drvHglrc = icd->DrvCreateLayerContext( hdc, layer );
74 if (!drvHglrc)
75 {
76 DBGPRINT( "Info: DrvCreateLayerContext (driver = %ws) failed: %d\n",
77 icd->driver_name, GetLastError() );
78 OPENGL32_UnloadICD( icd );
79 continue;
80 }
81
82 /* the ICD was loaded successfully and we got a HGLRC -- success! */
83 break;
84 }
85 RegCloseKey( hKey );
86
87 if (!drvHglrc)
88 {
89 /* FIXME: fallback to mesa */
90 HeapFree( GetProcessHeap(), 0, hglrc );
91 return NULL;
92 }
93
94 /* we have our GLRC in hglrc and the ICDs in drvHglrc */
95 hglrc->hglrc = drcHglrc;
96 hglrc->iFormat = -1; /* what is this used for? */
97 hglrc->icd = icd;
98 hglrc->threadid = 0xFFFFFFFF; /* TODO: make sure this is the "invalid" value */
99 memcpy( hglrc->func_list, icd->func_list, sizeof (PVOID) * GLIDX_COUNT );
100
101 /* FIXME: fill NULL-pointers in hglrc->func_list with mesa functions */
102
103 /* FIXME: append hglrc to process-local list of contexts */
104 }
105
106
107 BOOL wglDeleteContext( HGLRC hglrc )
108 {
109 }
110
111
112 BOOL wglDescribeLayerPlane( HDC hdc, int iPixelFormat, int iLayerPlane,
113 UINT nBytes, LPLAYERPLANEDESCRIPTOR plpd )
114 {
115 }
116
117
118 HGLRC wglGetCurrentContext()
119 {
120 }
121
122
123 HDC wglGetCurrentDC()
124 {
125 }
126
127
128 int wglGetLayerPaletteEntries( HDC hdc, int iLayerPlane, int iStart,
129 int cEntries, CONST COLORREF *pcr )
130 {
131 }
132
133
134 PROC wglGetProcAddress( LPCSTR proc )
135 {
136 }
137
138
139 BOOL wglMakeCurrent( HDC hdc, HGLRC hglrc )
140 {
141 }
142
143
144 BOOL wglRealizeLayerPalette( HDC hdc, int iLayerPlane, BOOL bRealize )
145 {
146 }
147
148
149 int wglSetLayerPaletteEntries( HDC hdc, int iLayerPlane, int iStart,
150 int cEntries, CONST COLORREF *pcr )
151 {
152 }
153
154
155 BOOL wglShareLists( HGLRC hglrc1, HGLRC hglrc2 )
156 {
157 }
158
159
160 BOOL wglSwapLayerBuffers( HDC hdc, UINT fuPlanes )
161 {
162 }
163
164
165 BOOL wglUseFontBitmapsA( HDC hdc, DWORD first, DWORD count, DWORD listBase )
166 {
167 }
168
169
170 BOOL wglUseFontBitmapsW( HDC hdc, DWORD first, DWORD count, DWORD listBase )
171 {
172 }
173
174
175 BOOL wglUseFontOutlinesA( HDC hdc, DWORD first, DWORD count, DWORD listBase,
176 FLOAT deviation, FLOAT extrusion, int format,
177 LPGLYPHMETRICSFLOAT lpgmf )
178 {
179 }
180
181
182 BOOL wglUseFontOutlinesW( HDC hdc, DWORD first, DWORD count, DWORD listBase,
183 FLOAT deviation, FLOAT extrusion, int format,
184 LPGLYPHMETRICSFLOAT lpgmf )
185 {
186 }
187