summaryrefslogtreecommitdiff
path: root/es_1_1/80ext.c
blob: 64c6f2121cd08446f5af1c4c5de4443cbab58c07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
/* 
 * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
 * 
 * Contact:
 * DongKyun Yun <dk77.yun@samsung.com>
 * SangJin Kim <sangjin3.kim@samsung.com>
 * HyunGoo Kang <hyungoo1.kang@samsung.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do
 * so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 * 
 * Contributors:
 * - S-Core Co., Ltd
 *
 */

#include "gl_imp.h"
#include <GLES/glext.h>
#include <math.h>


#if defined(PROVIDING_ES_2_0) || defined(PROVIDING_OES_blend_func_separate)
/* 2. GL_OES_blend_func_separate */
/* based on GL_EXT_blend_func_separate, core of OpenGL 1.4 */
/* BlendFuncSeparate() in the core of OpenGL ES 2.0 */

void GL_APIENTRY EXTFN(BlendFuncSeparateOES)(GLenum srcRGB, GLenum dstRGB,
        GLenum srcAlpha, GLenum dstAlpha) {
	switch (srcRGB) {
	default:
		INTFN(SetError)(GL_INVALID_ENUM);
		return;
	case GL_ZERO:
	case GL_ONE:
	case GL_SRC_COLOR:
	case GL_ONE_MINUS_SRC_COLOR:
	case GL_DST_COLOR:
	case GL_ONE_MINUS_DST_COLOR:
	case GL_SRC_ALPHA:
	case GL_ONE_MINUS_SRC_ALPHA:
	case GL_DST_ALPHA:
	case GL_ONE_MINUS_DST_ALPHA:
	case GL_SRC_ALPHA_SATURATE:
		break;
	}
	switch (dstRGB) {
	default:
		INTFN(SetError)(GL_INVALID_ENUM);
		return;
	case GL_ZERO:
	case GL_ONE:
	case GL_SRC_COLOR:
	case GL_ONE_MINUS_SRC_COLOR:
	case GL_DST_COLOR:
	case GL_ONE_MINUS_DST_COLOR:
	case GL_SRC_ALPHA:
	case GL_ONE_MINUS_SRC_ALPHA:
	case GL_DST_ALPHA:
	case GL_ONE_MINUS_DST_ALPHA:
		break;
	}
	switch (srcAlpha) {
	default:
		INTFN(SetError)(GL_INVALID_ENUM);
		return;
	case GL_ZERO:
	case GL_ONE:
	case GL_SRC_COLOR:
	case GL_ONE_MINUS_SRC_COLOR:
	case GL_DST_COLOR:
	case GL_ONE_MINUS_DST_COLOR:
	case GL_SRC_ALPHA:
	case GL_ONE_MINUS_SRC_ALPHA:
	case GL_DST_ALPHA:
	case GL_ONE_MINUS_DST_ALPHA:
	case GL_SRC_ALPHA_SATURATE:
		break;
	}
	switch (dstAlpha) {
	default:
		INTFN(SetError)(GL_INVALID_ENUM);
		return;
	case GL_ZERO:
	case GL_ONE:
	case GL_SRC_COLOR:
	case GL_ONE_MINUS_SRC_COLOR:
	case GL_DST_COLOR:
	case GL_ONE_MINUS_DST_COLOR:
	case GL_SRC_ALPHA:
	case GL_ONE_MINUS_SRC_ALPHA:
	case GL_DST_ALPHA:
	case GL_ONE_MINUS_DST_ALPHA:
		break;
	}
	FNPTR(BlendFuncSeparate)(srcRGB, dstRGB, srcAlpha, dstAlpha);
}

#endif 


#if defined(PROVIDING_ES_2_0) || defined(PROVIDING_OES_blend_subtract)
/* 2. GL_OES_blend_subtract */
/* based on GL_EXT_blend_subtract, core of OpenGL 1.2 */
/* BlendEquation() in the core of OpenGL ES 2.0 */

void GL_APIENTRY EXTFN(BlendEquationOES)(GLenum mode) {
	switch (mode) {
	default:
		INTFN(SetError)(GL_INVALID_ENUM);
		return;
	case GL_FUNC_ADD_OES:
	case GL_FUNC_SUBTRACT_OES:
	case GL_FUNC_REVERSE_SUBTRACT_OES:
		break;
	}
	FNPTR(BlendEquation)(mode);
}

#endif 


