DIB Engine: implement most engine functions
[wine/hacks.git] / dlls / winedib.drv / opengl.c
blobf7855f64b4ef569e1b2951f47e94478837cb642f
1 /*
2 * DIBDRV OpenGL functions
4 * Copyright 2009 Massimo Del Fedele
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include "dibdrv.h"
26 #define HPBUFFERARB void *
28 WINE_DEFAULT_DEBUG_CHANNEL(dibdrv);
30 int DIBDRV_ChoosePixelFormat( DIBDRVPHYSDEV *physDev,
31 const PIXELFORMATDESCRIPTOR *ppfd )
33 int res;
35 MAYBE(TRACE("physDev:%p, ppfd:%p\n", physDev, ppfd));
37 if(physDev->hasDIB)
39 /* DIB section selected in, use DIB Engine */
40 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
41 res = _DIBDRV_GetDisplayDriver()->pChoosePixelFormat(physDev->X11PhysDev, ppfd);
43 else
45 /* DDB selected in, use X11 driver */
46 res = _DIBDRV_GetDisplayDriver()->pChoosePixelFormat(physDev->X11PhysDev, ppfd);
48 return res;
51 int DIBDRV_DescribePixelFormat( DIBDRVPHYSDEV *physDev,
52 int iPixelFormat,
53 UINT nBytes,
54 PIXELFORMATDESCRIPTOR *ppfd )
56 int res;
58 MAYBE(TRACE("physDev:%p, iPixelFormat:%d, nBytes:%d, ppfd:%p\n", physDev, iPixelFormat, nBytes, ppfd));
60 if(physDev->hasDIB)
62 /* DIB section selected in, use DIB Engine */
63 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
64 res = _DIBDRV_GetDisplayDriver()->pDescribePixelFormat(physDev->X11PhysDev, iPixelFormat, nBytes, ppfd);
66 else
68 /* DDB selected in, use X11 driver */
69 res = _DIBDRV_GetDisplayDriver()->pDescribePixelFormat(physDev->X11PhysDev, iPixelFormat, nBytes, ppfd);
71 return res;
74 int DIBDRV_GetPixelFormat( DIBDRVPHYSDEV *physDev)
76 int res;
78 MAYBE(TRACE("physDev:%p\n", physDev));
80 if(physDev->hasDIB)
82 /* DIB section selected in, use DIB Engine */
83 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
84 res = _DIBDRV_GetDisplayDriver()->pGetPixelFormat(physDev->X11PhysDev);
86 else
88 /* DDB selected in, use X11 driver */
89 res = _DIBDRV_GetDisplayDriver()->pGetPixelFormat(physDev->X11PhysDev);
91 return res;
94 BOOL DIBDRV_SetPixelFormat( DIBDRVPHYSDEV *physDev,
95 int iPixelFormat,
96 const PIXELFORMATDESCRIPTOR *ppfd )
98 BOOL res;
100 MAYBE(TRACE("physDev:%p, iPixelFormat:%d, ppfd:%p\n", physDev, iPixelFormat, ppfd));
102 if(physDev->hasDIB)
104 /* DIB section selected in, use DIB Engine */
105 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
106 res = _DIBDRV_GetDisplayDriver()->pSetPixelFormat(physDev->X11PhysDev, iPixelFormat, ppfd);
108 else
110 /* DDB selected in, use X11 driver */
111 res = _DIBDRV_GetDisplayDriver()->pSetPixelFormat(physDev->X11PhysDev, iPixelFormat, ppfd);
113 return res;
116 BOOL DIBDRV_SwapBuffers( DIBDRVPHYSDEV *physDev )
118 BOOL res;
120 MAYBE(TRACE("physDev:%p\n", physDev));
122 if(physDev->hasDIB)
124 /* DIB section selected in, use DIB Engine */
125 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
126 res = _DIBDRV_GetDisplayDriver()->pSwapBuffers(physDev->X11PhysDev);
128 else
130 /* DDB selected in, use X11 driver */
131 res = _DIBDRV_GetDisplayDriver()->pSwapBuffers(physDev->X11PhysDev);
133 return res;
137 * DIBDRV_wglCopyContext
139 * For OpenGL32 wglCopyContext.
141 BOOL CDECL DIBDRV_wglCopyContext(HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask)
143 BOOL res;
145 MAYBE(TRACE("hglrcSrc:%p, hglrcDst:%p, mask:%x\n", hglrcSrc, hglrcDst, mask));
147 ONCE(FIXME("stub\n"));
148 res = _DIBDRV_GetDisplayDriver()->pwglCopyContext(hglrcSrc, hglrcDst, mask);
150 return res;
154 * DIBDRV_wglCreateContext
156 * For OpenGL32 wglCreateContext.
158 HGLRC CDECL DIBDRV_wglCreateContext(DIBDRVPHYSDEV *physDev)
160 HGLRC res;
162 MAYBE(TRACE("physDev:%p\n", physDev));
164 if(physDev->hasDIB)
166 /* DIB section selected in, use DIB Engine */
167 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
168 res = _DIBDRV_GetDisplayDriver()->pwglCreateContext(physDev->X11PhysDev);
170 else
172 /* DDB selected in, use X11 driver */
173 res = _DIBDRV_GetDisplayDriver()->pwglCreateContext(physDev->X11PhysDev);
175 return res;
179 * DIBDRV_wglDeleteContext
181 * For OpenGL32 wglDeleteContext.
183 BOOL CDECL DIBDRV_wglDeleteContext(HGLRC hglrc)
185 BOOL res;
187 MAYBE(TRACE("hglrc:%p\n", hglrc));
189 ONCE(FIXME("stub\n"));
190 res = _DIBDRV_GetDisplayDriver()->pwglDeleteContext(hglrc);
191 return res;
195 * DIBDRV_wglGetProcAddress
197 * For OpenGL32 wglGetProcAddress.
199 PROC CDECL DIBDRV_wglGetProcAddress(LPCSTR lpszProc)
201 PROC res;
203 MAYBE(TRACE("lpszProc:%p\n", lpszProc));
205 ONCE(FIXME("stub\n"));
206 res = _DIBDRV_GetDisplayDriver()->pwglGetProcAddress(lpszProc);
208 return res;
212 * DIBDRV_wglGetPbufferDCARB
214 * WGL_ARB_pbuffer: wglGetPbufferDCARB
215 * The function wglGetPbufferDCARB returns a device context for a pbuffer.
216 * Gdi32 implements the part of this function which creates a device context.
217 * This part associates the physDev with the X drawable of the pbuffer.
219 HDC CDECL DIBDRV_wglGetPbufferDCARB(DIBDRVPHYSDEV *physDev, HPBUFFERARB hPbuffer)
221 HDC res;
223 MAYBE(TRACE("physDev:%p, hPbuffer:%p\n", physDev, hPbuffer));
225 if(physDev->hasDIB)
227 /* DIB section selected in, use DIB Engine */
228 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
229 res = _DIBDRV_GetDisplayDriver()->pwglGetPbufferDCARB(physDev->X11PhysDev, hPbuffer);
231 else
233 /* DDB selected in, use X11 driver */
234 res = _DIBDRV_GetDisplayDriver()->pwglGetPbufferDCARB(physDev->X11PhysDev, hPbuffer);
236 return res;
240 * DIBDRV_wglMakeContextCurrentARB
242 * For OpenGL32 wglMakeContextCurrentARB
244 BOOL CDECL DIBDRV_wglMakeContextCurrentARB(DIBDRVPHYSDEV* pDrawDev, DIBDRVPHYSDEV* pReadDev, HGLRC hglrc)
246 BOOL res;
248 MAYBE(TRACE("pDrawDev:%p, pReadDev:%p, hglrc:%p\n", pDrawDev, pReadDev, hglrc));
250 if(pDrawDev->hasDIB && pReadDev->hasDIB)
252 /* DIB section selected both in source and dest DCs, use DIB Engine */
253 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
254 res = _DIBDRV_GetDisplayDriver()->pwglMakeContextCurrentARB(pDrawDev->X11PhysDev, pReadDev->X11PhysDev, hglrc);
256 if(!pDrawDev->hasDIB && !pReadDev->hasDIB)
258 /* DDB selected both in source and dest DCs, use X11 Driver */
259 res = _DIBDRV_GetDisplayDriver()->pwglMakeContextCurrentARB(pDrawDev->X11PhysDev, pReadDev->X11PhysDev, hglrc);
261 else if(pDrawDev->hasDIB)
263 /* DIB selected in pDrawDev, must convert pReadDev to DIB and use DIB Engine */
264 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
265 res = _DIBDRV_GetDisplayDriver()->pwglMakeContextCurrentARB(pDrawDev->X11PhysDev, pReadDev->X11PhysDev, hglrc);
267 else /* if(pReadDev->hasDIB) */
269 /* DIB selected in pReadDev, must convert pReadDev to DDB and use X11 Driver */
270 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
271 res = _DIBDRV_GetDisplayDriver()->pwglMakeContextCurrentARB(pDrawDev->X11PhysDev, pReadDev->X11PhysDev, hglrc);
273 return res;
277 * DIBDRV_wglMakeCurrent
279 * For OpenGL32 wglMakeCurrent.
281 BOOL CDECL DIBDRV_wglMakeCurrent(DIBDRVPHYSDEV *physDev, HGLRC hglrc)
283 BOOL res;
285 MAYBE(TRACE("physDev:%p, hglrc:%p\n", physDev, hglrc));
287 if(physDev->hasDIB)
289 /* DIB section selected in, use DIB Engine */
290 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
291 res = _DIBDRV_GetDisplayDriver()->pwglMakeCurrent(physDev->X11PhysDev, hglrc);
293 else
295 /* DDB selected in, use X11 driver */
296 res = _DIBDRV_GetDisplayDriver()->pwglMakeCurrent(physDev->X11PhysDev, hglrc);
298 return res;
302 * DIBDRV_wglSetPixelFormatWINE
304 * WGL_WINE_pixel_format_passthrough: wglSetPixelFormatWINE
305 * This is a WINE-specific wglSetPixelFormat which can set the pixel format multiple times.
307 BOOL CDECL DIBDRV_wglSetPixelFormatWINE(DIBDRVPHYSDEV *physDev, int iPixelFormat, const PIXELFORMATDESCRIPTOR *ppfd)
309 BOOL res;
311 MAYBE(TRACE("physDev:%p, iPixelFormat:%d, ppfd:%p\n", physDev, iPixelFormat, ppfd));
313 if(physDev->hasDIB)
315 /* DIB section selected in, use DIB Engine */
316 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
317 res = _DIBDRV_GetDisplayDriver()->pwglSetPixelFormatWINE(physDev->X11PhysDev, iPixelFormat, ppfd);
319 else
321 /* DDB selected in, use X11 driver */
322 res = _DIBDRV_GetDisplayDriver()->pwglSetPixelFormatWINE(physDev->X11PhysDev, iPixelFormat, ppfd);
324 return res;
328 * DIBDRV_wglShareLists
330 * For OpenGL32 wglShareLists.
332 BOOL CDECL DIBDRV_wglShareLists(HGLRC hglrc1, HGLRC hglrc2)
334 BOOL res;
336 MAYBE(TRACE("hglrc1:%p, hglrc2:%p\n", hglrc1, hglrc2));
338 ONCE(FIXME("stub\n"));
339 res = _DIBDRV_GetDisplayDriver()->pwglShareLists(hglrc1, hglrc2);
341 return res;
345 * DIBDRV_wglUseFontBitmapsA
347 * For OpenGL32 wglUseFontBitmapsA.
349 BOOL CDECL DIBDRV_wglUseFontBitmapsA(DIBDRVPHYSDEV *physDev, DWORD first, DWORD count, DWORD listBase)
351 BOOL res;
353 MAYBE(TRACE("physDev:%p, first:%d, count:%d, listBase:%d\n", physDev, first, count, listBase));
355 if(physDev->hasDIB)
357 /* DIB section selected in, use DIB Engine */
358 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
359 res = _DIBDRV_GetDisplayDriver()->pwglUseFontBitmapsA(physDev->X11PhysDev, first, count, listBase);
361 else
363 /* DDB selected in, use X11 driver */
364 res = _DIBDRV_GetDisplayDriver()->pwglUseFontBitmapsA(physDev->X11PhysDev, first, count, listBase);
366 return res;
370 * DIBDRV_wglUseFontBitmapsW
372 * For OpenGL32 wglUseFontBitmapsW.
374 BOOL CDECL DIBDRV_wglUseFontBitmapsW(DIBDRVPHYSDEV *physDev, DWORD first, DWORD count, DWORD listBase)
376 BOOL res;
378 MAYBE(TRACE("physDev:%p, first:%d, count:%d, listBase:%d\n", physDev, first, count, listBase));
380 if(physDev->hasDIB)
382 /* DIB section selected in, use DIB Engine */
383 ONCE(FIXME("TEMPORARY - fallback to X11 driver\n"));
384 res = _DIBDRV_GetDisplayDriver()->pwglUseFontBitmapsW(physDev->X11PhysDev, first, count, listBase);
386 else
388 /* DDB selected in, use X11 driver */
389 res = _DIBDRV_GetDisplayDriver()->pwglUseFontBitmapsW(physDev->X11PhysDev, first, count, listBase);
391 return res;