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