#if defined(PROVIDING_OES_byte_coordinates)
void GL_APIENTRY EXTFN(MultiTexCoord4bOES)(GLenum target,
        GLbyte s, GLbyte t, GLbyte r, GLbyte q) {
	FNPTR(MultiTexCoord4f)(target, b2f(s), b2f(t), b2f(r), b2f(q));
}
#endif 

#if defined(PROVIDING_OES_fixed_point)

void GL_APIENTRY EXTFN(AlphaFuncxOES)(GLenum func, GLclampx ref) {
	EXTFN(AlphaFuncx)(func, ref);
}

void GL_APIENTRY EXTFN(ClearColorxOES)(GLclampx red, GLclampx green,
        GLclampx blue, GLclampx alpha) {
	EXTFN(ClearColorx)(red, green, blue, alpha);
}

void GL_APIENTRY EXTFN(ClearDepthxOES)(GLclampx depth) {
	EXTFN(ClearDepthx)(depth);
}

void GL_APIENTRY EXTFN(ClipPlanexOES)(GLenum plane, const GLfixed* equation) {
	EXTFN(ClipPlanex)(plane, equation);
}

void GL_APIENTRY EXTFN(Color4xOES)(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha) {
	EXTFN(Color4x)(red, green, blue, alpha);
}

void GL_APIENTRY EXTFN(DepthRangexOES)(GLclampx zNear, GLclampx zFar) {
	EXTFN(DepthRangex)(zNear, zFar);
}

void GL_APIENTRY EXTFN(FogxOES)(GLenum pname, GLfixed param) {
	EXTFN(Fogx)(pname, param);
}

void GL_APIENTRY EXTFN(FogxvOES)(GLenum pname, const GLfixed* params) {
	EXTFN(Fogxv)(pname, params);
}

void GL_APIENTRY EXTFN(FrustumxOES)(GLfixed left, GLfixed right,
        GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) {
	EXTFN(Frustumx)(left, right,  bottom,  top,  zNear,  zFar);
}

void GL_APIENTRY EXTFN(GetClipPlanexOES)(GLenum pname, GLfixed eqn[4]) {
	EXTFN(GetClipPlanex)(pname, eqn);
}

void GL_APIENTRY EXTFN(GetFixedvOES)(GLenum pname, GLfixed* params) {
	EXTFN(GetFixedv)(pname, params);
}

void GL_APIENTRY EXTFN(GetLightxvOES)(GLenum light, GLenum pname, GLfixed* params) {
	EXTFN(GetLightxv)(light, pname, params);
}

void GL_APIENTRY EXTFN(GetMaterialxvOES)(GLenum face, GLenum pname, GLfixed* params) {
	EXTFN(GetMaterialxv)(face, pname, params);
}

void GL_APIENTRY EXTFN(GetTexEnvxvOES)(GLenum env, GLenum pname, GLfixed* params) {
	EXTFN(GetTexEnvxv)(env, pname, params);
}

void GL_APIENTRY EXTFN(GetTexParameterxvOES)(GLenum target, GLenum pname, GLfixed* params) {
	EXTFN(GetTexParameterxv)(target, pname, params);
}

void GL_APIENTRY EXTFN(LightModelxOES)(GLenum pname, GLfixed param) {
	EXTFN(LightModelx)(pname, param);
}

void GL_APIENTRY EXTFN(LightModelxvOES)(GLenum pname, const GLfixed* params) {
	EXTFN(LightModelxv)(pname, params);
}

void GL_APIENTRY EXTFN(LightxOES)(GLenum light, GLenum pname, GLfixed param) {
	EXTFN(Lightx)(light, pname, param);
}

void GL_APIENTRY EXTFN(LightxvOES)(GLenum light, GLenum pname, const GLfixed* params) {
	EXTFN(Lightxv)(light, pname, params);
}

void GL_APIENTRY EXTFN(LineWidthxOES)(GLfixed width) {
	EXTFN(LineWidthx)(width);
}

void GL_APIENTRY EXTFN(LoadMatrixxOES)(const GLfixed* m) {
	EXTFN(LoadMatrixx)(m);
}

void GL_APIENTRY EXTFN(MaterialxOES)(GLenum face, GLenum pname, GLfixed param) {
	EXTFN(Materialx)(face, pname, param);
}

void GL_APIENTRY EXTFN(MaterialxvOES)(GLenum face, GLenum pname, const GLfixed* params) {
	EXTFN(Materialxv)(face, pname, params);
}

void GL_APIENTRY EXTFN(MultMatrixxOES)(const GLfixed* m) {
	EXTFN(MultMatrixx)(m);
}

