5 #define VERTEX_ARRAY 0x0001
6 #define COLOR_ARRAY 0x0002
7 #define NORMAL_ARRAY 0x0004
8 #define TEXCOORD_ARRAY 0x0008
11 glopArrayElement(GLContext
*c
, GLParam
*param
)
14 int states
= c
->client_states
;
17 if (states
& COLOR_ARRAY
) {
19 int size
= c
->color_array_size
;
20 i
= idx
* (size
+ c
->color_array_stride
);
21 p
[1].f
= c
->color_array
[i
];
22 p
[2].f
= c
->color_array
[i
+1];
23 p
[3].f
= c
->color_array
[i
+2];
24 p
[4].f
= size
> 3 ? c
->color_array
[i
+3] : 1.0f
;
27 if (states
& NORMAL_ARRAY
) {
28 i
= idx
* (3 + c
->normal_array_stride
);
29 c
->current_normal
.X
= c
->normal_array
[i
];
30 c
->current_normal
.Y
= c
->normal_array
[i
+1];
31 c
->current_normal
.Z
= c
->normal_array
[i
+2];
32 c
->current_normal
.Z
= 0.0f
;
34 if (states
& TEXCOORD_ARRAY
) {
35 int size
= c
->texcoord_array_size
;
36 i
= idx
* (size
+ c
->texcoord_array_stride
);
37 c
->current_tex_coord
.X
= c
->texcoord_array
[i
];
38 c
->current_tex_coord
.Y
= c
->texcoord_array
[i
+1];
39 c
->current_tex_coord
.Z
= size
> 2 ? c
->texcoord_array
[i
+2] : 0.0f
;
40 c
->current_tex_coord
.W
= size
> 3 ? c
->texcoord_array
[i
+3] : 1.0f
;
42 if (states
& VERTEX_ARRAY
) {
44 int size
= c
->vertex_array_size
;
45 i
= idx
* (size
+ c
->vertex_array_stride
);
46 p
[1].f
= c
->vertex_array
[i
];
47 p
[2].f
= c
->vertex_array
[i
+1];
48 p
[3].f
= size
> 2 ? c
->vertex_array
[i
+2] : 0.0f
;
49 p
[4].f
= size
> 3 ? c
->vertex_array
[i
+3] : 1.0f
;
55 glArrayElement(GLint i
)
58 p
[0].op
= OP_ArrayElement
;
65 glopEnableClientState(GLContext
*c
, GLParam
*p
)
67 c
->client_states
|= p
[1].i
;
71 glEnableClientState(GLenum array
)
74 p
[0].op
= OP_EnableClientState
;
78 p
[1].i
= VERTEX_ARRAY
;
81 p
[1].i
= NORMAL_ARRAY
;
86 case GL_TEXTURE_COORD_ARRAY
:
87 p
[1].i
= TEXCOORD_ARRAY
;
97 glopDisableClientState(GLContext
*c
, GLParam
*p
)
99 c
->client_states
&= p
[1].i
;
103 glDisableClientState(GLenum array
)
106 p
[0].op
= OP_DisableClientState
;
109 case GL_VERTEX_ARRAY
:
110 p
[1].i
= ~VERTEX_ARRAY
;
112 case GL_NORMAL_ARRAY
:
113 p
[1].i
= ~NORMAL_ARRAY
;
116 p
[1].i
= ~COLOR_ARRAY
;
118 case GL_TEXTURE_COORD_ARRAY
:
119 p
[1].i
= ~TEXCOORD_ARRAY
;
129 glopVertexPointer(GLContext
*c
, GLParam
*p
)
131 c
->vertex_array_size
= p
[1].i
;
132 c
->vertex_array_stride
= p
[2].i
;
133 c
->vertex_array
= p
[3].p
;
137 glVertexPointer(GLint size
, GLenum type
, GLsizei stride
,
138 const GLvoid
*pointer
)
141 assert(type
== GL_FLOAT
);
142 p
[0].op
= OP_VertexPointer
;
145 p
[3].p
= (void*)pointer
;
150 glopColorPointer(GLContext
*c
, GLParam
*p
)
152 c
->color_array_size
= p
[1].i
;
153 c
->color_array_stride
= p
[2].i
;
154 c
->color_array
= p
[3].p
;
158 glColorPointer(GLint size
, GLenum type
, GLsizei stride
,
159 const GLvoid
*pointer
)
162 assert(type
== GL_FLOAT
);
163 p
[0].op
= OP_ColorPointer
;
166 p
[3].p
= (void*)pointer
;
171 glopNormalPointer(GLContext
*c
, GLParam
*p
)
173 c
->normal_array_stride
= p
[1].i
;
174 c
->normal_array
= p
[2].p
;
178 glNormalPointer(GLenum type
, GLsizei stride
,
179 const GLvoid
*pointer
)
182 assert(type
== GL_FLOAT
);
183 p
[0].op
= OP_NormalPointer
;
185 p
[2].p
= (void*)pointer
;
189 glopTexCoordPointer(GLContext
*c
, GLParam
*p
)
191 c
->texcoord_array_size
= p
[1].i
;
192 c
->texcoord_array_stride
= p
[2].i
;
193 c
->texcoord_array
= p
[3].p
;
197 glTexCoordPointer(GLint size
, GLenum type
, GLsizei stride
,
198 const GLvoid
*pointer
)
201 assert(type
== GL_FLOAT
);
202 p
[0].op
= OP_TexCoordPointer
;
205 p
[3].p
= (void*)pointer
;