2 ** License Applicability. Except to the extent portions of this file are
3 ** made subject to an alternative license as permitted in the SGI Free
4 ** Software License B, Version 1.1 (the "License"), the contents of this
5 ** file are subject only to the provisions of the License. You may not use
6 ** this file except in compliance with the License. You may obtain a copy
7 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
8 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
10 ** http://oss.sgi.com/projects/FreeB
12 ** Note that, as provided in the License, the Software is distributed on an
13 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
14 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
15 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
16 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
18 ** Original Code. The Original Code is: OpenGL Sample Implementation,
19 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
20 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
21 ** Copyright in any portions created by third parties is as indicated
22 ** elsewhere herein. All Rights Reserved.
24 ** Additional Notice Provisions: The application programming interfaces
25 ** established by SGI in conjunction with the Original Code are The
26 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
27 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
28 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
29 ** Window System(R) (Version 1.3), released October 19, 1998. This software
30 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
31 ** published by SGI, but has not been independently verified as being
32 ** compliant with the OpenGL(R) version 1.2.1 Specification.
37 #ifdef HAVE_DIX_CONFIG_H
38 #include <dix-config.h>
41 #include "glxserver.h"
44 #include "indirect_dispatch.h"
46 #include "glapitable.h"
51 int __glXDispSwap_FeedbackBuffer(__GLXclientState
*cl
, GLbyte
*pc
)
55 __GLX_DECLARE_SWAP_VARIABLES
;
59 __GLX_SWAP_INT(&((xGLXSingleReq
*)pc
)->contextTag
);
60 cx
= __glXForceCurrent(cl
, __GLX_GET_SINGLE_CONTEXT_TAG(pc
), &error
);
65 pc
+= __GLX_SINGLE_HDR_SIZE
;
68 size
= *(GLsizei
*)(pc
+0);
69 type
= *(GLenum
*)(pc
+4);
70 if (cx
->feedbackBufSize
< size
) {
71 cx
->feedbackBuf
= (GLfloat
*) xrealloc(cx
->feedbackBuf
,
73 * __GLX_SIZE_FLOAT32
);
74 if (!cx
->feedbackBuf
) {
75 cl
->client
->errorValue
= size
;
78 cx
->feedbackBufSize
= size
;
80 CALL_FeedbackBuffer( GET_DISPATCH(), (size
, type
, cx
->feedbackBuf
) );
81 __GLX_NOTE_UNFLUSHED_CMDS(cx
);
85 int __glXDispSwap_SelectBuffer(__GLXclientState
*cl
, GLbyte
*pc
)
89 __GLX_DECLARE_SWAP_VARIABLES
;
92 __GLX_SWAP_INT(&((xGLXSingleReq
*)pc
)->contextTag
);
93 cx
= __glXForceCurrent(cl
, __GLX_GET_SINGLE_CONTEXT_TAG(pc
), &error
);
98 pc
+= __GLX_SINGLE_HDR_SIZE
;
100 size
= *(GLsizei
*)(pc
+0);
101 if (cx
->selectBufSize
< size
) {
102 cx
->selectBuf
= (GLuint
*) xrealloc(cx
->selectBuf
,
104 * __GLX_SIZE_CARD32
);
105 if (!cx
->selectBuf
) {
106 cl
->client
->errorValue
= size
;
109 cx
->selectBufSize
= size
;
111 CALL_SelectBuffer( GET_DISPATCH(), (size
, cx
->selectBuf
) );
112 __GLX_NOTE_UNFLUSHED_CMDS(cx
);
116 int __glXDispSwap_RenderMode(__GLXclientState
*cl
, GLbyte
*pc
)
120 xGLXRenderModeReply reply
;
121 GLint nitems
=0, retBytes
=0, retval
, newModeCheck
;
122 GLubyte
*retBuffer
= NULL
;
124 __GLX_DECLARE_SWAP_VARIABLES
;
125 __GLX_DECLARE_SWAP_ARRAY_VARIABLES
;
128 __GLX_SWAP_INT(&((xGLXSingleReq
*)pc
)->contextTag
);
129 cx
= __glXForceCurrent(cl
, __GLX_GET_SINGLE_CONTEXT_TAG(pc
), &error
);
134 pc
+= __GLX_SINGLE_HDR_SIZE
;
136 newMode
= *(GLenum
*) pc
;
137 retval
= CALL_RenderMode( GET_DISPATCH(), (newMode
) );
139 /* Check that render mode worked */
140 CALL_GetIntegerv( GET_DISPATCH(), (GL_RENDER_MODE
, &newModeCheck
) );
141 if (newModeCheck
!= newMode
) {
142 /* Render mode change failed. Bail */
143 newMode
= newModeCheck
;
144 goto noChangeAllowed
;
148 ** Render mode might have still failed if we get here. But in this
149 ** case we can't really tell, nor does it matter. If it did fail, it
150 ** will return 0, and thus we won't send any data across the wire.
153 switch (cx
->renderMode
) {
155 cx
->renderMode
= newMode
;
159 /* Overflow happened. Copy the entire buffer */
160 nitems
= cx
->feedbackBufSize
;
164 retBytes
= nitems
* __GLX_SIZE_FLOAT32
;
165 retBuffer
= (GLubyte
*) cx
->feedbackBuf
;
166 __GLX_SWAP_FLOAT_ARRAY((GLbyte
*)retBuffer
, nitems
);
167 cx
->renderMode
= newMode
;
171 /* Overflow happened. Copy the entire buffer */
172 nitems
= cx
->selectBufSize
;
174 GLuint
*bp
= cx
->selectBuf
;
178 ** Figure out how many bytes of data need to be sent. Parse
179 ** the selection buffer to determine this fact as the
180 ** return value is the number of hits, not the number of
181 ** items in the buffer.
188 /* Parse select data for this hit */
192 nitems
= bp
- cx
->selectBuf
;
194 retBytes
= nitems
* __GLX_SIZE_CARD32
;
195 retBuffer
= (GLubyte
*) cx
->selectBuf
;
196 __GLX_SWAP_INT_ARRAY((GLbyte
*)retBuffer
, nitems
);
197 cx
->renderMode
= newMode
;
202 ** First reply is the number of elements returned in the feedback or
203 ** selection array, as per the API for glRenderMode itself.
207 reply
.length
= nitems
;
208 reply
.type
= X_Reply
;
209 reply
.sequenceNumber
= client
->sequence
;
210 reply
.retval
= retval
;
212 reply
.newMode
= newMode
;
213 __GLX_SWAP_SHORT(&reply
.sequenceNumber
);
214 __GLX_SWAP_INT(&reply
.length
);
215 __GLX_SWAP_INT(&reply
.retval
);
216 __GLX_SWAP_INT(&reply
.size
);
217 __GLX_SWAP_INT(&reply
.newMode
);
218 WriteToClient(client
, sz_xGLXRenderModeReply
, (char *)&reply
);
220 WriteToClient(client
, retBytes
, (char *)retBuffer
);
225 int __glXDispSwap_Flush(__GLXclientState
*cl
, GLbyte
*pc
)
229 __GLX_DECLARE_SWAP_VARIABLES
;
231 __GLX_SWAP_INT(&((xGLXSingleReq
*)pc
)->contextTag
);
232 cx
= __glXForceCurrent(cl
, __GLX_GET_SINGLE_CONTEXT_TAG(pc
), &error
);
237 CALL_Flush( GET_DISPATCH(), () );
238 __GLX_NOTE_FLUSHED_CMDS(cx
);
242 int __glXDispSwap_Finish(__GLXclientState
*cl
, GLbyte
*pc
)
247 __GLX_DECLARE_SWAP_VARIABLES
;
249 __GLX_SWAP_INT(&((xGLXSingleReq
*)pc
)->contextTag
);
250 cx
= __glXForceCurrent(cl
, __GLX_GET_SINGLE_CONTEXT_TAG(pc
), &error
);
255 /* Do a local glFinish */
256 CALL_Finish( GET_DISPATCH(), () );
257 __GLX_NOTE_FLUSHED_CMDS(cx
);
259 /* Send empty reply packet to indicate finish is finished */
261 __GLX_BEGIN_REPLY(0);
263 __GLX_SWAP_REPLY_HEADER();
269 int __glXDispSwap_GetString(__GLXclientState
*cl
, GLbyte
*pc
)
271 return DoGetString(cl
, pc
, GL_TRUE
);