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_public.h"
36 #include "icd/stw_icd.h"
40 #define DRV_CONTEXT_MAX 32
46 } ctx_array
[DRV_CONTEXT_MAX
];
52 static struct stw_icd
*stw_icd
= NULL
;
58 static struct stw_icd stw_icd_storage
;
62 stw_icd
= &stw_icd_storage
;
63 memset(stw_icd
, 0, sizeof(*stw_icd
));
76 /* Ensure all contexts are destroyed */
77 for (dhglrc
= 1; dhglrc
<= DRV_CONTEXT_MAX
; dhglrc
++)
78 if (stw_icd
->ctx_array
[dhglrc
- 1].hglrc
)
79 DrvDeleteContext( dhglrc
);
86 lookup_hglrc( DHGLRC dhglrc
)
89 dhglrc
>= DRV_CONTEXT_MAX
)
92 return stw_icd
->ctx_array
[dhglrc
- 1].hglrc
;
101 HGLRC src
= lookup_hglrc( dhrcSource
);
102 HGLRC dst
= lookup_hglrc( dhrcDest
);
108 return stw_copy_context( src
, dst
, fuMask
);
112 DrvCreateLayerContext(
118 for (i
= 0; i
< DRV_CONTEXT_MAX
; i
++) {
119 if (stw_icd
->ctx_array
[i
].hglrc
== NULL
)
123 /* No slot available, fail:
128 stw_icd
->ctx_array
[i
].hglrc
= stw_create_context( hdc
, iLayerPlane
);
129 if (stw_icd
->ctx_array
[i
].hglrc
== NULL
)
132 return (DHGLRC
) i
+ 1;
139 return DrvCreateLayerContext( hdc
, 0 );
146 HGLRC hglrc
= lookup_hglrc( dhglrc
);
147 BOOL success
= FALSE
;
150 success
= stw_delete_context( hglrc
);
152 stw_icd
->ctx_array
[dhglrc
- 1].hglrc
= NULL
;
155 debug_printf( "%s( %u ) = %s\n", __FUNCTION__
, dhglrc
, success
? "TRUE" : "FALSE" );
161 DrvDescribeLayerPlane(
166 LPLAYERPLANEDESCRIPTOR plpd
)
168 debug_printf( "%s\n", __FUNCTION__
);
174 DrvDescribePixelFormat(
178 PIXELFORMATDESCRIPTOR
*ppfd
)
182 r
= stw_pixelformat_describe( hdc
, iPixelFormat
, cjpfd
, ppfd
);
184 debug_printf( "%s( 0x%p, %d, %u, 0x%p ) = %d\n",
185 __FUNCTION__
, hdc
, iPixelFormat
, cjpfd
, ppfd
, r
);
191 DrvGetLayerPaletteEntries(
198 debug_printf( "%s\n", __FUNCTION__
);
209 r
= stw_get_proc_address( lpszProc
);
211 debug_printf( "%s( \", __FUNCTION__%s\" ) = 0x%p\n", lpszProc
, r
);
217 DrvRealizeLayerPalette(
222 debug_printf( "%s\n", __FUNCTION__
);
231 BOOL success
= FALSE
;
233 if (dhglrc
== stw_icd
->ctx_current
) {
234 HGLRC hglrc
= lookup_hglrc( dhglrc
);
237 success
= stw_make_current( NULL
, NULL
);
239 stw_icd
->ctx_current
= 0;
243 debug_printf( "%s( %u ) = %s\n", __FUNCTION__
, dhglrc
, success
? "TRUE" : "FALSE" );
253 debug_printf( "%s( %d, 0x%p )\n", __FUNCTION__
, nProcs
, pProcs
);
258 #define GPA_GL( NAME ) disp->NAME = gl##NAME
260 static GLCLTPROCTABLE cpt
;
262 PGLCLTPROCTABLE APIENTRY
266 PFN_SETPROCTABLE pfnSetProcTable
)
268 HGLRC hglrc
= lookup_hglrc( dhglrc
);
269 GLDISPATCHTABLE
*disp
= &cpt
.glDispatchTable
;
271 debug_printf( "%s( 0x%p, %u, 0x%p )\n", __FUNCTION__
, hdc
, dhglrc
, pfnSetProcTable
);
276 if (!stw_make_current( hdc
, hglrc
))
279 memset( &cpt
, 0, sizeof( cpt
) );
280 cpt
.cEntries
= OPENGL_VERSION_110_ENTRIES
;
286 GPA_GL( DeleteLists
);
344 GPA_GL( RasterPos2d
);
345 GPA_GL( RasterPos2dv
);
346 GPA_GL( RasterPos2f
);
347 GPA_GL( RasterPos2fv
);
348 GPA_GL( RasterPos2i
);
349 GPA_GL( RasterPos2iv
);
350 GPA_GL( RasterPos2s
);
351 GPA_GL( RasterPos2sv
);
352 GPA_GL( RasterPos3d
);
353 GPA_GL( RasterPos3dv
);
354 GPA_GL( RasterPos3f
);
355 GPA_GL( RasterPos3fv
);
356 GPA_GL( RasterPos3i
);
357 GPA_GL( RasterPos3iv
);
358 GPA_GL( RasterPos3s
);
359 GPA_GL( RasterPos3sv
);
360 GPA_GL( RasterPos4d
);
361 GPA_GL( RasterPos4dv
);
362 GPA_GL( RasterPos4f
);
363 GPA_GL( RasterPos4fv
);
364 GPA_GL( RasterPos4i
);
365 GPA_GL( RasterPos4iv
);
366 GPA_GL( RasterPos4s
);
367 GPA_GL( RasterPos4sv
);
376 GPA_GL( TexCoord1d
);
377 GPA_GL( TexCoord1dv
);
378 GPA_GL( TexCoord1f
);
379 GPA_GL( TexCoord1fv
);
380 GPA_GL( TexCoord1i
);
381 GPA_GL( TexCoord1iv
);
382 GPA_GL( TexCoord1s
);
383 GPA_GL( TexCoord1sv
);
384 GPA_GL( TexCoord2d
);
385 GPA_GL( TexCoord2dv
);
386 GPA_GL( TexCoord2f
);
387 GPA_GL( TexCoord2fv
);
388 GPA_GL( TexCoord2i
);
389 GPA_GL( TexCoord2iv
);
390 GPA_GL( TexCoord2s
);
391 GPA_GL( TexCoord2sv
);
392 GPA_GL( TexCoord3d
);
393 GPA_GL( TexCoord3dv
);
394 GPA_GL( TexCoord3f
);
395 GPA_GL( TexCoord3fv
);
396 GPA_GL( TexCoord3i
);
397 GPA_GL( TexCoord3iv
);
398 GPA_GL( TexCoord3s
);
399 GPA_GL( TexCoord3sv
);
400 GPA_GL( TexCoord4d
);
401 GPA_GL( TexCoord4dv
);
402 GPA_GL( TexCoord4f
);
403 GPA_GL( TexCoord4fv
);
404 GPA_GL( TexCoord4i
);
405 GPA_GL( TexCoord4iv
);
406 GPA_GL( TexCoord4s
);
407 GPA_GL( TexCoord4sv
);
433 GPA_GL( ColorMaterial
);
445 GPA_GL( LightModelf
);
446 GPA_GL( LightModelfv
);
447 GPA_GL( LightModeli
);
448 GPA_GL( LightModeliv
);
449 GPA_GL( LineStipple
);
452 GPA_GL( Materialfv
);
454 GPA_GL( Materialiv
);
456 GPA_GL( PolygonMode
);
457 GPA_GL( PolygonStipple
);
459 GPA_GL( ShadeModel
);
460 GPA_GL( TexParameterf
);
461 GPA_GL( TexParameterfv
);
462 GPA_GL( TexParameteri
);
463 GPA_GL( TexParameteriv
);
464 GPA_GL( TexImage1D
);
465 GPA_GL( TexImage2D
);
476 GPA_GL( FeedbackBuffer
);
477 GPA_GL( SelectBuffer
);
478 GPA_GL( RenderMode
);
481 GPA_GL( PassThrough
);
484 GPA_GL( DrawBuffer
);
486 GPA_GL( ClearAccum
);
487 GPA_GL( ClearIndex
);
488 GPA_GL( ClearColor
);
489 GPA_GL( ClearStencil
);
490 GPA_GL( ClearDepth
);
491 GPA_GL( StencilMask
);
501 GPA_GL( PushAttrib
);
510 GPA_GL( EvalCoord1d
);
511 GPA_GL( EvalCoord1dv
);
512 GPA_GL( EvalCoord1f
);
513 GPA_GL( EvalCoord1fv
);
514 GPA_GL( EvalCoord2d
);
515 GPA_GL( EvalCoord2dv
);
516 GPA_GL( EvalCoord2f
);
517 GPA_GL( EvalCoord2fv
);
519 GPA_GL( EvalPoint1
);
521 GPA_GL( EvalPoint2
);
525 GPA_GL( StencilFunc
);
529 GPA_GL( PixelTransferf
);
530 GPA_GL( PixelTransferi
);
531 GPA_GL( PixelStoref
);
532 GPA_GL( PixelStorei
);
533 GPA_GL( PixelMapfv
);
534 GPA_GL( PixelMapuiv
);
535 GPA_GL( PixelMapusv
);
536 GPA_GL( ReadBuffer
);
537 GPA_GL( CopyPixels
);
538 GPA_GL( ReadPixels
);
539 GPA_GL( DrawPixels
);
540 GPA_GL( GetBooleanv
);
541 GPA_GL( GetClipPlane
);
542 GPA_GL( GetDoublev
);
545 GPA_GL( GetIntegerv
);
546 GPA_GL( GetLightfv
);
547 GPA_GL( GetLightiv
);
551 GPA_GL( GetMaterialfv
);
552 GPA_GL( GetMaterialiv
);
553 GPA_GL( GetPixelMapfv
);
554 GPA_GL( GetPixelMapuiv
);
555 GPA_GL( GetPixelMapusv
);
556 GPA_GL( GetPolygonStipple
);
558 GPA_GL( GetTexEnvfv
);
559 GPA_GL( GetTexEnviv
);
560 GPA_GL( GetTexGendv
);
561 GPA_GL( GetTexGenfv
);
562 GPA_GL( GetTexGeniv
);
563 GPA_GL( GetTexImage
);
564 GPA_GL( GetTexParameterfv
);
565 GPA_GL( GetTexParameteriv
);
566 GPA_GL( GetTexLevelParameterfv
);
567 GPA_GL( GetTexLevelParameteriv
);
570 GPA_GL( DepthRange
);
572 GPA_GL( LoadIdentity
);
573 GPA_GL( LoadMatrixf
);
574 GPA_GL( LoadMatrixd
);
575 GPA_GL( MatrixMode
);
576 GPA_GL( MultMatrixf
);
577 GPA_GL( MultMatrixd
);
580 GPA_GL( PushMatrix
);
585 GPA_GL( Translated
);
586 GPA_GL( Translatef
);
588 GPA_GL( ArrayElement
);
589 GPA_GL( BindTexture
);
590 GPA_GL( ColorPointer
);
591 GPA_GL( DisableClientState
);
592 GPA_GL( DrawArrays
);
593 GPA_GL( DrawElements
);
594 GPA_GL( EdgeFlagPointer
);
595 GPA_GL( EnableClientState
);
596 GPA_GL( IndexPointer
);
599 GPA_GL( InterleavedArrays
);
600 GPA_GL( NormalPointer
);
601 GPA_GL( PolygonOffset
);
602 GPA_GL( TexCoordPointer
);
603 GPA_GL( VertexPointer
);
604 GPA_GL( AreTexturesResident
);
605 GPA_GL( CopyTexImage1D
);
606 GPA_GL( CopyTexImage2D
);
607 GPA_GL( CopyTexSubImage1D
);
608 GPA_GL( CopyTexSubImage2D
);
609 GPA_GL( DeleteTextures
);
610 GPA_GL( GenTextures
);
611 GPA_GL( GetPointerv
);
613 GPA_GL( PrioritizeTextures
);
614 GPA_GL( TexSubImage1D
);
615 GPA_GL( TexSubImage2D
);
616 GPA_GL( PopClientAttrib
);
617 GPA_GL( PushClientAttrib
);
623 DrvSetLayerPaletteEntries(
628 CONST COLORREF
*pcr
)
630 debug_printf( "%s\n", __FUNCTION__
);
642 r
= stw_pixelformat_set( hdc
, iPixelFormat
);
644 debug_printf( "%s( 0x%p, %d ) = %s\n", __FUNCTION__
, hdc
, iPixelFormat
, r
? "TRUE" : "FALSE" );
654 debug_printf( "%s\n", __FUNCTION__
);
663 debug_printf( "%s( 0x%p )\n", __FUNCTION__
, hdc
);
665 return stw_swap_buffers( hdc
);
673 debug_printf( "%s\n", __FUNCTION__
);
682 debug_printf( "%s( %u )\n", __FUNCTION__
, ulVersion
);
684 return ulVersion
== 1;