int __glXDisp_GetMapiv(__GLXclientState *cl, GLbyte *pc) { GLenum target; GLenum query; GLint compsize; __GLXcontext *cx; ClientPtr client = cl->client; int error; GLint answerBuffer[200]; char *answer; cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error); if (!cx) { return error; } pc += __GLX_SINGLE_HDR_SIZE; target = *(GLenum *)(pc + 0); query = *(GLenum *)(pc + 4); compsize = __glGetMapiv_size(target,query); if (compsize < 0) compsize = 0; __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4); __glXClearErrorOccured(); glGetMapiv( *(GLenum *)(pc + 0), *(GLenum *)(pc + 4), (GLint *) answer ); if (__glXErrorOccured()) { __GLX_BEGIN_REPLY(0); __GLX_PUT_SIZE(0); __GLX_SEND_HEADER(); } else if (compsize == 1) { __GLX_BEGIN_REPLY(0); __GLX_PUT_SIZE(1); __GLX_PUT_INT(); __GLX_SEND_HEADER(); } else { __GLX_BEGIN_REPLY(compsize*4); __GLX_PUT_SIZE(compsize); __GLX_SEND_HEADER(); __GLX_SEND_INT_ARRAY(compsize); } return Success; }
int __glXDisp_GetTexLevelParameterfv(__GLXclientState *cl, GLbyte *pc) { GLenum pname; GLint compsize; __GLXcontext *cx; ClientPtr client = cl->client; int error; GLfloat answerBuffer[200]; char *answer; cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error); if (!cx) { return error; } pc += __GLX_SINGLE_HDR_SIZE; pname = *(GLenum *)(pc + 8); compsize = __glGetTexLevelParameterfv_size(pname); if (compsize < 0) compsize = 0; __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*4,4); __glXClearErrorOccured(); glGetTexLevelParameterfv( *(GLenum *)(pc + 0), *(GLint *)(pc + 4), *(GLenum *)(pc + 8), (GLfloat *) answer ); if (__glXErrorOccured()) { __GLX_BEGIN_REPLY(0); __GLX_PUT_SIZE(0); __GLX_SEND_HEADER(); } else if (compsize == 1) { __GLX_BEGIN_REPLY(0); __GLX_PUT_SIZE(1); __GLX_PUT_FLOAT(); __GLX_SEND_HEADER(); } else { __GLX_BEGIN_REPLY(compsize*4); __GLX_PUT_SIZE(compsize); __GLX_SEND_HEADER(); __GLX_SEND_FLOAT_ARRAY(compsize); } return Success; }
int __glXDisp_GetPixelMapusv(__GLXclientState *cl, GLbyte *pc) { GLenum map; GLint compsize; __GLXcontext *cx; ClientPtr client = cl->client; int error; GLushort answerBuffer[200]; char *answer; cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error); if (!cx) { return error; } pc += __GLX_SINGLE_HDR_SIZE; map = *(GLenum *)(pc + 0); compsize = __glGetPixelMapusv_size(map); if (compsize < 0) compsize = 0; __GLX_GET_ANSWER_BUFFER(answer,cl,compsize*2,2); __glXClearErrorOccured(); glGetPixelMapusv( *(GLenum *)(pc + 0), (GLushort *) answer ); if (__glXErrorOccured()) { __GLX_BEGIN_REPLY(0); __GLX_PUT_SIZE(0); __GLX_SEND_HEADER(); } else if (compsize == 1) { __GLX_BEGIN_REPLY(0); __GLX_PUT_SIZE(1); __GLX_PUT_SHORT(); __GLX_SEND_HEADER(); } else { __GLX_BEGIN_REPLY(compsize*2); __GLX_PUT_SIZE(compsize); __GLX_SEND_HEADER(); __GLX_SEND_SHORT_ARRAY(compsize); } return Success; }
static int ephyrGLXGetStringReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap) { ClientPtr client=NULL ; int context_tag=0, name=0, res=BadImplementation, length=0 ; char *string=NULL; __GLX_DECLARE_SWAP_VARIABLES; EPHYR_RETURN_VAL_IF_FAIL (a_cl && a_pc, BadValue) ; EPHYR_LOG ("enter\n") ; client = a_cl->client ; if (a_do_swap) { __GLX_SWAP_INT (a_pc + 4); __GLX_SWAP_INT (a_pc + __GLX_SINGLE_HDR_SIZE); } context_tag = __GLX_GET_SINGLE_CONTEXT_TAG (a_pc) ; a_pc += __GLX_SINGLE_HDR_SIZE; name = *(GLenum*)(a_pc + 0); EPHYR_LOG ("context_tag:%d, name:%d\n", context_tag, name) ; if (!ephyrHostGLXGetStringFromServer (context_tag, name, EPHYR_HOST_GLX_GetString, &string)) { EPHYR_LOG_ERROR ("failed to get string from server\n") ; goto out ; } if (string) { length = strlen (string) + 1; EPHYR_LOG ("got string:'%s', size:%d\n", string, length) ; } else { EPHYR_LOG ("got string: string (null)\n") ; } __GLX_BEGIN_REPLY (length); __GLX_PUT_SIZE (length); __GLX_SEND_HEADER (); if (a_do_swap) { __GLX_SWAP_REPLY_SIZE (); __GLX_SWAP_REPLY_HEADER (); } WriteToClient (client, length, (char *)string); res = Success ; out: EPHYR_LOG ("leave\n") ; return res ; }
int DoGetString(__GLXclientState *cl, GLbyte *pc, GLboolean need_swap) { ClientPtr client; __GLXcontext *cx; GLenum name; const char *string; __GLX_DECLARE_SWAP_VARIABLES; int error; char *buf = NULL, *buf1 = NULL; GLint length = 0; /* If the client has the opposite byte order, swap the contextTag and * the name. */ if ( need_swap ) { __GLX_SWAP_INT(pc + 4); __GLX_SWAP_INT(pc + __GLX_SINGLE_HDR_SIZE); } cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc), &error); if (!cx) { return error; } pc += __GLX_SINGLE_HDR_SIZE; name = *(GLenum *)(pc + 0); string = (const char *) CALL_GetString( GET_DISPATCH(), (name) ); client = cl->client; if (string == NULL) string = ""; /* ** Restrict extensions to those that are supported by both the ** implementation and the connection. That is, return the ** intersection of client, server, and core extension strings. */ if (name == GL_EXTENSIONS) { buf1 = __glXcombine_strings(string, cl->GLClientextensions); buf = __glXcombine_strings(buf1, cx->pGlxScreen->GLextensions); free(buf1); string = buf; } else if ( name == GL_VERSION ) { if ( atof( string ) > atof( GLServerVersion ) ) { buf = malloc( strlen( string ) + strlen( GLServerVersion ) + 4 ); if ( buf == NULL ) { string = GLServerVersion; } else { sprintf( buf, "%s (%s)", GLServerVersion, string ); string = buf; } } } if (string) { length = strlen((const char *) string) + 1; } __GLX_BEGIN_REPLY(length); __GLX_PUT_SIZE(length); if ( need_swap ) { __GLX_SWAP_REPLY_SIZE(); __GLX_SWAP_REPLY_HEADER(); } __GLX_SEND_HEADER(); WriteToClient(client, length, (char *) string); free(buf); return Success; }
static int ephyrGLXMakeCurrentReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap) { int res = BadImplementation; xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc; xGLXMakeCurrentReply reply; DrawablePtr drawable = NULL; GLXContextTag contextTag = 0; int rc = 0; EPHYR_LOG("enter\n"); rc = dixLookupDrawable(&drawable, req->drawable, a_cl->client, 0, DixReadAccess); EPHYR_RETURN_VAL_IF_FAIL(drawable, BadValue); EPHYR_RETURN_VAL_IF_FAIL(drawable->pScreen, BadValue); EPHYR_LOG("screen nummber requested:%d\n", drawable->pScreen->myNum); if (!ephyrHostGLXMakeCurrent(hostx_get_window(drawable->pScreen->myNum), req->context, req->oldContextTag, (int *) &contextTag)) { EPHYR_LOG_ERROR("ephyrHostGLXMakeCurrent() failed\n"); goto out; } reply = (xGLXMakeCurrentReply) { .type = X_Reply, .sequenceNumber = a_cl->client->sequence, .length = 0, .contextTag = contextTag }; if (a_do_swap) { __GLX_DECLARE_SWAP_VARIABLES; __GLX_SWAP_SHORT(&reply.sequenceNumber); __GLX_SWAP_INT(&reply.length); __GLX_SWAP_INT(&reply.contextTag); } WriteToClient(a_cl->client, sz_xGLXMakeCurrentReply, &reply); res = Success; out: EPHYR_LOG("leave\n"); return res; } int ephyrGLXMakeCurrent(__GLXclientState * a_cl, GLbyte * a_pc) { return ephyrGLXMakeCurrentReal(a_cl, a_pc, FALSE); } int ephyrGLXMakeCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc) { return ephyrGLXMakeCurrentReal(a_cl, a_pc, TRUE); } static int ephyrGLXGetStringReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap) { ClientPtr client = NULL; int context_tag = 0, name = 0, res = BadImplementation, length = 0; char *string = NULL; __GLX_DECLARE_SWAP_VARIABLES; EPHYR_RETURN_VAL_IF_FAIL(a_cl && a_pc, BadValue); EPHYR_LOG("enter\n"); client = a_cl->client; if (a_do_swap) { __GLX_SWAP_INT(a_pc + 4); __GLX_SWAP_INT(a_pc + __GLX_SINGLE_HDR_SIZE); } context_tag = __GLX_GET_SINGLE_CONTEXT_TAG(a_pc); a_pc += __GLX_SINGLE_HDR_SIZE; name = *(GLenum *) (a_pc + 0); EPHYR_LOG("context_tag:%d, name:%d\n", context_tag, name); if (!ephyrHostGLXGetStringFromServer(context_tag, name, EPHYR_HOST_GLX_GetString, &string)) { EPHYR_LOG_ERROR("failed to get string from server\n"); goto out; } if (string) { length = strlen(string) + 1; EPHYR_LOG("got string:'%s', size:%d\n", string, length); } else { EPHYR_LOG("got string: string (null)\n"); } __GLX_BEGIN_REPLY(length); __GLX_PUT_SIZE(length); __GLX_SEND_HEADER(); if (a_do_swap) { __GLX_SWAP_REPLY_SIZE(); __GLX_SWAP_REPLY_HEADER(); } WriteToClient(client, length, string); res = Success; out: EPHYR_LOG("leave\n"); return res; }