void GL_APIENTRY EXTFN(MultiTexCoord4xOES)(GLenum target, GLfixed s, GLfixed t,
        GLfixed r, GLfixed q) {
	EXTFN(MultiTexCoord4x)(target, s, t, r, q);
}

void GL_APIENTRY EXTFN(Normal3xOES)(GLfixed nx, GLfixed ny, GLfixed nz) {
	EXTFN(Normal3x)(nx, ny, nz);
}

void GL_APIENTRY EXTFN(OrthoxOES)(GLfixed left, GLfixed right,
        GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar) {
	EXTFN(Orthox)(left, right, bottom, top, zNear, zFar);
}

void GL_APIENTRY EXTFN(PointParameterxOES)(GLenum pname, GLfixed param) {
	EXTFN(PointParameterx)(pname, param);
}

void GL_APIENTRY EXTFN(PointParameterxvOES)(GLenum pname, const GLfixed* params) {
	EXTFN(PointParameterxv)(pname, params);
}

void GL_APIENTRY EXTFN(PointSizexOES)(GLfixed size) {
	EXTFN(PointSizex)(size);
}

void GL_APIENTRY EXTFN(PolygonOffsetxOES)(GLfixed factor, GLfixed units) {
	EXTFN(PolygonOffsetx)(factor, units);
}

void GL_APIENTRY EXTFN(RotatexOES)(GLfixed angle, GLfixed x, GLfixed y, GLfixed z) {
	EXTFN(Rotatex)(angle, x, y, z);
}

void GL_APIENTRY EXTFN(SampleCoveragexOES)(GLclampx value, GLboolean invert) {
	EXTFN(SampleCoveragex)(value, invert);
}

void GL_APIENTRY EXTFN(ScalexOES)(GLfixed x, GLfixed y, GLfixed z) {
	EXTFN(Scalex)(x, y, z);
}

void GL_APIENTRY EXTFN(TexEnvxOES)(GLenum target, GLenum pname, GLfixed param) {
	EXTFN(TexEnvx)(target, pname, param);
}

void GL_APIENTRY EXTFN(TexEnvxvOES)(GLenum target, GLenum pname, const GLfixed* params) {
	EXTFN(TexEnvxv)(target, pname, params);
}

void GL_APIENTRY EXTFN(TexParameterxOES)(GLenum target, GLenum pname, GLfixed param) {
	EXTFN(TexParameterx)(target, pname, param);
}

void GL_APIENTRY EXTFN(TexParameterxvOES)(GLenum target, GLenum pname, const GLfixed* params) {
	EXTFN(TexParameterxv)(target, pname, params);
}

void GL_APIENTRY EXTFN(TranslatexOES)(GLfixed x, GLfixed y, GLfixed z) {
	EXTFN(Translatex)(x, y, z);
}

#endif

#if defined(PROVIDING_OES_query_matrix)
#if ! defined(PROVIDING_OES_fixed_point)
#error PROVIDING_OES_query_matrix requires PROVIDING_OES_fixed_point
#endif

GLbitfield GL_APIENTRY EXTFN(QueryMatrixxOES)(GLfixed mantissa[16], GLint exponent[16]) {
	GLfloat fMatrix[16];
	GLint eMatrixMode;
	GLbitfield flag = 0x0000;
	int i;
	FNPTR(GetIntegerv)(GL_MATRIX_MODE, &eMatrixMode);
	switch (eMatrixMode) {
	case GL_MODELVIEW:	FNPTR(GetFloatv)(GL_MODELVIEW_MATRIX, fMatrix); break;
	case GL_PROJECTION:	FNPTR(GetFloatv)(GL_PROJECTION_MATRIX, fMatrix); break;
	case GL_TEXTURE:	FNPTR(GetFloatv)(GL_TEXTURE_MATRIX, fMatrix); break;
	default:
		return 0xFFFF; 
	}
	for (i = 0; i < 16; i++) {
		if (finitef(fMatrix[i])) {
			GLfloat man = frexpf(fMatrix[i], &exponent[i]);
			mantissa[i] = f2x(man);
		} else {
			flag |= (0x0001 << i);
		}
	}
	return flag;
}

#endif 


#if defined(PROVIDING_OES_single_precision)

void GL_APIENTRY EXTFN(DepthRangefOES)(GLclampf zNear, GLclampf zFar) {
	EXTFN(DepthRangef)(zNear, zFar);
}

void GL_APIENTRY EXTFN(FrustumfOES)(GLfloat left, GLfloat right,
        GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) {
	EXTFN(Frustumf)(left, right, bottom, top, zNear, zFar);
}

