DEADSOFTWARE

Remove stupid gles bug hacks
[nanogl.git] / nanoWrap.cpp
1 /*
2 Copyright (C) 2007-2009 Olli Hinkka
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20 /*
21 #include <e32def.h>
22 #include <e32std.h>
23 */
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
29 #include "gl.h"
30 #include "glesinterface.h"
31 #include "nanogl.h"
33 #define GL_TEXTURE0_ARB 0x84C0
34 #define GL_TEXTURE1_ARB 0x84C1
36 struct nanoState
37 {
38 GLboolean alpha_test;
39 GLboolean blend;
40 GLboolean clip_planei;
41 GLboolean color_logic_op;
42 GLboolean color_material;
43 GLboolean cull_face;
44 GLboolean depth_test;
45 GLboolean dither;
46 GLboolean fog;
47 GLboolean light0;
48 GLboolean light1;
49 GLboolean light2;
50 GLboolean light3;
51 GLboolean light4;
52 GLboolean light5;
53 GLboolean light6;
54 GLboolean light7;
55 GLboolean lighting;
56 GLboolean line_smooth;
57 GLboolean matrix_palette_oes;
58 GLboolean multisample;
59 GLboolean normalize;
60 GLboolean point_smooth;
61 GLboolean point_sprite_oes;
62 GLboolean polygon_offset_fill;
63 GLboolean rescale_normal;
64 GLboolean sample_alpha_to_coverage;
65 GLboolean sample_alpha_to_one;
66 GLboolean sample_coverage;
67 GLboolean scissor_test;
68 GLboolean stencil_test;
69 GLboolean depthmask;
70 GLclampf depth_range_near;
71 GLclampf depth_range_far;
72 GLenum depth_func;
73 GLenum cullface;
74 GLenum shademodel;
75 GLenum sfactor;
76 GLenum dfactor;
77 GLenum matrixmode;
78 };
80 static struct nanoState nanoglState;
82 static struct nanoState nanoglInitState =
83 {
84 GL_FALSE,
85 GL_FALSE,
86 GL_FALSE,
87 GL_FALSE,
88 GL_FALSE,
89 GL_FALSE,
90 GL_FALSE,
91 GL_TRUE,
92 GL_FALSE,
93 GL_FALSE,
94 GL_FALSE,
95 GL_FALSE,
96 GL_FALSE,
97 GL_FALSE,
98 GL_FALSE,
99 GL_FALSE,
100 GL_FALSE,
101 GL_FALSE,
102 GL_FALSE,
103 GL_FALSE,
104 GL_TRUE,
105 GL_FALSE,
106 GL_FALSE,
107 GL_FALSE,
108 GL_FALSE,
109 GL_FALSE,
110 GL_FALSE,
111 GL_FALSE,
112 GL_FALSE,
113 GL_FALSE,
114 GL_FALSE,
115 GL_TRUE,
116 0.0f,
117 1.0f,
118 GL_LESS,
119 GL_BACK,
120 GL_SMOOTH,
121 GL_ONE,
122 GL_ZERO,
123 GL_MODELVIEW,
124 };
126 struct booleanstate
128 GLboolean value;
129 GLboolean changed;
130 };
132 struct floatstate
134 GLfloat value;
135 GLboolean changed;
136 };
138 struct uintstate
140 GLuint value;
141 GLboolean changed;
142 };
144 struct ptrstate
146 GLint size;
147 GLenum type;
148 GLsizei stride;
149 GLvoid *ptr;
150 GLboolean changed;
151 GLboolean enabled;
152 };
154 struct nanotmuState
156 struct booleanstate texture_2d;
157 struct floatstate texture_env_mode;
158 struct uintstate boundtexture;
159 struct ptrstate vertex_array;
160 struct ptrstate color_array;
161 struct ptrstate texture_coord_array;
162 struct ptrstate normal_array;
163 };
165 static struct nanotmuState tmuState0;
166 static struct nanotmuState tmuState1;
168 static struct nanotmuState tmuInitState =
170 {GL_FALSE, GL_FALSE},
171 {GL_MODULATE, GL_FALSE},
172 {0x7fffffff, GL_FALSE},
173 {4, GL_FLOAT, 0, NULL, GL_FALSE, GL_FALSE},
174 {4, GL_FLOAT, 0, NULL, GL_FALSE, GL_FALSE},
175 {4, GL_FLOAT, 0, NULL, GL_FALSE, GL_FALSE},
176 {3, GL_FLOAT, 0, NULL, GL_FALSE, GL_FALSE},
177 };
179 static struct nanotmuState *activetmuState = &tmuState0;
181 extern GlESInterface *glEsImpl;
183 static GLenum wrapperPrimitiveMode = GL_QUADS;
184 GLboolean useTexCoordArray = GL_FALSE;
185 static GLenum activetmu = GL_TEXTURE0;
186 static GLenum clientactivetmu = GL_TEXTURE0;
188 #if defined( __MULTITEXTURE_SUPPORT__ )
189 GLboolean useMultiTexCoordArray = GL_FALSE;
190 #endif
192 #if !defined( __WINS__ )
193 //#define __FORCEINLINE __forceinline
194 #define __FORCEINLINE inline
195 #else
196 #define __FORCEINLINE
197 #endif
199 static GLboolean delayedttmuchange = GL_FALSE;
200 static GLenum delayedtmutarget = GL_TEXTURE0;
202 struct VertexAttrib
204 float x;
205 float y;
206 float z;
207 #if !defined( __MULTITEXTURE_SUPPORT__ )
208 float padding;
209 #endif
210 unsigned char red;
211 unsigned char green;
212 unsigned char blue;
213 unsigned char alpha;
215 float s;
216 float t;
217 #if defined( __MULTITEXTURE_SUPPORT__ )
218 float s_multi;
219 float t_multi;
220 #endif
221 };
223 static VertexAttrib vertexattribs[60000];
225 static GLushort indexArray[50000];
227 static GLuint vertexCount = 0;
228 static GLuint indexCount = 0;
229 static GLuint vertexMark = 0;
230 static int indexbase = 0;
232 static VertexAttrib *ptrVertexAttribArray = NULL;
233 static VertexAttrib *ptrVertexAttribArrayMark = NULL;
235 static VertexAttrib currentVertexAttrib;
236 #if defined( __MULTITEXTURE_SUPPORT__ )
237 static VertexAttrib currentVertexAttribInit = {0.0f, 0.0f, 0.0f, 255, 255, 255, 255, 0.0f, 0.0f, 0.0f, 0.0f};
238 #else
239 static VertexAttrib currentVertexAttribInit = {
240 0.0f, 0.0f, 0.0f, 0.0f, 255, 255, 255, 255, 0.0f, 0.0f,
241 };
242 #endif
243 static GLushort *ptrIndexArray = NULL;
245 static GLboolean arraysValid = GL_FALSE;
247 static GLboolean skipnanogl;
249 void InitGLStructs( )
251 ptrVertexAttribArray = vertexattribs;
252 ptrVertexAttribArrayMark = ptrVertexAttribArray;
253 ptrIndexArray = indexArray;
255 memcpy( &nanoglState, &nanoglInitState, sizeof( struct nanoState ) );
256 memcpy( &tmuState0, &tmuInitState, sizeof( struct nanotmuState ) );
257 memcpy( &tmuState1, &tmuInitState, sizeof( struct nanotmuState ) );
258 memcpy( &currentVertexAttrib, &currentVertexAttribInit, sizeof( struct VertexAttrib ) );
260 activetmuState = &tmuState0;
261 wrapperPrimitiveMode = GL_QUADS;
262 useTexCoordArray = GL_FALSE;
263 activetmu = GL_TEXTURE0;
264 clientactivetmu = GL_TEXTURE0;
265 delayedttmuchange = GL_FALSE;
266 delayedtmutarget = GL_TEXTURE0;
267 vertexCount = 0;
268 indexCount = 0;
269 vertexMark = 0;
270 indexbase = 0;
271 arraysValid = GL_FALSE;
274 void ResetNanoState( )
277 if ( tmuState0.color_array.enabled )
279 glEsImpl->glEnableClientState( GL_COLOR_ARRAY );
281 else
283 glEsImpl->glDisableClientState( GL_COLOR_ARRAY );
286 if ( tmuState0.vertex_array.enabled )
288 glEsImpl->glEnableClientState( GL_VERTEX_ARRAY );
290 else
292 glEsImpl->glDisableClientState( GL_VERTEX_ARRAY );
295 if ( tmuState0.texture_coord_array.enabled )
297 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
299 else
301 glEsImpl->glDisableClientState( GL_TEXTURE_COORD_ARRAY );
304 if ( tmuState0.normal_array.enabled )
306 glEsImpl->glEnableClientState( GL_NORMAL_ARRAY );
308 else
310 glEsImpl->glDisableClientState( GL_NORMAL_ARRAY );
312 glEsImpl->glVertexPointer( tmuState0.vertex_array.size,
313 tmuState0.vertex_array.type,
314 tmuState0.vertex_array.stride,
315 tmuState0.vertex_array.ptr );
317 glEsImpl->glTexCoordPointer( tmuState0.texture_coord_array.size,
318 tmuState0.texture_coord_array.type,
319 tmuState0.texture_coord_array.stride,
320 tmuState0.texture_coord_array.ptr );
322 glEsImpl->glColorPointer( tmuState0.color_array.size,
323 tmuState0.color_array.type,
324 tmuState0.color_array.stride,
325 tmuState0.color_array.ptr );
327 glEsImpl->glNormalPointer(
328 tmuState0.normal_array.type,
329 tmuState0.normal_array.stride,
330 tmuState0.normal_array.ptr );
332 glEsImpl->glMatrixMode( nanoglState.matrixmode );
334 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
335 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
337 glEsImpl->glBlendFunc( nanoglState.sfactor, nanoglState.dfactor );
339 //glEsImpl->glBindTexture(GL_TEXTURE_2D, stackTextureState);
341 glEsImpl->glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, activetmuState->texture_env_mode.value );
343 arraysValid = GL_FALSE;
344 skipnanogl = GL_FALSE;
347 void FlushOnStateChange( )
349 if( skipnanogl )
350 return;
351 if ( delayedttmuchange )
353 delayedttmuchange = GL_FALSE;
354 #ifndef USE_CORE_PROFILE
355 glEsImpl->glActiveTexture( delayedtmutarget );
356 #endif
359 if ( !vertexCount )
360 return;
362 if ( !arraysValid )
364 glEsImpl->glClientActiveTexture( GL_TEXTURE0 );
365 glEsImpl->glVertexPointer( 3, GL_FLOAT, sizeof( VertexAttrib ), &vertexattribs[0].x );
366 glEsImpl->glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof( VertexAttrib ), &vertexattribs[0].red );
367 glEsImpl->glTexCoordPointer( 2, GL_FLOAT, sizeof( VertexAttrib ), &vertexattribs[0].s );
368 glEsImpl->glEnableClientState( GL_VERTEX_ARRAY );
369 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
370 glEsImpl->glEnableClientState( GL_COLOR_ARRAY );
371 #if defined( __MULTITEXTURE_SUPPORT__ )
372 glEsImpl->glClientActiveTexture( GL_TEXTURE1 );
373 glEsImpl->glTexCoordPointer( 2, GL_FLOAT, sizeof( VertexAttrib ), &vertexattribs[0].s_multi );
374 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
375 glEsImpl->glClientActiveTexture( GL_TEXTURE0 );
376 #endif
377 arraysValid = GL_TRUE;
380 glEsImpl->glDrawElements( GL_TRIANGLES, vertexCount, GL_UNSIGNED_SHORT, indexArray );
382 #if defined( __MULTITEXTURE_SUPPORT__ )
383 useMultiTexCoordArray = GL_FALSE;
384 #endif
385 vertexCount = 0;
386 indexCount = 0;
387 ptrVertexAttribArray = vertexattribs;
388 ptrVertexAttribArrayMark = ptrVertexAttribArray;
389 ptrIndexArray = indexArray;
390 useTexCoordArray = GL_FALSE;
392 void nanoGL_Flush( )
394 FlushOnStateChange( );
396 void nanoGL_Reset( )
398 ResetNanoState( );
400 void glBegin( GLenum mode )
402 wrapperPrimitiveMode = mode;
403 vertexMark = vertexCount;
404 ptrVertexAttribArrayMark = ptrVertexAttribArray;
405 indexbase = indexCount;
408 void glEnd( void )
410 vertexCount += ( (unsigned char *)ptrVertexAttribArray - (unsigned char *)ptrVertexAttribArrayMark ) / sizeof( VertexAttrib );
411 if ( vertexCount < 3 )
413 return;
415 switch ( wrapperPrimitiveMode )
417 case GL_QUADS:
419 *ptrIndexArray++ = indexCount;
420 *ptrIndexArray++ = indexCount + 1;
421 *ptrIndexArray++ = indexCount + 2;
422 *ptrIndexArray++ = indexCount;
423 *ptrIndexArray++ = indexCount + 2;
424 *ptrIndexArray++ = indexCount + 3;
425 indexCount += 4;
426 vertexCount += 2;
428 break;
429 case GL_TRIANGLES:
431 int vcount = ( vertexCount - vertexMark ) / 3;
432 for ( int count = 0; count < vcount; count++ )
434 *ptrIndexArray++ = indexCount;
435 *ptrIndexArray++ = indexCount + 1;
436 *ptrIndexArray++ = indexCount + 2;
437 indexCount += 3;
440 break;
441 case GL_TRIANGLE_STRIP:
443 *ptrIndexArray++ = indexCount;
444 *ptrIndexArray++ = indexCount + 1;
445 *ptrIndexArray++ = indexCount + 2;
446 indexCount += 3;
447 int vcount = ( ( vertexCount - vertexMark ) - 3 );
448 if ( vcount && ( (long)ptrIndexArray & 0x02 ) )
450 *ptrIndexArray++ = indexCount - 1; // 2
451 *ptrIndexArray++ = indexCount - 2; // 1
452 *ptrIndexArray++ = indexCount; // 3
453 indexCount++;
454 vcount -= 1;
455 int odd = vcount & 1;
456 vcount /= 2;
457 unsigned int *longptr = (unsigned int *)ptrIndexArray;
459 for ( int count = 0; count < vcount; count++ )
461 *( longptr++ ) = ( indexCount - 2 ) | ( ( indexCount - 1 ) << 16 );
462 *( longptr++ ) = ( indexCount ) | ( ( indexCount ) << 16 );
463 *( longptr++ ) = ( indexCount - 1 ) | ( ( indexCount + 1 ) << 16 );
464 indexCount += 2;
466 ptrIndexArray = (unsigned short *)( longptr );
467 if ( odd )
469 *ptrIndexArray++ = indexCount - 2; // 2
470 *ptrIndexArray++ = indexCount - 1; // 1
471 *ptrIndexArray++ = indexCount; // 3
472 indexCount++;
475 else
477 //already aligned
478 int odd = vcount & 1;
479 vcount /= 2;
480 unsigned int *longptr = (unsigned int *)ptrIndexArray;
482 for ( int count = 0; count < vcount; count++ )
484 *( longptr++ ) = ( indexCount - 1 ) | ( ( indexCount - 2 ) << 16 );
485 *( longptr++ ) = ( indexCount ) | ( ( indexCount - 1 ) << 16 );
486 *( longptr++ ) = ( indexCount ) | ( ( indexCount + 1 ) << 16 );
487 indexCount += 2;
489 ptrIndexArray = (unsigned short *)( longptr );
490 if ( odd )
493 *ptrIndexArray++ = indexCount - 1; // 2
494 *ptrIndexArray++ = indexCount - 2; // 1
495 *ptrIndexArray++ = indexCount; // 3
496 indexCount++;
499 vertexCount += ( vertexCount - vertexMark - 3 ) * 2;
501 break;
502 case GL_POLYGON:
503 case GL_TRIANGLE_FAN:
505 *ptrIndexArray++ = indexCount++;
506 *ptrIndexArray++ = indexCount++;
507 *ptrIndexArray++ = indexCount++;
508 int vcount = ( ( vertexCount - vertexMark ) - 3 );
509 for ( int count = 0; count < vcount; count++ )
511 *ptrIndexArray++ = indexbase;
512 *ptrIndexArray++ = indexCount - 1;
513 *ptrIndexArray++ = indexCount++;
514 vertexCount += 2;
517 break;
519 default:
520 break;
522 if ( ptrVertexAttribArray - vertexattribs > 20000 * sizeof( VertexAttrib ) ||
523 ptrIndexArray - indexArray > 15000 * sizeof( GLushort ) )
524 FlushOnStateChange( );
527 void glEnable( GLenum cap )
529 if( skipnanogl )
531 glEsImpl->glEnable( cap );
532 return;
534 GLboolean statechanged = GL_FALSE;
535 switch ( cap )
537 case GL_ALPHA_TEST:
539 if ( !nanoglState.alpha_test )
541 nanoglState.alpha_test = GL_TRUE;
542 statechanged = GL_TRUE;
544 break;
546 case GL_BLEND:
548 if ( !nanoglState.blend )
550 nanoglState.blend = GL_TRUE;
551 statechanged = GL_TRUE;
553 break;
555 //case GL_CLIP_PLANEi
556 case GL_COLOR_LOGIC_OP:
558 if ( !nanoglState.color_logic_op )
560 nanoglState.color_logic_op = GL_TRUE;
561 statechanged = GL_TRUE;
563 break;
565 case GL_COLOR_MATERIAL:
567 if ( !nanoglState.color_material )
569 nanoglState.color_material = GL_TRUE;
570 statechanged = GL_TRUE;
572 break;
574 case GL_CULL_FACE:
576 if ( !nanoglState.cull_face )
578 nanoglState.cull_face = GL_TRUE;
579 statechanged = GL_TRUE;
581 break;
583 case GL_DEPTH_TEST:
585 if ( !nanoglState.depth_test )
587 nanoglState.depth_test = GL_TRUE;
588 statechanged = GL_TRUE;
590 break;
592 case GL_DITHER:
594 if ( !nanoglState.dither )
596 nanoglState.dither = GL_TRUE;
597 statechanged = GL_TRUE;
599 break;
601 case GL_FOG:
603 if ( !nanoglState.fog )
605 nanoglState.fog = GL_TRUE;
606 statechanged = GL_TRUE;
608 break;
610 case GL_LIGHT0:
612 if ( !nanoglState.light0 )
614 nanoglState.light0 = GL_TRUE;
615 statechanged = GL_TRUE;
617 break;
619 case GL_LIGHT1:
621 if ( !nanoglState.light1 )
623 nanoglState.light1 = GL_TRUE;
624 statechanged = GL_TRUE;
626 break;
628 case GL_LIGHT2:
630 if ( !nanoglState.light2 )
632 nanoglState.light2 = GL_TRUE;
633 statechanged = GL_TRUE;
635 break;
637 case GL_LIGHT3:
639 if ( !nanoglState.light3 )
641 nanoglState.light3 = GL_TRUE;
642 statechanged = GL_TRUE;
644 break;
646 case GL_LIGHT4:
648 if ( !nanoglState.light4 )
650 nanoglState.light4 = GL_TRUE;
651 statechanged = GL_TRUE;
653 break;
655 case GL_LIGHT5:
657 if ( !nanoglState.light5 )
659 nanoglState.light5 = GL_TRUE;
660 statechanged = GL_TRUE;
662 break;
664 case GL_LIGHT6:
666 if ( !nanoglState.light6 )
668 nanoglState.light6 = GL_TRUE;
669 statechanged = GL_TRUE;
671 break;
673 case GL_LIGHT7:
675 if ( !nanoglState.light7 )
677 nanoglState.light7 = GL_TRUE;
678 statechanged = GL_TRUE;
680 break;
682 case GL_LIGHTING:
684 if ( !nanoglState.lighting )
686 nanoglState.lighting = GL_TRUE;
687 statechanged = GL_TRUE;
689 break;
691 case GL_LINE_SMOOTH:
693 if ( !nanoglState.line_smooth )
695 nanoglState.line_smooth = GL_TRUE;
696 statechanged = GL_TRUE;
698 break;
700 /* case GL_MATRIX_PALETTE_OES:
702 if (!nanoglState.matrix_palette_oes)
704 nanoglState.matrix_palette_oes = GL_TRUE;
705 statechanged = GL_TRUE;
707 break;
708 }*/
709 case GL_MULTISAMPLE:
711 if ( !nanoglState.multisample )
713 nanoglState.multisample = GL_TRUE;
714 statechanged = GL_TRUE;
716 break;
718 case GL_NORMALIZE:
720 if ( !nanoglState.normalize )
722 nanoglState.normalize = GL_TRUE;
723 statechanged = GL_TRUE;
725 break;
727 /* case GL_POINT_SPRITE_OES:
729 if (!nanoglState.point_sprite_oes)
731 nanoglState.point_sprite_oes = GL_TRUE;
732 statechanged = GL_TRUE;
734 break;
735 }*/
736 case GL_POLYGON_OFFSET_FILL:
738 if ( !nanoglState.polygon_offset_fill )
740 nanoglState.polygon_offset_fill = GL_TRUE;
741 statechanged = GL_TRUE;
743 break;
745 case GL_RESCALE_NORMAL:
747 if ( !nanoglState.rescale_normal )
749 nanoglState.rescale_normal = GL_TRUE;
750 statechanged = GL_TRUE;
752 break;
754 case GL_SAMPLE_ALPHA_TO_COVERAGE:
756 if ( !nanoglState.sample_alpha_to_coverage )
758 nanoglState.sample_alpha_to_coverage = GL_TRUE;
759 statechanged = GL_TRUE;
761 break;
763 case GL_SAMPLE_ALPHA_TO_ONE:
765 if ( !nanoglState.sample_alpha_to_one )
767 nanoglState.sample_alpha_to_one = GL_TRUE;
768 statechanged = GL_TRUE;
770 break;
772 case GL_SAMPLE_COVERAGE:
774 if ( !nanoglState.sample_coverage )
776 nanoglState.sample_coverage = GL_TRUE;
777 statechanged = GL_TRUE;
779 break;
781 case GL_SCISSOR_TEST:
783 if ( !nanoglState.scissor_test )
785 nanoglState.scissor_test = GL_TRUE;
786 statechanged = GL_TRUE;
788 break;
790 case GL_STENCIL_TEST:
792 return;
793 if (!nanoglState.stencil_test)
795 nanoglState.stencil_test = GL_TRUE;
796 statechanged = GL_TRUE;
798 break;
800 case GL_TEXTURE_2D:
802 if ( !activetmuState->texture_2d.value )
804 FlushOnStateChange( );
805 glEsImpl->glEnable( cap );
806 activetmuState->texture_2d.value = GL_TRUE;
807 return;
809 break;
811 #if 0 // todo: implement cubemap texgen
812 case GL_TEXTURE_GEN_S:
813 case GL_TEXTURE_GEN_T:
814 case GL_TEXTURE_GEN_R:
815 case GL_TEXTURE_GEN_Q:
817 FlushOnStateChange( );
818 nanoglState.texgen = true;
819 return;
821 #endif
822 default:
823 break;
826 if ( statechanged )
828 FlushOnStateChange( );
829 glEsImpl->glEnable( cap );
833 void glDisable( GLenum cap )
835 if( skipnanogl )
837 glEsImpl->glDisable( cap );
838 return;
840 GLboolean statechanged = GL_FALSE;
841 switch ( cap )
843 case GL_ALPHA_TEST:
845 if ( nanoglState.alpha_test )
847 nanoglState.alpha_test = GL_FALSE;
848 statechanged = GL_TRUE;
850 break;
852 case GL_BLEND:
854 if ( nanoglState.blend )
856 nanoglState.blend = GL_FALSE;
857 statechanged = GL_TRUE;
859 break;
861 //case GL_CLIP_PLANEi
862 case GL_COLOR_LOGIC_OP:
864 if ( nanoglState.color_logic_op )
866 nanoglState.color_logic_op = GL_FALSE;
867 statechanged = GL_TRUE;
869 break;
871 case GL_COLOR_MATERIAL:
873 if ( nanoglState.color_material )
875 nanoglState.color_material = GL_FALSE;
876 statechanged = GL_TRUE;
878 break;
880 case GL_CULL_FACE:
882 if ( nanoglState.cull_face )
884 nanoglState.cull_face = GL_FALSE;
885 statechanged = GL_TRUE;
887 break;
889 case GL_DEPTH_TEST:
891 if ( nanoglState.depth_test )
893 nanoglState.depth_test = GL_FALSE;
894 statechanged = GL_TRUE;
896 break;
898 case GL_DITHER:
900 if ( nanoglState.dither )
902 nanoglState.dither = GL_FALSE;
903 statechanged = GL_TRUE;
905 break;
907 case GL_FOG:
909 if ( nanoglState.fog )
911 nanoglState.fog = GL_FALSE;
912 statechanged = GL_TRUE;
914 break;
916 case GL_LIGHT0:
918 if ( !nanoglState.light0 )
920 nanoglState.light0 = GL_FALSE;
921 statechanged = GL_TRUE;
923 break;
925 case GL_LIGHT1:
927 if ( !nanoglState.light1 )
929 nanoglState.light1 = GL_FALSE;
930 statechanged = GL_TRUE;
932 break;
934 case GL_LIGHT2:
936 if ( !nanoglState.light2 )
938 nanoglState.light2 = GL_FALSE;
939 statechanged = GL_TRUE;
941 break;
943 case GL_LIGHT3:
945 if ( !nanoglState.light3 )
947 nanoglState.light3 = GL_FALSE;
948 statechanged = GL_TRUE;
950 break;
952 case GL_LIGHT4:
954 if ( !nanoglState.light4 )
956 nanoglState.light4 = GL_FALSE;
957 statechanged = GL_TRUE;
959 break;
961 case GL_LIGHT5:
963 if ( !nanoglState.light5 )
965 nanoglState.light5 = GL_FALSE;
966 statechanged = GL_TRUE;
968 break;
970 case GL_LIGHT6:
972 if ( !nanoglState.light6 )
974 nanoglState.light6 = GL_FALSE;
975 statechanged = GL_TRUE;
977 break;
979 case GL_LIGHT7:
981 if ( !nanoglState.light7 )
983 nanoglState.light7 = GL_FALSE;
984 statechanged = GL_TRUE;
986 break;
988 case GL_LIGHTING:
990 if ( nanoglState.lighting )
992 nanoglState.lighting = GL_FALSE;
993 statechanged = GL_TRUE;
995 break;
997 case GL_LINE_SMOOTH:
999 if ( nanoglState.line_smooth )
1001 nanoglState.line_smooth = GL_FALSE;
1002 statechanged = GL_TRUE;
1004 break;
1006 /* case GL_MATRIX_PALETTE_OES:
1008 if (nanoglState.matrix_palette_oes)
1010 nanoglState.matrix_palette_oes = GL_FALSE;
1011 statechanged = GL_TRUE;
1013 break;
1014 }*/
1015 case GL_MULTISAMPLE:
1017 if ( nanoglState.multisample )
1019 nanoglState.multisample = GL_FALSE;
1020 statechanged = GL_TRUE;
1022 break;
1024 case GL_NORMALIZE:
1026 if ( nanoglState.normalize )
1028 nanoglState.normalize = GL_FALSE;
1029 statechanged = GL_TRUE;
1031 break;
1033 /* case GL_POINT_SPRITE_OES:
1035 if (nanoglState.point_sprite_oes)
1037 nanoglState.point_sprite_oes = GL_FALSE;
1038 statechanged = GL_TRUE;
1040 break;
1041 }*/
1042 case GL_POLYGON_OFFSET_FILL:
1044 if ( nanoglState.polygon_offset_fill )
1046 nanoglState.polygon_offset_fill = GL_FALSE;
1047 statechanged = GL_TRUE;
1049 break;
1051 case GL_RESCALE_NORMAL:
1053 if ( nanoglState.rescale_normal )
1055 nanoglState.rescale_normal = GL_FALSE;
1056 statechanged = GL_TRUE;
1058 break;
1060 case GL_SAMPLE_ALPHA_TO_COVERAGE:
1062 if ( nanoglState.sample_alpha_to_coverage )
1064 nanoglState.sample_alpha_to_coverage = GL_FALSE;
1065 statechanged = GL_TRUE;
1067 break;
1069 case GL_SAMPLE_ALPHA_TO_ONE:
1071 if ( nanoglState.sample_alpha_to_one )
1073 nanoglState.sample_alpha_to_one = GL_FALSE;
1074 statechanged = GL_TRUE;
1076 break;
1078 case GL_SAMPLE_COVERAGE:
1080 if ( nanoglState.sample_coverage )
1082 nanoglState.sample_coverage = GL_FALSE;
1083 statechanged = GL_TRUE;
1085 break;
1087 case GL_SCISSOR_TEST:
1089 if ( nanoglState.scissor_test )
1091 nanoglState.scissor_test = GL_FALSE;
1092 statechanged = GL_TRUE;
1094 break;
1096 case GL_STENCIL_TEST:
1098 return;
1099 if (nanoglState.stencil_test)
1101 nanoglState.stencil_test = GL_FALSE;
1102 statechanged = GL_TRUE;
1104 break;
1106 case GL_TEXTURE_2D:
1108 if ( activetmuState->texture_2d.value )
1110 FlushOnStateChange( );
1111 glEsImpl->glDisable( cap );
1112 activetmuState->texture_2d.value = GL_FALSE;
1113 return;
1115 break;
1117 #if 0
1118 case GL_TEXTURE_GEN_S:
1119 case GL_TEXTURE_GEN_T:
1120 case GL_TEXTURE_GEN_R:
1121 case GL_TEXTURE_GEN_Q:
1123 FlushOnStateChange( );
1124 nanoglState.texgen = false;
1125 return;
1127 #endif
1128 default:
1129 break;
1132 if ( statechanged )
1134 FlushOnStateChange( );
1135 glEsImpl->glDisable( cap );
1139 void glVertex2f( GLfloat x, GLfloat y )
1141 glVertex3f( x, y, 0.0f );
1144 __FORCEINLINE unsigned int ClampTo255( float value )
1146 unsigned int retval = (unsigned int)( value );
1147 if ( retval > 255 )
1149 retval = 255;
1151 return retval;
1154 void glColor3f( GLfloat red, GLfloat green, GLfloat blue )
1156 currentVertexAttrib.red = (unsigned char)ClampTo255( red * 255.0f );
1157 currentVertexAttrib.green = (unsigned char)ClampTo255( green * 255.0f );
1158 currentVertexAttrib.blue = (unsigned char)ClampTo255( blue * 255.0f );
1159 currentVertexAttrib.alpha = 255;
1162 void glTexCoord2fv( const GLfloat *v )
1164 memcpy( &currentVertexAttrib.s, v, 2 * sizeof( float ) );
1167 void glTexCoord2f( GLfloat s, GLfloat t )
1169 currentVertexAttrib.s = s;
1170 currentVertexAttrib.t = t;
1173 void glViewport( GLint x, GLint y, GLsizei width, GLsizei height )
1175 FlushOnStateChange( );
1176 glEsImpl->glViewport( x, y, width, height );
1179 void glLoadIdentity( void )
1181 FlushOnStateChange( );
1182 glEsImpl->glLoadIdentity( );
1185 void glColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
1187 currentVertexAttrib.red = (unsigned char)ClampTo255( red * 255.0f );
1188 currentVertexAttrib.green = (unsigned char)ClampTo255( green * 255.0f );
1189 currentVertexAttrib.blue = (unsigned char)ClampTo255( blue * 255.0f );
1190 currentVertexAttrib.alpha = (unsigned char)ClampTo255( alpha * 255.0f );
1193 void glOrtho( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar )
1195 FlushOnStateChange( );
1196 #ifdef USE_CORE_PROFILE
1197 glEsImpl->glOrtho( left, right, bottom, top, zNear, zFar );
1198 #else
1199 glEsImpl->glOrthof( left, right, bottom, top, zNear, zFar );
1200 #endif
1203 // Rikku2000: Light
1204 void glLightf( GLenum light, GLenum pname, GLfloat param )
1206 FlushOnStateChange( );
1208 glEsImpl->glLightf( light, pname, param );
1210 void glLightfv( GLenum light, GLenum pname, const GLfloat *params )
1212 FlushOnStateChange( );
1214 glEsImpl->glLightfv( light, pname, params );
1216 void glLightModelf( GLenum pname, GLfloat param )
1218 FlushOnStateChange( );
1220 glEsImpl->glLightModelf( pname, param );
1222 void glLightModelfv( GLenum pname, const GLfloat *params )
1224 FlushOnStateChange( );
1226 glEsImpl->glLightModelfv( pname, params );
1228 void glMaterialf( GLenum face, GLenum pname, GLfloat param )
1230 FlushOnStateChange( );
1232 glEsImpl->glMaterialf( face, pname, param );
1234 void glMaterialfv( GLenum face, GLenum pname, const GLfloat *params )
1236 FlushOnStateChange( );
1238 glEsImpl->glMaterialfv( face, pname, params );
1240 void glColorMaterial( GLenum face, GLenum mode )
1242 FlushOnStateChange( );
1244 glEsImpl->glColorMaterial( face, mode );
1247 void glMatrixMode( GLenum mode )
1249 if ( nanoglState.matrixmode == mode )
1251 return;
1253 nanoglState.matrixmode = mode;
1254 FlushOnStateChange( );
1255 glEsImpl->glMatrixMode( mode );
1258 void glTexParameterf( GLenum target, GLenum pname, GLfloat param )
1260 if ( pname == GL_TEXTURE_BORDER_COLOR )
1262 return; // not supported by opengl es
1264 if ( ( pname == GL_TEXTURE_WRAP_S ||
1265 pname == GL_TEXTURE_WRAP_T ) &&
1266 param == GL_CLAMP )
1268 param = 0x812F;
1271 FlushOnStateChange( );
1272 glEsImpl->glTexParameterf( target, pname, param );
1275 void glTexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
1277 glTexParameterf( target, pname, params[0] );
1280 void glTexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
1282 unsigned char *data = (unsigned char*)pixels;
1284 if( internalformat == GL_RGB && format == GL_RGBA ) // strip alpha from texture
1286 unsigned char *in = data, *out;
1287 int i = 0, size = width * height * 4;
1289 data = out = (unsigned char*)malloc( size );
1291 for( i = 0; i < size; i += 4, in += 4, out += 4 )
1293 memcpy( out, in, 3 );
1294 out[3] = 255;
1298 internalformat = format;
1299 glEsImpl->glTexImage2D( target, level, internalformat, width, height, border, format, type, data );
1301 if( data != pixels )
1302 free(data);
1305 void glDrawBuffer( GLenum /*mode*/ )
1309 void glTranslatef( GLfloat x, GLfloat y, GLfloat z )
1311 FlushOnStateChange( );
1312 glEsImpl->glTranslatef( x, y, z );
1315 void glRotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
1317 FlushOnStateChange( );
1318 glEsImpl->glRotatef( angle, x, y, z );
1321 void glScalef( GLfloat x, GLfloat y, GLfloat z )
1323 FlushOnStateChange( );
1324 glEsImpl->glScalef( x, y, z );
1327 void glDepthRange( GLclampf zNear, GLclampf zFar )
1329 if ( ( nanoglState.depth_range_near == zNear ) && ( nanoglState.depth_range_far == zFar ) )
1331 return;
1333 else
1335 nanoglState.depth_range_near = zNear;
1336 nanoglState.depth_range_far = zFar;
1338 FlushOnStateChange( );
1339 #ifdef USE_CORE_PROFILE
1340 glEsImpl->glDepthRange( zNear, zFar );
1341 #else
1342 glEsImpl->glDepthRangef( zNear, zFar );
1343 #endif
1346 void glDepthFunc( GLenum func )
1348 if ( nanoglState.depth_func == func )
1350 return;
1352 else
1354 nanoglState.depth_func = func;
1356 FlushOnStateChange( );
1357 glEsImpl->glDepthFunc( func );
1360 void glFinish( void )
1362 FlushOnStateChange( );
1363 glEsImpl->glFinish( );
1366 void glGetFloatv( GLenum pname, GLfloat *params )
1368 FlushOnStateChange( );
1369 glEsImpl->glGetFloatv( pname, params );
1372 void glCullFace( GLenum mode )
1374 if ( nanoglState.cullface == mode )
1376 return;
1378 else
1380 nanoglState.cullface = mode;
1382 FlushOnStateChange( );
1383 glEsImpl->glCullFace( mode );
1386 void glFrustum( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar )
1388 FlushOnStateChange( );
1389 glEsImpl->glFrustumf( left, right, bottom, top, zNear, zFar );
1392 void glClear( GLbitfield mask )
1394 FlushOnStateChange( );
1395 glEsImpl->glClear( mask );
1398 void glVertex3f( GLfloat x, GLfloat y, GLfloat z )
1400 GLfloat *vert = (GLfloat *)ptrVertexAttribArray++;
1401 *vert++ = x;
1402 *vert++ = y;
1403 *vert++ = z;
1404 #if defined( __MULTITEXTURE_SUPPORT__ )
1405 memcpy( vert, &currentVertexAttrib.red, 5 * sizeof( GLfloat ) );
1406 #else
1407 memcpy( vert + 1, &currentVertexAttrib.red, 3 * sizeof( GLfloat ) );
1408 #endif
1411 void glColor4fv( const GLfloat *v )
1413 currentVertexAttrib.red = (unsigned char)ClampTo255( v[0] * 255.0f );
1414 currentVertexAttrib.green = (unsigned char)ClampTo255( v[1] * 255.0f );
1415 currentVertexAttrib.blue = (unsigned char)ClampTo255( v[2] * 255.0f );
1416 currentVertexAttrib.alpha = (unsigned char)ClampTo255( v[3] * 255.0f );
1417 if( skipnanogl )
1418 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
1419 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
1422 void glColor3ubv( const GLubyte *v )
1424 currentVertexAttrib.red = v[0];
1425 currentVertexAttrib.green = v[1];
1426 currentVertexAttrib.blue = v[2];
1427 currentVertexAttrib.alpha = 255;
1428 if( skipnanogl )
1429 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
1430 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
1433 void glColor4ubv( const GLubyte *v )
1435 //*((unsigned int*)(&currentVertexAttrib.red)) = *((unsigned int*)(v));
1436 currentVertexAttrib.red = v[0];
1437 currentVertexAttrib.green = v[1];
1438 currentVertexAttrib.blue = v[2];
1439 currentVertexAttrib.alpha = v[3];
1440 if( skipnanogl )
1441 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
1442 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
1445 void glColor3fv( const GLfloat *v )
1447 currentVertexAttrib.red = (unsigned char)ClampTo255( v[0] * 255.0f );
1448 currentVertexAttrib.green = (unsigned char)ClampTo255( v[1] * 255.0f );
1449 currentVertexAttrib.blue = (unsigned char)ClampTo255( v[2] * 255.0f );
1450 currentVertexAttrib.alpha = 255;
1451 if( skipnanogl )
1452 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
1453 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
1456 //-- nicknekit: xash3d funcs --
1458 void glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha )
1460 currentVertexAttrib.red = red;
1461 currentVertexAttrib.green = green;
1462 currentVertexAttrib.blue = blue;
1463 currentVertexAttrib.alpha = alpha;
1464 if( skipnanogl )
1465 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
1466 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
1469 void glColor3ub( GLubyte red, GLubyte green, GLubyte blue )
1471 currentVertexAttrib.red = red;
1472 currentVertexAttrib.green = green;
1473 currentVertexAttrib.blue = blue;
1474 currentVertexAttrib.alpha = 255;
1475 if( skipnanogl )
1476 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
1477 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
1480 void glNormal3fv( const GLfloat *v )
1482 FlushOnStateChange( );
1483 glEsImpl->glNormal3f( v[0], v[1], v[2] );
1486 void glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border )
1488 FlushOnStateChange( );
1489 glEsImpl->glCopyTexImage2D( target, level, internalformat, x, y, width, height, border );
1492 void glTexImage1D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
1494 glTexImage2D( GL_TEXTURE_2D, level, internalformat, width, 1, border, format, type, pixels );
1497 void glTexImage3D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
1499 glTexImage2D( GL_TEXTURE_2D, level, internalformat, width, height, border, format, type, pixels );
1502 void glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels )
1504 glTexSubImage2D( target, level, xoffset, 0, width, 1, format, type, pixels );
1507 void glTexSubImage3D( GLenum target, GLint level,
1508 GLint xoffset, GLint yoffset,
1509 GLint zoffset, GLsizei width,
1510 GLsizei height, GLsizei depth,
1511 GLenum format,
1512 GLenum type, const GLvoid *pixels )
1514 glTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels );
1517 GLboolean glIsTexture( GLuint texture )
1519 FlushOnStateChange( );
1520 return glEsImpl->glIsTexture( texture );
1523 // TODO: add native normal/reflection map texgen support
1525 void glTexGeni( GLenum coord, GLenum pname, GLint param )
1527 FlushOnStateChange();
1528 //glEsImpl->glTexGeniOES( coord, pname, param );
1531 void glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
1533 FlushOnStateChange();
1534 //glEsImpl->glTexGenfvOES( coord, pname, params );
1537 //-- --//
1539 void glHint( GLenum target, GLenum mode )
1541 FlushOnStateChange( );
1542 glEsImpl->glHint( target, mode );
1545 void glBlendFunc( GLenum sfactor, GLenum dfactor )
1547 if( skipnanogl )
1549 glEsImpl->glBlendFunc( sfactor, dfactor );
1550 return;
1552 if ( ( nanoglState.sfactor == sfactor ) && ( nanoglState.dfactor == dfactor ) )
1554 return;
1557 nanoglState.sfactor = sfactor;
1558 nanoglState.dfactor = dfactor;
1559 FlushOnStateChange( );
1560 glEsImpl->glBlendFunc( sfactor, dfactor );
1563 void glPopMatrix( void )
1565 FlushOnStateChange( );
1566 glEsImpl->glPopMatrix( );
1569 void glShadeModel( GLenum mode )
1571 if ( nanoglState.shademodel == mode )
1573 return;
1575 nanoglState.shademodel = mode;
1576 FlushOnStateChange( );
1577 glEsImpl->glShadeModel( mode );
1580 void glPushMatrix( void )
1582 FlushOnStateChange( );
1583 glEsImpl->glPushMatrix( );
1586 void glTexEnvf( GLenum target, GLenum pname, GLfloat param )
1588 if( skipnanogl )
1590 glEsImpl->glTexEnvf( target, pname, param );
1591 return;
1593 if ( target == GL_TEXTURE_ENV )
1595 if ( pname == GL_TEXTURE_ENV_MODE )
1597 if ( param == activetmuState->texture_env_mode.value )
1599 return;
1601 else
1603 FlushOnStateChange( );
1604 glEsImpl->glTexEnvf( target, pname, param );
1605 activetmuState->texture_env_mode.value = param;
1606 return;
1610 FlushOnStateChange( );
1611 glEsImpl->glTexEnvf( target, pname, param );
1614 void glVertex3fv( const GLfloat *v )
1616 GLfloat *vert = (GLfloat *)ptrVertexAttribArray++;
1617 memcpy( vert, v, 3 * sizeof( GLfloat ) );
1618 #if defined( __MULTITEXTURE_SUPPORT__ )
1619 memcpy( vert + 3, &currentVertexAttrib.red, 5 * sizeof( GLfloat ) );
1620 #else
1621 memcpy( vert + 4, &currentVertexAttrib.red, 3 * sizeof( GLfloat ) );
1622 #endif
1625 void glDepthMask( GLboolean flag )
1627 if( !skipnanogl )
1629 if ( nanoglState.depthmask == flag )
1631 return;
1633 nanoglState.depthmask = flag;
1634 FlushOnStateChange( );
1636 glEsImpl->glDepthMask( flag );
1639 void glBindTexture( GLenum target, GLuint texture )
1641 if( skipnanogl )
1643 glEsImpl->glBindTexture( target,texture );
1644 return;
1646 if ( activetmuState->boundtexture.value == texture )
1648 return;
1650 FlushOnStateChange( );
1651 activetmuState->boundtexture.value = texture;
1652 glEsImpl->glBindTexture( target, texture );
1655 void glGetIntegerv( GLenum pname, GLint *params )
1657 FlushOnStateChange( );
1658 glEsImpl->glGetIntegerv( pname, params );
1661 GLubyte nano_extensions_string[4096];
1662 const GLubyte *glGetString( GLenum name )
1665 if ( name == GL_EXTENSIONS )
1667 #if defined( __MULTITEXTURE_SUPPORT__ )
1668 sprintf( (char *)nano_extensions_string, "%s %s", glEsImpl->glGetString( name ), "GL_ARB_multitexture EXT_texture_env_add" );
1669 #else
1670 sprintf( (char *)nano_extensions_string, "%s %s", glEsImpl->glGetString( name ), "EXT_texture_env_add" );
1671 #endif
1672 return nano_extensions_string;
1674 return glEsImpl->glGetString( name );
1677 void glAlphaFunc( GLenum func, GLclampf ref )
1679 FlushOnStateChange( );
1680 glEsImpl->glAlphaFunc( func, ref );
1683 void glFlush( void )
1685 FlushOnStateChange( );
1686 glEsImpl->glFlush( );
1689 void glReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels )
1691 if ( format == GL_DEPTH_COMPONENT )
1693 // OpenglEs 1.1 does not support reading depth buffer without an extension
1694 memset( pixels, 0xff, 4 );
1695 return;
1697 FlushOnStateChange( );
1698 glEsImpl->glReadPixels( x, y, width, height, format, type, pixels );
1701 void glReadBuffer( GLenum /*mode*/ )
1705 void glLoadMatrixf( const GLfloat *m )
1707 FlushOnStateChange( );
1708 glEsImpl->glLoadMatrixf( m );
1711 void glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels )
1713 FlushOnStateChange( );
1714 glEsImpl->glTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels );
1717 void glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
1719 FlushOnStateChange( );
1720 glEsImpl->glClearColor( red, green, blue, alpha );
1723 GLenum glGetError( void )
1725 //FlushOnStateChange();
1726 return GL_NO_ERROR; //glEsImpl->glGetError();
1729 void glActiveTexture( GLenum texture )
1731 if( skipnanogl )
1733 glEsImpl->glActiveTexture( texture );
1734 return;
1736 if ( activetmu == texture )
1738 return;
1740 if ( delayedttmuchange )
1742 delayedttmuchange = GL_FALSE;
1744 else
1746 delayedttmuchange = GL_TRUE;
1747 delayedtmutarget = texture;
1749 if ( texture == GL_TEXTURE0 )
1751 activetmuState = &tmuState0;
1753 else
1755 activetmuState = &tmuState1;
1757 activetmu = texture;
1760 void glClientActiveTexture( GLenum texture )
1762 if( skipnanogl )
1764 glEsImpl->glClientActiveTexture( texture );
1765 return;
1767 clientactivetmu = texture;
1770 void glPolygonMode( GLenum face, GLenum mode )
1774 void glDeleteTextures( GLsizei n, const GLuint *textures )
1776 FlushOnStateChange( );
1777 glEsImpl->glDeleteTextures( n, textures );
1780 void glClearDepth( GLclampf depth )
1782 FlushOnStateChange( );
1783 glEsImpl->glClearDepthf( depth );
1786 void glClipPlane( GLenum plane, const GLdouble *equation )
1788 FlushOnStateChange( );
1789 float array[4];
1790 array[0] = ( GLfloat )( equation[0] );
1791 array[1] = ( GLfloat )( equation[1] );
1792 array[2] = ( GLfloat )( equation[2] );
1793 array[3] = ( GLfloat )( equation[3] );
1794 glEsImpl->glClipPlanef( plane, array );
1797 void glScissor( GLint x, GLint y, GLsizei width, GLsizei height )
1799 FlushOnStateChange( );
1800 glEsImpl->glScissor( x, y, width, height );
1803 void glPointSize( GLfloat size )
1805 FlushOnStateChange( );
1806 glEsImpl->glPointSize( size );
1809 void glArrayElement( GLint i )
1812 void glLineWidth( GLfloat width )
1815 void glCallList( GLuint list )
1818 void glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha )
1821 void glStencilFunc( GLenum func, GLint ref, GLuint mask )
1824 void glStencilOp( GLenum fail, GLenum zfail, GLenum zpass )
1828 struct ptrstate vertex_array;
1829 struct ptrstate color_array;
1830 struct ptrstate texture_coord_array;
1832 void glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices )
1834 if( skipnanogl )
1836 glEsImpl->glDrawElements( mode, count, type, indices );
1837 return;
1839 // ensure that all primitives specified between glBegin/glEnd pairs
1840 // are rendered first, and that we have correct tmu in use..
1841 FlushOnStateChange( );
1842 // setup correct vertex/color/texcoord pointers
1843 if ( arraysValid ||
1844 tmuState0.vertex_array.changed ||
1845 tmuState0.color_array.changed ||
1846 tmuState0.texture_coord_array.changed || tmuState0.normal_array.changed )
1848 glEsImpl->glClientActiveTexture( GL_TEXTURE0 );
1850 if ( arraysValid || tmuState0.vertex_array.changed )
1852 if ( tmuState0.vertex_array.enabled )
1854 glEsImpl->glEnableClientState( GL_VERTEX_ARRAY );
1856 else
1858 glEsImpl->glDisableClientState( GL_VERTEX_ARRAY );
1860 glEsImpl->glVertexPointer( tmuState0.vertex_array.size,
1861 tmuState0.vertex_array.type,
1862 tmuState0.vertex_array.stride,
1863 tmuState0.vertex_array.ptr );
1864 tmuState0.vertex_array.changed = GL_FALSE;
1866 if ( arraysValid || tmuState0.color_array.changed )
1868 if ( tmuState0.color_array.enabled )
1870 glEsImpl->glEnableClientState( GL_COLOR_ARRAY );
1872 else
1874 glEsImpl->glDisableClientState( GL_COLOR_ARRAY );
1876 glEsImpl->glColorPointer( tmuState0.color_array.size,
1877 tmuState0.color_array.type,
1878 tmuState0.color_array.stride,
1879 tmuState0.color_array.ptr );
1880 tmuState0.color_array.changed = GL_FALSE;
1882 if ( arraysValid || tmuState0.normal_array.changed )
1884 if ( tmuState0.normal_array.enabled )
1886 glEsImpl->glEnableClientState( GL_NORMAL_ARRAY );
1888 else
1890 glEsImpl->glDisableClientState( GL_NORMAL_ARRAY );
1892 glEsImpl->glNormalPointer( tmuState0.normal_array.type,
1893 tmuState0.normal_array.stride,
1894 tmuState0.normal_array.ptr );
1895 tmuState0.normal_array.changed = GL_FALSE;
1897 if ( arraysValid || tmuState0.texture_coord_array.changed )
1899 tmuState0.texture_coord_array.changed = GL_FALSE;
1900 if ( tmuState0.texture_coord_array.enabled )
1902 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
1904 else
1906 glEsImpl->glDisableClientState( GL_TEXTURE_COORD_ARRAY );
1908 glEsImpl->glTexCoordPointer( tmuState0.texture_coord_array.size,
1909 tmuState0.texture_coord_array.type,
1910 tmuState0.texture_coord_array.stride,
1911 tmuState0.texture_coord_array.ptr );
1914 if ( arraysValid || tmuState1.texture_coord_array.changed )
1916 tmuState1.texture_coord_array.changed = GL_FALSE;
1917 glEsImpl->glClientActiveTexture( GL_TEXTURE1 );
1918 if ( tmuState1.texture_coord_array.enabled )
1920 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
1922 else
1924 glEsImpl->glDisableClientState( GL_TEXTURE_COORD_ARRAY );
1926 glEsImpl->glTexCoordPointer( tmuState1.texture_coord_array.size,
1927 tmuState1.texture_coord_array.type,
1928 tmuState1.texture_coord_array.stride,
1929 tmuState1.texture_coord_array.ptr );
1932 arraysValid = GL_FALSE;
1933 glEsImpl->glDrawElements( mode, count, type, indices );
1936 bool vboarray;
1938 void glEnableClientState( GLenum array )
1940 if( skipnanogl )
1942 glEsImpl->glEnableClientState( array );
1943 if( array == GL_VERTEX_ARRAY )
1944 vboarray = true;
1945 return;
1947 struct nanotmuState *clientstate = NULL;
1948 if ( clientactivetmu == GL_TEXTURE0 )
1950 clientstate = &tmuState0;
1952 else if ( clientactivetmu == GL_TEXTURE1 )
1954 clientstate = &tmuState1;
1956 else
1958 return;
1960 switch ( array )
1962 case GL_VERTEX_ARRAY:
1963 if ( clientstate->vertex_array.enabled )
1965 return;
1967 clientstate->vertex_array.enabled = GL_TRUE;
1968 clientstate->vertex_array.changed = GL_TRUE;
1969 break;
1970 case GL_COLOR_ARRAY:
1971 if ( clientstate->color_array.enabled )
1973 return;
1975 clientstate->color_array.enabled = GL_TRUE;
1976 clientstate->color_array.changed = GL_TRUE;
1978 break;
1979 case GL_NORMAL_ARRAY:
1980 if ( clientstate->normal_array.enabled )
1982 return;
1984 clientstate->normal_array.enabled = GL_TRUE;
1985 clientstate->normal_array.changed = GL_TRUE;
1987 break;
1988 case GL_TEXTURE_COORD_ARRAY:
1989 if ( clientstate->texture_coord_array.enabled )
1991 return;
1993 clientstate->texture_coord_array.enabled = GL_TRUE;
1994 clientstate->texture_coord_array.changed = GL_TRUE;
1995 break;
1996 default:
1997 break;
2000 void glDisableClientState( GLenum array )
2002 if( skipnanogl )
2004 glEsImpl->glDisableClientState( array );
2005 if( array == GL_VERTEX_ARRAY )
2006 vboarray = false;
2007 return;
2009 struct nanotmuState *clientstate = NULL;
2010 if ( clientactivetmu == GL_TEXTURE0 )
2012 clientstate = &tmuState0;
2014 else if ( clientactivetmu == GL_TEXTURE1 )
2016 clientstate = &tmuState1;
2018 else
2020 return;
2022 switch ( array )
2024 case GL_VERTEX_ARRAY:
2025 if ( !clientstate->vertex_array.enabled )
2027 return;
2029 clientstate->vertex_array.enabled = GL_FALSE;
2030 clientstate->vertex_array.changed = GL_TRUE;
2031 break;
2032 case GL_COLOR_ARRAY:
2033 if ( !clientstate->color_array.enabled )
2035 return;
2037 clientstate->color_array.enabled = GL_FALSE;
2038 clientstate->color_array.changed = GL_TRUE;
2040 break;
2041 case GL_NORMAL_ARRAY:
2042 if ( !clientstate->normal_array.enabled )
2044 return;
2046 clientstate->normal_array.enabled = GL_FALSE;
2047 clientstate->normal_array.changed = GL_TRUE;
2049 break;
2050 case GL_TEXTURE_COORD_ARRAY:
2051 if ( !clientstate->texture_coord_array.enabled )
2053 return;
2055 clientstate->texture_coord_array.enabled = GL_FALSE;
2056 clientstate->texture_coord_array.changed = GL_TRUE;
2057 break;
2058 default:
2059 break;
2062 void glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
2065 if( skipnanogl )
2067 glEsImpl->glVertexPointer( size, type, stride, pointer );
2068 return;
2070 if ( tmuState0.vertex_array.size == size &&
2071 tmuState0.vertex_array.stride == stride &&
2072 tmuState0.vertex_array.type == type &&
2073 tmuState0.vertex_array.ptr == pointer )
2075 return;
2077 tmuState0.vertex_array.size = size;
2078 tmuState0.vertex_array.stride = stride;
2079 tmuState0.vertex_array.type = type;
2080 tmuState0.vertex_array.ptr = (GLvoid *)pointer;
2081 tmuState0.vertex_array.changed = GL_TRUE;
2083 void glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
2085 if( skipnanogl )
2087 glEsImpl->glTexCoordPointer( size, type, stride, pointer );
2088 return;
2090 struct nanotmuState *clientstate = NULL;
2091 if ( clientactivetmu == GL_TEXTURE0 )
2093 clientstate = &tmuState0;
2095 else if ( clientactivetmu == GL_TEXTURE1 )
2097 clientstate = &tmuState1;
2099 if ( clientstate->texture_coord_array.size == size &&
2100 clientstate->texture_coord_array.stride == stride &&
2101 clientstate->texture_coord_array.type == type &&
2102 clientstate->texture_coord_array.ptr == pointer )
2104 return;
2106 clientstate->texture_coord_array.size = size;
2107 clientstate->texture_coord_array.stride = stride;
2108 clientstate->texture_coord_array.type = type;
2109 clientstate->texture_coord_array.ptr = (GLvoid *)pointer;
2110 clientstate->texture_coord_array.changed = GL_TRUE;
2112 void glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
2114 if ( tmuState0.color_array.size == size &&
2115 tmuState0.color_array.stride == stride &&
2116 tmuState0.color_array.type == type &&
2117 tmuState0.color_array.ptr == pointer )
2119 return;
2121 tmuState0.color_array.size = size;
2122 tmuState0.color_array.stride = stride;
2123 tmuState0.color_array.type = type;
2124 tmuState0.color_array.ptr = (GLvoid *)pointer;
2125 tmuState0.color_array.changed = GL_TRUE;
2128 void glNormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
2130 int size = 0;
2131 if ( tmuState0.normal_array.size == size &&
2132 tmuState0.normal_array.stride == stride &&
2133 tmuState0.normal_array.type == type &&
2134 tmuState0.normal_array.ptr == pointer )
2136 return;
2138 tmuState0.normal_array.size = size;
2139 tmuState0.normal_array.stride = stride;
2140 tmuState0.normal_array.type = type;
2141 tmuState0.normal_array.ptr = (GLvoid *)pointer;
2142 tmuState0.normal_array.changed = GL_TRUE;
2144 void glPolygonOffset( GLfloat factor, GLfloat units )
2146 FlushOnStateChange( );
2147 glEsImpl->glPolygonOffset( factor, units );
2149 void glStencilMask( GLuint mask )
2152 void glClearStencil( GLint s )
2156 #if defined( __MULTITEXTURE_SUPPORT__ )
2158 extern "C" void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t );
2160 void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t )
2162 if ( target == GL_TEXTURE0 )
2164 glTexCoord2f( s, t );
2166 else
2168 currentVertexAttrib.s_multi = s;
2169 currentVertexAttrib.t_multi = t;
2172 #endif
2174 /* Vladimir */
2175 /*void glDrawArrays( GLenum mode, int first, int count)
2177 FlushOnStateChange();
2178 glEsImpl->glDrawArrays(mode, first , count);
2179 }*/
2180 void glMultMatrixf( const GLfloat *m )
2182 FlushOnStateChange( );
2183 glEsImpl->glMultMatrixf( m );
2186 void glPixelStorei( GLenum pname, GLint param )
2188 FlushOnStateChange( );
2189 glEsImpl->glPixelStorei( pname, param );
2192 void glFogf( GLenum pname, GLfloat param )
2194 FlushOnStateChange( );
2195 glEsImpl->glFogf( pname, param );
2198 void glFogfv( GLenum pname, const GLfloat *params )
2200 FlushOnStateChange( );
2201 glEsImpl->glFogfv( pname, params );
2204 void glGetTexParameteriv( GLenum target, GLenum pname, GLint *params )
2206 FlushOnStateChange( );
2207 glEsImpl->glGetTexParameteriv( target, pname, params );
2210 // This gives: called unimplemented OpenGL ES API (Android)
2211 void glTexParameteri( GLenum target, GLenum pname, GLint param )
2213 if ( pname == GL_TEXTURE_BORDER_COLOR )
2215 return; // not supported by opengl es
2217 if ( ( pname == GL_TEXTURE_WRAP_S ||
2218 pname == GL_TEXTURE_WRAP_T ) &&
2219 param == GL_CLAMP )
2221 param = 0x812F;
2224 FlushOnStateChange( );
2225 glEsImpl->glTexParameteri( target, pname, param );
2228 void glTexParameterx( GLenum target, GLenum pname, GLfixed param )
2230 if ( pname == GL_TEXTURE_BORDER_COLOR )
2232 return; // not supported by opengl es
2234 if ( ( pname == GL_TEXTURE_WRAP_S ||
2235 pname == GL_TEXTURE_WRAP_T ) &&
2236 param == GL_CLAMP )
2238 param = 0x812F;
2240 FlushOnStateChange( );
2241 glEsImpl->glTexParameterx( target, pname, param );
2244 void glGenTextures( GLsizei n, GLuint *textures )
2246 FlushOnStateChange( );
2247 glEsImpl->glGenTextures( n, textures );
2250 void glFrontFace( GLenum mode )
2252 FlushOnStateChange( );
2253 glEsImpl->glFrontFace( mode );
2255 // End Vladimir
2257 void glTexEnvi( GLenum target, GLenum pname, GLint param )
2259 if( skipnanogl )
2261 glEsImpl->glTexEnvi( target, pname, param );
2262 return;
2264 if ( target == GL_TEXTURE_ENV )
2266 if ( pname == GL_TEXTURE_ENV_MODE )
2268 if ( param == activetmuState->texture_env_mode.value )
2270 return;
2272 else
2274 FlushOnStateChange( );
2275 glEsImpl->glTexEnvi( target, pname, param );
2276 activetmuState->texture_env_mode.value = param;
2277 return;
2281 FlushOnStateChange( );
2282 glEsImpl->glTexEnvi( target, pname, param );
2285 #ifdef __MULTITEXTURE_SUPPORT__
2286 void glMultiTexCoord3fARB( GLenum a, GLfloat b, GLfloat c, GLfloat )
2288 return glMultiTexCoord2fARB( a, b, c );
2291 void glMultiTexCoord2f( GLenum a, GLfloat b, GLfloat c )
2293 glMultiTexCoord2fARB(a,b,c);
2295 #endif
2296 void glDrawArrays( GLenum mode, GLint first, GLsizei count )
2298 if( skipnanogl )
2300 glEsImpl->glDrawArrays( mode, first, count );
2301 return;
2303 // ensure that all primitives specified between glBegin/glEnd pairs
2304 // are rendered first, and that we have correct tmu in use..
2305 if ( mode == GL_QUADS )
2306 mode = GL_TRIANGLE_FAN;
2307 FlushOnStateChange( );
2308 // setup correct vertex/color/texcoord pointers
2309 if ( arraysValid ||
2310 tmuState0.vertex_array.changed ||
2311 tmuState0.color_array.changed ||
2312 tmuState0.texture_coord_array.changed || tmuState0.normal_array.changed )
2314 glEsImpl->glClientActiveTexture( GL_TEXTURE0 );
2316 if ( arraysValid || tmuState0.vertex_array.changed )
2318 if ( tmuState0.vertex_array.enabled )
2320 glEsImpl->glEnableClientState( GL_VERTEX_ARRAY );
2322 else
2324 glEsImpl->glDisableClientState( GL_VERTEX_ARRAY );
2326 glEsImpl->glVertexPointer( tmuState0.vertex_array.size,
2327 tmuState0.vertex_array.type,
2328 tmuState0.vertex_array.stride,
2329 tmuState0.vertex_array.ptr );
2330 tmuState0.vertex_array.changed = GL_FALSE;
2332 if ( arraysValid || tmuState0.color_array.changed )
2334 if ( tmuState0.color_array.enabled )
2336 glEsImpl->glEnableClientState( GL_COLOR_ARRAY );
2338 else
2340 glEsImpl->glDisableClientState( GL_COLOR_ARRAY );
2342 glEsImpl->glColorPointer( tmuState0.color_array.size,
2343 tmuState0.color_array.type,
2344 tmuState0.color_array.stride,
2345 tmuState0.color_array.ptr );
2346 tmuState0.color_array.changed = GL_FALSE;
2348 if ( arraysValid || tmuState0.normal_array.changed )
2350 if ( tmuState0.normal_array.enabled )
2352 glEsImpl->glEnableClientState( GL_NORMAL_ARRAY );
2354 else
2356 glEsImpl->glDisableClientState( GL_NORMAL_ARRAY );
2358 glEsImpl->glNormalPointer( tmuState0.normal_array.type,
2359 tmuState0.normal_array.stride,
2360 tmuState0.normal_array.ptr );
2361 tmuState0.normal_array.changed = GL_FALSE;
2363 if ( arraysValid || tmuState0.texture_coord_array.changed )
2365 tmuState0.texture_coord_array.changed = GL_FALSE;
2366 if ( tmuState0.texture_coord_array.enabled )
2368 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
2370 else
2372 glEsImpl->glDisableClientState( GL_TEXTURE_COORD_ARRAY );
2374 glEsImpl->glTexCoordPointer( tmuState0.texture_coord_array.size,
2375 tmuState0.texture_coord_array.type,
2376 tmuState0.texture_coord_array.stride,
2377 tmuState0.texture_coord_array.ptr );
2380 if ( arraysValid || tmuState1.texture_coord_array.changed )
2382 tmuState1.texture_coord_array.changed = GL_FALSE;
2383 glEsImpl->glClientActiveTexture( GL_TEXTURE1 );
2384 if ( tmuState1.texture_coord_array.enabled )
2386 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
2388 else
2390 glEsImpl->glDisableClientState( GL_TEXTURE_COORD_ARRAY );
2392 glEsImpl->glTexCoordPointer( tmuState1.texture_coord_array.size,
2393 tmuState1.texture_coord_array.type,
2394 tmuState1.texture_coord_array.stride,
2395 tmuState1.texture_coord_array.ptr );
2398 arraysValid = GL_FALSE;
2399 glEsImpl->glDrawArrays( mode, first, count );
2401 /*void glNormalPointer(GLenum type, GLsizei stride, const void *ptr)
2403 glEsImpl->glNormalPointer( type, stride, ptr );
2404 }*/
2406 void glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height )
2408 FlushOnStateChange( );
2409 glEsImpl->glCopyTexSubImage2D( target, level, xoffset, yoffset, x, y, width, height );
2412 void glGenFramebuffers( GLsizei n, GLuint *framebuffers )
2414 FlushOnStateChange( );
2415 glEsImpl->glGenFramebuffers( n, framebuffers );
2418 void glGenRenderbuffers( GLsizei n, GLuint *renderbuffers )
2420 FlushOnStateChange( );
2421 glEsImpl->glGenRenderbuffers( n, renderbuffers );
2424 void glBindRenderbuffer( GLenum target, GLuint renderbuffer )
2426 FlushOnStateChange( );
2427 glEsImpl->glBindRenderbuffer( target, renderbuffer );
2430 void glBindFramebuffer( GLenum target, GLuint framebuffer )
2432 FlushOnStateChange( );
2433 glEsImpl->glBindFramebuffer( target, framebuffer );
2436 void glFramebufferRenderbuffer( GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer )
2438 FlushOnStateChange( );
2439 glEsImpl->glFramebufferRenderbuffer( target, attachment, renderbuffertarget, renderbuffer );
2442 void glDeleteFramebuffers( GLsizei n, const GLuint *framebuffers )
2444 FlushOnStateChange( );
2445 glEsImpl->glDeleteFramebuffers( n, framebuffers );
2448 void glDeleteRenderbuffers( GLsizei n, const GLuint *renderbuffers )
2450 FlushOnStateChange( );
2451 glEsImpl->glDeleteRenderbuffers( n, renderbuffers );
2453 void glFramebufferTexture2D( GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level )
2455 FlushOnStateChange( );
2456 glEsImpl->glFramebufferTexture2D( target, attachment, textarget, texture, level );
2459 void glRenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height )
2461 FlushOnStateChange( );
2462 glEsImpl->glRenderbufferStorage( target, internalformat, width, height );
2465 void glBindBufferARB( GLuint target, GLuint index )
2467 static int sindex;
2469 if( index && !sindex && !skipnanogl )
2470 FlushOnStateChange();
2471 glEsImpl->glDisableClientState( GL_COLOR_ARRAY );
2472 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
2473 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
2475 skipnanogl = (!!index) || vboarray;
2476 glEsImpl->glBindBuffer( target, index );
2477 if( sindex && !index )
2479 arraysValid = GL_FALSE;
2481 sindex = index;
2484 void glGenBuffersARB( GLuint count, GLuint *indexes )
2486 glEsImpl->glGenBuffers( count, indexes );
2489 void glDeleteBuffersARB( GLuint count, GLuint *indexes )
2491 glEsImpl->glDeleteBuffers( count, indexes );
2494 void glBufferDataARB( GLuint target, GLuint size, void *buffer, GLuint type )
2496 glEsImpl->glBufferData( target, size, buffer, type );
2499 void glBufferSubDataARB( GLuint target, GLsizei offset, GLsizei size, void *buffer )
2501 glEsImpl->glBufferSubData( target, offset, size, buffer );