1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
33 #include "pipe/p_debug.h"
35 #include "shared/stw_device.h"
36 #include "shared/stw_context.h"
37 #include "shared/stw_pixelformat.h"
38 #include "icd/stw_icd.h"
39 #include "wgl/stw_wgl.h"
43 lookup_hglrc( DHGLRC dhglrc
)
46 dhglrc
>= DRV_CONTEXT_MAX
)
49 return stw_dev
->ctx_array
[dhglrc
- 1].hglrc
;
58 HGLRC src
= lookup_hglrc( dhrcSource
);
59 HGLRC dst
= lookup_hglrc( dhrcDest
);
65 return stw_wgl_copy_context( src
, dst
, fuMask
);
69 DrvCreateLayerContext(
75 for (i
= 0; i
< DRV_CONTEXT_MAX
; i
++) {
76 if (stw_dev
->ctx_array
[i
].hglrc
== NULL
)
80 /* No slot available, fail:
85 stw_dev
->ctx_array
[i
].hglrc
= stw_wgl_create_context( hdc
, iLayerPlane
);
86 if (stw_dev
->ctx_array
[i
].hglrc
== NULL
)
89 return (DHGLRC
) i
+ 1;
96 return DrvCreateLayerContext( hdc
, 0 );
103 HGLRC hglrc
= lookup_hglrc( dhglrc
);
104 BOOL success
= FALSE
;
107 success
= stw_wgl_delete_context( hglrc
);
109 stw_dev
->ctx_array
[dhglrc
- 1].hglrc
= NULL
;
112 debug_printf( "%s( %u ) = %s\n", __FUNCTION__
, dhglrc
, success
? "TRUE" : "FALSE" );
118 DrvDescribeLayerPlane(
123 LPLAYERPLANEDESCRIPTOR plpd
)
125 debug_printf( "%s\n", __FUNCTION__
);
131 DrvDescribePixelFormat(
135 PIXELFORMATDESCRIPTOR
*ppfd
)
139 r
= stw_pixelformat_describe( hdc
, iPixelFormat
, cjpfd
, ppfd
);
141 debug_printf( "%s( 0x%p, %d, %u, 0x%p ) = %d\n",
142 __FUNCTION__
, hdc
, iPixelFormat
, cjpfd
, ppfd
, r
);
148 DrvGetLayerPaletteEntries(
155 debug_printf( "%s\n", __FUNCTION__
);
166 r
= wglGetProcAddress( lpszProc
);
168 debug_printf( "%s( \", __FUNCTION__%s\" ) = 0x%p\n", lpszProc
, r
);
174 DrvRealizeLayerPalette(
179 debug_printf( "%s\n", __FUNCTION__
);
188 BOOL success
= FALSE
;
190 if (dhglrc
== stw_dev
->ctx_current
) {
191 HGLRC hglrc
= lookup_hglrc( dhglrc
);
194 success
= wglMakeCurrent( NULL
, NULL
);
196 stw_dev
->ctx_current
= 0;
200 debug_printf( "%s( %u ) = %s\n", __FUNCTION__
, dhglrc
, success
? "TRUE" : "FALSE" );
210 debug_printf( "%s( %d, 0x%p )\n", __FUNCTION__
, nProcs
, pProcs
);
215 #define GPA_GL( NAME ) disp->NAME = gl##NAME
217 static GLCLTPROCTABLE cpt
;
219 PGLCLTPROCTABLE APIENTRY
223 PFN_SETPROCTABLE pfnSetProcTable
)
225 HGLRC hglrc
= lookup_hglrc( dhglrc
);
226 GLDISPATCHTABLE
*disp
= &cpt
.glDispatchTable
;
228 debug_printf( "%s( 0x%p, %u, 0x%p )\n", __FUNCTION__
, hdc
, dhglrc
, pfnSetProcTable
);
233 if (!wglMakeCurrent( hdc
, hglrc
))
236 memset( &cpt
, 0, sizeof( cpt
) );
237 cpt
.cEntries
= OPENGL_VERSION_110_ENTRIES
;
243 GPA_GL( DeleteLists
);
301 GPA_GL( RasterPos2d
);
302 GPA_GL( RasterPos2dv
);
303 GPA_GL( RasterPos2f
);
304 GPA_GL( RasterPos2fv
);
305 GPA_GL( RasterPos2i
);
306 GPA_GL( RasterPos2iv
);
307 GPA_GL( RasterPos2s
);
308 GPA_GL( RasterPos2sv
);
309 GPA_GL( RasterPos3d
);
310 GPA_GL( RasterPos3dv
);
311 GPA_GL( RasterPos3f
);
312 GPA_GL( RasterPos3fv
);
313 GPA_GL( RasterPos3i
);
314 GPA_GL( RasterPos3iv
);
315 GPA_GL( RasterPos3s
);
316 GPA_GL( RasterPos3sv
);
317 GPA_GL( RasterPos4d
);
318 GPA_GL( RasterPos4dv
);
319 GPA_GL( RasterPos4f
);
320 GPA_GL( RasterPos4fv
);
321 GPA_GL( RasterPos4i
);
322 GPA_GL( RasterPos4iv
);
323 GPA_GL( RasterPos4s
);
324 GPA_GL( RasterPos4sv
);
333 GPA_GL( TexCoord1d
);
334 GPA_GL( TexCoord1dv
);
335 GPA_GL( TexCoord1f
);
336 GPA_GL( TexCoord1fv
);
337 GPA_GL( TexCoord1i
);
338 GPA_GL( TexCoord1iv
);
339 GPA_GL( TexCoord1s
);
340 GPA_GL( TexCoord1sv
);
341 GPA_GL( TexCoord2d
);
342 GPA_GL( TexCoord2dv
);
343 GPA_GL( TexCoord2f
);
344 GPA_GL( TexCoord2fv
);
345 GPA_GL( TexCoord2i
);
346 GPA_GL( TexCoord2iv
);
347 GPA_GL( TexCoord2s
);
348 GPA_GL( TexCoord2sv
);
349 GPA_GL( TexCoord3d
);
350 GPA_GL( TexCoord3dv
);
351 GPA_GL( TexCoord3f
);
352 GPA_GL( TexCoord3fv
);
353 GPA_GL( TexCoord3i
);
354 GPA_GL( TexCoord3iv
);
355 GPA_GL( TexCoord3s
);
356 GPA_GL( TexCoord3sv
);
357 GPA_GL( TexCoord4d
);
358 GPA_GL( TexCoord4dv
);
359 GPA_GL( TexCoord4f
);
360 GPA_GL( TexCoord4fv
);
361 GPA_GL( TexCoord4i
);
362 GPA_GL( TexCoord4iv
);
363 GPA_GL( TexCoord4s
);
364 GPA_GL( TexCoord4sv
);
390 GPA_GL( ColorMaterial
);
402 GPA_GL( LightModelf
);
403 GPA_GL( LightModelfv
);
404 GPA_GL( LightModeli
);
405 GPA_GL( LightModeliv
);
406 GPA_GL( LineStipple
);
409 GPA_GL( Materialfv
);
411 GPA_GL( Materialiv
);
413 GPA_GL( PolygonMode
);
414 GPA_GL( PolygonStipple
);
416 GPA_GL( ShadeModel
);
417 GPA_GL( TexParameterf
);
418 GPA_GL( TexParameterfv
);
419 GPA_GL( TexParameteri
);
420 GPA_GL( TexParameteriv
);
421 GPA_GL( TexImage1D
);
422 GPA_GL( TexImage2D
);
433 GPA_GL( FeedbackBuffer
);
434 GPA_GL( SelectBuffer
);
435 GPA_GL( RenderMode
);
438 GPA_GL( PassThrough
);
441 GPA_GL( DrawBuffer
);
443 GPA_GL( ClearAccum
);
444 GPA_GL( ClearIndex
);
445 GPA_GL( ClearColor
);
446 GPA_GL( ClearStencil
);
447 GPA_GL( ClearDepth
);
448 GPA_GL( StencilMask
);
458 GPA_GL( PushAttrib
);
467 GPA_GL( EvalCoord1d
);
468 GPA_GL( EvalCoord1dv
);
469 GPA_GL( EvalCoord1f
);
470 GPA_GL( EvalCoord1fv
);
471 GPA_GL( EvalCoord2d
);
472 GPA_GL( EvalCoord2dv
);
473 GPA_GL( EvalCoord2f
);
474 GPA_GL( EvalCoord2fv
);
476 GPA_GL( EvalPoint1
);
478 GPA_GL( EvalPoint2
);
482 GPA_GL( StencilFunc
);
486 GPA_GL( PixelTransferf
);
487 GPA_GL( PixelTransferi
);
488 GPA_GL( PixelStoref
);
489 GPA_GL( PixelStorei
);
490 GPA_GL( PixelMapfv
);
491 GPA_GL( PixelMapuiv
);
492 GPA_GL( PixelMapusv
);
493 GPA_GL( ReadBuffer
);
494 GPA_GL( CopyPixels
);
495 GPA_GL( ReadPixels
);
496 GPA_GL( DrawPixels
);
497 GPA_GL( GetBooleanv
);
498 GPA_GL( GetClipPlane
);
499 GPA_GL( GetDoublev
);
502 GPA_GL( GetIntegerv
);
503 GPA_GL( GetLightfv
);
504 GPA_GL( GetLightiv
);
508 GPA_GL( GetMaterialfv
);
509 GPA_GL( GetMaterialiv
);
510 GPA_GL( GetPixelMapfv
);
511 GPA_GL( GetPixelMapuiv
);
512 GPA_GL( GetPixelMapusv
);
513 GPA_GL( GetPolygonStipple
);
515 GPA_GL( GetTexEnvfv
);
516 GPA_GL( GetTexEnviv
);
517 GPA_GL( GetTexGendv
);
518 GPA_GL( GetTexGenfv
);
519 GPA_GL( GetTexGeniv
);
520 GPA_GL( GetTexImage
);
521 GPA_GL( GetTexParameterfv
);
522 GPA_GL( GetTexParameteriv
);
523 GPA_GL( GetTexLevelParameterfv
);
524 GPA_GL( GetTexLevelParameteriv
);
527 GPA_GL( DepthRange
);
529 GPA_GL( LoadIdentity
);
530 GPA_GL( LoadMatrixf
);
531 GPA_GL( LoadMatrixd
);
532 GPA_GL( MatrixMode
);
533 GPA_GL( MultMatrixf
);
534 GPA_GL( MultMatrixd
);
537 GPA_GL( PushMatrix
);
542 GPA_GL( Translated
);
543 GPA_GL( Translatef
);
545 GPA_GL( ArrayElement
);
546 GPA_GL( BindTexture
);
547 GPA_GL( ColorPointer
);
548 GPA_GL( DisableClientState
);
549 GPA_GL( DrawArrays
);
550 GPA_GL( DrawElements
);
551 GPA_GL( EdgeFlagPointer
);
552 GPA_GL( EnableClientState
);
553 GPA_GL( IndexPointer
);
556 GPA_GL( InterleavedArrays
);
557 GPA_GL( NormalPointer
);
558 GPA_GL( PolygonOffset
);
559 GPA_GL( TexCoordPointer
);
560 GPA_GL( VertexPointer
);
561 GPA_GL( AreTexturesResident
);
562 GPA_GL( CopyTexImage1D
);
563 GPA_GL( CopyTexImage2D
);
564 GPA_GL( CopyTexSubImage1D
);
565 GPA_GL( CopyTexSubImage2D
);
566 GPA_GL( DeleteTextures
);
567 GPA_GL( GenTextures
);
568 GPA_GL( GetPointerv
);
570 GPA_GL( PrioritizeTextures
);
571 GPA_GL( TexSubImage1D
);
572 GPA_GL( TexSubImage2D
);
573 GPA_GL( PopClientAttrib
);
574 GPA_GL( PushClientAttrib
);
580 DrvSetLayerPaletteEntries(
585 CONST COLORREF
*pcr
)
587 debug_printf( "%s\n", __FUNCTION__
);
597 PIXELFORMATDESCRIPTOR pfd
;
600 stw_pixelformat_describe( hdc
, iPixelFormat
, sizeof( pfd
), &pfd
);
602 r
= wglSetPixelFormat( hdc
, iPixelFormat
, &pfd
);
604 debug_printf( "%s( 0x%p, %d ) = %s\n", __FUNCTION__
, hdc
, iPixelFormat
, r
? "TRUE" : "FALSE" );
614 debug_printf( "%s\n", __FUNCTION__
);
623 debug_printf( "%s( 0x%p )\n", __FUNCTION__
, hdc
);
625 return wglSwapBuffers( hdc
);
633 debug_printf( "%s\n", __FUNCTION__
);
642 debug_printf( "%s( %u )\n", __FUNCTION__
, ulVersion
);
644 return ulVersion
== 1;