1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3bf215546Sopenharmony_ci * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4bf215546Sopenharmony_ci *
5bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
6bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
7bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
8bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
10bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
11bf215546Sopenharmony_ci *
12bf215546Sopenharmony_ci * The above copyright notice including the dates of first publication and
13bf215546Sopenharmony_ci * either this permission notice or a reference to
14bf215546Sopenharmony_ci * http://oss.sgi.com/projects/FreeB/
15bf215546Sopenharmony_ci * shall be included in all copies or substantial portions of the Software.
16bf215546Sopenharmony_ci *
17bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20bf215546Sopenharmony_ci * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21bf215546Sopenharmony_ci * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22bf215546Sopenharmony_ci * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23bf215546Sopenharmony_ci * SOFTWARE.
24bf215546Sopenharmony_ci *
25bf215546Sopenharmony_ci * Except as contained in this notice, the name of Silicon Graphics, Inc.
26bf215546Sopenharmony_ci * shall not be used in advertising or otherwise to promote the sale, use or
27bf215546Sopenharmony_ci * other dealings in this Software without prior written authorization from
28bf215546Sopenharmony_ci * Silicon Graphics, Inc.
29bf215546Sopenharmony_ci */
30bf215546Sopenharmony_ci
31bf215546Sopenharmony_ci#include <assert.h>
32bf215546Sopenharmony_ci#include "glxclient.h"
33bf215546Sopenharmony_ci#include "indirect.h"
34bf215546Sopenharmony_ci#include "indirect_vertex_array.h"
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_ci/*****************************************************************************/
37bf215546Sopenharmony_ci
38bf215546Sopenharmony_ci#ifndef GLX_USE_APPLEGL
39bf215546Sopenharmony_cistatic void
40bf215546Sopenharmony_cido_enable_disable(GLenum array, GLboolean val)
41bf215546Sopenharmony_ci{
42bf215546Sopenharmony_ci   struct glx_context *gc = __glXGetCurrentContext();
43bf215546Sopenharmony_ci   __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
44bf215546Sopenharmony_ci   unsigned index = 0;
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_ci   if (array == GL_TEXTURE_COORD_ARRAY) {
47bf215546Sopenharmony_ci      index = __glXGetActiveTextureUnit(state);
48bf215546Sopenharmony_ci   }
49bf215546Sopenharmony_ci
50bf215546Sopenharmony_ci   if (!__glXSetArrayEnable(state, array, index, val)) {
51bf215546Sopenharmony_ci      __glXSetError(gc, GL_INVALID_ENUM);
52bf215546Sopenharmony_ci   }
53bf215546Sopenharmony_ci}
54bf215546Sopenharmony_ci
55bf215546Sopenharmony_civoid
56bf215546Sopenharmony_ci__indirect_glEnableClientState(GLenum array)
57bf215546Sopenharmony_ci{
58bf215546Sopenharmony_ci   do_enable_disable(array, GL_TRUE);
59bf215546Sopenharmony_ci}
60bf215546Sopenharmony_ci
61bf215546Sopenharmony_civoid
62bf215546Sopenharmony_ci__indirect_glDisableClientState(GLenum array)
63bf215546Sopenharmony_ci{
64bf215546Sopenharmony_ci   do_enable_disable(array, GL_FALSE);
65bf215546Sopenharmony_ci}
66bf215546Sopenharmony_ci
67bf215546Sopenharmony_ci/************************************************************************/
68bf215546Sopenharmony_ci
69bf215546Sopenharmony_civoid
70bf215546Sopenharmony_ci__indirect_glPushClientAttrib(GLuint mask)
71bf215546Sopenharmony_ci{
72bf215546Sopenharmony_ci   struct glx_context *gc = __glXGetCurrentContext();
73bf215546Sopenharmony_ci   __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
74bf215546Sopenharmony_ci   __GLXattribute **spp = gc->attributes.stackPointer, *sp;
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_ci   if (spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]) {
77bf215546Sopenharmony_ci      if (!(sp = *spp)) {
78bf215546Sopenharmony_ci         sp = malloc(sizeof(__GLXattribute));
79bf215546Sopenharmony_ci         if (sp == NULL) {
80bf215546Sopenharmony_ci            __glXSetError(gc, GL_OUT_OF_MEMORY);
81bf215546Sopenharmony_ci            return;
82bf215546Sopenharmony_ci         }
83bf215546Sopenharmony_ci         *spp = sp;
84bf215546Sopenharmony_ci      }
85bf215546Sopenharmony_ci      sp->mask = mask;
86bf215546Sopenharmony_ci      gc->attributes.stackPointer = spp + 1;
87bf215546Sopenharmony_ci      if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
88bf215546Sopenharmony_ci         sp->storePack = state->storePack;
89bf215546Sopenharmony_ci         sp->storeUnpack = state->storeUnpack;
90bf215546Sopenharmony_ci      }
91bf215546Sopenharmony_ci      if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
92bf215546Sopenharmony_ci         __glXPushArrayState(state);
93bf215546Sopenharmony_ci      }
94bf215546Sopenharmony_ci   }
95bf215546Sopenharmony_ci   else {
96bf215546Sopenharmony_ci      __glXSetError(gc, GL_STACK_OVERFLOW);
97bf215546Sopenharmony_ci      return;
98bf215546Sopenharmony_ci   }
99bf215546Sopenharmony_ci}
100bf215546Sopenharmony_ci
101bf215546Sopenharmony_civoid
102bf215546Sopenharmony_ci__indirect_glPopClientAttrib(void)
103bf215546Sopenharmony_ci{
104bf215546Sopenharmony_ci   struct glx_context *gc = __glXGetCurrentContext();
105bf215546Sopenharmony_ci   __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
106bf215546Sopenharmony_ci   __GLXattribute **spp = gc->attributes.stackPointer, *sp;
107bf215546Sopenharmony_ci   GLuint mask;
108bf215546Sopenharmony_ci
109bf215546Sopenharmony_ci   if (spp > &gc->attributes.stack[0]) {
110bf215546Sopenharmony_ci      --spp;
111bf215546Sopenharmony_ci      sp = *spp;
112bf215546Sopenharmony_ci      assert(sp != 0);
113bf215546Sopenharmony_ci      mask = sp->mask;
114bf215546Sopenharmony_ci      gc->attributes.stackPointer = spp;
115bf215546Sopenharmony_ci
116bf215546Sopenharmony_ci      if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
117bf215546Sopenharmony_ci         state->storePack = sp->storePack;
118bf215546Sopenharmony_ci         state->storeUnpack = sp->storeUnpack;
119bf215546Sopenharmony_ci      }
120bf215546Sopenharmony_ci      if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
121bf215546Sopenharmony_ci         __glXPopArrayState(state);
122bf215546Sopenharmony_ci      }
123bf215546Sopenharmony_ci
124bf215546Sopenharmony_ci      sp->mask = 0;
125bf215546Sopenharmony_ci   }
126bf215546Sopenharmony_ci   else {
127bf215546Sopenharmony_ci      __glXSetError(gc, GL_STACK_UNDERFLOW);
128bf215546Sopenharmony_ci      return;
129bf215546Sopenharmony_ci   }
130bf215546Sopenharmony_ci}
131bf215546Sopenharmony_ci#endif
132