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> |
| 38 | #include "glapi.h" |
| 39 | #include "glxextensions.h" |
| 40 | #include "glcontextmodes.h" |
| 41 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 42 | |
| 43 | /** |
| 44 | * Change a drawable's attribute. |
| 45 | * |
| 46 | * This function is used to implement \c glXSelectEvent and |
| 47 | * \c glXSelectEventSGIX. |
| 48 | * |
| 49 | * \note |
| 50 | * This function dynamically determines whether to use the SGIX_pbuffer |
| 51 | * version of the protocol or the GLX 1.3 version of the protocol. |
| 52 | * |
| 53 | * \todo |
| 54 | * This function needs to be modified to work with direct-rendering drivers. |
| 55 | */ |
| 56 | static void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 57 | ChangeDrawableAttribute(Display * dpy, GLXDrawable drawable, |
| 58 | const CARD32 * attribs, size_t num_attribs) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 59 | { |
| 60 | __GLXdisplayPrivate *priv = __glXInitialize(dpy); |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 61 | CARD32 *output; |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 62 | CARD8 opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 63 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 64 | if ((dpy == NULL) || (drawable == 0)) { |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 65 | return; |
| 66 | } |
| 67 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 68 | opcode = __glXSetupForCommand(dpy); |
| 69 | if (!opcode) |
| 70 | return; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 71 | |
| 72 | LockDisplay(dpy); |
| 73 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 74 | if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 75 | xGLXChangeDrawableAttributesReq *req; |
| 76 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 77 | GetReqExtra(GLXChangeDrawableAttributes, 8 + (8 * num_attribs), req); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 78 | output = (CARD32 *) (req + 1); |
| 79 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 80 | req->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 81 | req->glxCode = X_GLXChangeDrawableAttributes; |
| 82 | req->drawable = drawable; |
| 83 | req->numAttribs = (CARD32) num_attribs; |
| 84 | } |
| 85 | else { |
| 86 | xGLXVendorPrivateWithReplyReq *vpreq; |
| 87 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 88 | GetReqExtra(GLXVendorPrivateWithReply, 4 + (8 * num_attribs), vpreq); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 89 | output = (CARD32 *) (vpreq + 1); |
| 90 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 91 | vpreq->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 92 | vpreq->glxCode = X_GLXVendorPrivateWithReply; |
| 93 | vpreq->vendorCode = X_GLXvop_ChangeDrawableAttributesSGIX; |
| 94 | |
| 95 | output[0] = (CARD32) drawable; |
| 96 | output++; |
| 97 | } |
| 98 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 99 | (void) memcpy(output, attribs, sizeof(CARD32) * 2 * num_attribs); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 100 | |
| 101 | UnlockDisplay(dpy); |
| 102 | SyncHandle(); |
| 103 | |
| 104 | return; |
| 105 | } |
| 106 | |
| 107 | |
| 108 | /** |
| 109 | * Destroy a pbuffer. |
| 110 | * |
| 111 | * This function is used to implement \c glXDestroyPbuffer and |
| 112 | * \c glXDestroyGLXPbufferSGIX. |
| 113 | * |
| 114 | * \note |
| 115 | * This function dynamically determines whether to use the SGIX_pbuffer |
| 116 | * version of the protocol or the GLX 1.3 version of the protocol. |
RALOVICH, Kristóf | 0896268 | 2009-08-12 12:41:22 +0200 | [diff] [blame^] | 117 | * |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 118 | * \todo |
| 119 | * This function needs to be modified to work with direct-rendering drivers. |
| 120 | */ |
| 121 | static void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 122 | DestroyPbuffer(Display * dpy, GLXDrawable drawable) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 123 | { |
| 124 | __GLXdisplayPrivate *priv = __glXInitialize(dpy); |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 125 | CARD8 opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 126 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 127 | if ((dpy == NULL) || (drawable == 0)) { |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 128 | return; |
| 129 | } |
| 130 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 131 | opcode = __glXSetupForCommand(dpy); |
| 132 | if (!opcode) |
| 133 | return; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 134 | |
| 135 | LockDisplay(dpy); |
| 136 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 137 | if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { |
| 138 | xGLXDestroyPbufferReq *req; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 139 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 140 | GetReq(GLXDestroyPbuffer, req); |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 141 | req->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 142 | req->glxCode = X_GLXDestroyPbuffer; |
| 143 | req->pbuffer = (GLXPbuffer) drawable; |
| 144 | } |
| 145 | else { |
| 146 | xGLXVendorPrivateWithReplyReq *vpreq; |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 147 | CARD32 *data; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 148 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 149 | GetReqExtra(GLXVendorPrivateWithReply, 4, vpreq); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 150 | data = (CARD32 *) (vpreq + 1); |
| 151 | |
| 152 | data[0] = (CARD32) drawable; |
| 153 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 154 | vpreq->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 155 | vpreq->glxCode = X_GLXVendorPrivateWithReply; |
| 156 | vpreq->vendorCode = X_GLXvop_DestroyGLXPbufferSGIX; |
| 157 | } |
| 158 | |
| 159 | UnlockDisplay(dpy); |
| 160 | SyncHandle(); |
| 161 | |
| 162 | return; |
| 163 | } |
| 164 | |
| 165 | |
Michel Dänzer | 23635510 | 2008-04-10 15:45:52 -0400 | [diff] [blame] | 166 | #ifdef GLX_DIRECT_RENDERING |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 167 | extern __GLXDRIdrawable *GetGLXDRIDrawable(Display * dpy, |
| 168 | GLXDrawable drawable, |
| 169 | int *const scrn_num); |
Michel Dänzer | 23635510 | 2008-04-10 15:45:52 -0400 | [diff] [blame] | 170 | |
| 171 | static GLenum |
| 172 | determineTextureTarget(const int *attribs, int numAttribs) |
| 173 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 174 | GLenum target = 0; |
| 175 | int i; |
Michel Dänzer | 23635510 | 2008-04-10 15:45:52 -0400 | [diff] [blame] | 176 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 177 | for (i = 0; i < numAttribs; i++) { |
| 178 | if (attribs[2 * i] == GLX_TEXTURE_TARGET_EXT) { |
| 179 | switch (attribs[2 * i + 1]) { |
| 180 | case GLX_TEXTURE_2D_EXT: |
| 181 | target = GL_TEXTURE_2D; |
| 182 | break; |
| 183 | case GLX_TEXTURE_RECTANGLE_EXT: |
| 184 | target = GL_TEXTURE_RECTANGLE_ARB; |
| 185 | break; |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | return target; |
Michel Dänzer | 23635510 | 2008-04-10 15:45:52 -0400 | [diff] [blame] | 191 | } |
Eric Anholt | 66175aa | 2009-03-18 12:07:09 -0700 | [diff] [blame] | 192 | |
| 193 | |
| 194 | static GLenum |
| 195 | determineTextureFormat(const int *attribs, int numAttribs) |
| 196 | { |
Eric Anholt | 66175aa | 2009-03-18 12:07:09 -0700 | [diff] [blame] | 197 | int i; |
| 198 | |
| 199 | for (i = 0; i < numAttribs; i++) { |
| 200 | if (attribs[2 * i] == GLX_TEXTURE_FORMAT_EXT) |
RALOVICH, Kristóf | 0896268 | 2009-08-12 12:41:22 +0200 | [diff] [blame^] | 201 | return attribs[2 * i + 1]; |
Eric Anholt | 66175aa | 2009-03-18 12:07:09 -0700 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | return 0; |
| 205 | } |
Michel Dänzer | 23635510 | 2008-04-10 15:45:52 -0400 | [diff] [blame] | 206 | #endif |
| 207 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 208 | /** |
| 209 | * Get a drawable's attribute. |
| 210 | * |
| 211 | * This function is used to implement \c glXGetSelectedEvent and |
| 212 | * \c glXGetSelectedEventSGIX. |
| 213 | * |
| 214 | * \note |
| 215 | * This function dynamically determines whether to use the SGIX_pbuffer |
| 216 | * version of the protocol or the GLX 1.3 version of the protocol. |
| 217 | * |
| 218 | * \todo |
| 219 | * The number of attributes returned is likely to be small, probably less than |
| 220 | * 10. Given that, this routine should try to use an array on the stack to |
| 221 | * capture the reply rather than always calling Xmalloc. |
| 222 | * |
| 223 | * \todo |
| 224 | * This function needs to be modified to work with direct-rendering drivers. |
| 225 | */ |
| 226 | static int |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 227 | GetDrawableAttribute(Display * dpy, GLXDrawable drawable, |
| 228 | int attribute, unsigned int *value) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 229 | { |
Adam Jackson | d25ad50 | 2006-04-07 00:05:50 +0000 | [diff] [blame] | 230 | __GLXdisplayPrivate *priv; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 231 | xGLXGetDrawableAttributesReply reply; |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 232 | CARD32 *data; |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 233 | CARD8 opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 234 | unsigned int length; |
| 235 | unsigned int i; |
| 236 | unsigned int num_attributes; |
Owain G. Ainsworth | b4866f8 | 2009-01-11 20:40:07 +0000 | [diff] [blame] | 237 | GLboolean use_glx_1_3; |
Adam Jackson | d25ad50 | 2006-04-07 00:05:50 +0000 | [diff] [blame] | 238 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 239 | if ((dpy == NULL) || (drawable == 0)) { |
Adam Jackson | d25ad50 | 2006-04-07 00:05:50 +0000 | [diff] [blame] | 240 | return 0; |
| 241 | } |
| 242 | |
| 243 | priv = __glXInitialize(dpy); |
Owain G. Ainsworth | b4866f8 | 2009-01-11 20:40:07 +0000 | [diff] [blame] | 244 | use_glx_1_3 = ((priv->majorVersion > 1) || (priv->minorVersion >= 3)); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 245 | |
Brian Paul | 42725d6 | 2006-02-07 00:39:56 +0000 | [diff] [blame] | 246 | *value = 0; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 247 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 248 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 249 | opcode = __glXSetupForCommand(dpy); |
| 250 | if (!opcode) |
| 251 | return 0; |
| 252 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 253 | LockDisplay(dpy); |
| 254 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 255 | if (use_glx_1_3) { |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 256 | xGLXGetDrawableAttributesReq *req; |
| 257 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 258 | GetReqExtra(GLXGetDrawableAttributes, 4, req); |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 259 | req->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 260 | req->glxCode = X_GLXGetDrawableAttributes; |
| 261 | req->drawable = drawable; |
| 262 | } |
| 263 | else { |
| 264 | xGLXVendorPrivateWithReplyReq *vpreq; |
| 265 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 266 | GetReqExtra(GLXVendorPrivateWithReply, 4, vpreq); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 267 | data = (CARD32 *) (vpreq + 1); |
| 268 | data[0] = (CARD32) drawable; |
| 269 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 270 | vpreq->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 271 | vpreq->glxCode = X_GLXVendorPrivateWithReply; |
| 272 | vpreq->vendorCode = X_GLXvop_GetDrawableAttributesSGIX; |
| 273 | } |
| 274 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 275 | _XReply(dpy, (xReply *) & reply, 0, False); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 276 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 277 | if (reply.type == X_Error) { |
| 278 | UnlockDisplay(dpy); |
| 279 | SyncHandle(); |
| 280 | return 0; |
Brian Paul | 42725d6 | 2006-02-07 00:39:56 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 283 | length = reply.length; |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 284 | if (length) { |
| 285 | num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2; |
| 286 | data = (CARD32 *) Xmalloc(length * sizeof(CARD32)); |
| 287 | if (data == NULL) { |
| 288 | /* Throw data on the floor */ |
| 289 | _XEatData(dpy, length); |
| 290 | } |
| 291 | else { |
| 292 | _XRead(dpy, (char *) data, length * sizeof(CARD32)); |
Brian Paul | 42725d6 | 2006-02-07 00:39:56 +0000 | [diff] [blame] | 293 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 294 | /* Search the set of returned attributes for the attribute requested by |
| 295 | * the caller. |
| 296 | */ |
| 297 | for (i = 0; i < num_attributes; i++) { |
| 298 | if (data[i * 2] == attribute) { |
| 299 | *value = data[(i * 2) + 1]; |
| 300 | break; |
| 301 | } |
| 302 | } |
Brian Paul | 42725d6 | 2006-02-07 00:39:56 +0000 | [diff] [blame] | 303 | |
Michel Dänzer | 23635510 | 2008-04-10 15:45:52 -0400 | [diff] [blame] | 304 | #ifdef GLX_DIRECT_RENDERING |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 305 | { |
| 306 | __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL); |
Michel Dänzer | 23635510 | 2008-04-10 15:45:52 -0400 | [diff] [blame] | 307 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 308 | if (pdraw != NULL && !pdraw->textureTarget) |
| 309 | pdraw->textureTarget = |
| 310 | determineTextureTarget((const int *) data, num_attributes); |
Eric Anholt | 66175aa | 2009-03-18 12:07:09 -0700 | [diff] [blame] | 311 | if (pdraw != NULL && !pdraw->textureFormat) |
| 312 | pdraw->textureFormat = |
| 313 | determineTextureFormat((const int *) data, num_attributes); |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 314 | } |
Michel Dänzer | 23635510 | 2008-04-10 15:45:52 -0400 | [diff] [blame] | 315 | #endif |
| 316 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 317 | Xfree(data); |
| 318 | } |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | UnlockDisplay(dpy); |
| 322 | SyncHandle(); |
| 323 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 324 | return 0; |
| 325 | } |
| 326 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 327 | /** |
| 328 | * Create a non-pbuffer GLX drawable. |
| 329 | * |
| 330 | * \todo |
| 331 | * This function needs to be modified to work with direct-rendering drivers. |
| 332 | */ |
| 333 | static GLXDrawable |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 334 | CreateDrawable(Display * dpy, const __GLcontextModes * fbconfig, |
| 335 | Drawable drawable, const int *attrib_list, CARD8 glxCode) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 336 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 337 | xGLXCreateWindowReq *req; |
| 338 | CARD32 *data; |
Ian Romanick | b47731f | 2005-03-04 17:53:24 +0000 | [diff] [blame] | 339 | unsigned int i; |
David Reveman | 342d1de | 2006-04-11 12:07:41 +0000 | [diff] [blame] | 340 | CARD8 opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 341 | |
Ian Romanick | b47731f | 2005-03-04 17:53:24 +0000 | [diff] [blame] | 342 | i = 0; |
| 343 | if (attrib_list) { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 344 | while (attrib_list[i * 2] != None) |
| 345 | i++; |
Ian Romanick | b47731f | 2005-03-04 17:53:24 +0000 | [diff] [blame] | 346 | } |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 347 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 348 | opcode = __glXSetupForCommand(dpy); |
| 349 | if (!opcode) |
| 350 | return None; |
David Reveman | 342d1de | 2006-04-11 12:07:41 +0000 | [diff] [blame] | 351 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 352 | LockDisplay(dpy); |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 353 | GetReqExtra(GLXCreateWindow, 8 * i, req); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 354 | data = (CARD32 *) (req + 1); |
| 355 | |
David Reveman | 342d1de | 2006-04-11 12:07:41 +0000 | [diff] [blame] | 356 | req->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 357 | req->glxCode = glxCode; |
| 358 | req->screen = (CARD32) fbconfig->screen; |
| 359 | req->fbconfig = fbconfig->fbconfigID; |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 360 | req->window = (CARD32) drawable; |
Ian Romanick | b47731f | 2005-03-04 17:53:24 +0000 | [diff] [blame] | 361 | req->glxwindow = (GLXWindow) XAllocID(dpy); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 362 | req->numAttribs = (CARD32) i; |
| 363 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 364 | memcpy(data, attrib_list, 8 * i); |
| 365 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 366 | UnlockDisplay(dpy); |
| 367 | SyncHandle(); |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 368 | |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 369 | #ifdef GLX_DIRECT_RENDERING |
| 370 | do { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 371 | /* FIXME: Maybe delay __DRIdrawable creation until the drawable |
| 372 | * is actually bound to a context... */ |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 373 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 374 | __GLXdisplayPrivate *const priv = __glXInitialize(dpy); |
| 375 | __GLXDRIdrawable *pdraw; |
| 376 | __GLXscreenConfigs *psc; |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 377 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 378 | psc = &priv->screenConfigs[fbconfig->screen]; |
| 379 | if (psc->driScreen == NULL) |
| 380 | break; |
| 381 | pdraw = psc->driScreen->createDrawable(psc, drawable, |
| 382 | req->glxwindow, fbconfig); |
| 383 | if (pdraw == NULL) { |
| 384 | fprintf(stderr, "failed to create drawable\n"); |
| 385 | break; |
| 386 | } |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 387 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 388 | if (__glxHashInsert(psc->drawHash, req->glxwindow, pdraw)) { |
| 389 | (*pdraw->destroyDrawable) (pdraw); |
| 390 | return None; /* FIXME: Check what we're supposed to do here... */ |
| 391 | } |
| 392 | |
| 393 | pdraw->textureTarget = determineTextureTarget(attrib_list, i); |
Eric Anholt | 66175aa | 2009-03-18 12:07:09 -0700 | [diff] [blame] | 394 | pdraw->textureFormat = determineTextureFormat(attrib_list, i); |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 395 | } while (0); |
| 396 | #endif |
| 397 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 398 | return (GLXDrawable) req->glxwindow; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | |
| 402 | /** |
| 403 | * Destroy a non-pbuffer GLX drawable. |
| 404 | * |
| 405 | * \todo |
| 406 | * This function needs to be modified to work with direct-rendering drivers. |
| 407 | */ |
| 408 | static void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 409 | DestroyDrawable(Display * dpy, GLXDrawable drawable, CARD32 glxCode) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 410 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 411 | xGLXDestroyPbufferReq *req; |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 412 | CARD8 opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 413 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 414 | if ((dpy == NULL) || (drawable == 0)) { |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 415 | return; |
| 416 | } |
| 417 | |
| 418 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 419 | opcode = __glXSetupForCommand(dpy); |
| 420 | if (!opcode) |
| 421 | return; |
| 422 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 423 | LockDisplay(dpy); |
| 424 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 425 | GetReqExtra(GLXDestroyPbuffer, 4, req); |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 426 | req->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 427 | req->glxCode = glxCode; |
| 428 | req->pbuffer = (GLXPbuffer) drawable; |
| 429 | |
| 430 | UnlockDisplay(dpy); |
| 431 | SyncHandle(); |
| 432 | |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 433 | #ifdef GLX_DIRECT_RENDERING |
| 434 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 435 | int screen; |
| 436 | __GLXdisplayPrivate *const priv = __glXInitialize(dpy); |
| 437 | __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen); |
| 438 | __GLXscreenConfigs *psc = &priv->screenConfigs[screen]; |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 439 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 440 | if (pdraw != NULL) { |
| 441 | (*pdraw->destroyDrawable) (pdraw); |
| 442 | __glxHashDelete(psc->drawHash, drawable); |
| 443 | } |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 444 | } |
| 445 | #endif |
| 446 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 447 | return; |
| 448 | } |
| 449 | |
| 450 | |
| 451 | /** |
| 452 | * Create a pbuffer. |
| 453 | * |
| 454 | * This function is used to implement \c glXCreatePbuffer and |
| 455 | * \c glXCreateGLXPbufferSGIX. |
| 456 | * |
| 457 | * \note |
| 458 | * This function dynamically determines whether to use the SGIX_pbuffer |
| 459 | * version of the protocol or the GLX 1.3 version of the protocol. |
| 460 | * |
| 461 | * \todo |
| 462 | * This function needs to be modified to work with direct-rendering drivers. |
| 463 | */ |
| 464 | static GLXDrawable |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 465 | CreatePbuffer(Display * dpy, const __GLcontextModes * fbconfig, |
| 466 | unsigned int width, unsigned int height, |
| 467 | const int *attrib_list, GLboolean size_in_attribs) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 468 | { |
| 469 | __GLXdisplayPrivate *priv = __glXInitialize(dpy); |
| 470 | GLXDrawable id = 0; |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 471 | CARD32 *data; |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 472 | CARD8 opcode; |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 473 | unsigned int i; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 474 | |
Ian Romanick | b47731f | 2005-03-04 17:53:24 +0000 | [diff] [blame] | 475 | i = 0; |
| 476 | if (attrib_list) { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 477 | while (attrib_list[i * 2]) |
| 478 | i++; |
Ian Romanick | b47731f | 2005-03-04 17:53:24 +0000 | [diff] [blame] | 479 | } |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 480 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 481 | opcode = __glXSetupForCommand(dpy); |
| 482 | if (!opcode) |
| 483 | return None; |
| 484 | |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 485 | LockDisplay(dpy); |
| 486 | id = XAllocID(dpy); |
| 487 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 488 | if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) { |
| 489 | xGLXCreatePbufferReq *req; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 490 | unsigned int extra = (size_in_attribs) ? 0 : 2; |
| 491 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 492 | GetReqExtra(GLXCreatePbuffer, (8 * (i + extra)), req); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 493 | data = (CARD32 *) (req + 1); |
| 494 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 495 | req->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 496 | req->glxCode = X_GLXCreatePbuffer; |
| 497 | req->screen = (CARD32) fbconfig->screen; |
| 498 | req->fbconfig = fbconfig->fbconfigID; |
| 499 | req->pbuffer = (GLXPbuffer) id; |
| 500 | req->numAttribs = (CARD32) (i + extra); |
| 501 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 502 | if (!size_in_attribs) { |
| 503 | data[(2 * i) + 0] = GLX_PBUFFER_WIDTH; |
| 504 | data[(2 * i) + 1] = width; |
| 505 | data[(2 * i) + 2] = GLX_PBUFFER_HEIGHT; |
| 506 | data[(2 * i) + 3] = height; |
| 507 | data += 4; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 508 | } |
| 509 | } |
| 510 | else { |
| 511 | xGLXVendorPrivateReq *vpreq; |
| 512 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 513 | GetReqExtra(GLXVendorPrivate, 20 + (8 * i), vpreq); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 514 | data = (CARD32 *) (vpreq + 1); |
| 515 | |
Kristian Høgsberg | c25eb99 | 2006-06-13 01:41:18 +0000 | [diff] [blame] | 516 | vpreq->reqType = opcode; |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 517 | vpreq->glxCode = X_GLXVendorPrivate; |
| 518 | vpreq->vendorCode = X_GLXvop_CreateGLXPbufferSGIX; |
| 519 | |
| 520 | data[0] = (CARD32) fbconfig->screen; |
| 521 | data[1] = (CARD32) fbconfig->fbconfigID; |
| 522 | data[2] = (CARD32) id; |
| 523 | data[3] = (CARD32) width; |
| 524 | data[4] = (CARD32) height; |
| 525 | data += 5; |
| 526 | } |
| 527 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 528 | (void) memcpy(data, attrib_list, sizeof(CARD32) * 2 * i); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 529 | |
| 530 | UnlockDisplay(dpy); |
| 531 | SyncHandle(); |
| 532 | |
| 533 | return id; |
| 534 | } |
| 535 | |
| 536 | |
| 537 | /** |
| 538 | * Create a new pbuffer. |
| 539 | */ |
Adam Jackson | 489ccef | 2004-12-15 17:18:06 +0000 | [diff] [blame] | 540 | PUBLIC GLXPbufferSGIX |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 541 | glXCreateGLXPbufferSGIX(Display * dpy, GLXFBConfigSGIX config, |
| 542 | unsigned int width, unsigned int height, |
| 543 | int *attrib_list) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 544 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 545 | return (GLXPbufferSGIX) CreatePbuffer(dpy, (__GLcontextModes *) config, |
| 546 | width, height, |
| 547 | attrib_list, GL_FALSE); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | |
| 551 | /** |
| 552 | * Create a new pbuffer. |
| 553 | */ |
Adam Jackson | 489ccef | 2004-12-15 17:18:06 +0000 | [diff] [blame] | 554 | PUBLIC GLXPbuffer |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 555 | glXCreatePbuffer(Display * dpy, GLXFBConfig config, const int *attrib_list) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 556 | { |
Kristian Høgsberg | 8b20411 | 2007-08-27 14:16:30 -0400 | [diff] [blame] | 557 | int i, width, height; |
| 558 | |
| 559 | width = 0; |
| 560 | height = 0; |
| 561 | |
| 562 | for (i = 0; attrib_list[i * 2]; i++) { |
| 563 | switch (attrib_list[i * 2]) { |
| 564 | case GLX_PBUFFER_WIDTH: |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 565 | width = attrib_list[i * 2 + 1]; |
| 566 | break; |
Kristian Høgsberg | 8b20411 | 2007-08-27 14:16:30 -0400 | [diff] [blame] | 567 | case GLX_PBUFFER_HEIGHT: |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 568 | height = attrib_list[i * 2 + 1]; |
| 569 | break; |
Kristian Høgsberg | 8b20411 | 2007-08-27 14:16:30 -0400 | [diff] [blame] | 570 | } |
| 571 | } |
| 572 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 573 | return (GLXPbuffer) CreatePbuffer(dpy, (__GLcontextModes *) config, |
| 574 | width, height, attrib_list, GL_TRUE); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | |
| 578 | /** |
| 579 | * Destroy an existing pbuffer. |
| 580 | */ |
Adam Jackson | 489ccef | 2004-12-15 17:18:06 +0000 | [diff] [blame] | 581 | PUBLIC void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 582 | glXDestroyPbuffer(Display * dpy, GLXPbuffer pbuf) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 583 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 584 | DestroyPbuffer(dpy, pbuf); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | |
| 588 | /** |
| 589 | * Query an attribute of a drawable. |
| 590 | */ |
Adam Jackson | 489ccef | 2004-12-15 17:18:06 +0000 | [diff] [blame] | 591 | PUBLIC void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 592 | glXQueryDrawable(Display * dpy, GLXDrawable drawable, |
| 593 | int attribute, unsigned int *value) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 594 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 595 | GetDrawableAttribute(dpy, drawable, attribute, value); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | |
| 599 | /** |
| 600 | * Query an attribute of a pbuffer. |
| 601 | */ |
Adam Jackson | 489ccef | 2004-12-15 17:18:06 +0000 | [diff] [blame] | 602 | PUBLIC int |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 603 | glXQueryGLXPbufferSGIX(Display * dpy, GLXPbufferSGIX drawable, |
| 604 | int attribute, unsigned int *value) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 605 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 606 | return GetDrawableAttribute(dpy, drawable, attribute, value); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | |
| 610 | /** |
| 611 | * Select the event mask for a drawable. |
| 612 | */ |
Adam Jackson | 489ccef | 2004-12-15 17:18:06 +0000 | [diff] [blame] | 613 | PUBLIC void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 614 | glXSelectEvent(Display * dpy, GLXDrawable drawable, unsigned long mask) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 615 | { |
| 616 | CARD32 attribs[2]; |
| 617 | |
| 618 | attribs[0] = (CARD32) GLX_EVENT_MASK; |
| 619 | attribs[1] = (CARD32) mask; |
| 620 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 621 | ChangeDrawableAttribute(dpy, drawable, attribs, 1); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | |
| 625 | /** |
| 626 | * Get the selected event mask for a drawable. |
| 627 | */ |
Adam Jackson | 489ccef | 2004-12-15 17:18:06 +0000 | [diff] [blame] | 628 | PUBLIC void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 629 | glXGetSelectedEvent(Display * dpy, GLXDrawable drawable, unsigned long *mask) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 630 | { |
| 631 | unsigned int value; |
| 632 | |
| 633 | |
| 634 | /* The non-sense with value is required because on LP64 platforms |
| 635 | * sizeof(unsigned int) != sizeof(unsigned long). On little-endian |
| 636 | * we could just type-cast the pointer, but why? |
| 637 | */ |
| 638 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 639 | GetDrawableAttribute(dpy, drawable, GLX_EVENT_MASK_SGIX, &value); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 640 | *mask = value; |
| 641 | } |
| 642 | |
| 643 | |
Adam Jackson | 489ccef | 2004-12-15 17:18:06 +0000 | [diff] [blame] | 644 | PUBLIC GLXPixmap |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 645 | glXCreatePixmap(Display * dpy, GLXFBConfig config, Pixmap pixmap, |
| 646 | const int *attrib_list) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 647 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 648 | return CreateDrawable(dpy, (__GLcontextModes *) config, |
| 649 | (Drawable) pixmap, attrib_list, X_GLXCreatePixmap); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 650 | } |
| 651 | |
| 652 | |
Adam Jackson | 489ccef | 2004-12-15 17:18:06 +0000 | [diff] [blame] | 653 | PUBLIC GLXWindow |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 654 | glXCreateWindow(Display * dpy, GLXFBConfig config, Window win, |
| 655 | const int *attrib_list) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 656 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 657 | return CreateDrawable(dpy, (__GLcontextModes *) config, |
| 658 | (Drawable) win, attrib_list, X_GLXCreateWindow); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | |
Adam Jackson | 489ccef | 2004-12-15 17:18:06 +0000 | [diff] [blame] | 662 | PUBLIC void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 663 | glXDestroyPixmap(Display * dpy, GLXPixmap pixmap) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 664 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 665 | DestroyDrawable(dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | |
Adam Jackson | 489ccef | 2004-12-15 17:18:06 +0000 | [diff] [blame] | 669 | PUBLIC void |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 670 | glXDestroyWindow(Display * dpy, GLXWindow win) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 671 | { |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 672 | DestroyDrawable(dpy, (GLXDrawable) win, X_GLXDestroyWindow); |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 676 | PUBLIC |
| 677 | GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX, |
| 678 | (Display * dpy, GLXPbufferSGIX pbuf), |
| 679 | (dpy, pbuf), glXDestroyPbuffer) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 680 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 681 | PUBLIC |
| 682 | GLX_ALIAS_VOID(glXSelectEventSGIX, |
| 683 | (Display * dpy, GLXDrawable drawable, |
RALOVICH, Kristóf | 0896268 | 2009-08-12 12:41:22 +0200 | [diff] [blame^] | 684 | unsigned long mask), (dpy, drawable, mask), glXSelectEvent) |
Adam Jackson | cb3610e | 2004-10-25 21:09:16 +0000 | [diff] [blame] | 685 | |
RALOVICH, Kristóf | 2d4c26b | 2008-10-13 14:12:02 +0200 | [diff] [blame] | 686 | PUBLIC |
| 687 | GLX_ALIAS_VOID(glXGetSelectedEventSGIX, |
| 688 | (Display * dpy, GLXDrawable drawable, |
| 689 | unsigned long *mask), (dpy, drawable, mask), |
| 690 | glXGetSelectedEvent) |