Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 1 | /* |
| 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óf | 0896268 | 2009-08-12 12:41:22 +0200 | [diff] [blame] | 28 | * |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 29 | * \author Ian Romanick <idr@us.ibm.com> |
| 30 | */ |
| 31 | |
| 32 | #include <inttypes.h> |
| 33 | #include "glxclient.h" |
Brian Paul | 82dfd4b | 2005-08-11 14:18:53 +0000 | [diff] [blame] | 34 | #include <X11/extensions/extutil.h> |
| 35 | #include <X11/extensions/Xext.h> |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 36 | #include <assert.h> |
| 37 | #include <string.h> |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 38 | #include "glxextensions.h" |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 39 | |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 40 | #ifdef GLX_USE_APPLEGL |
| 41 | #include <pthread.h> |
| 42 | #include "apple_glx_drawable.h" |
| 43 | #include "glx_error.h" |
| 44 | #endif |
| 45 | |
Tormod Volden | e857303 | 2009-09-20 20:20:01 +0200 | [diff] [blame] | 46 | #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 Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 53 | |
| 54 | /** |
Ian Romanick | 1f309c4 | 2009-09-15 13:12:22 -0700 | [diff] [blame] | 55 | * Emit a warning when clients use GLX 1.3 functions on pre-1.3 systems. |
| 56 | */ |
| 57 | static void |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 58 | warn_GLX_1_3(Display * dpy, const char *function_name) |
Ian Romanick | 1f309c4 | 2009-09-15 13:12:22 -0700 | [diff] [blame] | 59 | { |
Kristian Høgsberg | c356f58 | 2010-07-28 11:16:00 -0400 | [diff] [blame] | 60 | struct glx_display *priv = __glXInitialize(dpy); |
Ian Romanick | 1f309c4 | 2009-09-15 13:12:22 -0700 | [diff] [blame] | 61 | |
| 62 | if (priv->minorVersion < 3) { |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 63 | 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 Romanick | 1f309c4 | 2009-09-15 13:12:22 -0700 | [diff] [blame] | 67 | } |
| 68 | } |
| 69 | |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 70 | #ifndef GLX_USE_APPLEGL |
Ian Romanick | 1f309c4 | 2009-09-15 13:12:22 -0700 | [diff] [blame] | 71 | /** |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 72 | * 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. |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 80 | */ |
| 81 | static void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 82 | ChangeDrawableAttribute(Display * dpy, GLXDrawable drawable, |
| 83 | const CARD32 * attribs, size_t num_attribs) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 84 | { |
Kristian Høgsberg | c356f58 | 2010-07-28 11:16:00 -0400 | [diff] [blame] | 85 | struct glx_display *priv = __glXInitialize(dpy); |
Jon TURNEY | ae9487c | 2010-08-09 14:47:26 +0100 | [diff] [blame] | 86 | #ifdef GLX_DIRECT_RENDERING |
Vinson Lee | 5c9e54f | 2010-07-15 00:20:41 -0700 | [diff] [blame] | 87 | __GLXDRIdrawable *pdraw; |
Jon TURNEY | ae9487c | 2010-08-09 14:47:26 +0100 | [diff] [blame] | 88 | #endif |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 89 | CARD32 *output; |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 90 | CARD8 opcode; |
Nick Bowler | f8d81c3 | 2010-07-14 12:01:49 -0400 | [diff] [blame] | 91 | int i; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 92 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 93 | if ((dpy == NULL) || (drawable == 0)) { |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 94 | return; |
| 95 | } |
| 96 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 97 | opcode = __glXSetupForCommand(dpy); |
| 98 | if (!opcode) |
| 99 | return; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 100 | |
| 101 | LockDisplay(dpy); |
| 102 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 103 | if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 104 | xGLXChangeDrawableAttributesReq *req; |
| 105 | |
Julien Cristau | 4324d6f | 2011-01-23 08:26:35 -0800 | [diff] [blame] | 106 | GetReqExtra(GLXChangeDrawableAttributes, 8 * num_attribs, req); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 107 | output = (CARD32 *) (req + 1); |
| 108 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 109 | req->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 110 | req->glxCode = X_GLXChangeDrawableAttributes; |
| 111 | req->drawable = drawable; |
| 112 | req->numAttribs = (CARD32) num_attribs; |
| 113 | } |
| 114 | else { |
| 115 | xGLXVendorPrivateWithReplyReq *vpreq; |
| 116 | |
Julien Cristau | e27913f | 2011-01-26 04:03:16 -0800 | [diff] [blame] | 117 | GetReqExtra(GLXVendorPrivateWithReply, 8 + (8 * num_attribs), vpreq); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 118 | output = (CARD32 *) (vpreq + 1); |
| 119 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 120 | vpreq->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 121 | vpreq->glxCode = X_GLXVendorPrivateWithReply; |
| 122 | vpreq->vendorCode = X_GLXvop_ChangeDrawableAttributesSGIX; |
| 123 | |
| 124 | output[0] = (CARD32) drawable; |
Julien Cristau | e27913f | 2011-01-26 04:03:16 -0800 | [diff] [blame] | 125 | output[1] = num_attribs; |
| 126 | output += 2; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 127 | } |
| 128 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 129 | (void) memcpy(output, attribs, sizeof(CARD32) * 2 * num_attribs); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 130 | |
| 131 | UnlockDisplay(dpy); |
| 132 | SyncHandle(); |
| 133 | |
Jon TURNEY | ae9487c | 2010-08-09 14:47:26 +0100 | [diff] [blame] | 134 | #ifdef GLX_DIRECT_RENDERING |
| 135 | pdraw = GetGLXDRIDrawable(dpy, drawable); |
| 136 | |
Jesse Barnes | 6ae9e8c | 2011-05-03 10:20:14 -0700 | [diff] [blame] | 137 | if (!pdraw) |
| 138 | return; |
| 139 | |
Nick Bowler | f8d81c3 | 2010-07-14 12:01:49 -0400 | [diff] [blame] | 140 | for (i = 0; i < num_attribs; i++) { |
| 141 | switch(attribs[i * 2]) { |
| 142 | case GLX_EVENT_MASK: |
| 143 | /* Keep a local copy for masking out DRI2 proto events as needed */ |
| 144 | pdraw->eventMask = attribs[i * 2 + 1]; |
| 145 | break; |
| 146 | } |
| 147 | } |
Jon TURNEY | ae9487c | 2010-08-09 14:47:26 +0100 | [diff] [blame] | 148 | #endif |
Nick Bowler | f8d81c3 | 2010-07-14 12:01:49 -0400 | [diff] [blame] | 149 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 150 | return; |
| 151 | } |
| 152 | |
| 153 | |
Michel Dänzer | 23635510 | 2008-04-10 15:45:52 -0400 | [diff] [blame] | 154 | #ifdef GLX_DIRECT_RENDERING |
Michel Dänzer | 23635510 | 2008-04-10 15:45:52 -0400 | [diff] [blame] | 155 | static GLenum |
| 156 | determineTextureTarget(const int *attribs, int numAttribs) |
| 157 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 158 | GLenum target = 0; |
| 159 | int i; |
Michel Dänzer | 23635510 | 2008-04-10 15:45:52 -0400 | [diff] [blame] | 160 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 161 | for (i = 0; i < numAttribs; i++) { |
| 162 | if (attribs[2 * i] == GLX_TEXTURE_TARGET_EXT) { |
| 163 | switch (attribs[2 * i + 1]) { |
| 164 | case GLX_TEXTURE_2D_EXT: |
| 165 | target = GL_TEXTURE_2D; |
| 166 | break; |
| 167 | case GLX_TEXTURE_RECTANGLE_EXT: |
| 168 | target = GL_TEXTURE_RECTANGLE_ARB; |
| 169 | break; |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | return target; |
Michel Dänzer | 23635510 | 2008-04-10 15:45:52 -0400 | [diff] [blame] | 175 | } |
Eric Anholt | 66175aa | 2009-03-18 12:07:09 -0700 | [diff] [blame] | 176 | |
Eric Anholt | 66175aa | 2009-03-18 12:07:09 -0700 | [diff] [blame] | 177 | static GLenum |
| 178 | determineTextureFormat(const int *attribs, int numAttribs) |
| 179 | { |
Eric Anholt | 66175aa | 2009-03-18 12:07:09 -0700 | [diff] [blame] | 180 | int i; |
| 181 | |
| 182 | for (i = 0; i < numAttribs; i++) { |
| 183 | if (attribs[2 * i] == GLX_TEXTURE_FORMAT_EXT) |
RALOVICH, Kristóf | 0896268 | 2009-08-12 12:41:22 +0200 | [diff] [blame] | 184 | return attribs[2 * i + 1]; |
Eric Anholt | 66175aa | 2009-03-18 12:07:09 -0700 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | return 0; |
| 188 | } |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 189 | |
Adam Jackson | 4833104 | 2011-03-31 20:43:57 +0000 | [diff] [blame^] | 190 | static GLboolean |
Kristian Høgsberg | 6ddf66e | 2010-07-28 10:07:52 -0400 | [diff] [blame] | 191 | CreateDRIDrawable(Display *dpy, struct glx_config *config, |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 192 | XID drawable, XID glxdrawable, |
| 193 | const int *attrib_list, size_t num_attribs) |
| 194 | { |
Kristian Høgsberg | c356f58 | 2010-07-28 11:16:00 -0400 | [diff] [blame] | 195 | struct glx_display *const priv = __glXInitialize(dpy); |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 196 | __GLXDRIdrawable *pdraw; |
Kristian Høgsberg | 66fc35c | 2010-07-28 10:28:43 -0400 | [diff] [blame] | 197 | struct glx_screen *psc; |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 198 | |
Kristian Høgsberg | 66fc35c | 2010-07-28 10:28:43 -0400 | [diff] [blame] | 199 | psc = priv->screens[config->screen]; |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 200 | if (psc->driScreen == NULL) |
Adam Jackson | 4833104 | 2011-03-31 20:43:57 +0000 | [diff] [blame^] | 201 | return GL_TRUE; |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 202 | |
| 203 | pdraw = psc->driScreen->createDrawable(psc, drawable, |
Kristian Høgsberg | 6ddf66e | 2010-07-28 10:07:52 -0400 | [diff] [blame] | 204 | glxdrawable, config); |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 205 | if (pdraw == NULL) { |
| 206 | fprintf(stderr, "failed to create drawable\n"); |
Adam Jackson | 4833104 | 2011-03-31 20:43:57 +0000 | [diff] [blame^] | 207 | return GL_FALSE; |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 208 | } |
| 209 | |
Kristian Høgsberg | e3e8196 | 2010-07-19 21:15:50 -0400 | [diff] [blame] | 210 | if (__glxHashInsert(priv->drawHash, glxdrawable, pdraw)) { |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 211 | (*pdraw->destroyDrawable) (pdraw); |
Adam Jackson | 4833104 | 2011-03-31 20:43:57 +0000 | [diff] [blame^] | 212 | return GL_FALSE; |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | pdraw->textureTarget = determineTextureTarget(attrib_list, num_attribs); |
| 216 | pdraw->textureFormat = determineTextureFormat(attrib_list, num_attribs); |
Adam Jackson | 4833104 | 2011-03-31 20:43:57 +0000 | [diff] [blame^] | 217 | |
| 218 | return GL_TRUE; |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | static void |
| 222 | DestroyDRIDrawable(Display *dpy, GLXDrawable drawable, int destroy_xdrawable) |
| 223 | { |
Kristian Høgsberg | c356f58 | 2010-07-28 11:16:00 -0400 | [diff] [blame] | 224 | struct glx_display *const priv = __glXInitialize(dpy); |
Kristian Høgsberg | eeaab20 | 2010-07-22 22:36:37 -0400 | [diff] [blame] | 225 | __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable); |
Kristian Høgsberg | 80e48dd | 2010-09-09 08:06:40 -0400 | [diff] [blame] | 226 | XID xid; |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 227 | |
| 228 | if (pdraw != NULL) { |
Kristian Høgsberg | 80e48dd | 2010-09-09 08:06:40 -0400 | [diff] [blame] | 229 | xid = pdraw->xDrawable; |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 230 | (*pdraw->destroyDrawable) (pdraw); |
Kristian Høgsberg | e3e8196 | 2010-07-19 21:15:50 -0400 | [diff] [blame] | 231 | __glxHashDelete(priv->drawHash, drawable); |
Kristian Høgsberg | d8ab9aa | 2010-09-08 20:55:02 -0400 | [diff] [blame] | 232 | if (destroy_xdrawable) |
Kristian Høgsberg | 80e48dd | 2010-09-09 08:06:40 -0400 | [diff] [blame] | 233 | XFreePixmap(priv->dpy, xid); |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 234 | } |
| 235 | } |
| 236 | |
| 237 | #else |
| 238 | |
Adam Jackson | 4833104 | 2011-03-31 20:43:57 +0000 | [diff] [blame^] | 239 | static GLboolean |
Kristian Høgsberg | 6ddf66e | 2010-07-28 10:07:52 -0400 | [diff] [blame] | 240 | CreateDRIDrawable(Display *dpy, const struct glx_config * fbconfig, |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 241 | XID drawable, XID glxdrawable, |
| 242 | const int *attrib_list, size_t num_attribs) |
| 243 | { |
Adam Jackson | 4833104 | 2011-03-31 20:43:57 +0000 | [diff] [blame^] | 244 | return GL_FALSE; |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | static void |
| 248 | DestroyDRIDrawable(Display *dpy, GLXDrawable drawable, int destroy_xdrawable) |
| 249 | { |
| 250 | } |
| 251 | |
Michel Dänzer | 23635510 | 2008-04-10 15:45:52 -0400 | [diff] [blame] | 252 | #endif |
| 253 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 254 | /** |
| 255 | * Get a drawable's attribute. |
| 256 | * |
| 257 | * This function is used to implement \c glXGetSelectedEvent and |
| 258 | * \c glXGetSelectedEventSGIX. |
| 259 | * |
| 260 | * \note |
| 261 | * This function dynamically determines whether to use the SGIX_pbuffer |
| 262 | * version of the protocol or the GLX 1.3 version of the protocol. |
| 263 | * |
| 264 | * \todo |
| 265 | * The number of attributes returned is likely to be small, probably less than |
| 266 | * 10. Given that, this routine should try to use an array on the stack to |
| 267 | * capture the reply rather than always calling Xmalloc. |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 268 | */ |
| 269 | static int |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 270 | GetDrawableAttribute(Display * dpy, GLXDrawable drawable, |
| 271 | int attribute, unsigned int *value) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 272 | { |
Kristian Høgsberg | c356f58 | 2010-07-28 11:16:00 -0400 | [diff] [blame] | 273 | struct glx_display *priv; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 274 | xGLXGetDrawableAttributesReply reply; |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 275 | CARD32 *data; |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 276 | CARD8 opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 277 | unsigned int length; |
| 278 | unsigned int i; |
| 279 | unsigned int num_attributes; |
Owain G. Ainsworth | b4866f8 | 2009-01-11 20:40:07 +0000 | [diff] [blame] | 280 | GLboolean use_glx_1_3; |
Adam Jackson | d25ad50 | 2006-04-07 00:05:50 +0000 | [diff] [blame] | 281 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 282 | if ((dpy == NULL) || (drawable == 0)) { |
Adam Jackson | d25ad50 | 2006-04-07 00:05:50 +0000 | [diff] [blame] | 283 | return 0; |
| 284 | } |
| 285 | |
| 286 | priv = __glXInitialize(dpy); |
Owain G. Ainsworth | b4866f8 | 2009-01-11 20:40:07 +0000 | [diff] [blame] | 287 | use_glx_1_3 = ((priv->majorVersion > 1) || (priv->minorVersion >= 3)); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 288 | |
Brian Paul | 42725d6 | 2006-02-07 00:39:56 +0000 | [diff] [blame] | 289 | *value = 0; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 290 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 291 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 292 | opcode = __glXSetupForCommand(dpy); |
| 293 | if (!opcode) |
| 294 | return 0; |
| 295 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 296 | LockDisplay(dpy); |
| 297 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 298 | if (use_glx_1_3) { |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 299 | xGLXGetDrawableAttributesReq *req; |
| 300 | |
Julien Cristau | 4324d6f | 2011-01-23 08:26:35 -0800 | [diff] [blame] | 301 | GetReq(GLXGetDrawableAttributes, req); |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 302 | req->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 303 | req->glxCode = X_GLXGetDrawableAttributes; |
| 304 | req->drawable = drawable; |
| 305 | } |
| 306 | else { |
| 307 | xGLXVendorPrivateWithReplyReq *vpreq; |
| 308 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 309 | GetReqExtra(GLXVendorPrivateWithReply, 4, vpreq); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 310 | data = (CARD32 *) (vpreq + 1); |
| 311 | data[0] = (CARD32) drawable; |
| 312 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 313 | vpreq->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 314 | vpreq->glxCode = X_GLXVendorPrivateWithReply; |
| 315 | vpreq->vendorCode = X_GLXvop_GetDrawableAttributesSGIX; |
| 316 | } |
| 317 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 318 | _XReply(dpy, (xReply *) & reply, 0, False); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 319 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 320 | if (reply.type == X_Error) { |
| 321 | UnlockDisplay(dpy); |
| 322 | SyncHandle(); |
| 323 | return 0; |
Brian Paul | 42725d6 | 2006-02-07 00:39:56 +0000 | [diff] [blame] | 324 | } |
| 325 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 326 | length = reply.length; |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 327 | if (length) { |
| 328 | num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2; |
| 329 | data = (CARD32 *) Xmalloc(length * sizeof(CARD32)); |
| 330 | if (data == NULL) { |
| 331 | /* Throw data on the floor */ |
| 332 | _XEatData(dpy, length); |
| 333 | } |
| 334 | else { |
| 335 | _XRead(dpy, (char *) data, length * sizeof(CARD32)); |
Brian Paul | 42725d6 | 2006-02-07 00:39:56 +0000 | [diff] [blame] | 336 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 337 | /* Search the set of returned attributes for the attribute requested by |
| 338 | * the caller. |
| 339 | */ |
| 340 | for (i = 0; i < num_attributes; i++) { |
| 341 | if (data[i * 2] == attribute) { |
| 342 | *value = data[(i * 2) + 1]; |
| 343 | break; |
| 344 | } |
| 345 | } |
Brian Paul | 42725d6 | 2006-02-07 00:39:56 +0000 | [diff] [blame] | 346 | |
Jeremy Huddleston | 80b280d | 2010-04-02 01:35:19 -0700 | [diff] [blame] | 347 | #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 348 | { |
Kristian Høgsberg | eeaab20 | 2010-07-22 22:36:37 -0400 | [diff] [blame] | 349 | __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable); |
Michel Dänzer | 23635510 | 2008-04-10 15:45:52 -0400 | [diff] [blame] | 350 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 351 | if (pdraw != NULL && !pdraw->textureTarget) |
| 352 | pdraw->textureTarget = |
| 353 | determineTextureTarget((const int *) data, num_attributes); |
Eric Anholt | 66175aa | 2009-03-18 12:07:09 -0700 | [diff] [blame] | 354 | if (pdraw != NULL && !pdraw->textureFormat) |
| 355 | pdraw->textureFormat = |
| 356 | determineTextureFormat((const int *) data, num_attributes); |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 357 | } |
Michel Dänzer | 23635510 | 2008-04-10 15:45:52 -0400 | [diff] [blame] | 358 | #endif |
| 359 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 360 | Xfree(data); |
| 361 | } |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | UnlockDisplay(dpy); |
| 365 | SyncHandle(); |
| 366 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 367 | return 0; |
| 368 | } |
| 369 | |
Adam Jackson | 4833104 | 2011-03-31 20:43:57 +0000 | [diff] [blame^] | 370 | static void |
| 371 | protocolDestroyDrawable(Display *dpy, GLXDrawable drawable, CARD32 glxCode) |
| 372 | { |
| 373 | xGLXDestroyPbufferReq *req; |
| 374 | CARD8 opcode; |
| 375 | |
| 376 | opcode = __glXSetupForCommand(dpy); |
| 377 | if (!opcode) |
| 378 | return; |
| 379 | |
| 380 | LockDisplay(dpy); |
| 381 | |
| 382 | GetReq(GLXDestroyPbuffer, req); |
| 383 | req->reqType = opcode; |
| 384 | req->glxCode = glxCode; |
| 385 | req->pbuffer = (GLXPbuffer) drawable; |
| 386 | |
| 387 | UnlockDisplay(dpy); |
| 388 | SyncHandle(); |
| 389 | } |
| 390 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 391 | /** |
| 392 | * Create a non-pbuffer GLX drawable. |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 393 | */ |
| 394 | static GLXDrawable |
Kristian Høgsberg | 6ddf66e | 2010-07-28 10:07:52 -0400 | [diff] [blame] | 395 | CreateDrawable(Display *dpy, struct glx_config *config, |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 396 | Drawable drawable, const int *attrib_list, CARD8 glxCode) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 397 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 398 | xGLXCreateWindowReq *req; |
| 399 | CARD32 *data; |
Ian Romanick | b47731f | 2005-03-04 17:53:24 +0000 | [diff] [blame] | 400 | unsigned int i; |
David Reveman | 342d1de | 2006-04-11 12:07:41 +0000 | [diff] [blame] | 401 | CARD8 opcode; |
Adam Jackson | a95ec18 | 2011-05-25 06:11:20 -0400 | [diff] [blame] | 402 | GLXDrawable xid; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 403 | |
Ian Romanick | b47731f | 2005-03-04 17:53:24 +0000 | [diff] [blame] | 404 | i = 0; |
| 405 | if (attrib_list) { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 406 | while (attrib_list[i * 2] != None) |
| 407 | i++; |
Ian Romanick | b47731f | 2005-03-04 17:53:24 +0000 | [diff] [blame] | 408 | } |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 409 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 410 | opcode = __glXSetupForCommand(dpy); |
| 411 | if (!opcode) |
| 412 | return None; |
David Reveman | 342d1de | 2006-04-11 12:07:41 +0000 | [diff] [blame] | 413 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 414 | LockDisplay(dpy); |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 415 | GetReqExtra(GLXCreateWindow, 8 * i, req); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 416 | data = (CARD32 *) (req + 1); |
| 417 | |
David Reveman | 342d1de | 2006-04-11 12:07:41 +0000 | [diff] [blame] | 418 | req->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 419 | req->glxCode = glxCode; |
Kristian Høgsberg | 6ddf66e | 2010-07-28 10:07:52 -0400 | [diff] [blame] | 420 | req->screen = config->screen; |
| 421 | req->fbconfig = config->fbconfigID; |
| 422 | req->window = drawable; |
Adam Jackson | a95ec18 | 2011-05-25 06:11:20 -0400 | [diff] [blame] | 423 | req->glxwindow = xid = XAllocID(dpy); |
Kristian Høgsberg | 6ddf66e | 2010-07-28 10:07:52 -0400 | [diff] [blame] | 424 | req->numAttribs = i; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 425 | |
Brian Paul | 5f40a7a | 2010-03-02 07:34:29 -0700 | [diff] [blame] | 426 | if (attrib_list) |
| 427 | memcpy(data, attrib_list, 8 * i); |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 428 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 429 | UnlockDisplay(dpy); |
| 430 | SyncHandle(); |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 431 | |
Adam Jackson | 4833104 | 2011-03-31 20:43:57 +0000 | [diff] [blame^] | 432 | if (!CreateDRIDrawable(dpy, config, drawable, xid, attrib_list, i)) { |
| 433 | if (glxCode == X_GLXCreatePixmap) |
| 434 | glxCode = X_GLXDestroyPixmap; |
| 435 | else |
| 436 | glxCode = X_GLXDestroyWindow; |
| 437 | protocolDestroyDrawable(dpy, xid, glxCode); |
| 438 | xid = None; |
| 439 | } |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 440 | |
Adam Jackson | a95ec18 | 2011-05-25 06:11:20 -0400 | [diff] [blame] | 441 | return xid; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | |
| 445 | /** |
| 446 | * Destroy a non-pbuffer GLX drawable. |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 447 | */ |
| 448 | static void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 449 | DestroyDrawable(Display * dpy, GLXDrawable drawable, CARD32 glxCode) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 450 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 451 | if ((dpy == NULL) || (drawable == 0)) { |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 452 | return; |
| 453 | } |
| 454 | |
Adam Jackson | 4833104 | 2011-03-31 20:43:57 +0000 | [diff] [blame^] | 455 | protocolDestroyDrawable(dpy, drawable, glxCode); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 456 | |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 457 | DestroyDRIDrawable(dpy, drawable, GL_FALSE); |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 458 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 459 | return; |
| 460 | } |
| 461 | |
| 462 | |
| 463 | /** |
| 464 | * Create a pbuffer. |
| 465 | * |
| 466 | * This function is used to implement \c glXCreatePbuffer and |
| 467 | * \c glXCreateGLXPbufferSGIX. |
| 468 | * |
| 469 | * \note |
| 470 | * This function dynamically determines whether to use the SGIX_pbuffer |
| 471 | * version of the protocol or the GLX 1.3 version of the protocol. |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 472 | */ |
| 473 | static GLXDrawable |
Kristian Høgsberg | 6ddf66e | 2010-07-28 10:07:52 -0400 | [diff] [blame] | 474 | CreatePbuffer(Display * dpy, struct glx_config *config, |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 475 | unsigned int width, unsigned int height, |
| 476 | const int *attrib_list, GLboolean size_in_attribs) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 477 | { |
Kristian Høgsberg | c356f58 | 2010-07-28 11:16:00 -0400 | [diff] [blame] | 478 | struct glx_display *priv = __glXInitialize(dpy); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 479 | GLXDrawable id = 0; |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 480 | CARD32 *data; |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 481 | CARD8 opcode; |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 482 | unsigned int i; |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 483 | Pixmap pixmap; |
Adam Jackson | 4833104 | 2011-03-31 20:43:57 +0000 | [diff] [blame^] | 484 | GLboolean glx_1_3 = GL_FALSE; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 485 | |
Ian Romanick | b47731f | 2005-03-04 17:53:24 +0000 | [diff] [blame] | 486 | i = 0; |
| 487 | if (attrib_list) { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 488 | while (attrib_list[i * 2]) |
| 489 | i++; |
Ian Romanick | b47731f | 2005-03-04 17:53:24 +0000 | [diff] [blame] | 490 | } |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 491 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 492 | opcode = __glXSetupForCommand(dpy); |
| 493 | if (!opcode) |
| 494 | return None; |
| 495 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 496 | LockDisplay(dpy); |
| 497 | id = XAllocID(dpy); |
| 498 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 499 | if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { |
| 500 | xGLXCreatePbufferReq *req; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 501 | unsigned int extra = (size_in_attribs) ? 0 : 2; |
| 502 | |
Adam Jackson | 4833104 | 2011-03-31 20:43:57 +0000 | [diff] [blame^] | 503 | glx_1_3 = GL_TRUE; |
| 504 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 505 | GetReqExtra(GLXCreatePbuffer, (8 * (i + extra)), req); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 506 | data = (CARD32 *) (req + 1); |
| 507 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 508 | req->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 509 | req->glxCode = X_GLXCreatePbuffer; |
Kristian Høgsberg | 6ddf66e | 2010-07-28 10:07:52 -0400 | [diff] [blame] | 510 | req->screen = config->screen; |
| 511 | req->fbconfig = config->fbconfigID; |
| 512 | req->pbuffer = id; |
| 513 | req->numAttribs = i + extra; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 514 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 515 | if (!size_in_attribs) { |
| 516 | data[(2 * i) + 0] = GLX_PBUFFER_WIDTH; |
| 517 | data[(2 * i) + 1] = width; |
| 518 | data[(2 * i) + 2] = GLX_PBUFFER_HEIGHT; |
| 519 | data[(2 * i) + 3] = height; |
| 520 | data += 4; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 521 | } |
| 522 | } |
| 523 | else { |
| 524 | xGLXVendorPrivateReq *vpreq; |
| 525 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 526 | GetReqExtra(GLXVendorPrivate, 20 + (8 * i), vpreq); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 527 | data = (CARD32 *) (vpreq + 1); |
| 528 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 529 | vpreq->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 530 | vpreq->glxCode = X_GLXVendorPrivate; |
| 531 | vpreq->vendorCode = X_GLXvop_CreateGLXPbufferSGIX; |
| 532 | |
Kristian Høgsberg | 6ddf66e | 2010-07-28 10:07:52 -0400 | [diff] [blame] | 533 | data[0] = config->screen; |
| 534 | data[1] = config->fbconfigID; |
| 535 | data[2] = id; |
| 536 | data[3] = width; |
| 537 | data[4] = height; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 538 | data += 5; |
| 539 | } |
| 540 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 541 | (void) memcpy(data, attrib_list, sizeof(CARD32) * 2 * i); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 542 | |
| 543 | UnlockDisplay(dpy); |
| 544 | SyncHandle(); |
| 545 | |
Kristian Høgsberg | 6ddf66e | 2010-07-28 10:07:52 -0400 | [diff] [blame] | 546 | pixmap = XCreatePixmap(dpy, RootWindow(dpy, config->screen), |
| 547 | width, height, config->rgbBits); |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 548 | |
Adam Jackson | 4833104 | 2011-03-31 20:43:57 +0000 | [diff] [blame^] | 549 | if (!CreateDRIDrawable(dpy, config, pixmap, id, attrib_list, i)) { |
| 550 | CARD32 o = glx_1_3 ? X_GLXDestroyPbuffer : X_GLXvop_DestroyGLXPbufferSGIX; |
| 551 | XFreePixmap(dpy, pixmap); |
| 552 | protocolDestroyDrawable(dpy, id, o); |
| 553 | id = None; |
| 554 | } |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 555 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 556 | return id; |
| 557 | } |
| 558 | |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 559 | /** |
| 560 | * Destroy a pbuffer. |
| 561 | * |
| 562 | * This function is used to implement \c glXDestroyPbuffer and |
| 563 | * \c glXDestroyGLXPbufferSGIX. |
| 564 | * |
| 565 | * \note |
| 566 | * This function dynamically determines whether to use the SGIX_pbuffer |
| 567 | * version of the protocol or the GLX 1.3 version of the protocol. |
| 568 | */ |
| 569 | static void |
| 570 | DestroyPbuffer(Display * dpy, GLXDrawable drawable) |
| 571 | { |
Kristian Høgsberg | c356f58 | 2010-07-28 11:16:00 -0400 | [diff] [blame] | 572 | struct glx_display *priv = __glXInitialize(dpy); |
Kristian Høgsberg | 5a43dba | 2010-04-09 17:16:33 -0400 | [diff] [blame] | 573 | CARD8 opcode; |
| 574 | |
| 575 | if ((dpy == NULL) || (drawable == 0)) { |
| 576 | return; |
| 577 | } |
| 578 | |
| 579 | opcode = __glXSetupForCommand(dpy); |
| 580 | if (!opcode) |
| 581 | return; |
| 582 | |
| 583 | LockDisplay(dpy); |
| 584 | |
| 585 | if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { |
| 586 | xGLXDestroyPbufferReq *req; |
| 587 | |
| 588 | GetReq(GLXDestroyPbuffer, req); |
| 589 | req->reqType = opcode; |
| 590 | req->glxCode = X_GLXDestroyPbuffer; |
| 591 | req->pbuffer = (GLXPbuffer) drawable; |
| 592 | } |
| 593 | else { |
| 594 | xGLXVendorPrivateWithReplyReq *vpreq; |
| 595 | CARD32 *data; |
| 596 | |
| 597 | GetReqExtra(GLXVendorPrivateWithReply, 4, vpreq); |
| 598 | data = (CARD32 *) (vpreq + 1); |
| 599 | |
| 600 | data[0] = (CARD32) drawable; |
| 601 | |
| 602 | vpreq->reqType = opcode; |
| 603 | vpreq->glxCode = X_GLXVendorPrivateWithReply; |
| 604 | vpreq->vendorCode = X_GLXvop_DestroyGLXPbufferSGIX; |
| 605 | } |
| 606 | |
| 607 | UnlockDisplay(dpy); |
| 608 | SyncHandle(); |
| 609 | |
| 610 | DestroyDRIDrawable(dpy, drawable, GL_TRUE); |
| 611 | |
| 612 | return; |
| 613 | } |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 614 | |
| 615 | /** |
| 616 | * Create a new pbuffer. |
| 617 | */ |
Kristian Høgsberg | 38c51a7 | 2010-07-28 10:20:41 -0400 | [diff] [blame] | 618 | _X_EXPORT GLXPbufferSGIX |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 619 | glXCreateGLXPbufferSGIX(Display * dpy, GLXFBConfigSGIX config, |
| 620 | unsigned int width, unsigned int height, |
| 621 | int *attrib_list) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 622 | { |
Kristian Høgsberg | 6ddf66e | 2010-07-28 10:07:52 -0400 | [diff] [blame] | 623 | return (GLXPbufferSGIX) CreatePbuffer(dpy, (struct glx_config *) config, |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 624 | width, height, |
| 625 | attrib_list, GL_FALSE); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 626 | } |
| 627 | |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 628 | #endif /* GLX_USE_APPLEGL */ |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 629 | |
| 630 | /** |
| 631 | * Create a new pbuffer. |
| 632 | */ |
Kristian Høgsberg | 38c51a7 | 2010-07-28 10:20:41 -0400 | [diff] [blame] | 633 | _X_EXPORT GLXPbuffer |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 634 | glXCreatePbuffer(Display * dpy, GLXFBConfig config, const int *attrib_list) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 635 | { |
Kristian Høgsberg | 8b20411 | 2007-08-27 14:16:30 -0400 | [diff] [blame] | 636 | int i, width, height; |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 637 | #ifdef GLX_USE_APPLEGL |
| 638 | GLXPbuffer result; |
| 639 | int errorcode; |
| 640 | #endif |
Kristian Høgsberg | 8b20411 | 2007-08-27 14:16:30 -0400 | [diff] [blame] | 641 | |
| 642 | width = 0; |
| 643 | height = 0; |
| 644 | |
Tormod Volden | e857303 | 2009-09-20 20:20:01 +0200 | [diff] [blame] | 645 | WARN_ONCE_GLX_1_3(dpy, __func__); |
Ian Romanick | 1f309c4 | 2009-09-15 13:12:22 -0700 | [diff] [blame] | 646 | |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 647 | #ifdef GLX_USE_APPLEGL |
| 648 | for (i = 0; attrib_list[i]; ++i) { |
| 649 | switch (attrib_list[i]) { |
| 650 | case GLX_PBUFFER_WIDTH: |
| 651 | width = attrib_list[i + 1]; |
| 652 | ++i; |
| 653 | break; |
| 654 | |
| 655 | case GLX_PBUFFER_HEIGHT: |
| 656 | height = attrib_list[i + 1]; |
| 657 | ++i; |
| 658 | break; |
| 659 | |
| 660 | case GLX_LARGEST_PBUFFER: |
| 661 | /* This is a hint we should probably handle, but how? */ |
| 662 | ++i; |
| 663 | break; |
| 664 | |
| 665 | case GLX_PRESERVED_CONTENTS: |
| 666 | /* The contents are always preserved with AppleSGLX with CGL. */ |
| 667 | ++i; |
| 668 | break; |
| 669 | |
| 670 | default: |
| 671 | return None; |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | if (apple_glx_pbuffer_create(dpy, config, width, height, &errorcode, |
| 676 | &result)) { |
| 677 | /* |
| 678 | * apple_glx_pbuffer_create only sets the errorcode to core X11 |
| 679 | * errors. |
| 680 | */ |
| 681 | __glXSendError(dpy, errorcode, 0, X_GLXCreatePbuffer, true); |
| 682 | |
| 683 | return None; |
| 684 | } |
| 685 | |
| 686 | return result; |
| 687 | #else |
Kristian Høgsberg | 8b20411 | 2007-08-27 14:16:30 -0400 | [diff] [blame] | 688 | for (i = 0; attrib_list[i * 2]; i++) { |
| 689 | switch (attrib_list[i * 2]) { |
| 690 | case GLX_PBUFFER_WIDTH: |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 691 | width = attrib_list[i * 2 + 1]; |
| 692 | break; |
Kristian Høgsberg | 8b20411 | 2007-08-27 14:16:30 -0400 | [diff] [blame] | 693 | case GLX_PBUFFER_HEIGHT: |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 694 | height = attrib_list[i * 2 + 1]; |
| 695 | break; |
Kristian Høgsberg | 8b20411 | 2007-08-27 14:16:30 -0400 | [diff] [blame] | 696 | } |
| 697 | } |
| 698 | |
Kristian Høgsberg | 6ddf66e | 2010-07-28 10:07:52 -0400 | [diff] [blame] | 699 | return (GLXPbuffer) CreatePbuffer(dpy, (struct glx_config *) config, |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 700 | width, height, attrib_list, GL_TRUE); |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 701 | #endif |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 702 | } |
| 703 | |
| 704 | |
| 705 | /** |
| 706 | * Destroy an existing pbuffer. |
| 707 | */ |
Kristian Høgsberg | 38c51a7 | 2010-07-28 10:20:41 -0400 | [diff] [blame] | 708 | _X_EXPORT void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 709 | glXDestroyPbuffer(Display * dpy, GLXPbuffer pbuf) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 710 | { |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 711 | #ifdef GLX_USE_APPLEGL |
| 712 | if (apple_glx_pbuffer_destroy(dpy, pbuf)) { |
| 713 | __glXSendError(dpy, GLXBadPbuffer, pbuf, X_GLXDestroyPbuffer, false); |
| 714 | } |
| 715 | #else |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 716 | DestroyPbuffer(dpy, pbuf); |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 717 | #endif |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 718 | } |
| 719 | |
| 720 | |
| 721 | /** |
| 722 | * Query an attribute of a drawable. |
| 723 | */ |
Kristian Høgsberg | 38c51a7 | 2010-07-28 10:20:41 -0400 | [diff] [blame] | 724 | _X_EXPORT void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 725 | glXQueryDrawable(Display * dpy, GLXDrawable drawable, |
| 726 | int attribute, unsigned int *value) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 727 | { |
Tormod Volden | e857303 | 2009-09-20 20:20:01 +0200 | [diff] [blame] | 728 | WARN_ONCE_GLX_1_3(dpy, __func__); |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 729 | #ifdef GLX_USE_APPLEGL |
| 730 | Window root; |
| 731 | int x, y; |
| 732 | unsigned int width, height, bd, depth; |
| 733 | |
| 734 | if (apple_glx_pixmap_query(drawable, attribute, value)) |
| 735 | return; /*done */ |
| 736 | |
| 737 | if (apple_glx_pbuffer_query(drawable, attribute, value)) |
| 738 | return; /*done */ |
| 739 | |
| 740 | /* |
| 741 | * The OpenGL spec states that we should report GLXBadDrawable if |
| 742 | * the drawable is invalid, however doing so would require that we |
| 743 | * use XSetErrorHandler(), which is known to not be thread safe. |
| 744 | * If we use a round-trip call to validate the drawable, there could |
| 745 | * be a race, so instead we just opt in favor of letting the |
| 746 | * XGetGeometry request fail with a GetGeometry request X error |
| 747 | * rather than GLXBadDrawable, in what is hoped to be a rare |
| 748 | * case of an invalid drawable. In practice most and possibly all |
| 749 | * X11 apps using GLX shouldn't notice a difference. |
| 750 | */ |
| 751 | if (XGetGeometry |
| 752 | (dpy, drawable, &root, &x, &y, &width, &height, &bd, &depth)) { |
| 753 | switch (attribute) { |
| 754 | case GLX_WIDTH: |
| 755 | *value = width; |
| 756 | break; |
| 757 | |
| 758 | case GLX_HEIGHT: |
| 759 | *value = height; |
| 760 | break; |
| 761 | } |
| 762 | } |
| 763 | #else |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 764 | GetDrawableAttribute(dpy, drawable, attribute, value); |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 765 | #endif |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 766 | } |
| 767 | |
| 768 | |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 769 | #ifndef GLX_USE_APPLEGL |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 770 | /** |
| 771 | * Query an attribute of a pbuffer. |
| 772 | */ |
Kristian Høgsberg | 38c51a7 | 2010-07-28 10:20:41 -0400 | [diff] [blame] | 773 | _X_EXPORT int |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 774 | glXQueryGLXPbufferSGIX(Display * dpy, GLXPbufferSGIX drawable, |
| 775 | int attribute, unsigned int *value) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 776 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 777 | return GetDrawableAttribute(dpy, drawable, attribute, value); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 778 | } |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 779 | #endif |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 780 | |
| 781 | /** |
| 782 | * Select the event mask for a drawable. |
| 783 | */ |
Kristian Høgsberg | 38c51a7 | 2010-07-28 10:20:41 -0400 | [diff] [blame] | 784 | _X_EXPORT void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 785 | glXSelectEvent(Display * dpy, GLXDrawable drawable, unsigned long mask) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 786 | { |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 787 | #ifdef GLX_USE_APPLEGL |
| 788 | XWindowAttributes xwattr; |
| 789 | |
| 790 | if (apple_glx_pbuffer_set_event_mask(drawable, mask)) |
| 791 | return; /*done */ |
| 792 | |
| 793 | /* |
| 794 | * The spec allows a window, but currently there are no valid |
| 795 | * events for a window, so do nothing. |
| 796 | */ |
| 797 | if (XGetWindowAttributes(dpy, drawable, &xwattr)) |
| 798 | return; /*done */ |
| 799 | /* The drawable seems to be invalid. Report an error. */ |
| 800 | |
| 801 | __glXSendError(dpy, GLXBadDrawable, drawable, |
| 802 | X_GLXChangeDrawableAttributes, false); |
| 803 | #else |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 804 | CARD32 attribs[2]; |
| 805 | |
| 806 | attribs[0] = (CARD32) GLX_EVENT_MASK; |
| 807 | attribs[1] = (CARD32) mask; |
| 808 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 809 | ChangeDrawableAttribute(dpy, drawable, attribs, 1); |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 810 | #endif |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 811 | } |
| 812 | |
| 813 | |
| 814 | /** |
| 815 | * Get the selected event mask for a drawable. |
| 816 | */ |
Kristian Høgsberg | 38c51a7 | 2010-07-28 10:20:41 -0400 | [diff] [blame] | 817 | _X_EXPORT void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 818 | glXGetSelectedEvent(Display * dpy, GLXDrawable drawable, unsigned long *mask) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 819 | { |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 820 | #ifdef GLX_USE_APPLEGL |
| 821 | XWindowAttributes xwattr; |
| 822 | |
| 823 | if (apple_glx_pbuffer_get_event_mask(drawable, mask)) |
| 824 | return; /*done */ |
| 825 | |
| 826 | /* |
| 827 | * The spec allows a window, but currently there are no valid |
| 828 | * events for a window, so do nothing, but set the mask to 0. |
| 829 | */ |
| 830 | if (XGetWindowAttributes(dpy, drawable, &xwattr)) { |
| 831 | /* The window is valid, so set the mask to 0. */ |
| 832 | *mask = 0; |
| 833 | return; /*done */ |
| 834 | } |
| 835 | /* The drawable seems to be invalid. Report an error. */ |
| 836 | |
| 837 | __glXSendError(dpy, GLXBadDrawable, drawable, X_GLXGetDrawableAttributes, |
| 838 | true); |
| 839 | #else |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 840 | unsigned int value; |
| 841 | |
| 842 | |
| 843 | /* The non-sense with value is required because on LP64 platforms |
| 844 | * sizeof(unsigned int) != sizeof(unsigned long). On little-endian |
| 845 | * we could just type-cast the pointer, but why? |
| 846 | */ |
| 847 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 848 | GetDrawableAttribute(dpy, drawable, GLX_EVENT_MASK_SGIX, &value); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 849 | *mask = value; |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 850 | #endif |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 851 | } |
| 852 | |
| 853 | |
Kristian Høgsberg | 38c51a7 | 2010-07-28 10:20:41 -0400 | [diff] [blame] | 854 | _X_EXPORT GLXPixmap |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 855 | glXCreatePixmap(Display * dpy, GLXFBConfig config, Pixmap pixmap, |
| 856 | const int *attrib_list) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 857 | { |
Tormod Volden | e857303 | 2009-09-20 20:20:01 +0200 | [diff] [blame] | 858 | WARN_ONCE_GLX_1_3(dpy, __func__); |
Ian Romanick | 1f309c4 | 2009-09-15 13:12:22 -0700 | [diff] [blame] | 859 | |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 860 | #ifdef GLX_USE_APPLEGL |
Jeremy Huddleston | bb621cb | 2011-06-05 17:02:33 -0400 | [diff] [blame] | 861 | const struct glx_config *modes = (const struct glx_config *) config; |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 862 | |
| 863 | if (apple_glx_pixmap_create(dpy, modes->screen, pixmap, modes)) |
| 864 | return None; |
| 865 | |
| 866 | return pixmap; |
| 867 | #else |
Kristian Høgsberg | 6ddf66e | 2010-07-28 10:07:52 -0400 | [diff] [blame] | 868 | return CreateDrawable(dpy, (struct glx_config *) config, |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 869 | (Drawable) pixmap, attrib_list, X_GLXCreatePixmap); |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 870 | #endif |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 871 | } |
| 872 | |
| 873 | |
Kristian Høgsberg | 38c51a7 | 2010-07-28 10:20:41 -0400 | [diff] [blame] | 874 | _X_EXPORT GLXWindow |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 875 | glXCreateWindow(Display * dpy, GLXFBConfig config, Window win, |
| 876 | const int *attrib_list) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 877 | { |
Tormod Volden | e857303 | 2009-09-20 20:20:01 +0200 | [diff] [blame] | 878 | WARN_ONCE_GLX_1_3(dpy, __func__); |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 879 | #ifdef GLX_USE_APPLEGL |
| 880 | XWindowAttributes xwattr; |
| 881 | XVisualInfo *visinfo; |
Ian Romanick | 1f309c4 | 2009-09-15 13:12:22 -0700 | [diff] [blame] | 882 | |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 883 | (void) attrib_list; /*unused according to GLX 1.4 */ |
| 884 | |
| 885 | XGetWindowAttributes(dpy, win, &xwattr); |
| 886 | |
| 887 | visinfo = glXGetVisualFromFBConfig(dpy, config); |
| 888 | |
| 889 | if (NULL == visinfo) { |
| 890 | __glXSendError(dpy, GLXBadFBConfig, 0, X_GLXCreateWindow, false); |
| 891 | return None; |
| 892 | } |
| 893 | |
| 894 | if (visinfo->visualid != XVisualIDFromVisual(xwattr.visual)) { |
| 895 | __glXSendError(dpy, BadMatch, 0, X_GLXCreateWindow, true); |
| 896 | return None; |
| 897 | } |
| 898 | |
| 899 | XFree(visinfo); |
| 900 | |
| 901 | return win; |
| 902 | #else |
Kristian Høgsberg | 6ddf66e | 2010-07-28 10:07:52 -0400 | [diff] [blame] | 903 | return CreateDrawable(dpy, (struct glx_config *) config, |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 904 | (Drawable) win, attrib_list, X_GLXCreateWindow); |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 905 | #endif |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 906 | } |
| 907 | |
| 908 | |
Kristian Høgsberg | 38c51a7 | 2010-07-28 10:20:41 -0400 | [diff] [blame] | 909 | _X_EXPORT void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 910 | glXDestroyPixmap(Display * dpy, GLXPixmap pixmap) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 911 | { |
Tormod Volden | e857303 | 2009-09-20 20:20:01 +0200 | [diff] [blame] | 912 | WARN_ONCE_GLX_1_3(dpy, __func__); |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 913 | #ifdef GLX_USE_APPLEGL |
| 914 | if (apple_glx_pixmap_destroy(dpy, pixmap)) |
| 915 | __glXSendError(dpy, GLXBadPixmap, pixmap, X_GLXDestroyPixmap, false); |
| 916 | #else |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 917 | DestroyDrawable(dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap); |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 918 | #endif |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 919 | } |
| 920 | |
| 921 | |
Kristian Høgsberg | 38c51a7 | 2010-07-28 10:20:41 -0400 | [diff] [blame] | 922 | _X_EXPORT void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 923 | glXDestroyWindow(Display * dpy, GLXWindow win) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 924 | { |
Tormod Volden | e857303 | 2009-09-20 20:20:01 +0200 | [diff] [blame] | 925 | WARN_ONCE_GLX_1_3(dpy, __func__); |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 926 | #ifndef GLX_USE_APPLEGL |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 927 | DestroyDrawable(dpy, (GLXDrawable) win, X_GLXDestroyWindow); |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 928 | #endif |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 929 | } |
| 930 | |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 931 | #ifndef GLX_USE_APPLEGL |
Kristian Høgsberg | 38c51a7 | 2010-07-28 10:20:41 -0400 | [diff] [blame] | 932 | _X_EXPORT |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 933 | GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX, |
| 934 | (Display * dpy, GLXPbufferSGIX pbuf), |
| 935 | (dpy, pbuf), glXDestroyPbuffer) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 936 | |
Kristian Høgsberg | 38c51a7 | 2010-07-28 10:20:41 -0400 | [diff] [blame] | 937 | _X_EXPORT |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 938 | GLX_ALIAS_VOID(glXSelectEventSGIX, |
| 939 | (Display * dpy, GLXDrawable drawable, |
RALOVICH, Kristóf | 0896268 | 2009-08-12 12:41:22 +0200 | [diff] [blame] | 940 | unsigned long mask), (dpy, drawable, mask), glXSelectEvent) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 941 | |
Kristian Høgsberg | 38c51a7 | 2010-07-28 10:20:41 -0400 | [diff] [blame] | 942 | _X_EXPORT |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 943 | GLX_ALIAS_VOID(glXGetSelectedEventSGIX, |
| 944 | (Display * dpy, GLXDrawable drawable, |
| 945 | unsigned long *mask), (dpy, drawable, mask), |
| 946 | glXGetSelectedEvent) |
Jeremy Huddleston | ad503c4 | 2010-04-01 11:01:31 -0700 | [diff] [blame] | 947 | #endif |