DEADSOFTWARE

Fix crash with null texture
[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 GLclampd depth_range_near;
71 GLclampd 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( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble 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( pixels && 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( GLclampd zNear, GLclampd 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( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble 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 glActiveTextureARB( GLenum texture )
1762 if( skipnanogl )
1764 glEsImpl->glActiveTexture( texture );
1765 return;
1767 if ( activetmu == texture )
1769 return;
1771 if ( delayedttmuchange )
1773 delayedttmuchange = GL_FALSE;
1775 else
1777 delayedttmuchange = GL_TRUE;
1778 delayedtmutarget = texture;
1780 if ( texture == GL_TEXTURE0 )
1782 activetmuState = &tmuState0;
1784 else
1786 activetmuState = &tmuState1;
1788 activetmu = texture;
1791 void glClientActiveTexture( GLenum texture )
1793 if( skipnanogl )
1795 glEsImpl->glClientActiveTexture( texture );
1796 return;
1798 clientactivetmu = texture;
1800 void glClientActiveTextureARB( GLenum texture )
1802 if( skipnanogl )
1804 glEsImpl->glClientActiveTexture( texture );
1805 return;
1807 clientactivetmu = texture;
1811 void glPolygonMode( GLenum face, GLenum mode )
1815 void glDeleteTextures( GLsizei n, const GLuint *textures )
1817 FlushOnStateChange( );
1818 glEsImpl->glDeleteTextures( n, textures );
1821 void glClearDepth( GLclampd depth )
1823 FlushOnStateChange( );
1824 glEsImpl->glClearDepthf( depth );
1827 void glClipPlane( GLenum plane, const GLdouble *equation )
1829 FlushOnStateChange( );
1830 float array[4];
1831 array[0] = ( GLfloat )( equation[0] );
1832 array[1] = ( GLfloat )( equation[1] );
1833 array[2] = ( GLfloat )( equation[2] );
1834 array[3] = ( GLfloat )( equation[3] );
1835 glEsImpl->glClipPlanef( plane, array );
1838 void glScissor( GLint x, GLint y, GLsizei width, GLsizei height )
1840 FlushOnStateChange( );
1841 glEsImpl->glScissor( x, y, width, height );
1844 void glPointSize( GLfloat size )
1846 FlushOnStateChange( );
1847 glEsImpl->glPointSize( size );
1850 void glArrayElement( GLint i )
1853 void glLineWidth( GLfloat width )
1856 void glCallList( GLuint list )
1859 void glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha )
1862 void glStencilFunc( GLenum func, GLint ref, GLuint mask )
1865 void glStencilOp( GLenum fail, GLenum zfail, GLenum zpass )
1869 struct ptrstate vertex_array;
1870 struct ptrstate color_array;
1871 struct ptrstate texture_coord_array;
1873 void glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices )
1875 if( skipnanogl )
1877 glEsImpl->glDrawElements( mode, count, type, indices );
1878 return;
1880 // ensure that all primitives specified between glBegin/glEnd pairs
1881 // are rendered first, and that we have correct tmu in use..
1882 FlushOnStateChange( );
1883 // setup correct vertex/color/texcoord pointers
1884 if ( arraysValid ||
1885 tmuState0.vertex_array.changed ||
1886 tmuState0.color_array.changed ||
1887 tmuState0.texture_coord_array.changed || tmuState0.normal_array.changed )
1889 glEsImpl->glClientActiveTexture( GL_TEXTURE0 );
1891 if ( arraysValid || tmuState0.vertex_array.changed )
1893 if ( tmuState0.vertex_array.enabled )
1895 glEsImpl->glEnableClientState( GL_VERTEX_ARRAY );
1897 else
1899 glEsImpl->glDisableClientState( GL_VERTEX_ARRAY );
1901 glEsImpl->glVertexPointer( tmuState0.vertex_array.size,
1902 tmuState0.vertex_array.type,
1903 tmuState0.vertex_array.stride,
1904 tmuState0.vertex_array.ptr );
1905 tmuState0.vertex_array.changed = GL_FALSE;
1907 if ( arraysValid || tmuState0.color_array.changed )
1909 if ( tmuState0.color_array.enabled )
1911 glEsImpl->glEnableClientState( GL_COLOR_ARRAY );
1913 else
1915 glEsImpl->glDisableClientState( GL_COLOR_ARRAY );
1917 glEsImpl->glColorPointer( tmuState0.color_array.size,
1918 tmuState0.color_array.type,
1919 tmuState0.color_array.stride,
1920 tmuState0.color_array.ptr );
1921 tmuState0.color_array.changed = GL_FALSE;
1923 if ( arraysValid || tmuState0.normal_array.changed )
1925 if ( tmuState0.normal_array.enabled )
1927 glEsImpl->glEnableClientState( GL_NORMAL_ARRAY );
1929 else
1931 glEsImpl->glDisableClientState( GL_NORMAL_ARRAY );
1933 glEsImpl->glNormalPointer( tmuState0.normal_array.type,
1934 tmuState0.normal_array.stride,
1935 tmuState0.normal_array.ptr );
1936 tmuState0.normal_array.changed = GL_FALSE;
1938 if ( arraysValid || tmuState0.texture_coord_array.changed )
1940 tmuState0.texture_coord_array.changed = GL_FALSE;
1941 if ( tmuState0.texture_coord_array.enabled )
1943 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
1945 else
1947 glEsImpl->glDisableClientState( GL_TEXTURE_COORD_ARRAY );
1949 glEsImpl->glTexCoordPointer( tmuState0.texture_coord_array.size,
1950 tmuState0.texture_coord_array.type,
1951 tmuState0.texture_coord_array.stride,
1952 tmuState0.texture_coord_array.ptr );
1955 if ( arraysValid || tmuState1.texture_coord_array.changed )
1957 tmuState1.texture_coord_array.changed = GL_FALSE;
1958 glEsImpl->glClientActiveTexture( GL_TEXTURE1 );
1959 if ( tmuState1.texture_coord_array.enabled )
1961 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
1963 else
1965 glEsImpl->glDisableClientState( GL_TEXTURE_COORD_ARRAY );
1967 glEsImpl->glTexCoordPointer( tmuState1.texture_coord_array.size,
1968 tmuState1.texture_coord_array.type,
1969 tmuState1.texture_coord_array.stride,
1970 tmuState1.texture_coord_array.ptr );
1973 arraysValid = GL_FALSE;
1974 glEsImpl->glDrawElements( mode, count, type, indices );
1977 bool vboarray;
1979 void glEnableClientState( GLenum array )
1981 if( skipnanogl )
1983 glEsImpl->glEnableClientState( array );
1984 if( array == GL_VERTEX_ARRAY )
1985 vboarray = true;
1986 return;
1988 struct nanotmuState *clientstate = NULL;
1989 if ( clientactivetmu == GL_TEXTURE0 )
1991 clientstate = &tmuState0;
1993 else if ( clientactivetmu == GL_TEXTURE1 )
1995 clientstate = &tmuState1;
1997 else
1999 return;
2001 switch ( array )
2003 case GL_VERTEX_ARRAY:
2004 if ( clientstate->vertex_array.enabled )
2006 return;
2008 clientstate->vertex_array.enabled = GL_TRUE;
2009 clientstate->vertex_array.changed = GL_TRUE;
2010 break;
2011 case GL_COLOR_ARRAY:
2012 if ( clientstate->color_array.enabled )
2014 return;
2016 clientstate->color_array.enabled = GL_TRUE;
2017 clientstate->color_array.changed = GL_TRUE;
2019 break;
2020 case GL_NORMAL_ARRAY:
2021 if ( clientstate->normal_array.enabled )
2023 return;
2025 clientstate->normal_array.enabled = GL_TRUE;
2026 clientstate->normal_array.changed = GL_TRUE;
2028 break;
2029 case GL_TEXTURE_COORD_ARRAY:
2030 if ( clientstate->texture_coord_array.enabled )
2032 return;
2034 clientstate->texture_coord_array.enabled = GL_TRUE;
2035 clientstate->texture_coord_array.changed = GL_TRUE;
2036 break;
2037 default:
2038 break;
2041 void glDisableClientState( GLenum array )
2043 if( skipnanogl )
2045 glEsImpl->glDisableClientState( array );
2046 if( array == GL_VERTEX_ARRAY )
2047 vboarray = false;
2048 return;
2050 struct nanotmuState *clientstate = NULL;
2051 if ( clientactivetmu == GL_TEXTURE0 )
2053 clientstate = &tmuState0;
2055 else if ( clientactivetmu == GL_TEXTURE1 )
2057 clientstate = &tmuState1;
2059 else
2061 return;
2063 switch ( array )
2065 case GL_VERTEX_ARRAY:
2066 if ( !clientstate->vertex_array.enabled )
2068 return;
2070 clientstate->vertex_array.enabled = GL_FALSE;
2071 clientstate->vertex_array.changed = GL_TRUE;
2072 break;
2073 case GL_COLOR_ARRAY:
2074 if ( !clientstate->color_array.enabled )
2076 return;
2078 clientstate->color_array.enabled = GL_FALSE;
2079 clientstate->color_array.changed = GL_TRUE;
2081 break;
2082 case GL_NORMAL_ARRAY:
2083 if ( !clientstate->normal_array.enabled )
2085 return;
2087 clientstate->normal_array.enabled = GL_FALSE;
2088 clientstate->normal_array.changed = GL_TRUE;
2090 break;
2091 case GL_TEXTURE_COORD_ARRAY:
2092 if ( !clientstate->texture_coord_array.enabled )
2094 return;
2096 clientstate->texture_coord_array.enabled = GL_FALSE;
2097 clientstate->texture_coord_array.changed = GL_TRUE;
2098 break;
2099 default:
2100 break;
2103 void glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
2106 if( skipnanogl )
2108 glEsImpl->glVertexPointer( size, type, stride, pointer );
2109 return;
2111 if ( tmuState0.vertex_array.size == size &&
2112 tmuState0.vertex_array.stride == stride &&
2113 tmuState0.vertex_array.type == type &&
2114 tmuState0.vertex_array.ptr == pointer )
2116 return;
2118 tmuState0.vertex_array.size = size;
2119 tmuState0.vertex_array.stride = stride;
2120 tmuState0.vertex_array.type = type;
2121 tmuState0.vertex_array.ptr = (GLvoid *)pointer;
2122 tmuState0.vertex_array.changed = GL_TRUE;
2124 void glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
2126 if( skipnanogl )
2128 glEsImpl->glTexCoordPointer( size, type, stride, pointer );
2129 return;
2131 struct nanotmuState *clientstate = NULL;
2132 if ( clientactivetmu == GL_TEXTURE0 )
2134 clientstate = &tmuState0;
2136 else if ( clientactivetmu == GL_TEXTURE1 )
2138 clientstate = &tmuState1;
2140 if ( clientstate->texture_coord_array.size == size &&
2141 clientstate->texture_coord_array.stride == stride &&
2142 clientstate->texture_coord_array.type == type &&
2143 clientstate->texture_coord_array.ptr == pointer )
2145 return;
2147 clientstate->texture_coord_array.size = size;
2148 clientstate->texture_coord_array.stride = stride;
2149 clientstate->texture_coord_array.type = type;
2150 clientstate->texture_coord_array.ptr = (GLvoid *)pointer;
2151 clientstate->texture_coord_array.changed = GL_TRUE;
2153 void glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
2155 if ( tmuState0.color_array.size == size &&
2156 tmuState0.color_array.stride == stride &&
2157 tmuState0.color_array.type == type &&
2158 tmuState0.color_array.ptr == pointer )
2160 return;
2162 tmuState0.color_array.size = size;
2163 tmuState0.color_array.stride = stride;
2164 tmuState0.color_array.type = type;
2165 tmuState0.color_array.ptr = (GLvoid *)pointer;
2166 tmuState0.color_array.changed = GL_TRUE;
2169 void glNormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
2171 int size = 0;
2172 if ( tmuState0.normal_array.size == size &&
2173 tmuState0.normal_array.stride == stride &&
2174 tmuState0.normal_array.type == type &&
2175 tmuState0.normal_array.ptr == pointer )
2177 return;
2179 tmuState0.normal_array.size = size;
2180 tmuState0.normal_array.stride = stride;
2181 tmuState0.normal_array.type = type;
2182 tmuState0.normal_array.ptr = (GLvoid *)pointer;
2183 tmuState0.normal_array.changed = GL_TRUE;
2185 void glPolygonOffset( GLfloat factor, GLfloat units )
2187 FlushOnStateChange( );
2188 glEsImpl->glPolygonOffset( factor, units );
2190 void glStencilMask( GLuint mask )
2193 void glClearStencil( GLint s )
2197 #if defined( __MULTITEXTURE_SUPPORT__ )
2199 extern "C" void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t );
2201 void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t )
2203 if ( target == GL_TEXTURE0 )
2205 glTexCoord2f( s, t );
2207 else
2209 currentVertexAttrib.s_multi = s;
2210 currentVertexAttrib.t_multi = t;
2213 #endif
2215 /* Vladimir */
2216 /*void glDrawArrays( GLenum mode, int first, int count)
2218 FlushOnStateChange();
2219 glEsImpl->glDrawArrays(mode, first , count);
2220 }*/
2221 void glMultMatrixf( const GLfloat *m )
2223 FlushOnStateChange( );
2224 glEsImpl->glMultMatrixf( m );
2227 void glPixelStorei( GLenum pname, GLint param )
2229 FlushOnStateChange( );
2230 glEsImpl->glPixelStorei( pname, param );
2233 void glFogi( GLenum pname, GLint param )
2235 FlushOnStateChange( );
2236 glEsImpl->glFogf( pname, param );
2239 void glFogf( GLenum pname, GLfloat param )
2241 FlushOnStateChange( );
2242 glEsImpl->glFogf( pname, param );
2245 void glFogfv( GLenum pname, const GLfloat *params )
2247 FlushOnStateChange( );
2248 glEsImpl->glFogfv( pname, params );
2251 void glGetTexParameteriv( GLenum target, GLenum pname, GLint *params )
2253 FlushOnStateChange( );
2254 glEsImpl->glGetTexParameteriv( target, pname, params );
2257 // This gives: called unimplemented OpenGL ES API (Android)
2258 void glTexParameteri( GLenum target, GLenum pname, GLint param )
2260 if ( pname == GL_TEXTURE_BORDER_COLOR )
2262 return; // not supported by opengl es
2264 if ( ( pname == GL_TEXTURE_WRAP_S ||
2265 pname == GL_TEXTURE_WRAP_T ) &&
2266 param == GL_CLAMP )
2268 param = 0x812F;
2271 FlushOnStateChange( );
2272 glEsImpl->glTexParameteri( target, pname, param );
2275 void glTexParameterx( GLenum target, GLenum pname, GLfixed param )
2277 if ( pname == GL_TEXTURE_BORDER_COLOR )
2279 return; // not supported by opengl es
2281 if ( ( pname == GL_TEXTURE_WRAP_S ||
2282 pname == GL_TEXTURE_WRAP_T ) &&
2283 param == GL_CLAMP )
2285 param = 0x812F;
2287 FlushOnStateChange( );
2288 glEsImpl->glTexParameterx( target, pname, param );
2291 void glGenTextures( GLsizei n, GLuint *textures )
2293 FlushOnStateChange( );
2294 glEsImpl->glGenTextures( n, textures );
2297 void glFrontFace( GLenum mode )
2299 FlushOnStateChange( );
2300 glEsImpl->glFrontFace( mode );
2302 // End Vladimir
2304 void glTexEnvi( GLenum target, GLenum pname, GLint param )
2306 if( skipnanogl )
2308 glEsImpl->glTexEnvi( target, pname, param );
2309 return;
2311 if ( target == GL_TEXTURE_ENV )
2313 if ( pname == GL_TEXTURE_ENV_MODE )
2315 if ( param == activetmuState->texture_env_mode.value )
2317 return;
2319 else
2321 FlushOnStateChange( );
2322 glEsImpl->glTexEnvi( target, pname, param );
2323 activetmuState->texture_env_mode.value = param;
2324 return;
2328 FlushOnStateChange( );
2329 glEsImpl->glTexEnvi( target, pname, param );
2332 #ifdef __MULTITEXTURE_SUPPORT__
2333 void glMultiTexCoord3fARB( GLenum a, GLfloat b, GLfloat c, GLfloat )
2335 return glMultiTexCoord2fARB( a, b, c );
2338 void glMultiTexCoord2f( GLenum a, GLfloat b, GLfloat c )
2340 glMultiTexCoord2fARB(a,b,c);
2342 #endif
2343 void glDrawArrays( GLenum mode, GLint first, GLsizei count )
2345 if( skipnanogl )
2347 glEsImpl->glDrawArrays( mode, first, count );
2348 return;
2350 // ensure that all primitives specified between glBegin/glEnd pairs
2351 // are rendered first, and that we have correct tmu in use..
2352 if ( mode == GL_QUADS )
2353 mode = GL_TRIANGLE_FAN;
2354 FlushOnStateChange( );
2355 // setup correct vertex/color/texcoord pointers
2356 if ( arraysValid ||
2357 tmuState0.vertex_array.changed ||
2358 tmuState0.color_array.changed ||
2359 tmuState0.texture_coord_array.changed || tmuState0.normal_array.changed )
2361 glEsImpl->glClientActiveTexture( GL_TEXTURE0 );
2363 if ( arraysValid || tmuState0.vertex_array.changed )
2365 if ( tmuState0.vertex_array.enabled )
2367 glEsImpl->glEnableClientState( GL_VERTEX_ARRAY );
2369 else
2371 glEsImpl->glDisableClientState( GL_VERTEX_ARRAY );
2373 glEsImpl->glVertexPointer( tmuState0.vertex_array.size,
2374 tmuState0.vertex_array.type,
2375 tmuState0.vertex_array.stride,
2376 tmuState0.vertex_array.ptr );
2377 tmuState0.vertex_array.changed = GL_FALSE;
2379 if ( arraysValid || tmuState0.color_array.changed )
2381 if ( tmuState0.color_array.enabled )
2383 glEsImpl->glEnableClientState( GL_COLOR_ARRAY );
2385 else
2387 glEsImpl->glDisableClientState( GL_COLOR_ARRAY );
2389 glEsImpl->glColorPointer( tmuState0.color_array.size,
2390 tmuState0.color_array.type,
2391 tmuState0.color_array.stride,
2392 tmuState0.color_array.ptr );
2393 tmuState0.color_array.changed = GL_FALSE;
2395 if ( arraysValid || tmuState0.normal_array.changed )
2397 if ( tmuState0.normal_array.enabled )
2399 glEsImpl->glEnableClientState( GL_NORMAL_ARRAY );
2401 else
2403 glEsImpl->glDisableClientState( GL_NORMAL_ARRAY );
2405 glEsImpl->glNormalPointer( tmuState0.normal_array.type,
2406 tmuState0.normal_array.stride,
2407 tmuState0.normal_array.ptr );
2408 tmuState0.normal_array.changed = GL_FALSE;
2410 if ( arraysValid || tmuState0.texture_coord_array.changed )
2412 tmuState0.texture_coord_array.changed = GL_FALSE;
2413 if ( tmuState0.texture_coord_array.enabled )
2415 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
2417 else
2419 glEsImpl->glDisableClientState( GL_TEXTURE_COORD_ARRAY );
2421 glEsImpl->glTexCoordPointer( tmuState0.texture_coord_array.size,
2422 tmuState0.texture_coord_array.type,
2423 tmuState0.texture_coord_array.stride,
2424 tmuState0.texture_coord_array.ptr );
2427 if ( arraysValid || tmuState1.texture_coord_array.changed )
2429 tmuState1.texture_coord_array.changed = GL_FALSE;
2430 glEsImpl->glClientActiveTexture( GL_TEXTURE1 );
2431 if ( tmuState1.texture_coord_array.enabled )
2433 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
2435 else
2437 glEsImpl->glDisableClientState( GL_TEXTURE_COORD_ARRAY );
2439 glEsImpl->glTexCoordPointer( tmuState1.texture_coord_array.size,
2440 tmuState1.texture_coord_array.type,
2441 tmuState1.texture_coord_array.stride,
2442 tmuState1.texture_coord_array.ptr );
2445 arraysValid = GL_FALSE;
2446 glEsImpl->glDrawArrays( mode, first, count );
2448 /*void glNormalPointer(GLenum type, GLsizei stride, const void *ptr)
2450 glEsImpl->glNormalPointer( type, stride, ptr );
2451 }*/
2453 void glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height )
2455 FlushOnStateChange( );
2456 glEsImpl->glCopyTexSubImage2D( target, level, xoffset, yoffset, x, y, width, height );
2459 void glGenFramebuffers( GLsizei n, GLuint *framebuffers )
2461 FlushOnStateChange( );
2462 glEsImpl->glGenFramebuffers( n, framebuffers );
2465 void glGenRenderbuffers( GLsizei n, GLuint *renderbuffers )
2467 FlushOnStateChange( );
2468 glEsImpl->glGenRenderbuffers( n, renderbuffers );
2471 void glBindRenderbuffer( GLenum target, GLuint renderbuffer )
2473 FlushOnStateChange( );
2474 glEsImpl->glBindRenderbuffer( target, renderbuffer );
2477 void glBindFramebuffer( GLenum target, GLuint framebuffer )
2479 FlushOnStateChange( );
2480 glEsImpl->glBindFramebuffer( target, framebuffer );
2483 void glFramebufferRenderbuffer( GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer )
2485 FlushOnStateChange( );
2486 glEsImpl->glFramebufferRenderbuffer( target, attachment, renderbuffertarget, renderbuffer );
2489 void glDeleteFramebuffers( GLsizei n, const GLuint *framebuffers )
2491 FlushOnStateChange( );
2492 glEsImpl->glDeleteFramebuffers( n, framebuffers );
2495 void glDeleteRenderbuffers( GLsizei n, const GLuint *renderbuffers )
2497 FlushOnStateChange( );
2498 glEsImpl->glDeleteRenderbuffers( n, renderbuffers );
2500 void glFramebufferTexture2D( GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level )
2502 FlushOnStateChange( );
2503 glEsImpl->glFramebufferTexture2D( target, attachment, textarget, texture, level );
2506 void glRenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height )
2508 FlushOnStateChange( );
2509 glEsImpl->glRenderbufferStorage( target, internalformat, width, height );
2512 void glBindBufferARB( GLuint target, GLuint index )
2514 static int sindex;
2516 if( index && !sindex && !skipnanogl )
2517 FlushOnStateChange();
2518 glEsImpl->glDisableClientState( GL_COLOR_ARRAY );
2519 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
2520 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
2522 skipnanogl = (!!index) || vboarray;
2523 glEsImpl->glBindBuffer( target, index );
2524 if( sindex && !index )
2526 arraysValid = GL_FALSE;
2528 sindex = index;
2531 void glGenBuffersARB( GLuint count, GLuint *indexes )
2533 glEsImpl->glGenBuffers( count, indexes );
2536 void glDeleteBuffersARB( GLuint count, GLuint *indexes )
2538 glEsImpl->glDeleteBuffers( count, indexes );
2541 void glBufferDataARB( GLuint target, GLuint size, void *buffer, GLuint type )
2543 glEsImpl->glBufferData( target, size, buffer, type );
2546 void glBufferSubDataARB( GLuint target, GLsizei offset, GLsizei size, void *buffer )
2548 glEsImpl->glBufferSubData( target, offset, size, buffer );