void GL_APIENTRY EXTFN(OrthofOES)(GLfloat left, GLfloat right,
        GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar) {
	EXTFN(Orthof)(left, right, bottom, top, zNear, zFar);
}

void GL_APIENTRY EXTFN(ClipPlanefOES)(GLenum plane, const GLfloat* equation) {
	EXTFN(ClipPlanef)(plane, equation);
}

void GL_APIENTRY EXTFN(GetClipPlanefOES)(GLenum pname, GLfloat eqn[4]) {
	EXTFN(GetClipPlanef)(pname, eqn);
}

void GL_APIENTRY EXTFN(ClearDepthfOES)(GLclampf depth) {
	EXTFN(ClearDepthf)(depth);
}

#endif 


#if defined(PROVIDING_OES_texture_cube_map)
/* 20. GL_OES_texture_cube_map */
/* based on ARB_texture_cube_map and core of OpenGL 1.1 */

void GL_APIENTRY EXTFN(TexGeniOES)(GLenum coord, GLenum pname, GLint param) {
	switch (coord) {
	default:
		INTFN(SetError)(GL_INVALID_ENUM);
		break;
	case GL_TEXTURE_GEN_STR_OES:
		break;
	}
	switch (pname) {
	default:
		INTFN(SetError)(GL_INVALID_ENUM);
		break;
	case GL_TEXTURE_GEN_MODE_OES:
		break;
	}
	switch (param) {
	default:
		INTFN(SetError)(GL_INVALID_ENUM);
		break;
	case GL_NORMAL_MAP_OES:
	case GL_REFLECTION_MAP_OES:
		break;
	}
	FNPTR(TexGeni)(coord, pname, param);
}

void GL_APIENTRY EXTFN(TexGenfOES)(GLenum coord, GLenum pname, GLfloat param) {
	EXTFN(TexGeniOES)(coord, pname, (int)(param));
}

void GL_APIENTRY EXTFN(TexGenxOES)(GLenum coord, GLenum pname, GLfixed param) {
	EXTFN(TexGeniOES)(coord, pname, param);
}

void GL_APIENTRY EXTFN(TexGenivOES)(GLenum coord, GLenum pname, const GLint *params) {
	EXTFN(TexGeniOES)(coord, pname, *params);
}

void GL_APIENTRY EXTFN(TexGenfvOES)(GLenum coord, GLenum pname, const GLfloat *params) {
	EXTFN(TexGeniOES)(coord, pname, (int)(*params));
}

void GL_APIENTRY EXTFN(TexGenxvOES)(GLenum coord, GLenum pname, const GLfixed *params) {
	EXTFN(TexGeniOES)(coord, pname, *params);
}

void GL_APIENTRY EXTFN(GetTexGenivOES)(GLenum coord, GLenum pname, GLint *params) {
	switch (coord) {
	default:
		INTFN(SetError)(GL_INVALID_ENUM);
		break;
	case GL_TEXTURE_GEN_STR_OES:
		break;
	}
	switch (pname) {
	default:
		INTFN(SetError)(GL_INVALID_ENUM);
		break;
	case GL_TEXTURE_GEN_MODE_OES:
		break;
	}
	FNPTR(GetTexGeniv)(coord, pname, params);
}

void GL_APIENTRY EXTFN(GetTexGenxvOES)(GLenum coord, GLenum pname, GLfixed *params) {
	EXTFN(GetTexGenivOES)(coord, pname, params);
}

void GL_APIENTRY EXTFN(GetTexGenfvOES)(GLenum coord, GLenum pname, GLfloat *params) {
	switch (coord) {
	default:
		INTFN(SetError)(GL_INVALID_ENUM);
		break;
	case GL_TEXTURE_GEN_STR_OES:
		break;
	}
	switch (pname) {
	default:
		INTFN(SetError)(GL_INVALID_ENUM);
		break;
	case GL_TEXTURE_GEN_MODE_OES:
		break;
	}
	FNPTR(GetTexGenfv)(coord, pname, params);
}


#endif 


/* ----------------------- */


void GL_APIENTRY EXTFN(CurrentPaletteMatrixOES)(GLuint matrixpaletteindex) {
	return;
}

void GL_APIENTRY EXTFN(LoadPaletteFromModelViewMatrixOES)(void) {
	return;
}

void GL_APIENTRY EXTFN(MatrixIndexPointerOES)(GLint size, GLenum type,
		GLsizei stride, const GLvoid* pointer) {
	return;
}

void GL_APIENTRY EXTFN(WeightPointerOES)(GLint size, GLenum type,
        GLsizei stride, const GLvoid* pointer) {
	return;
}