2 * Copyright © 2010 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Soft-
6 * ware"), to deal in the Software without restriction, including without
7 * limitation the rights to use, copy, modify, merge, publish, distribute,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, provided that the above copyright
10 * notice(s) and this permission notice appear in all copies of the Soft-
11 * ware and that both the above copyright notice(s) and this permission
12 * notice appear in supporting documentation.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16 * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
17 * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
18 * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
19 * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
22 * MANCE OF THIS SOFTWARE.
24 * Except as contained in this notice, the name of a copyright holder shall
25 * not be used in advertising or otherwise to promote the sale, use or
26 * other dealings in this Software without prior written authorization of
27 * the copyright holder.
30 * Kristian Høgsberg (krh@bitplanet.net)
33 #if defined(GLX_USE_APPLEGL)
36 applegl_destroy_context(struct glx_context
*gc
)
38 apple_glx_destroy_context(&gc
->driContext
, gc
->currentDpy
);
42 applegl_bind_context(struct glx_context
*gc
, struct glx_context
*old
,
43 GLXDrawable draw
, GLXDrawable read
)
45 bool error
= apple_glx_make_current_context(dpy
,
46 (oldGC
&& oldGC
!= &dummyContext
) ? oldGC
->driContext
: NUL
~
47 gc
? gc
->driContext
: NULL
, draw
);
49 apple_glx_diagnostic("%s: error %s\n", __func__
, error
? "YES" : "NO");
57 applegl_unbind_context(struct glx_context
*gc
, struct glx_context
*new)
62 applegl_wait_gl(struct glx_context
*gc
)
68 applegl_wait_x(struct glx_context
*gc
)
70 apple_glx_waitx(gc
->dpy
, gc
->driContext
);
73 static const struct glx_context_vtable applegl_context_vtable
= {
74 applegl_destroy_context
,
76 applegl_unbind_context
,
80 NULL
, /* bind_tex_image, */
81 NULL
, /* release_tex_image, */
84 static struct glx_context
*
85 applegl_create_context(struct glx_screen
*psc
,
86 struct glx_config
*mode
,
87 struct glx_context
*shareList
, int renderType
)
89 struct glx_context
*gc
;
93 /* TODO: Integrate this with apple_glx_create_context and make
94 * struct apple_glx_context inherit from struct glx_context. */
96 gc
= Xmalloc(sizeof *gc
);
100 memset(gc
, 0, sizeof *gc
);
101 if (!glx_context_init(&gc
->base
, &psc
->base
, mode
)) {
106 gc
->vtable
= &applegl_context_vtable
;
107 gc
->driContext
= NULL
;
108 gc
->do_destroy
= False
;
110 /* TODO: darwin: Integrate with above to do indirect */
111 if(apple_glx_create_context(&gc
->driContext
, dpy
, screen
, fbconfig
,
112 shareList
? shareList
->driContext
: NULL
,
113 &errorcode
, &x11error
)) {
114 __glXSendError(dpy
, errorcode
, 0, X_GLXCreateContext
, x11error
);
115 gc
->vtable
->destroy(gc
);
119 gc
->currentContextTag
= -1;
121 gc
->isDirect
= allowDirect
;
122 gc
->xid
= 1; /* Just something not None, so we know when to destroy
123 * it in MakeContextCurrent. */
128 struct glx_screen_vtable appegl_screen_vtable
= {
129 applegl_create_context
132 _X_HIDDEN
struct glx_screen
*
133 applegl_create_screen(int screen
, struct glx_display
* priv
)
135 struct glx_screen
*psc
;
137 psc
= Xmalloc(sizeof *psc
);
141 memset(psc
, 0, sizeof *psc
);
142 glx_screen_init(psc
, screen
, priv
);
143 psc
->vtable
= &applegl_screen_vtable
;
149 applegl_create_display(struct glx_display
*display
)
151 /* create applegl display and stuff in display->appleglDisplay */
152 apple_init_glx(display
);