99debfddadc7380e049dd6d1563eeadd491e98fb
[mesa.git] / src / gallium / state_trackers / wgl / stw_context.c
1 /**************************************************************************
2 *
3 * Copyright 2008 VMware, Inc.
4 * All Rights Reserved.
5 *
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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 VMWARE 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.
25 *
26 **************************************************************************/
27
28 #include <windows.h>
29
30 #define WGL_WGLEXT_PROTOTYPES
31
32 #include <GL/gl.h>
33 #include <GL/wglext.h>
34
35 #include "pipe/p_compiler.h"
36 #include "pipe/p_context.h"
37 #include "pipe/p_state.h"
38 #include "util/u_memory.h"
39 #include "util/u_atomic.h"
40 #include "state_tracker/st_api.h"
41 #include "hud/hud_context.h"
42
43 #include "stw_icd.h"
44 #include "stw_device.h"
45 #include "stw_winsys.h"
46 #include "stw_framebuffer.h"
47 #include "stw_pixelformat.h"
48 #include "stw_context.h"
49 #include "stw_tls.h"
50
51
52 struct stw_context *
53 stw_current_context(void)
54 {
55 struct st_context_iface *st;
56
57 st = (stw_dev) ? stw_dev->stapi->get_current(stw_dev->stapi) : NULL;
58
59 return (struct stw_context *) ((st) ? st->st_manager_private : NULL);
60 }
61
62 BOOL APIENTRY
63 DrvCopyContext(
64 DHGLRC dhrcSource,
65 DHGLRC dhrcDest,
66 UINT fuMask )
67 {
68 struct stw_context *src;
69 struct stw_context *dst;
70 BOOL ret = FALSE;
71
72 if (!stw_dev)
73 return FALSE;
74
75 pipe_mutex_lock( stw_dev->ctx_mutex );
76
77 src = stw_lookup_context_locked( dhrcSource );
78 dst = stw_lookup_context_locked( dhrcDest );
79
80 if (src && dst) {
81 /* FIXME */
82 assert(0);
83 (void) src;
84 (void) dst;
85 (void) fuMask;
86 }
87
88 pipe_mutex_unlock( stw_dev->ctx_mutex );
89
90 return ret;
91 }
92
93 BOOL APIENTRY
94 DrvShareLists(
95 DHGLRC dhglrc1,
96 DHGLRC dhglrc2 )
97 {
98 struct stw_context *ctx1;
99 struct stw_context *ctx2;
100 BOOL ret = FALSE;
101
102 if (!stw_dev)
103 return FALSE;
104
105 pipe_mutex_lock( stw_dev->ctx_mutex );
106
107 ctx1 = stw_lookup_context_locked( dhglrc1 );
108 ctx2 = stw_lookup_context_locked( dhglrc2 );
109
110 if (ctx1 && ctx2 && ctx2->st->share)
111 ret = ctx2->st->share(ctx2->st, ctx1->st);
112
113 pipe_mutex_unlock( stw_dev->ctx_mutex );
114
115 return ret;
116 }
117
118 DHGLRC APIENTRY
119 DrvCreateContext(
120 HDC hdc )
121 {
122 return DrvCreateLayerContext( hdc, 0 );
123 }
124
125 DHGLRC APIENTRY
126 DrvCreateLayerContext(
127 HDC hdc,
128 INT iLayerPlane )
129 {
130 return stw_create_context_attribs(hdc, iLayerPlane, 0, 1, 0, 0,
131 WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB,
132 0);
133 }
134
135
136 /**
137 * Called via DrvCreateContext(), DrvCreateLayerContext() and
138 * wglCreateContextAttribsARB() to actually create a rendering context.
139 * \param handle the desired DHGLRC handle to use for the context, or zero
140 * if a new handle should be allocated.
141 * \return the handle for the new context or zero if there was a problem.
142 */
143 DHGLRC
144 stw_create_context_attribs(HDC hdc, INT iLayerPlane, DHGLRC hShareContext,
145 int majorVersion, int minorVersion,
146 int contextFlags, int profileMask,
147 DHGLRC handle)
148 {
149 int iPixelFormat;
150 struct stw_framebuffer *fb;
151 const struct stw_pixelformat_info *pfi;
152 struct st_context_attribs attribs;
153 struct stw_context *ctx = NULL;
154 struct stw_context *shareCtx = NULL;
155 enum st_context_error ctx_err = 0;
156
157 if (!stw_dev)
158 return 0;
159
160 if (iLayerPlane != 0)
161 return 0;
162
163 iPixelFormat = GetPixelFormat(hdc);
164 if(!iPixelFormat)
165 return 0;
166
167 /*
168 * GDI only knows about displayable pixel formats, so determine the pixel
169 * format from the framebuffer.
170 *
171 * TODO: Remove the GetPixelFormat() above, and stop relying on GDI.
172 */
173 fb = stw_framebuffer_from_hdc( hdc );
174 if (fb) {
175 assert(iPixelFormat == fb->iDisplayablePixelFormat);
176 iPixelFormat = fb->iPixelFormat;
177 stw_framebuffer_release(fb);
178 }
179
180 pfi = stw_pixelformat_get_info( iPixelFormat );
181
182 if (hShareContext != 0) {
183 pipe_mutex_lock( stw_dev->ctx_mutex );
184 shareCtx = stw_lookup_context_locked( hShareContext );
185 pipe_mutex_unlock( stw_dev->ctx_mutex );
186 }
187
188 ctx = CALLOC_STRUCT( stw_context );
189 if (ctx == NULL)
190 goto no_ctx;
191
192 ctx->hdc = hdc;
193 ctx->iPixelFormat = iPixelFormat;
194
195 memset(&attribs, 0, sizeof(attribs));
196 attribs.visual = pfi->stvis;
197 attribs.major = majorVersion;
198 attribs.minor = minorVersion;
199 if (contextFlags & WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB)
200 attribs.flags |= ST_CONTEXT_FLAG_FORWARD_COMPATIBLE;
201 if (contextFlags & WGL_CONTEXT_DEBUG_BIT_ARB)
202 attribs.flags |= ST_CONTEXT_FLAG_DEBUG;
203
204 /* There are no profiles before OpenGL 3.2. The
205 * WGL_ARB_create_context_profile spec says:
206 *
207 * "If the requested OpenGL version is less than 3.2,
208 * WGL_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality of the
209 * context is determined solely by the requested version."
210 *
211 * The spec also says:
212 *
213 * "The default value for WGL_CONTEXT_PROFILE_MASK_ARB is
214 * WGL_CONTEXT_CORE_PROFILE_BIT_ARB."
215 *
216 * The spec also says:
217 *
218 * "If version 3.1 is requested, the context returned may implement
219 * any of the following versions:
220 *
221 * * Version 3.1. The GL_ARB_compatibility extension may or may not
222 * be implemented, as determined by the implementation.
223 * * The core profile of version 3.2 or greater."
224 *
225 * and because Mesa doesn't support GL_ARB_compatibility, the only chance to
226 * honour a 3.1 context is through core profile.
227 */
228 attribs.profile = ST_PROFILE_DEFAULT;
229 if (((majorVersion > 3 || (majorVersion == 3 && minorVersion >= 2))
230 && ((profileMask & WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) == 0)) ||
231 (majorVersion == 3 && minorVersion == 1))
232 attribs.profile = ST_PROFILE_OPENGL_CORE;
233
234 ctx->st = stw_dev->stapi->create_context(stw_dev->stapi,
235 stw_dev->smapi, &attribs, &ctx_err, shareCtx ? shareCtx->st : NULL);
236 if (ctx->st == NULL)
237 goto no_st_ctx;
238
239 ctx->st->st_manager_private = (void *) ctx;
240
241 if (ctx->st->cso_context) {
242 ctx->hud = hud_create(ctx->st->pipe, ctx->st->cso_context);
243 }
244
245 pipe_mutex_lock( stw_dev->ctx_mutex );
246 if (handle) {
247 /* We're replacing the context data for this handle. See the
248 * wglCreateContextAttribsARB() function.
249 */
250 struct stw_context *old_ctx =
251 stw_lookup_context_locked((unsigned) handle);
252 if (old_ctx) {
253 /* free the old context data associated with this handle */
254 if (old_ctx->hud) {
255 hud_destroy(old_ctx->hud);
256 }
257 ctx->st->destroy(old_ctx->st);
258 FREE(old_ctx);
259 }
260
261 /* replace table entry */
262 handle_table_set(stw_dev->ctx_table, (unsigned) handle, ctx);
263 }
264 else {
265 /* create new table entry */
266 handle = (DHGLRC) handle_table_add(stw_dev->ctx_table, ctx);
267 }
268
269 ctx->dhglrc = handle;
270
271 pipe_mutex_unlock( stw_dev->ctx_mutex );
272 if (!ctx->dhglrc)
273 goto no_hglrc;
274
275 return ctx->dhglrc;
276
277 no_hglrc:
278 if (ctx->hud) {
279 hud_destroy(ctx->hud);
280 }
281 ctx->st->destroy(ctx->st);
282 no_st_ctx:
283 FREE(ctx);
284 no_ctx:
285 return 0;
286 }
287
288 BOOL APIENTRY
289 DrvDeleteContext(
290 DHGLRC dhglrc )
291 {
292 struct stw_context *ctx ;
293 BOOL ret = FALSE;
294
295 if (!stw_dev)
296 return FALSE;
297
298 pipe_mutex_lock( stw_dev->ctx_mutex );
299 ctx = stw_lookup_context_locked(dhglrc);
300 handle_table_remove(stw_dev->ctx_table, dhglrc);
301 pipe_mutex_unlock( stw_dev->ctx_mutex );
302
303 if (ctx) {
304 struct stw_context *curctx = stw_current_context();
305
306 /* Unbind current if deleting current context. */
307 if (curctx == ctx)
308 stw_dev->stapi->make_current(stw_dev->stapi, NULL, NULL, NULL);
309
310 if (ctx->hud) {
311 hud_destroy(ctx->hud);
312 }
313
314 ctx->st->destroy(ctx->st);
315 FREE(ctx);
316
317 ret = TRUE;
318 }
319
320 return ret;
321 }
322
323 BOOL APIENTRY
324 DrvReleaseContext(
325 DHGLRC dhglrc )
326 {
327 struct stw_context *ctx;
328
329 if (!stw_dev)
330 return FALSE;
331
332 pipe_mutex_lock( stw_dev->ctx_mutex );
333 ctx = stw_lookup_context_locked( dhglrc );
334 pipe_mutex_unlock( stw_dev->ctx_mutex );
335
336 if (!ctx)
337 return FALSE;
338
339 /* The expectation is that ctx is the same context which is
340 * current for this thread. We should check that and return False
341 * if not the case.
342 */
343 if (ctx != stw_current_context())
344 return FALSE;
345
346 if (stw_make_current( NULL, 0 ) == FALSE)
347 return FALSE;
348
349 return TRUE;
350 }
351
352
353 DHGLRC
354 stw_get_current_context( void )
355 {
356 struct stw_context *ctx;
357
358 ctx = stw_current_context();
359 if(!ctx)
360 return 0;
361
362 return ctx->dhglrc;
363 }
364
365 HDC
366 stw_get_current_dc( void )
367 {
368 struct stw_context *ctx;
369
370 ctx = stw_current_context();
371 if(!ctx)
372 return NULL;
373
374 return ctx->hdc;
375 }
376
377 BOOL
378 stw_make_current(
379 HDC hdc,
380 DHGLRC dhglrc )
381 {
382 struct stw_context *curctx = NULL;
383 struct stw_context *ctx = NULL;
384 struct stw_framebuffer *fb = NULL;
385 BOOL ret = FALSE;
386
387 if (!stw_dev)
388 return FALSE;
389
390 curctx = stw_current_context();
391 if (curctx != NULL) {
392 if (curctx->dhglrc == dhglrc) {
393 if (curctx->hdc == hdc) {
394 /* Return if already current. */
395 return TRUE;
396 }
397 } else {
398 curctx->st->flush(curctx->st, ST_FLUSH_FRONT, NULL);
399 }
400 }
401
402 if (dhglrc) {
403 pipe_mutex_lock( stw_dev->ctx_mutex );
404 ctx = stw_lookup_context_locked( dhglrc );
405 pipe_mutex_unlock( stw_dev->ctx_mutex );
406 if (!ctx) {
407 goto fail;
408 }
409
410 fb = stw_framebuffer_from_hdc( hdc );
411 if (fb) {
412 stw_framebuffer_update(fb);
413 }
414 else {
415 /* Applications should call SetPixelFormat before creating a context,
416 * but not all do, and the opengl32 runtime seems to use a default pixel
417 * format in some cases, so we must create a framebuffer for those here
418 */
419 int iPixelFormat = GetPixelFormat(hdc);
420 if (iPixelFormat)
421 fb = stw_framebuffer_create( hdc, iPixelFormat );
422 if (!fb)
423 goto fail;
424 }
425
426 if (fb->iPixelFormat != ctx->iPixelFormat) {
427 SetLastError(ERROR_INVALID_PIXEL_FORMAT);
428 goto fail;
429 }
430
431 /* Bind the new framebuffer */
432 ctx->hdc = hdc;
433
434 ret = stw_dev->stapi->make_current(stw_dev->stapi, ctx->st,
435 fb->stfb, fb->stfb);
436 stw_framebuffer_reference(&ctx->current_framebuffer, fb);
437 } else {
438 ret = stw_dev->stapi->make_current(stw_dev->stapi, NULL, NULL, NULL);
439 }
440
441 fail:
442
443 if (fb) {
444 stw_framebuffer_release(fb);
445 }
446
447 /* On failure, make the thread's current rendering context not current
448 * before returning */
449 if (!ret) {
450 stw_dev->stapi->make_current(stw_dev->stapi, NULL, NULL, NULL);
451 ctx = NULL;
452 }
453
454 /* Unreference the previous framebuffer if any. It must be done after
455 * make_current, as it can be referenced inside.
456 */
457 if (curctx && curctx != ctx) {
458 stw_framebuffer_reference(&curctx->current_framebuffer, NULL);
459 }
460
461 return ret;
462 }
463
464 /**
465 * Flush the current context if it is bound to the framebuffer.
466 */
467 void
468 stw_flush_current_locked( struct stw_framebuffer *fb )
469 {
470 struct stw_context *ctx = stw_current_context();
471
472 if (ctx && ctx->current_framebuffer == fb) {
473 ctx->st->flush(ctx->st, ST_FLUSH_FRONT, NULL);
474 }
475 }
476
477 /**
478 * Notify the current context that the framebuffer has become invalid.
479 */
480 void
481 stw_notify_current_locked( struct stw_framebuffer *fb )
482 {
483 p_atomic_inc(&fb->stfb->stamp);
484 }
485
486 /**
487 * Although WGL allows different dispatch entrypoints per context
488 */
489 static const GLCLTPROCTABLE cpt =
490 {
491 OPENGL_VERSION_110_ENTRIES,
492 {
493 &glNewList,
494 &glEndList,
495 &glCallList,
496 &glCallLists,
497 &glDeleteLists,
498 &glGenLists,
499 &glListBase,
500 &glBegin,
501 &glBitmap,
502 &glColor3b,
503 &glColor3bv,
504 &glColor3d,
505 &glColor3dv,
506 &glColor3f,
507 &glColor3fv,
508 &glColor3i,
509 &glColor3iv,
510 &glColor3s,
511 &glColor3sv,
512 &glColor3ub,
513 &glColor3ubv,
514 &glColor3ui,
515 &glColor3uiv,
516 &glColor3us,
517 &glColor3usv,
518 &glColor4b,
519 &glColor4bv,
520 &glColor4d,
521 &glColor4dv,
522 &glColor4f,
523 &glColor4fv,
524 &glColor4i,
525 &glColor4iv,
526 &glColor4s,
527 &glColor4sv,
528 &glColor4ub,
529 &glColor4ubv,
530 &glColor4ui,
531 &glColor4uiv,
532 &glColor4us,
533 &glColor4usv,
534 &glEdgeFlag,
535 &glEdgeFlagv,
536 &glEnd,
537 &glIndexd,
538 &glIndexdv,
539 &glIndexf,
540 &glIndexfv,
541 &glIndexi,
542 &glIndexiv,
543 &glIndexs,
544 &glIndexsv,
545 &glNormal3b,
546 &glNormal3bv,
547 &glNormal3d,
548 &glNormal3dv,
549 &glNormal3f,
550 &glNormal3fv,
551 &glNormal3i,
552 &glNormal3iv,
553 &glNormal3s,
554 &glNormal3sv,
555 &glRasterPos2d,
556 &glRasterPos2dv,
557 &glRasterPos2f,
558 &glRasterPos2fv,
559 &glRasterPos2i,
560 &glRasterPos2iv,
561 &glRasterPos2s,
562 &glRasterPos2sv,
563 &glRasterPos3d,
564 &glRasterPos3dv,
565 &glRasterPos3f,
566 &glRasterPos3fv,
567 &glRasterPos3i,
568 &glRasterPos3iv,
569 &glRasterPos3s,
570 &glRasterPos3sv,
571 &glRasterPos4d,
572 &glRasterPos4dv,
573 &glRasterPos4f,
574 &glRasterPos4fv,
575 &glRasterPos4i,
576 &glRasterPos4iv,
577 &glRasterPos4s,
578 &glRasterPos4sv,
579 &glRectd,
580 &glRectdv,
581 &glRectf,
582 &glRectfv,
583 &glRecti,
584 &glRectiv,
585 &glRects,
586 &glRectsv,
587 &glTexCoord1d,
588 &glTexCoord1dv,
589 &glTexCoord1f,
590 &glTexCoord1fv,
591 &glTexCoord1i,
592 &glTexCoord1iv,
593 &glTexCoord1s,
594 &glTexCoord1sv,
595 &glTexCoord2d,
596 &glTexCoord2dv,
597 &glTexCoord2f,
598 &glTexCoord2fv,
599 &glTexCoord2i,
600 &glTexCoord2iv,
601 &glTexCoord2s,
602 &glTexCoord2sv,
603 &glTexCoord3d,
604 &glTexCoord3dv,
605 &glTexCoord3f,
606 &glTexCoord3fv,
607 &glTexCoord3i,
608 &glTexCoord3iv,
609 &glTexCoord3s,
610 &glTexCoord3sv,
611 &glTexCoord4d,
612 &glTexCoord4dv,
613 &glTexCoord4f,
614 &glTexCoord4fv,
615 &glTexCoord4i,
616 &glTexCoord4iv,
617 &glTexCoord4s,
618 &glTexCoord4sv,
619 &glVertex2d,
620 &glVertex2dv,
621 &glVertex2f,
622 &glVertex2fv,
623 &glVertex2i,
624 &glVertex2iv,
625 &glVertex2s,
626 &glVertex2sv,
627 &glVertex3d,
628 &glVertex3dv,
629 &glVertex3f,
630 &glVertex3fv,
631 &glVertex3i,
632 &glVertex3iv,
633 &glVertex3s,
634 &glVertex3sv,
635 &glVertex4d,
636 &glVertex4dv,
637 &glVertex4f,
638 &glVertex4fv,
639 &glVertex4i,
640 &glVertex4iv,
641 &glVertex4s,
642 &glVertex4sv,
643 &glClipPlane,
644 &glColorMaterial,
645 &glCullFace,
646 &glFogf,
647 &glFogfv,
648 &glFogi,
649 &glFogiv,
650 &glFrontFace,
651 &glHint,
652 &glLightf,
653 &glLightfv,
654 &glLighti,
655 &glLightiv,
656 &glLightModelf,
657 &glLightModelfv,
658 &glLightModeli,
659 &glLightModeliv,
660 &glLineStipple,
661 &glLineWidth,
662 &glMaterialf,
663 &glMaterialfv,
664 &glMateriali,
665 &glMaterialiv,
666 &glPointSize,
667 &glPolygonMode,
668 &glPolygonStipple,
669 &glScissor,
670 &glShadeModel,
671 &glTexParameterf,
672 &glTexParameterfv,
673 &glTexParameteri,
674 &glTexParameteriv,
675 &glTexImage1D,
676 &glTexImage2D,
677 &glTexEnvf,
678 &glTexEnvfv,
679 &glTexEnvi,
680 &glTexEnviv,
681 &glTexGend,
682 &glTexGendv,
683 &glTexGenf,
684 &glTexGenfv,
685 &glTexGeni,
686 &glTexGeniv,
687 &glFeedbackBuffer,
688 &glSelectBuffer,
689 &glRenderMode,
690 &glInitNames,
691 &glLoadName,
692 &glPassThrough,
693 &glPopName,
694 &glPushName,
695 &glDrawBuffer,
696 &glClear,
697 &glClearAccum,
698 &glClearIndex,
699 &glClearColor,
700 &glClearStencil,
701 &glClearDepth,
702 &glStencilMask,
703 &glColorMask,
704 &glDepthMask,
705 &glIndexMask,
706 &glAccum,
707 &glDisable,
708 &glEnable,
709 &glFinish,
710 &glFlush,
711 &glPopAttrib,
712 &glPushAttrib,
713 &glMap1d,
714 &glMap1f,
715 &glMap2d,
716 &glMap2f,
717 &glMapGrid1d,
718 &glMapGrid1f,
719 &glMapGrid2d,
720 &glMapGrid2f,
721 &glEvalCoord1d,
722 &glEvalCoord1dv,
723 &glEvalCoord1f,
724 &glEvalCoord1fv,
725 &glEvalCoord2d,
726 &glEvalCoord2dv,
727 &glEvalCoord2f,
728 &glEvalCoord2fv,
729 &glEvalMesh1,
730 &glEvalPoint1,
731 &glEvalMesh2,
732 &glEvalPoint2,
733 &glAlphaFunc,
734 &glBlendFunc,
735 &glLogicOp,
736 &glStencilFunc,
737 &glStencilOp,
738 &glDepthFunc,
739 &glPixelZoom,
740 &glPixelTransferf,
741 &glPixelTransferi,
742 &glPixelStoref,
743 &glPixelStorei,
744 &glPixelMapfv,
745 &glPixelMapuiv,
746 &glPixelMapusv,
747 &glReadBuffer,
748 &glCopyPixels,
749 &glReadPixels,
750 &glDrawPixels,
751 &glGetBooleanv,
752 &glGetClipPlane,
753 &glGetDoublev,
754 &glGetError,
755 &glGetFloatv,
756 &glGetIntegerv,
757 &glGetLightfv,
758 &glGetLightiv,
759 &glGetMapdv,
760 &glGetMapfv,
761 &glGetMapiv,
762 &glGetMaterialfv,
763 &glGetMaterialiv,
764 &glGetPixelMapfv,
765 &glGetPixelMapuiv,
766 &glGetPixelMapusv,
767 &glGetPolygonStipple,
768 &glGetString,
769 &glGetTexEnvfv,
770 &glGetTexEnviv,
771 &glGetTexGendv,
772 &glGetTexGenfv,
773 &glGetTexGeniv,
774 &glGetTexImage,
775 &glGetTexParameterfv,
776 &glGetTexParameteriv,
777 &glGetTexLevelParameterfv,
778 &glGetTexLevelParameteriv,
779 &glIsEnabled,
780 &glIsList,
781 &glDepthRange,
782 &glFrustum,
783 &glLoadIdentity,
784 &glLoadMatrixf,
785 &glLoadMatrixd,
786 &glMatrixMode,
787 &glMultMatrixf,
788 &glMultMatrixd,
789 &glOrtho,
790 &glPopMatrix,
791 &glPushMatrix,
792 &glRotated,
793 &glRotatef,
794 &glScaled,
795 &glScalef,
796 &glTranslated,
797 &glTranslatef,
798 &glViewport,
799 &glArrayElement,
800 &glBindTexture,
801 &glColorPointer,
802 &glDisableClientState,
803 &glDrawArrays,
804 &glDrawElements,
805 &glEdgeFlagPointer,
806 &glEnableClientState,
807 &glIndexPointer,
808 &glIndexub,
809 &glIndexubv,
810 &glInterleavedArrays,
811 &glNormalPointer,
812 &glPolygonOffset,
813 &glTexCoordPointer,
814 &glVertexPointer,
815 &glAreTexturesResident,
816 &glCopyTexImage1D,
817 &glCopyTexImage2D,
818 &glCopyTexSubImage1D,
819 &glCopyTexSubImage2D,
820 &glDeleteTextures,
821 &glGenTextures,
822 &glGetPointerv,
823 &glIsTexture,
824 &glPrioritizeTextures,
825 &glTexSubImage1D,
826 &glTexSubImage2D,
827 &glPopClientAttrib,
828 &glPushClientAttrib
829 }
830 };
831
832 PGLCLTPROCTABLE APIENTRY
833 DrvSetContext(
834 HDC hdc,
835 DHGLRC dhglrc,
836 PFN_SETPROCTABLE pfnSetProcTable )
837 {
838 PGLCLTPROCTABLE r = (PGLCLTPROCTABLE)&cpt;
839
840 if (!stw_make_current( hdc, dhglrc ))
841 r = NULL;
842
843 return r;
844 }