blob: 02809aacfa5ccef7161a50c73525573f08d7d512 [file] [log] [blame]
Adam Jacksoncb3610e2004-10-25 21:09:16 +00001/*
2 * (C) Copyright IBM Corporation 2004
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25/**
26 * \file glx_pbuffer.c
27 * Implementation of pbuffer related functions.
RALOVICH, Kristóf08962682009-08-12 12:41:22 +020028 *
Adam Jacksoncb3610e2004-10-25 21:09:16 +000029 * \author Ian Romanick <idr@us.ibm.com>
30 */
31
32#include <inttypes.h>
33#include "glxclient.h"
Brian Paul82dfd4b2005-08-11 14:18:53 +000034#include <X11/extensions/extutil.h>
35#include <X11/extensions/Xext.h>
Adam Jacksoncb3610e2004-10-25 21:09:16 +000036#include <assert.h>
37#include <string.h>
Adam Jacksoncb3610e2004-10-25 21:09:16 +000038#include "glxextensions.h"
Adam Jacksoncb3610e2004-10-25 21:09:16 +000039
Jeremy Huddlestonad503c42010-04-01 11:01:31 -070040#ifdef GLX_USE_APPLEGL
41#include <pthread.h>
42#include "apple_glx_drawable.h"
43#include "glx_error.h"
44#endif
45
Tormod Voldene8573032009-09-20 20:20:01 +020046#define WARN_ONCE_GLX_1_3(a, b) { \
47 static int warned=1; \
48 if(warned) { \
49 warn_GLX_1_3((a), b ); \
50 warned=0; \
51 } \
52 }
Adam Jacksoncb3610e2004-10-25 21:09:16 +000053
54/**
Ian Romanick1f309c42009-09-15 13:12:22 -070055 * Emit a warning when clients use GLX 1.3 functions on pre-1.3 systems.
56 */
57static void
Jeremy Huddlestonad503c42010-04-01 11:01:31 -070058warn_GLX_1_3(Display * dpy, const char *function_name)
Ian Romanick1f309c42009-09-15 13:12:22 -070059{
60 __GLXdisplayPrivate *priv = __glXInitialize(dpy);
61
62 if (priv->minorVersion < 3) {
Jeremy Huddlestonad503c42010-04-01 11:01:31 -070063 fprintf(stderr,
64 "WARNING: Application calling GLX 1.3 function \"%s\" "
65 "when GLX 1.3 is not supported! This is an application bug!\n",
66 function_name);
Ian Romanick1f309c42009-09-15 13:12:22 -070067 }
68}
69
Jeremy Huddlestonad503c42010-04-01 11:01:31 -070070#ifndef GLX_USE_APPLEGL
Ian Romanick1f309c42009-09-15 13:12:22 -070071/**
Adam Jacksoncb3610e2004-10-25 21:09:16 +000072 * Change a drawable's attribute.
73 *
74 * This function is used to implement \c glXSelectEvent and
75 * \c glXSelectEventSGIX.
76 *
77 * \note
78 * This function dynamically determines whether to use the SGIX_pbuffer
79 * version of the protocol or the GLX 1.3 version of the protocol.
80 *
81 * \todo
82 * This function needs to be modified to work with direct-rendering drivers.
83 */
84static void
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +020085ChangeDrawableAttribute(Display * dpy, GLXDrawable drawable,
86 const CARD32 * attribs, size_t num_attribs)
Adam Jacksoncb3610e2004-10-25 21:09:16 +000087{
88 __GLXdisplayPrivate *priv = __glXInitialize(dpy);
Vinson Lee5c9e54f2010-07-15 00:20:41 -070089 __GLXDRIdrawable *pdraw;
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +020090 CARD32 *output;
Kristian Høgsbergc25eb992006-06-13 01:41:18 +000091 CARD8 opcode;
Nick Bowlerf8d81c32010-07-14 12:01:49 -040092 int i;
Adam Jacksoncb3610e2004-10-25 21:09:16 +000093
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +020094 if ((dpy == NULL) || (drawable == 0)) {
Adam Jacksoncb3610e2004-10-25 21:09:16 +000095 return;
96 }
97
Kristian Høgsbergeeaab202010-07-22 22:36:37 -040098 pdraw = GetGLXDRIDrawable(dpy, drawable);
Vinson Lee5c9e54f2010-07-15 00:20:41 -070099
Kristian Høgsbergc25eb992006-06-13 01:41:18 +0000100 opcode = __glXSetupForCommand(dpy);
101 if (!opcode)
102 return;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000103
104 LockDisplay(dpy);
105
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200106 if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000107 xGLXChangeDrawableAttributesReq *req;
108
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200109 GetReqExtra(GLXChangeDrawableAttributes, 8 + (8 * num_attribs), req);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000110 output = (CARD32 *) (req + 1);
111
Kristian Høgsbergc25eb992006-06-13 01:41:18 +0000112 req->reqType = opcode;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000113 req->glxCode = X_GLXChangeDrawableAttributes;
114 req->drawable = drawable;
115 req->numAttribs = (CARD32) num_attribs;
116 }
117 else {
118 xGLXVendorPrivateWithReplyReq *vpreq;
119
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200120 GetReqExtra(GLXVendorPrivateWithReply, 4 + (8 * num_attribs), vpreq);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000121 output = (CARD32 *) (vpreq + 1);
122
Kristian Høgsbergc25eb992006-06-13 01:41:18 +0000123 vpreq->reqType = opcode;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000124 vpreq->glxCode = X_GLXVendorPrivateWithReply;
125 vpreq->vendorCode = X_GLXvop_ChangeDrawableAttributesSGIX;
126
127 output[0] = (CARD32) drawable;
128 output++;
129 }
130
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200131 (void) memcpy(output, attribs, sizeof(CARD32) * 2 * num_attribs);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000132
133 UnlockDisplay(dpy);
134 SyncHandle();
135
Nick Bowlerf8d81c32010-07-14 12:01:49 -0400136 for (i = 0; i < num_attribs; i++) {
137 switch(attribs[i * 2]) {
138 case GLX_EVENT_MASK:
139 /* Keep a local copy for masking out DRI2 proto events as needed */
140 pdraw->eventMask = attribs[i * 2 + 1];
141 break;
142 }
143 }
144
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000145 return;
146}
147
148
Michel Dänzer236355102008-04-10 15:45:52 -0400149#ifdef GLX_DIRECT_RENDERING
Michel Dänzer236355102008-04-10 15:45:52 -0400150static GLenum
151determineTextureTarget(const int *attribs, int numAttribs)
152{
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200153 GLenum target = 0;
154 int i;
Michel Dänzer236355102008-04-10 15:45:52 -0400155
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200156 for (i = 0; i < numAttribs; i++) {
157 if (attribs[2 * i] == GLX_TEXTURE_TARGET_EXT) {
158 switch (attribs[2 * i + 1]) {
159 case GLX_TEXTURE_2D_EXT:
160 target = GL_TEXTURE_2D;
161 break;
162 case GLX_TEXTURE_RECTANGLE_EXT:
163 target = GL_TEXTURE_RECTANGLE_ARB;
164 break;
165 }
166 }
167 }
168
169 return target;
Michel Dänzer236355102008-04-10 15:45:52 -0400170}
Eric Anholt66175aa2009-03-18 12:07:09 -0700171
Eric Anholt66175aa2009-03-18 12:07:09 -0700172static GLenum
173determineTextureFormat(const int *attribs, int numAttribs)
174{
Eric Anholt66175aa2009-03-18 12:07:09 -0700175 int i;
176
177 for (i = 0; i < numAttribs; i++) {
178 if (attribs[2 * i] == GLX_TEXTURE_FORMAT_EXT)
RALOVICH, Kristóf08962682009-08-12 12:41:22 +0200179 return attribs[2 * i + 1];
Eric Anholt66175aa2009-03-18 12:07:09 -0700180 }
181
182 return 0;
183}
Kristian Høgsberg5a43dba2010-04-09 17:16:33 -0400184
185static void
186CreateDRIDrawable(Display *dpy, const __GLcontextModes *fbconfig,
187 XID drawable, XID glxdrawable,
188 const int *attrib_list, size_t num_attribs)
189{
190 __GLXdisplayPrivate *const priv = __glXInitialize(dpy);
191 __GLXDRIdrawable *pdraw;
192 __GLXscreenConfigs *psc;
193
Kristian Høgsbergf9721152010-07-19 14:57:59 -0400194 psc = priv->screenConfigs[fbconfig->screen];
Kristian Høgsberg5a43dba2010-04-09 17:16:33 -0400195 if (psc->driScreen == NULL)
196 return;
197
198 pdraw = psc->driScreen->createDrawable(psc, drawable,
199 glxdrawable, fbconfig);
200 if (pdraw == NULL) {
201 fprintf(stderr, "failed to create drawable\n");
202 return;
203 }
204
Kristian Høgsberge3e81962010-07-19 21:15:50 -0400205 if (__glxHashInsert(priv->drawHash, glxdrawable, pdraw)) {
Kristian Høgsberg5a43dba2010-04-09 17:16:33 -0400206 (*pdraw->destroyDrawable) (pdraw);
207 return; /* FIXME: Check what we're supposed to do here... */
208 }
209
210 pdraw->textureTarget = determineTextureTarget(attrib_list, num_attribs);
211 pdraw->textureFormat = determineTextureFormat(attrib_list, num_attribs);
212}
213
214static void
215DestroyDRIDrawable(Display *dpy, GLXDrawable drawable, int destroy_xdrawable)
216{
Kristian Høgsberg5a43dba2010-04-09 17:16:33 -0400217 __GLXdisplayPrivate *const priv = __glXInitialize(dpy);
Kristian Høgsbergeeaab202010-07-22 22:36:37 -0400218 __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
Kristian Høgsberg5a43dba2010-04-09 17:16:33 -0400219
220 if (pdraw != NULL) {
221 if (destroy_xdrawable)
Kristian Høgsbergeeaab202010-07-22 22:36:37 -0400222 XFreePixmap(pdraw->psc->dpy, pdraw->xDrawable);
Kristian Høgsberg5a43dba2010-04-09 17:16:33 -0400223 (*pdraw->destroyDrawable) (pdraw);
Kristian Høgsberge3e81962010-07-19 21:15:50 -0400224 __glxHashDelete(priv->drawHash, drawable);
Kristian Høgsberg5a43dba2010-04-09 17:16:33 -0400225 }
226}
227
228#else
229
230static void
231CreateDRIDrawable(Display *dpy, const __GLcontextModes * fbconfig,
232 XID drawable, XID glxdrawable,
233 const int *attrib_list, size_t num_attribs)
234{
235}
236
237static void
238DestroyDRIDrawable(Display *dpy, GLXDrawable drawable, int destroy_xdrawable)
239{
240}
241
Michel Dänzer236355102008-04-10 15:45:52 -0400242#endif
243
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000244/**
245 * Get a drawable's attribute.
246 *
247 * This function is used to implement \c glXGetSelectedEvent and
248 * \c glXGetSelectedEventSGIX.
249 *
250 * \note
251 * This function dynamically determines whether to use the SGIX_pbuffer
252 * version of the protocol or the GLX 1.3 version of the protocol.
253 *
254 * \todo
255 * The number of attributes returned is likely to be small, probably less than
256 * 10. Given that, this routine should try to use an array on the stack to
257 * capture the reply rather than always calling Xmalloc.
258 *
259 * \todo
260 * This function needs to be modified to work with direct-rendering drivers.
261 */
262static int
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200263GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
264 int attribute, unsigned int *value)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000265{
Adam Jacksond25ad502006-04-07 00:05:50 +0000266 __GLXdisplayPrivate *priv;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000267 xGLXGetDrawableAttributesReply reply;
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200268 CARD32 *data;
Kristian Høgsbergc25eb992006-06-13 01:41:18 +0000269 CARD8 opcode;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000270 unsigned int length;
271 unsigned int i;
272 unsigned int num_attributes;
Owain G. Ainsworthb4866f82009-01-11 20:40:07 +0000273 GLboolean use_glx_1_3;
Adam Jacksond25ad502006-04-07 00:05:50 +0000274
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200275 if ((dpy == NULL) || (drawable == 0)) {
Adam Jacksond25ad502006-04-07 00:05:50 +0000276 return 0;
277 }
278
279 priv = __glXInitialize(dpy);
Owain G. Ainsworthb4866f82009-01-11 20:40:07 +0000280 use_glx_1_3 = ((priv->majorVersion > 1) || (priv->minorVersion >= 3));
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000281
Brian Paul42725d62006-02-07 00:39:56 +0000282 *value = 0;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000283
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000284
Kristian Høgsbergc25eb992006-06-13 01:41:18 +0000285 opcode = __glXSetupForCommand(dpy);
286 if (!opcode)
287 return 0;
288
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000289 LockDisplay(dpy);
290
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200291 if (use_glx_1_3) {
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000292 xGLXGetDrawableAttributesReq *req;
293
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200294 GetReqExtra(GLXGetDrawableAttributes, 4, req);
Kristian Høgsbergc25eb992006-06-13 01:41:18 +0000295 req->reqType = opcode;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000296 req->glxCode = X_GLXGetDrawableAttributes;
297 req->drawable = drawable;
298 }
299 else {
300 xGLXVendorPrivateWithReplyReq *vpreq;
301
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200302 GetReqExtra(GLXVendorPrivateWithReply, 4, vpreq);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000303 data = (CARD32 *) (vpreq + 1);
304 data[0] = (CARD32) drawable;
305
Kristian Høgsbergc25eb992006-06-13 01:41:18 +0000306 vpreq->reqType = opcode;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000307 vpreq->glxCode = X_GLXVendorPrivateWithReply;
308 vpreq->vendorCode = X_GLXvop_GetDrawableAttributesSGIX;
309 }
310
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200311 _XReply(dpy, (xReply *) & reply, 0, False);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000312
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200313 if (reply.type == X_Error) {
314 UnlockDisplay(dpy);
315 SyncHandle();
316 return 0;
Brian Paul42725d62006-02-07 00:39:56 +0000317 }
318
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000319 length = reply.length;
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200320 if (length) {
321 num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2;
322 data = (CARD32 *) Xmalloc(length * sizeof(CARD32));
323 if (data == NULL) {
324 /* Throw data on the floor */
325 _XEatData(dpy, length);
326 }
327 else {
328 _XRead(dpy, (char *) data, length * sizeof(CARD32));
Brian Paul42725d62006-02-07 00:39:56 +0000329
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200330 /* Search the set of returned attributes for the attribute requested by
331 * the caller.
332 */
333 for (i = 0; i < num_attributes; i++) {
334 if (data[i * 2] == attribute) {
335 *value = data[(i * 2) + 1];
336 break;
337 }
338 }
Brian Paul42725d62006-02-07 00:39:56 +0000339
Jeremy Huddleston80b280d2010-04-02 01:35:19 -0700340#if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200341 {
Kristian Høgsbergeeaab202010-07-22 22:36:37 -0400342 __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable);
Michel Dänzer236355102008-04-10 15:45:52 -0400343
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200344 if (pdraw != NULL && !pdraw->textureTarget)
345 pdraw->textureTarget =
346 determineTextureTarget((const int *) data, num_attributes);
Eric Anholt66175aa2009-03-18 12:07:09 -0700347 if (pdraw != NULL && !pdraw->textureFormat)
348 pdraw->textureFormat =
349 determineTextureFormat((const int *) data, num_attributes);
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200350 }
Michel Dänzer236355102008-04-10 15:45:52 -0400351#endif
352
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200353 Xfree(data);
354 }
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000355 }
356
357 UnlockDisplay(dpy);
358 SyncHandle();
359
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000360 return 0;
361}
362
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000363/**
364 * Create a non-pbuffer GLX drawable.
365 *
366 * \todo
367 * This function needs to be modified to work with direct-rendering drivers.
368 */
369static GLXDrawable
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200370CreateDrawable(Display * dpy, const __GLcontextModes * fbconfig,
371 Drawable drawable, const int *attrib_list, CARD8 glxCode)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000372{
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200373 xGLXCreateWindowReq *req;
374 CARD32 *data;
Ian Romanickb47731f2005-03-04 17:53:24 +0000375 unsigned int i;
David Reveman342d1de2006-04-11 12:07:41 +0000376 CARD8 opcode;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000377
Ian Romanickb47731f2005-03-04 17:53:24 +0000378 i = 0;
379 if (attrib_list) {
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200380 while (attrib_list[i * 2] != None)
381 i++;
Ian Romanickb47731f2005-03-04 17:53:24 +0000382 }
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000383
Kristian Høgsbergc25eb992006-06-13 01:41:18 +0000384 opcode = __glXSetupForCommand(dpy);
385 if (!opcode)
386 return None;
David Reveman342d1de2006-04-11 12:07:41 +0000387
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000388 LockDisplay(dpy);
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200389 GetReqExtra(GLXCreateWindow, 8 * i, req);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000390 data = (CARD32 *) (req + 1);
391
David Reveman342d1de2006-04-11 12:07:41 +0000392 req->reqType = opcode;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000393 req->glxCode = glxCode;
394 req->screen = (CARD32) fbconfig->screen;
395 req->fbconfig = fbconfig->fbconfigID;
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400396 req->window = (CARD32) drawable;
Ian Romanickb47731f2005-03-04 17:53:24 +0000397 req->glxwindow = (GLXWindow) XAllocID(dpy);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000398 req->numAttribs = (CARD32) i;
399
Brian Paul5f40a7a2010-03-02 07:34:29 -0700400 if (attrib_list)
401 memcpy(data, attrib_list, 8 * i);
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200402
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000403 UnlockDisplay(dpy);
404 SyncHandle();
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200405
Kristian Høgsberg5a43dba2010-04-09 17:16:33 -0400406 CreateDRIDrawable(dpy, fbconfig, drawable, req->glxwindow, attrib_list, i);
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400407
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200408 return (GLXDrawable) req->glxwindow;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000409}
410
411
412/**
413 * Destroy a non-pbuffer GLX drawable.
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000414 */
415static void
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200416DestroyDrawable(Display * dpy, GLXDrawable drawable, CARD32 glxCode)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000417{
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200418 xGLXDestroyPbufferReq *req;
Kristian Høgsbergc25eb992006-06-13 01:41:18 +0000419 CARD8 opcode;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000420
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200421 if ((dpy == NULL) || (drawable == 0)) {
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000422 return;
423 }
424
425
Kristian Høgsbergc25eb992006-06-13 01:41:18 +0000426 opcode = __glXSetupForCommand(dpy);
427 if (!opcode)
428 return;
429
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000430 LockDisplay(dpy);
431
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200432 GetReqExtra(GLXDestroyPbuffer, 4, req);
Kristian Høgsbergc25eb992006-06-13 01:41:18 +0000433 req->reqType = opcode;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000434 req->glxCode = glxCode;
435 req->pbuffer = (GLXPbuffer) drawable;
436
437 UnlockDisplay(dpy);
438 SyncHandle();
439
Kristian Høgsberg5a43dba2010-04-09 17:16:33 -0400440 DestroyDRIDrawable(dpy, drawable, GL_FALSE);
Kristian Høgsberge82dd8c2008-03-26 19:26:59 -0400441
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000442 return;
443}
444
445
446/**
447 * Create a pbuffer.
448 *
449 * This function is used to implement \c glXCreatePbuffer and
450 * \c glXCreateGLXPbufferSGIX.
451 *
452 * \note
453 * This function dynamically determines whether to use the SGIX_pbuffer
454 * version of the protocol or the GLX 1.3 version of the protocol.
455 *
456 * \todo
457 * This function needs to be modified to work with direct-rendering drivers.
458 */
459static GLXDrawable
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200460CreatePbuffer(Display * dpy, const __GLcontextModes * fbconfig,
461 unsigned int width, unsigned int height,
462 const int *attrib_list, GLboolean size_in_attribs)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000463{
464 __GLXdisplayPrivate *priv = __glXInitialize(dpy);
465 GLXDrawable id = 0;
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200466 CARD32 *data;
Kristian Høgsbergc25eb992006-06-13 01:41:18 +0000467 CARD8 opcode;
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200468 unsigned int i;
Kristian Høgsberg5a43dba2010-04-09 17:16:33 -0400469 Pixmap pixmap;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000470
Ian Romanickb47731f2005-03-04 17:53:24 +0000471 i = 0;
472 if (attrib_list) {
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200473 while (attrib_list[i * 2])
474 i++;
Ian Romanickb47731f2005-03-04 17:53:24 +0000475 }
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000476
Kristian Høgsbergc25eb992006-06-13 01:41:18 +0000477 opcode = __glXSetupForCommand(dpy);
478 if (!opcode)
479 return None;
480
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000481 LockDisplay(dpy);
482 id = XAllocID(dpy);
483
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200484 if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
485 xGLXCreatePbufferReq *req;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000486 unsigned int extra = (size_in_attribs) ? 0 : 2;
487
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200488 GetReqExtra(GLXCreatePbuffer, (8 * (i + extra)), req);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000489 data = (CARD32 *) (req + 1);
490
Kristian Høgsbergc25eb992006-06-13 01:41:18 +0000491 req->reqType = opcode;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000492 req->glxCode = X_GLXCreatePbuffer;
493 req->screen = (CARD32) fbconfig->screen;
494 req->fbconfig = fbconfig->fbconfigID;
495 req->pbuffer = (GLXPbuffer) id;
496 req->numAttribs = (CARD32) (i + extra);
497
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200498 if (!size_in_attribs) {
499 data[(2 * i) + 0] = GLX_PBUFFER_WIDTH;
500 data[(2 * i) + 1] = width;
501 data[(2 * i) + 2] = GLX_PBUFFER_HEIGHT;
502 data[(2 * i) + 3] = height;
503 data += 4;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000504 }
505 }
506 else {
507 xGLXVendorPrivateReq *vpreq;
508
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200509 GetReqExtra(GLXVendorPrivate, 20 + (8 * i), vpreq);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000510 data = (CARD32 *) (vpreq + 1);
511
Kristian Høgsbergc25eb992006-06-13 01:41:18 +0000512 vpreq->reqType = opcode;
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000513 vpreq->glxCode = X_GLXVendorPrivate;
514 vpreq->vendorCode = X_GLXvop_CreateGLXPbufferSGIX;
515
516 data[0] = (CARD32) fbconfig->screen;
517 data[1] = (CARD32) fbconfig->fbconfigID;
518 data[2] = (CARD32) id;
519 data[3] = (CARD32) width;
520 data[4] = (CARD32) height;
521 data += 5;
522 }
523
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200524 (void) memcpy(data, attrib_list, sizeof(CARD32) * 2 * i);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000525
526 UnlockDisplay(dpy);
527 SyncHandle();
528
Kristian Høgsberg5a43dba2010-04-09 17:16:33 -0400529 pixmap = XCreatePixmap(dpy, RootWindow(dpy, fbconfig->screen),
530 width, height, fbconfig->rgbBits);
531
532 CreateDRIDrawable(dpy, fbconfig, pixmap, id, attrib_list, i);
533
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000534 return id;
535}
536
Kristian Høgsberg5a43dba2010-04-09 17:16:33 -0400537/**
538 * Destroy a pbuffer.
539 *
540 * This function is used to implement \c glXDestroyPbuffer and
541 * \c glXDestroyGLXPbufferSGIX.
542 *
543 * \note
544 * This function dynamically determines whether to use the SGIX_pbuffer
545 * version of the protocol or the GLX 1.3 version of the protocol.
546 */
547static void
548DestroyPbuffer(Display * dpy, GLXDrawable drawable)
549{
550 __GLXdisplayPrivate *priv = __glXInitialize(dpy);
551 CARD8 opcode;
552
553 if ((dpy == NULL) || (drawable == 0)) {
554 return;
555 }
556
557 opcode = __glXSetupForCommand(dpy);
558 if (!opcode)
559 return;
560
561 LockDisplay(dpy);
562
563 if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
564 xGLXDestroyPbufferReq *req;
565
566 GetReq(GLXDestroyPbuffer, req);
567 req->reqType = opcode;
568 req->glxCode = X_GLXDestroyPbuffer;
569 req->pbuffer = (GLXPbuffer) drawable;
570 }
571 else {
572 xGLXVendorPrivateWithReplyReq *vpreq;
573 CARD32 *data;
574
575 GetReqExtra(GLXVendorPrivateWithReply, 4, vpreq);
576 data = (CARD32 *) (vpreq + 1);
577
578 data[0] = (CARD32) drawable;
579
580 vpreq->reqType = opcode;
581 vpreq->glxCode = X_GLXVendorPrivateWithReply;
582 vpreq->vendorCode = X_GLXvop_DestroyGLXPbufferSGIX;
583 }
584
585 UnlockDisplay(dpy);
586 SyncHandle();
587
588 DestroyDRIDrawable(dpy, drawable, GL_TRUE);
589
590 return;
591}
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000592
593/**
594 * Create a new pbuffer.
595 */
Adam Jackson489ccef2004-12-15 17:18:06 +0000596PUBLIC GLXPbufferSGIX
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200597glXCreateGLXPbufferSGIX(Display * dpy, GLXFBConfigSGIX config,
598 unsigned int width, unsigned int height,
599 int *attrib_list)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000600{
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200601 return (GLXPbufferSGIX) CreatePbuffer(dpy, (__GLcontextModes *) config,
602 width, height,
603 attrib_list, GL_FALSE);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000604}
605
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700606#endif /* GLX_USE_APPLEGL */
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000607
608/**
609 * Create a new pbuffer.
610 */
Adam Jackson489ccef2004-12-15 17:18:06 +0000611PUBLIC GLXPbuffer
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200612glXCreatePbuffer(Display * dpy, GLXFBConfig config, const int *attrib_list)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000613{
Kristian Høgsberg8b204112007-08-27 14:16:30 -0400614 int i, width, height;
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700615#ifdef GLX_USE_APPLEGL
616 GLXPbuffer result;
617 int errorcode;
618#endif
Kristian Høgsberg8b204112007-08-27 14:16:30 -0400619
620 width = 0;
621 height = 0;
622
Tormod Voldene8573032009-09-20 20:20:01 +0200623 WARN_ONCE_GLX_1_3(dpy, __func__);
Ian Romanick1f309c42009-09-15 13:12:22 -0700624
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700625#ifdef GLX_USE_APPLEGL
626 for (i = 0; attrib_list[i]; ++i) {
627 switch (attrib_list[i]) {
628 case GLX_PBUFFER_WIDTH:
629 width = attrib_list[i + 1];
630 ++i;
631 break;
632
633 case GLX_PBUFFER_HEIGHT:
634 height = attrib_list[i + 1];
635 ++i;
636 break;
637
638 case GLX_LARGEST_PBUFFER:
639 /* This is a hint we should probably handle, but how? */
640 ++i;
641 break;
642
643 case GLX_PRESERVED_CONTENTS:
644 /* The contents are always preserved with AppleSGLX with CGL. */
645 ++i;
646 break;
647
648 default:
649 return None;
650 }
651 }
652
653 if (apple_glx_pbuffer_create(dpy, config, width, height, &errorcode,
654 &result)) {
655 /*
656 * apple_glx_pbuffer_create only sets the errorcode to core X11
657 * errors.
658 */
659 __glXSendError(dpy, errorcode, 0, X_GLXCreatePbuffer, true);
660
661 return None;
662 }
663
664 return result;
665#else
Kristian Høgsberg8b204112007-08-27 14:16:30 -0400666 for (i = 0; attrib_list[i * 2]; i++) {
667 switch (attrib_list[i * 2]) {
668 case GLX_PBUFFER_WIDTH:
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200669 width = attrib_list[i * 2 + 1];
670 break;
Kristian Høgsberg8b204112007-08-27 14:16:30 -0400671 case GLX_PBUFFER_HEIGHT:
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200672 height = attrib_list[i * 2 + 1];
673 break;
Kristian Høgsberg8b204112007-08-27 14:16:30 -0400674 }
675 }
676
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200677 return (GLXPbuffer) CreatePbuffer(dpy, (__GLcontextModes *) config,
678 width, height, attrib_list, GL_TRUE);
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700679#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000680}
681
682
683/**
684 * Destroy an existing pbuffer.
685 */
Adam Jackson489ccef2004-12-15 17:18:06 +0000686PUBLIC void
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200687glXDestroyPbuffer(Display * dpy, GLXPbuffer pbuf)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000688{
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700689#ifdef GLX_USE_APPLEGL
690 if (apple_glx_pbuffer_destroy(dpy, pbuf)) {
691 __glXSendError(dpy, GLXBadPbuffer, pbuf, X_GLXDestroyPbuffer, false);
692 }
693#else
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200694 DestroyPbuffer(dpy, pbuf);
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700695#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000696}
697
698
699/**
700 * Query an attribute of a drawable.
701 */
Adam Jackson489ccef2004-12-15 17:18:06 +0000702PUBLIC void
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200703glXQueryDrawable(Display * dpy, GLXDrawable drawable,
704 int attribute, unsigned int *value)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000705{
Tormod Voldene8573032009-09-20 20:20:01 +0200706 WARN_ONCE_GLX_1_3(dpy, __func__);
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700707#ifdef GLX_USE_APPLEGL
708 Window root;
709 int x, y;
710 unsigned int width, height, bd, depth;
711
712 if (apple_glx_pixmap_query(drawable, attribute, value))
713 return; /*done */
714
715 if (apple_glx_pbuffer_query(drawable, attribute, value))
716 return; /*done */
717
718 /*
719 * The OpenGL spec states that we should report GLXBadDrawable if
720 * the drawable is invalid, however doing so would require that we
721 * use XSetErrorHandler(), which is known to not be thread safe.
722 * If we use a round-trip call to validate the drawable, there could
723 * be a race, so instead we just opt in favor of letting the
724 * XGetGeometry request fail with a GetGeometry request X error
725 * rather than GLXBadDrawable, in what is hoped to be a rare
726 * case of an invalid drawable. In practice most and possibly all
727 * X11 apps using GLX shouldn't notice a difference.
728 */
729 if (XGetGeometry
730 (dpy, drawable, &root, &x, &y, &width, &height, &bd, &depth)) {
731 switch (attribute) {
732 case GLX_WIDTH:
733 *value = width;
734 break;
735
736 case GLX_HEIGHT:
737 *value = height;
738 break;
739 }
740 }
741#else
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200742 GetDrawableAttribute(dpy, drawable, attribute, value);
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700743#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000744}
745
746
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700747#ifndef GLX_USE_APPLEGL
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000748/**
749 * Query an attribute of a pbuffer.
750 */
Adam Jackson489ccef2004-12-15 17:18:06 +0000751PUBLIC int
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200752glXQueryGLXPbufferSGIX(Display * dpy, GLXPbufferSGIX drawable,
753 int attribute, unsigned int *value)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000754{
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200755 return GetDrawableAttribute(dpy, drawable, attribute, value);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000756}
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700757#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000758
759/**
760 * Select the event mask for a drawable.
761 */
Adam Jackson489ccef2004-12-15 17:18:06 +0000762PUBLIC void
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200763glXSelectEvent(Display * dpy, GLXDrawable drawable, unsigned long mask)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000764{
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700765#ifdef GLX_USE_APPLEGL
766 XWindowAttributes xwattr;
767
768 if (apple_glx_pbuffer_set_event_mask(drawable, mask))
769 return; /*done */
770
771 /*
772 * The spec allows a window, but currently there are no valid
773 * events for a window, so do nothing.
774 */
775 if (XGetWindowAttributes(dpy, drawable, &xwattr))
776 return; /*done */
777 /* The drawable seems to be invalid. Report an error. */
778
779 __glXSendError(dpy, GLXBadDrawable, drawable,
780 X_GLXChangeDrawableAttributes, false);
781#else
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000782 CARD32 attribs[2];
783
784 attribs[0] = (CARD32) GLX_EVENT_MASK;
785 attribs[1] = (CARD32) mask;
786
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200787 ChangeDrawableAttribute(dpy, drawable, attribs, 1);
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700788#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000789}
790
791
792/**
793 * Get the selected event mask for a drawable.
794 */
Adam Jackson489ccef2004-12-15 17:18:06 +0000795PUBLIC void
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200796glXGetSelectedEvent(Display * dpy, GLXDrawable drawable, unsigned long *mask)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000797{
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700798#ifdef GLX_USE_APPLEGL
799 XWindowAttributes xwattr;
800
801 if (apple_glx_pbuffer_get_event_mask(drawable, mask))
802 return; /*done */
803
804 /*
805 * The spec allows a window, but currently there are no valid
806 * events for a window, so do nothing, but set the mask to 0.
807 */
808 if (XGetWindowAttributes(dpy, drawable, &xwattr)) {
809 /* The window is valid, so set the mask to 0. */
810 *mask = 0;
811 return; /*done */
812 }
813 /* The drawable seems to be invalid. Report an error. */
814
815 __glXSendError(dpy, GLXBadDrawable, drawable, X_GLXGetDrawableAttributes,
816 true);
817#else
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000818 unsigned int value;
819
820
821 /* The non-sense with value is required because on LP64 platforms
822 * sizeof(unsigned int) != sizeof(unsigned long). On little-endian
823 * we could just type-cast the pointer, but why?
824 */
825
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200826 GetDrawableAttribute(dpy, drawable, GLX_EVENT_MASK_SGIX, &value);
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000827 *mask = value;
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700828#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000829}
830
831
Adam Jackson489ccef2004-12-15 17:18:06 +0000832PUBLIC GLXPixmap
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200833glXCreatePixmap(Display * dpy, GLXFBConfig config, Pixmap pixmap,
834 const int *attrib_list)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000835{
Tormod Voldene8573032009-09-20 20:20:01 +0200836 WARN_ONCE_GLX_1_3(dpy, __func__);
Ian Romanick1f309c42009-09-15 13:12:22 -0700837
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700838#ifdef GLX_USE_APPLEGL
839 const __GLcontextModes *modes = (const __GLcontextModes *) config;
840
841 if (apple_glx_pixmap_create(dpy, modes->screen, pixmap, modes))
842 return None;
843
844 return pixmap;
845#else
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200846 return CreateDrawable(dpy, (__GLcontextModes *) config,
847 (Drawable) pixmap, attrib_list, X_GLXCreatePixmap);
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700848#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000849}
850
851
Adam Jackson489ccef2004-12-15 17:18:06 +0000852PUBLIC GLXWindow
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200853glXCreateWindow(Display * dpy, GLXFBConfig config, Window win,
854 const int *attrib_list)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000855{
Tormod Voldene8573032009-09-20 20:20:01 +0200856 WARN_ONCE_GLX_1_3(dpy, __func__);
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700857#ifdef GLX_USE_APPLEGL
858 XWindowAttributes xwattr;
859 XVisualInfo *visinfo;
Ian Romanick1f309c42009-09-15 13:12:22 -0700860
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700861 (void) attrib_list; /*unused according to GLX 1.4 */
862
863 XGetWindowAttributes(dpy, win, &xwattr);
864
865 visinfo = glXGetVisualFromFBConfig(dpy, config);
866
867 if (NULL == visinfo) {
868 __glXSendError(dpy, GLXBadFBConfig, 0, X_GLXCreateWindow, false);
869 return None;
870 }
871
872 if (visinfo->visualid != XVisualIDFromVisual(xwattr.visual)) {
873 __glXSendError(dpy, BadMatch, 0, X_GLXCreateWindow, true);
874 return None;
875 }
876
877 XFree(visinfo);
878
879 return win;
880#else
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200881 return CreateDrawable(dpy, (__GLcontextModes *) config,
882 (Drawable) win, attrib_list, X_GLXCreateWindow);
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700883#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000884}
885
886
Adam Jackson489ccef2004-12-15 17:18:06 +0000887PUBLIC void
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200888glXDestroyPixmap(Display * dpy, GLXPixmap pixmap)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000889{
Tormod Voldene8573032009-09-20 20:20:01 +0200890 WARN_ONCE_GLX_1_3(dpy, __func__);
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700891#ifdef GLX_USE_APPLEGL
892 if (apple_glx_pixmap_destroy(dpy, pixmap))
893 __glXSendError(dpy, GLXBadPixmap, pixmap, X_GLXDestroyPixmap, false);
894#else
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200895 DestroyDrawable(dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap);
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700896#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000897}
898
899
Adam Jackson489ccef2004-12-15 17:18:06 +0000900PUBLIC void
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200901glXDestroyWindow(Display * dpy, GLXWindow win)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000902{
Tormod Voldene8573032009-09-20 20:20:01 +0200903 WARN_ONCE_GLX_1_3(dpy, __func__);
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700904#ifndef GLX_USE_APPLEGL
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200905 DestroyDrawable(dpy, (GLXDrawable) win, X_GLXDestroyWindow);
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700906#endif
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000907}
908
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700909#ifndef GLX_USE_APPLEGL
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200910PUBLIC
911GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX,
912 (Display * dpy, GLXPbufferSGIX pbuf),
913 (dpy, pbuf), glXDestroyPbuffer)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000914
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200915PUBLIC
916GLX_ALIAS_VOID(glXSelectEventSGIX,
917 (Display * dpy, GLXDrawable drawable,
RALOVICH, Kristóf08962682009-08-12 12:41:22 +0200918 unsigned long mask), (dpy, drawable, mask), glXSelectEvent)
Adam Jacksoncb3610e2004-10-25 21:09:16 +0000919
RALOVICH, Kristóf2d4c26b2008-10-13 14:12:02 +0200920PUBLIC
921GLX_ALIAS_VOID(glXGetSelectedEventSGIX,
922 (Display * dpy, GLXDrawable drawable,
923 unsigned long *mask), (dpy, drawable, mask),
924 glXGetSelectedEvent)
Jeremy Huddlestonad503c42010-04-01 11:01:31 -0700925#endif