DEADSOFTWARE

Change getProcAddress search order
[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 GLboolean stupidglesbug;
71 GLclampf depth_range_near;
72 GLclampf depth_range_far;
73 GLenum depth_func;
74 GLenum cullface;
75 GLenum shademodel;
76 GLenum sfactor;
77 GLenum dfactor;
78 GLenum matrixmode;
79 };
81 static struct nanoState nanoglState;
83 static struct nanoState nanoglInitState =
84 {
85 GL_FALSE,
86 GL_FALSE,
87 GL_FALSE,
88 GL_FALSE,
89 GL_FALSE,
90 GL_FALSE,
91 GL_FALSE,
92 GL_TRUE,
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_FALSE,
105 GL_TRUE,
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_FALSE,
116 GL_TRUE,
117 GL_FALSE,
118 0.0f,
119 1.0f,
120 GL_LESS,
121 GL_BACK,
122 GL_SMOOTH,
123 GL_ONE,
124 GL_ZERO,
125 GL_MODELVIEW,
126 };
128 struct booleanstate
130 GLboolean value;
131 GLboolean changed;
132 };
134 struct floatstate
136 GLfloat value;
137 GLboolean changed;
138 };
140 struct uintstate
142 GLuint value;
143 GLboolean changed;
144 };
146 struct ptrstate
148 GLint size;
149 GLenum type;
150 GLsizei stride;
151 GLvoid *ptr;
152 GLboolean changed;
153 GLboolean enabled;
154 };
156 struct nanotmuState
158 struct booleanstate texture_2d;
159 struct floatstate texture_env_mode;
160 struct uintstate boundtexture;
161 struct ptrstate vertex_array;
162 struct ptrstate color_array;
163 struct ptrstate texture_coord_array;
164 struct ptrstate normal_array;
165 };
167 static struct nanotmuState tmuState0;
168 static struct nanotmuState tmuState1;
170 static struct nanotmuState tmuInitState =
172 {GL_FALSE, GL_FALSE},
173 {GL_MODULATE, GL_FALSE},
174 {0x7fffffff, GL_FALSE},
175 {4, GL_FLOAT, 0, NULL, GL_FALSE, GL_FALSE},
176 {4, GL_FLOAT, 0, NULL, GL_FALSE, GL_FALSE},
177 {4, GL_FLOAT, 0, NULL, GL_FALSE, GL_FALSE},
178 {3, GL_FLOAT, 0, NULL, GL_FALSE, GL_FALSE},
179 };
181 static struct nanotmuState *activetmuState = &tmuState0;
183 extern GlESInterface *glEsImpl;
185 static GLenum wrapperPrimitiveMode = GL_QUADS;
186 GLboolean useTexCoordArray = GL_FALSE;
187 static GLenum activetmu = GL_TEXTURE0;
188 static GLenum clientactivetmu = GL_TEXTURE0;
190 #if defined( __MULTITEXTURE_SUPPORT__ )
191 GLboolean useMultiTexCoordArray = GL_FALSE;
192 #endif
194 #if !defined( __WINS__ )
195 //#define __FORCEINLINE __forceinline
196 #define __FORCEINLINE inline
197 #else
198 #define __FORCEINLINE
199 #endif
201 static GLboolean delayedttmuchange = GL_FALSE;
202 static GLenum delayedtmutarget = GL_TEXTURE0;
204 struct VertexAttrib
206 float x;
207 float y;
208 float z;
209 #if !defined( __MULTITEXTURE_SUPPORT__ )
210 float padding;
211 #endif
212 unsigned char red;
213 unsigned char green;
214 unsigned char blue;
215 unsigned char alpha;
217 float s;
218 float t;
219 #if defined( __MULTITEXTURE_SUPPORT__ )
220 float s_multi;
221 float t_multi;
222 #endif
223 };
225 static VertexAttrib vertexattribs[60000];
227 static GLushort indexArray[50000];
229 static GLuint vertexCount = 0;
230 static GLuint indexCount = 0;
231 static GLuint vertexMark = 0;
232 static int indexbase = 0;
234 static VertexAttrib *ptrVertexAttribArray = NULL;
235 static VertexAttrib *ptrVertexAttribArrayMark = NULL;
237 static VertexAttrib currentVertexAttrib;
238 #if defined( __MULTITEXTURE_SUPPORT__ )
239 static VertexAttrib currentVertexAttribInit = {0.0f, 0.0f, 0.0f, 255, 255, 255, 255, 0.0f, 0.0f, 0.0f, 0.0f};
240 #else
241 static VertexAttrib currentVertexAttribInit = {
242 0.0f, 0.0f, 0.0f, 0.0f, 255, 255, 255, 255, 0.0f, 0.0f,
243 };
244 #endif
245 static GLushort *ptrIndexArray = NULL;
247 static GLboolean arraysValid = GL_FALSE;
249 static GLboolean skipnanogl;
251 void InitGLStructs( )
253 ptrVertexAttribArray = vertexattribs;
254 ptrVertexAttribArrayMark = ptrVertexAttribArray;
255 ptrIndexArray = indexArray;
257 memcpy( &nanoglState, &nanoglInitState, sizeof( struct nanoState ) );
258 memcpy( &tmuState0, &tmuInitState, sizeof( struct nanotmuState ) );
259 memcpy( &tmuState1, &tmuInitState, sizeof( struct nanotmuState ) );
260 memcpy( &currentVertexAttrib, &currentVertexAttribInit, sizeof( struct VertexAttrib ) );
262 activetmuState = &tmuState0;
263 wrapperPrimitiveMode = GL_QUADS;
264 useTexCoordArray = GL_FALSE;
265 activetmu = GL_TEXTURE0;
266 clientactivetmu = GL_TEXTURE0;
267 delayedttmuchange = GL_FALSE;
268 delayedtmutarget = GL_TEXTURE0;
269 vertexCount = 0;
270 indexCount = 0;
271 vertexMark = 0;
272 indexbase = 0;
273 arraysValid = GL_FALSE;
276 void ResetNanoState( )
279 if ( tmuState0.color_array.enabled )
281 glEsImpl->glEnableClientState( GL_COLOR_ARRAY );
283 else
285 glEsImpl->glDisableClientState( GL_COLOR_ARRAY );
288 if ( tmuState0.vertex_array.enabled )
290 glEsImpl->glEnableClientState( GL_VERTEX_ARRAY );
292 else
294 glEsImpl->glDisableClientState( GL_VERTEX_ARRAY );
297 if ( tmuState0.texture_coord_array.enabled )
299 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
301 else
303 glEsImpl->glDisableClientState( GL_TEXTURE_COORD_ARRAY );
306 if ( tmuState0.normal_array.enabled )
308 glEsImpl->glEnableClientState( GL_NORMAL_ARRAY );
310 else
312 glEsImpl->glDisableClientState( GL_NORMAL_ARRAY );
314 glEsImpl->glVertexPointer( tmuState0.vertex_array.size,
315 tmuState0.vertex_array.type,
316 tmuState0.vertex_array.stride,
317 tmuState0.vertex_array.ptr );
319 glEsImpl->glTexCoordPointer( tmuState0.texture_coord_array.size,
320 tmuState0.texture_coord_array.type,
321 tmuState0.texture_coord_array.stride,
322 tmuState0.texture_coord_array.ptr );
324 glEsImpl->glColorPointer( tmuState0.color_array.size,
325 tmuState0.color_array.type,
326 tmuState0.color_array.stride,
327 tmuState0.color_array.ptr );
329 glEsImpl->glNormalPointer(
330 tmuState0.normal_array.type,
331 tmuState0.normal_array.stride,
332 tmuState0.normal_array.ptr );
334 glEsImpl->glMatrixMode( nanoglState.matrixmode );
336 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
337 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
339 glEsImpl->glBlendFunc( nanoglState.sfactor, nanoglState.dfactor );
341 //glEsImpl->glBindTexture(GL_TEXTURE_2D, stackTextureState);
343 glEsImpl->glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, activetmuState->texture_env_mode.value );
345 arraysValid = GL_FALSE;
346 skipnanogl = GL_FALSE;
349 void FlushOnStateChange( )
351 if( skipnanogl )
352 return;
353 if ( delayedttmuchange )
355 delayedttmuchange = GL_FALSE;
356 #ifndef USE_CORE_PROFILE
357 glEsImpl->glActiveTexture( delayedtmutarget );
358 #endif
361 if ( !vertexCount )
362 return;
364 if ( !arraysValid )
366 glEsImpl->glClientActiveTexture( GL_TEXTURE0 );
367 glEsImpl->glVertexPointer( 3, GL_FLOAT, sizeof( VertexAttrib ), &vertexattribs[0].x );
368 glEsImpl->glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof( VertexAttrib ), &vertexattribs[0].red );
369 glEsImpl->glTexCoordPointer( 2, GL_FLOAT, sizeof( VertexAttrib ), &vertexattribs[0].s );
370 glEsImpl->glEnableClientState( GL_VERTEX_ARRAY );
371 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
372 glEsImpl->glEnableClientState( GL_COLOR_ARRAY );
373 #if defined( __MULTITEXTURE_SUPPORT__ )
374 glEsImpl->glClientActiveTexture( GL_TEXTURE1 );
375 glEsImpl->glTexCoordPointer( 2, GL_FLOAT, sizeof( VertexAttrib ), &vertexattribs[0].s_multi );
376 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
377 glEsImpl->glClientActiveTexture( GL_TEXTURE0 );
378 #endif
379 arraysValid = GL_TRUE;
382 glEsImpl->glDrawElements( GL_TRIANGLES, vertexCount, GL_UNSIGNED_SHORT, indexArray );
384 #if defined( __MULTITEXTURE_SUPPORT__ )
385 useMultiTexCoordArray = GL_FALSE;
386 #endif
387 vertexCount = 0;
388 indexCount = 0;
389 ptrVertexAttribArray = vertexattribs;
390 ptrVertexAttribArrayMark = ptrVertexAttribArray;
391 ptrIndexArray = indexArray;
392 useTexCoordArray = GL_FALSE;
394 void nanoGL_Flush( )
396 FlushOnStateChange( );
398 void nanoGL_Reset( )
400 ResetNanoState( );
402 void glBegin( GLenum mode )
404 wrapperPrimitiveMode = mode;
405 vertexMark = vertexCount;
406 ptrVertexAttribArrayMark = ptrVertexAttribArray;
407 indexbase = indexCount;
410 void glEnd( void )
412 vertexCount += ( (unsigned char *)ptrVertexAttribArray - (unsigned char *)ptrVertexAttribArrayMark ) / sizeof( VertexAttrib );
413 if ( vertexCount < 3 )
415 return;
417 switch ( wrapperPrimitiveMode )
419 case GL_QUADS:
421 *ptrIndexArray++ = indexCount;
422 *ptrIndexArray++ = indexCount + 1;
423 *ptrIndexArray++ = indexCount + 2;
424 *ptrIndexArray++ = indexCount;
425 *ptrIndexArray++ = indexCount + 2;
426 *ptrIndexArray++ = indexCount + 3;
427 indexCount += 4;
428 vertexCount += 2;
430 break;
431 case GL_TRIANGLES:
433 int vcount = ( vertexCount - vertexMark ) / 3;
434 for ( int count = 0; count < vcount; count++ )
436 *ptrIndexArray++ = indexCount;
437 *ptrIndexArray++ = indexCount + 1;
438 *ptrIndexArray++ = indexCount + 2;
439 indexCount += 3;
442 break;
443 case GL_TRIANGLE_STRIP:
445 *ptrIndexArray++ = indexCount;
446 *ptrIndexArray++ = indexCount + 1;
447 *ptrIndexArray++ = indexCount + 2;
448 indexCount += 3;
449 int vcount = ( ( vertexCount - vertexMark ) - 3 );
450 if ( vcount && ( (long)ptrIndexArray & 0x02 ) )
452 *ptrIndexArray++ = indexCount - 1; // 2
453 *ptrIndexArray++ = indexCount - 2; // 1
454 *ptrIndexArray++ = indexCount; // 3
455 indexCount++;
456 vcount -= 1;
457 int odd = vcount & 1;
458 vcount /= 2;
459 unsigned int *longptr = (unsigned int *)ptrIndexArray;
461 for ( int count = 0; count < vcount; count++ )
463 *( longptr++ ) = ( indexCount - 2 ) | ( ( indexCount - 1 ) << 16 );
464 *( longptr++ ) = ( indexCount ) | ( ( indexCount ) << 16 );
465 *( longptr++ ) = ( indexCount - 1 ) | ( ( indexCount + 1 ) << 16 );
466 indexCount += 2;
468 ptrIndexArray = (unsigned short *)( longptr );
469 if ( odd )
471 *ptrIndexArray++ = indexCount - 2; // 2
472 *ptrIndexArray++ = indexCount - 1; // 1
473 *ptrIndexArray++ = indexCount; // 3
474 indexCount++;
477 else
479 //already aligned
480 int odd = vcount & 1;
481 vcount /= 2;
482 unsigned int *longptr = (unsigned int *)ptrIndexArray;
484 for ( int count = 0; count < vcount; count++ )
486 *( longptr++ ) = ( indexCount - 1 ) | ( ( indexCount - 2 ) << 16 );
487 *( longptr++ ) = ( indexCount ) | ( ( indexCount - 1 ) << 16 );
488 *( longptr++ ) = ( indexCount ) | ( ( indexCount + 1 ) << 16 );
489 indexCount += 2;
491 ptrIndexArray = (unsigned short *)( longptr );
492 if ( odd )
495 *ptrIndexArray++ = indexCount - 1; // 2
496 *ptrIndexArray++ = indexCount - 2; // 1
497 *ptrIndexArray++ = indexCount; // 3
498 indexCount++;
501 vertexCount += ( vertexCount - vertexMark - 3 ) * 2;
503 break;
504 case GL_POLYGON:
505 case GL_TRIANGLE_FAN:
507 *ptrIndexArray++ = indexCount++;
508 *ptrIndexArray++ = indexCount++;
509 *ptrIndexArray++ = indexCount++;
510 int vcount = ( ( vertexCount - vertexMark ) - 3 );
511 for ( int count = 0; count < vcount; count++ )
513 *ptrIndexArray++ = indexbase;
514 *ptrIndexArray++ = indexCount - 1;
515 *ptrIndexArray++ = indexCount++;
516 vertexCount += 2;
519 break;
521 default:
522 break;
524 if ( ptrVertexAttribArray - vertexattribs > 20000 * sizeof( VertexAttrib ) ||
525 ptrIndexArray - indexArray > 15000 * sizeof( GLushort ) )
526 FlushOnStateChange( );
529 void glEnable( GLenum cap )
531 if( skipnanogl )
533 glEsImpl->glEnable( cap );
534 return;
536 GLboolean statechanged = GL_FALSE;
537 switch ( cap )
539 case GL_ALPHA_TEST:
541 if ( !nanoglState.alpha_test )
543 nanoglState.alpha_test = GL_TRUE;
544 statechanged = GL_TRUE;
546 break;
548 case GL_BLEND:
550 if ( !nanoglState.blend )
552 nanoglState.blend = GL_TRUE;
553 statechanged = GL_TRUE;
555 break;
557 //case GL_CLIP_PLANEi
558 case GL_COLOR_LOGIC_OP:
560 if ( !nanoglState.color_logic_op )
562 nanoglState.color_logic_op = GL_TRUE;
563 statechanged = GL_TRUE;
565 break;
567 case GL_COLOR_MATERIAL:
569 if ( !nanoglState.color_material )
571 nanoglState.color_material = GL_TRUE;
572 statechanged = GL_TRUE;
574 break;
576 case GL_CULL_FACE:
578 if ( !nanoglState.cull_face )
580 nanoglState.cull_face = GL_TRUE;
581 statechanged = GL_TRUE;
583 break;
585 case GL_DEPTH_TEST:
587 if ( !nanoglState.depth_test )
589 nanoglState.depth_test = GL_TRUE;
590 statechanged = GL_TRUE;
592 break;
594 case GL_DITHER:
596 if ( !nanoglState.dither )
598 nanoglState.dither = GL_TRUE;
599 statechanged = GL_TRUE;
601 break;
603 case GL_FOG:
605 if ( !nanoglState.fog )
607 nanoglState.fog = GL_TRUE;
608 statechanged = GL_TRUE;
610 break;
612 case GL_LIGHT0:
614 if ( !nanoglState.light0 )
616 nanoglState.light0 = GL_TRUE;
617 statechanged = GL_TRUE;
619 break;
621 case GL_LIGHT1:
623 if ( !nanoglState.light1 )
625 nanoglState.light1 = GL_TRUE;
626 statechanged = GL_TRUE;
628 break;
630 case GL_LIGHT2:
632 if ( !nanoglState.light2 )
634 nanoglState.light2 = GL_TRUE;
635 statechanged = GL_TRUE;
637 break;
639 case GL_LIGHT3:
641 if ( !nanoglState.light3 )
643 nanoglState.light3 = GL_TRUE;
644 statechanged = GL_TRUE;
646 break;
648 case GL_LIGHT4:
650 if ( !nanoglState.light4 )
652 nanoglState.light4 = GL_TRUE;
653 statechanged = GL_TRUE;
655 break;
657 case GL_LIGHT5:
659 if ( !nanoglState.light5 )
661 nanoglState.light5 = GL_TRUE;
662 statechanged = GL_TRUE;
664 break;
666 case GL_LIGHT6:
668 if ( !nanoglState.light6 )
670 nanoglState.light6 = GL_TRUE;
671 statechanged = GL_TRUE;
673 break;
675 case GL_LIGHT7:
677 if ( !nanoglState.light7 )
679 nanoglState.light7 = GL_TRUE;
680 statechanged = GL_TRUE;
682 break;
684 case GL_LIGHTING:
686 if ( !nanoglState.lighting )
688 nanoglState.lighting = GL_TRUE;
689 statechanged = GL_TRUE;
691 break;
693 case GL_LINE_SMOOTH:
695 if ( !nanoglState.line_smooth )
697 nanoglState.line_smooth = GL_TRUE;
698 statechanged = GL_TRUE;
700 break;
702 /* case GL_MATRIX_PALETTE_OES:
704 if (!nanoglState.matrix_palette_oes)
706 nanoglState.matrix_palette_oes = GL_TRUE;
707 statechanged = GL_TRUE;
709 break;
710 }*/
711 case GL_MULTISAMPLE:
713 if ( !nanoglState.multisample )
715 nanoglState.multisample = GL_TRUE;
716 statechanged = GL_TRUE;
718 break;
720 case GL_NORMALIZE:
722 if ( !nanoglState.normalize )
724 nanoglState.normalize = GL_TRUE;
725 statechanged = GL_TRUE;
727 break;
729 /* case GL_POINT_SPRITE_OES:
731 if (!nanoglState.point_sprite_oes)
733 nanoglState.point_sprite_oes = GL_TRUE;
734 statechanged = GL_TRUE;
736 break;
737 }*/
738 case GL_POLYGON_OFFSET_FILL:
740 if ( !nanoglState.polygon_offset_fill )
742 nanoglState.polygon_offset_fill = GL_TRUE;
743 statechanged = GL_TRUE;
745 break;
747 case GL_RESCALE_NORMAL:
749 if ( !nanoglState.rescale_normal )
751 nanoglState.rescale_normal = GL_TRUE;
752 statechanged = GL_TRUE;
754 break;
756 case GL_SAMPLE_ALPHA_TO_COVERAGE:
758 if ( !nanoglState.sample_alpha_to_coverage )
760 nanoglState.sample_alpha_to_coverage = GL_TRUE;
761 statechanged = GL_TRUE;
763 break;
765 case GL_SAMPLE_ALPHA_TO_ONE:
767 if ( !nanoglState.sample_alpha_to_one )
769 nanoglState.sample_alpha_to_one = GL_TRUE;
770 statechanged = GL_TRUE;
772 break;
774 case GL_SAMPLE_COVERAGE:
776 if ( !nanoglState.sample_coverage )
778 nanoglState.sample_coverage = GL_TRUE;
779 statechanged = GL_TRUE;
781 break;
783 case GL_SCISSOR_TEST:
785 if ( !nanoglState.scissor_test )
787 nanoglState.scissor_test = GL_TRUE;
788 statechanged = GL_TRUE;
790 break;
792 case GL_STENCIL_TEST:
794 return;
795 if (!nanoglState.stencil_test)
797 nanoglState.stencil_test = GL_TRUE;
798 statechanged = GL_TRUE;
800 break;
802 case GL_TEXTURE_2D:
804 if ( !activetmuState->texture_2d.value )
806 FlushOnStateChange( );
807 glEsImpl->glEnable( cap );
808 activetmuState->texture_2d.value = GL_TRUE;
809 return;
811 break;
813 #if 0 // todo: implement cubemap texgen
814 case GL_TEXTURE_GEN_S:
815 case GL_TEXTURE_GEN_T:
816 case GL_TEXTURE_GEN_R:
817 case GL_TEXTURE_GEN_Q:
819 FlushOnStateChange( );
820 nanoglState.texgen = true;
821 return;
823 #endif
824 default:
825 break;
828 if ( statechanged )
830 FlushOnStateChange( );
831 glEsImpl->glEnable( cap );
835 void glDisable( GLenum cap )
837 if( skipnanogl )
839 glEsImpl->glDisable( cap );
840 return;
842 GLboolean statechanged = GL_FALSE;
843 switch ( cap )
845 case GL_ALPHA_TEST:
847 if ( nanoglState.alpha_test )
849 nanoglState.alpha_test = GL_FALSE;
850 statechanged = GL_TRUE;
852 break;
854 case GL_BLEND:
856 if ( nanoglState.blend )
858 nanoglState.blend = GL_FALSE;
859 statechanged = GL_TRUE;
861 break;
863 //case GL_CLIP_PLANEi
864 case GL_COLOR_LOGIC_OP:
866 if ( nanoglState.color_logic_op )
868 nanoglState.color_logic_op = GL_FALSE;
869 statechanged = GL_TRUE;
871 break;
873 case GL_COLOR_MATERIAL:
875 if ( nanoglState.color_material )
877 nanoglState.color_material = GL_FALSE;
878 statechanged = GL_TRUE;
880 break;
882 case GL_CULL_FACE:
884 if ( nanoglState.cull_face )
886 nanoglState.cull_face = GL_FALSE;
887 statechanged = GL_TRUE;
889 break;
891 case GL_DEPTH_TEST:
893 if ( nanoglState.depth_test )
895 nanoglState.depth_test = GL_FALSE;
896 statechanged = GL_TRUE;
898 break;
900 case GL_DITHER:
902 if ( nanoglState.dither )
904 nanoglState.dither = GL_FALSE;
905 statechanged = GL_TRUE;
907 break;
909 case GL_FOG:
911 if ( nanoglState.fog )
913 nanoglState.fog = GL_FALSE;
914 statechanged = GL_TRUE;
916 break;
918 case GL_LIGHT0:
920 if ( !nanoglState.light0 )
922 nanoglState.light0 = GL_FALSE;
923 statechanged = GL_TRUE;
925 break;
927 case GL_LIGHT1:
929 if ( !nanoglState.light1 )
931 nanoglState.light1 = GL_FALSE;
932 statechanged = GL_TRUE;
934 break;
936 case GL_LIGHT2:
938 if ( !nanoglState.light2 )
940 nanoglState.light2 = GL_FALSE;
941 statechanged = GL_TRUE;
943 break;
945 case GL_LIGHT3:
947 if ( !nanoglState.light3 )
949 nanoglState.light3 = GL_FALSE;
950 statechanged = GL_TRUE;
952 break;
954 case GL_LIGHT4:
956 if ( !nanoglState.light4 )
958 nanoglState.light4 = GL_FALSE;
959 statechanged = GL_TRUE;
961 break;
963 case GL_LIGHT5:
965 if ( !nanoglState.light5 )
967 nanoglState.light5 = GL_FALSE;
968 statechanged = GL_TRUE;
970 break;
972 case GL_LIGHT6:
974 if ( !nanoglState.light6 )
976 nanoglState.light6 = GL_FALSE;
977 statechanged = GL_TRUE;
979 break;
981 case GL_LIGHT7:
983 if ( !nanoglState.light7 )
985 nanoglState.light7 = GL_FALSE;
986 statechanged = GL_TRUE;
988 break;
990 case GL_LIGHTING:
992 if ( nanoglState.lighting )
994 nanoglState.lighting = GL_FALSE;
995 statechanged = GL_TRUE;
997 break;
999 case GL_LINE_SMOOTH:
1001 if ( nanoglState.line_smooth )
1003 nanoglState.line_smooth = GL_FALSE;
1004 statechanged = GL_TRUE;
1006 break;
1008 /* case GL_MATRIX_PALETTE_OES:
1010 if (nanoglState.matrix_palette_oes)
1012 nanoglState.matrix_palette_oes = GL_FALSE;
1013 statechanged = GL_TRUE;
1015 break;
1016 }*/
1017 case GL_MULTISAMPLE:
1019 if ( nanoglState.multisample )
1021 nanoglState.multisample = GL_FALSE;
1022 statechanged = GL_TRUE;
1024 break;
1026 case GL_NORMALIZE:
1028 if ( nanoglState.normalize )
1030 nanoglState.normalize = GL_FALSE;
1031 statechanged = GL_TRUE;
1033 break;
1035 /* case GL_POINT_SPRITE_OES:
1037 if (nanoglState.point_sprite_oes)
1039 nanoglState.point_sprite_oes = GL_FALSE;
1040 statechanged = GL_TRUE;
1042 break;
1043 }*/
1044 case GL_POLYGON_OFFSET_FILL:
1046 if ( nanoglState.polygon_offset_fill )
1048 nanoglState.polygon_offset_fill = GL_FALSE;
1049 statechanged = GL_TRUE;
1051 break;
1053 case GL_RESCALE_NORMAL:
1055 if ( nanoglState.rescale_normal )
1057 nanoglState.rescale_normal = GL_FALSE;
1058 statechanged = GL_TRUE;
1060 break;
1062 case GL_SAMPLE_ALPHA_TO_COVERAGE:
1064 if ( nanoglState.sample_alpha_to_coverage )
1066 nanoglState.sample_alpha_to_coverage = GL_FALSE;
1067 statechanged = GL_TRUE;
1069 break;
1071 case GL_SAMPLE_ALPHA_TO_ONE:
1073 if ( nanoglState.sample_alpha_to_one )
1075 nanoglState.sample_alpha_to_one = GL_FALSE;
1076 statechanged = GL_TRUE;
1078 break;
1080 case GL_SAMPLE_COVERAGE:
1082 if ( nanoglState.sample_coverage )
1084 nanoglState.sample_coverage = GL_FALSE;
1085 statechanged = GL_TRUE;
1087 break;
1089 case GL_SCISSOR_TEST:
1091 if ( nanoglState.scissor_test )
1093 nanoglState.scissor_test = GL_FALSE;
1094 statechanged = GL_TRUE;
1096 break;
1098 case GL_STENCIL_TEST:
1100 return;
1101 if (nanoglState.stencil_test)
1103 nanoglState.stencil_test = GL_FALSE;
1104 statechanged = GL_TRUE;
1106 break;
1108 case GL_TEXTURE_2D:
1110 if ( activetmuState->texture_2d.value )
1112 FlushOnStateChange( );
1113 glEsImpl->glDisable( cap );
1114 activetmuState->texture_2d.value = GL_FALSE;
1115 return;
1117 break;
1119 #if 0
1120 case GL_TEXTURE_GEN_S:
1121 case GL_TEXTURE_GEN_T:
1122 case GL_TEXTURE_GEN_R:
1123 case GL_TEXTURE_GEN_Q:
1125 FlushOnStateChange( );
1126 nanoglState.texgen = false;
1127 return;
1129 #endif
1130 default:
1131 break;
1134 if ( statechanged )
1136 FlushOnStateChange( );
1137 glEsImpl->glDisable( cap );
1141 void glVertex2f( GLfloat x, GLfloat y )
1143 glVertex3f( x, y, 0.0f );
1146 __FORCEINLINE unsigned int ClampTo255( float value )
1148 unsigned int retval = (unsigned int)( value );
1149 if ( retval > 255 )
1151 retval = 255;
1153 return retval;
1156 void glColor3f( GLfloat red, GLfloat green, GLfloat blue )
1158 currentVertexAttrib.red = (unsigned char)ClampTo255( red * 255.0f );
1159 currentVertexAttrib.green = (unsigned char)ClampTo255( green * 255.0f );
1160 currentVertexAttrib.blue = (unsigned char)ClampTo255( blue * 255.0f );
1161 currentVertexAttrib.alpha = 255;
1164 void glTexCoord2fv( const GLfloat *v )
1166 memcpy( &currentVertexAttrib.s, v, 2 * sizeof( float ) );
1169 void glTexCoord2f( GLfloat s, GLfloat t )
1171 currentVertexAttrib.s = s;
1172 currentVertexAttrib.t = t;
1175 void glViewport( GLint x, GLint y, GLsizei width, GLsizei height )
1177 FlushOnStateChange( );
1178 glEsImpl->glViewport( x, y, width, height );
1181 void glLoadIdentity( void )
1183 FlushOnStateChange( );
1184 glEsImpl->glLoadIdentity( );
1187 void glColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
1188 {
1189 if( nanoglState.stupidglesbug )
1191 currentVertexAttrib.red = (unsigned char)ClampTo255( ( red * alpha ) * 255.0f );
1192 currentVertexAttrib.green = (unsigned char)ClampTo255( ( green * alpha ) * 255.0f );
1193 currentVertexAttrib.blue = (unsigned char)ClampTo255( ( blue * alpha ) * 255.0f );
1195 else
1197 currentVertexAttrib.red = (unsigned char)ClampTo255( red * 255.0f );
1198 currentVertexAttrib.green = (unsigned char)ClampTo255( green * 255.0f );
1199 currentVertexAttrib.blue = (unsigned char)ClampTo255( blue * 255.0f );
1201 currentVertexAttrib.alpha = (unsigned char)ClampTo255( alpha * 255.0f );
1204 void glOrtho( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar )
1206 FlushOnStateChange( );
1207 #ifdef USE_CORE_PROFILE
1208 glEsImpl->glOrtho( left, right, bottom, top, zNear, zFar );
1209 #else
1210 glEsImpl->glOrthof( left, right, bottom, top, zNear, zFar );
1211 #endif
1214 // Rikku2000: Light
1215 void glLightf( GLenum light, GLenum pname, GLfloat param )
1217 FlushOnStateChange( );
1219 glEsImpl->glLightf( light, pname, param );
1221 void glLightfv( GLenum light, GLenum pname, const GLfloat *params )
1223 FlushOnStateChange( );
1225 glEsImpl->glLightfv( light, pname, params );
1227 void glLightModelf( GLenum pname, GLfloat param )
1229 FlushOnStateChange( );
1231 glEsImpl->glLightModelf( pname, param );
1233 void glLightModelfv( GLenum pname, const GLfloat *params )
1235 FlushOnStateChange( );
1237 glEsImpl->glLightModelfv( pname, params );
1239 void glMaterialf( GLenum face, GLenum pname, GLfloat param )
1241 FlushOnStateChange( );
1243 glEsImpl->glMaterialf( face, pname, param );
1245 void glMaterialfv( GLenum face, GLenum pname, const GLfloat *params )
1247 FlushOnStateChange( );
1249 glEsImpl->glMaterialfv( face, pname, params );
1251 void glColorMaterial( GLenum face, GLenum mode )
1253 FlushOnStateChange( );
1255 glEsImpl->glColorMaterial( face, mode );
1258 void glMatrixMode( GLenum mode )
1260 if ( nanoglState.matrixmode == mode )
1262 return;
1264 nanoglState.matrixmode = mode;
1265 FlushOnStateChange( );
1266 glEsImpl->glMatrixMode( mode );
1269 void glTexParameterf( GLenum target, GLenum pname, GLfloat param )
1271 if ( pname == GL_TEXTURE_BORDER_COLOR )
1273 return; // not supported by opengl es
1275 if ( ( pname == GL_TEXTURE_WRAP_S ||
1276 pname == GL_TEXTURE_WRAP_T ) &&
1277 param == GL_CLAMP )
1279 param = 0x812F;
1282 FlushOnStateChange( );
1283 glEsImpl->glTexParameterf( target, pname, param );
1286 void glTexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
1288 glTexParameterf( target, pname, params[0] );
1291 void glTexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
1293 FlushOnStateChange( );
1294 internalformat = format;
1295 glEsImpl->glTexImage2D( target, level, internalformat, width, height, border, format, type, pixels );
1298 void glDrawBuffer( GLenum /*mode*/ )
1302 void glTranslatef( GLfloat x, GLfloat y, GLfloat z )
1304 FlushOnStateChange( );
1305 glEsImpl->glTranslatef( x, y, z );
1308 void glRotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
1310 FlushOnStateChange( );
1311 glEsImpl->glRotatef( angle, x, y, z );
1314 void glScalef( GLfloat x, GLfloat y, GLfloat z )
1316 FlushOnStateChange( );
1317 glEsImpl->glScalef( x, y, z );
1320 void glDepthRange( GLclampf zNear, GLclampf zFar )
1322 if ( ( nanoglState.depth_range_near == zNear ) && ( nanoglState.depth_range_far == zFar ) )
1324 return;
1326 else
1328 nanoglState.depth_range_near = zNear;
1329 nanoglState.depth_range_far = zFar;
1331 FlushOnStateChange( );
1332 #ifdef USE_CORE_PROFILE
1333 glEsImpl->glDepthRange( zNear, zFar );
1334 #else
1335 glEsImpl->glDepthRangef( zNear, zFar );
1336 #endif
1339 void glDepthFunc( GLenum func )
1341 if ( nanoglState.depth_func == func )
1343 return;
1345 else
1347 nanoglState.depth_func = func;
1349 FlushOnStateChange( );
1350 glEsImpl->glDepthFunc( func );
1353 void glFinish( void )
1355 FlushOnStateChange( );
1356 glEsImpl->glFinish( );
1359 void glGetFloatv( GLenum pname, GLfloat *params )
1361 FlushOnStateChange( );
1362 glEsImpl->glGetFloatv( pname, params );
1365 void glCullFace( GLenum mode )
1367 if ( nanoglState.cullface == mode )
1369 return;
1371 else
1373 nanoglState.cullface = mode;
1375 FlushOnStateChange( );
1376 glEsImpl->glCullFace( mode );
1379 void glFrustum( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar )
1381 FlushOnStateChange( );
1382 glEsImpl->glFrustumf( left, right, bottom, top, zNear, zFar );
1385 void glClear( GLbitfield mask )
1387 FlushOnStateChange( );
1388 glEsImpl->glClear( mask );
1391 void glVertex3f( GLfloat x, GLfloat y, GLfloat z )
1393 GLfloat *vert = (GLfloat *)ptrVertexAttribArray++;
1394 *vert++ = x;
1395 *vert++ = y;
1396 *vert++ = z;
1397 #if defined( __MULTITEXTURE_SUPPORT__ )
1398 memcpy( vert, &currentVertexAttrib.red, 5 * sizeof( GLfloat ) );
1399 #else
1400 memcpy( vert + 1, &currentVertexAttrib.red, 3 * sizeof( GLfloat ) );
1401 #endif
1404 void glColor4fv( const GLfloat *v )
1405 {
1406 if( nanoglState.stupidglesbug )
1408 currentVertexAttrib.red = (unsigned char)ClampTo255( ( v[0] * v[3] ) * 255.0f );
1409 currentVertexAttrib.green = (unsigned char)ClampTo255( ( v[1] * v[3] ) * 255.0f );
1410 currentVertexAttrib.blue = (unsigned char)ClampTo255( ( v[2] * v[3] ) * 255.0f );
1412 else
1414 currentVertexAttrib.red = (unsigned char)ClampTo255( v[0] * 255.0f );
1415 currentVertexAttrib.green = (unsigned char)ClampTo255( v[1] * 255.0f );
1416 currentVertexAttrib.blue = (unsigned char)ClampTo255( v[2] * 255.0f );
1418 currentVertexAttrib.alpha = (unsigned char)ClampTo255( v[3] * 255.0f );
1419 if( skipnanogl )
1420 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
1421 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
1424 void glColor3ubv( const GLubyte *v )
1426 currentVertexAttrib.red = v[0];
1427 currentVertexAttrib.green = v[1];
1428 currentVertexAttrib.blue = v[2];
1429 currentVertexAttrib.alpha = 255;
1430 if( skipnanogl )
1431 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
1432 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
1435 void glColor4ubv( const GLubyte *v )
1437 //*((unsigned int*)(&currentVertexAttrib.red)) = *((unsigned int*)(v));
1438 if( nanoglState.stupidglesbug )
1440 currentVertexAttrib.red = (unsigned char)ClampTo255( v[0] * v[3] / 255.0f );
1441 currentVertexAttrib.green = (unsigned char)ClampTo255( v[1] * v[3] / 255.0f );
1442 currentVertexAttrib.blue = (unsigned char)ClampTo255( v[2] * v[3] / 255.0f );
1444 else
1446 currentVertexAttrib.red = v[0];
1447 currentVertexAttrib.green = v[1];
1448 currentVertexAttrib.blue = v[2];
1450 currentVertexAttrib.alpha = v[3];
1451 if( skipnanogl )
1452 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
1453 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
1456 void glColor3fv( const GLfloat *v )
1458 currentVertexAttrib.red = (unsigned char)ClampTo255( v[0] * 255.0f );
1459 currentVertexAttrib.green = (unsigned char)ClampTo255( v[1] * 255.0f );
1460 currentVertexAttrib.blue = (unsigned char)ClampTo255( v[2] * 255.0f );
1461 currentVertexAttrib.alpha = 255;
1462 if( skipnanogl )
1463 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
1464 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
1467 //-- nicknekit: xash3d funcs --
1469 void glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha )
1471 if( nanoglState.stupidglesbug )
1473 currentVertexAttrib.red = (unsigned char)ClampTo255( red * alpha / 255.0f );
1474 currentVertexAttrib.green = (unsigned char)ClampTo255( green * alpha / 255.0f );
1475 currentVertexAttrib.blue = (unsigned char)ClampTo255( blue * alpha / 255.0f );
1477 else
1479 currentVertexAttrib.red = red;
1480 currentVertexAttrib.green = green;
1481 currentVertexAttrib.blue = blue;
1483 currentVertexAttrib.alpha = alpha;
1484 if( skipnanogl )
1485 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
1486 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
1489 void glColor3ub( GLubyte red, GLubyte green, GLubyte blue )
1491 currentVertexAttrib.red = red;
1492 currentVertexAttrib.green = green;
1493 currentVertexAttrib.blue = blue;
1494 currentVertexAttrib.alpha = 255;
1495 if( skipnanogl )
1496 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
1497 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
1500 void glNormal3fv( const GLfloat *v )
1502 FlushOnStateChange( );
1503 glEsImpl->glNormal3f( v[0], v[1], v[2] );
1506 void glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border )
1508 FlushOnStateChange( );
1509 glEsImpl->glCopyTexImage2D( target, level, internalformat, x, y, width, height, border );
1512 void glTexImage1D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
1514 glTexImage2D( GL_TEXTURE_2D, level, internalformat, width, 1, border, format, type, pixels );
1517 void glTexImage3D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
1519 glTexImage2D( GL_TEXTURE_2D, level, internalformat, width, height, border, format, type, pixels );
1522 void glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels )
1524 glTexSubImage2D( target, level, xoffset, 0, width, 1, format, type, pixels );
1527 void glTexSubImage3D( GLenum target, GLint level,
1528 GLint xoffset, GLint yoffset,
1529 GLint zoffset, GLsizei width,
1530 GLsizei height, GLsizei depth,
1531 GLenum format,
1532 GLenum type, const GLvoid *pixels )
1534 glTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels );
1537 GLboolean glIsTexture( GLuint texture )
1539 FlushOnStateChange( );
1540 return glEsImpl->glIsTexture( texture );
1543 // TODO: add native normal/reflection map texgen support
1545 void glTexGeni( GLenum coord, GLenum pname, GLint param )
1547 FlushOnStateChange();
1548 //glEsImpl->glTexGeniOES( coord, pname, param );
1551 void glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
1553 FlushOnStateChange();
1554 //glEsImpl->glTexGenfvOES( coord, pname, params );
1557 //-- --//
1559 void glHint( GLenum target, GLenum mode )
1561 FlushOnStateChange( );
1562 glEsImpl->glHint( target, mode );
1565 void glBlendFunc( GLenum sfactor, GLenum dfactor )
1567 if( skipnanogl )
1569 glEsImpl->glBlendFunc( sfactor, dfactor );
1570 return;
1572 if ( ( nanoglState.sfactor == sfactor ) && ( nanoglState.dfactor == dfactor ) )
1574 return;
1577 if( sfactor == GL_SRC_ALPHA && dfactor == GL_ONE )
1579 sfactor = GL_ONE; // workaround gles bug
1580 nanoglState.stupidglesbug = GL_TRUE;
1582 else
1583 nanoglState.stupidglesbug = GL_FALSE;
1585 nanoglState.sfactor = sfactor;
1586 nanoglState.dfactor = dfactor;
1587 FlushOnStateChange( );
1588 glEsImpl->glBlendFunc( sfactor, dfactor );
1591 void glPopMatrix( void )
1593 FlushOnStateChange( );
1594 glEsImpl->glPopMatrix( );
1597 void glShadeModel( GLenum mode )
1599 if ( nanoglState.shademodel == mode )
1601 return;
1603 nanoglState.shademodel = mode;
1604 FlushOnStateChange( );
1605 glEsImpl->glShadeModel( mode );
1608 void glPushMatrix( void )
1610 FlushOnStateChange( );
1611 glEsImpl->glPushMatrix( );
1614 void glTexEnvf( GLenum target, GLenum pname, GLfloat param )
1616 if( skipnanogl )
1618 glEsImpl->glTexEnvf( target, pname, param );
1619 return;
1621 if ( target == GL_TEXTURE_ENV )
1623 if ( pname == GL_TEXTURE_ENV_MODE )
1625 if ( param == activetmuState->texture_env_mode.value )
1627 return;
1629 else
1631 FlushOnStateChange( );
1632 glEsImpl->glTexEnvf( target, pname, param );
1633 activetmuState->texture_env_mode.value = param;
1634 return;
1638 FlushOnStateChange( );
1639 glEsImpl->glTexEnvf( target, pname, param );
1642 void glVertex3fv( const GLfloat *v )
1644 GLfloat *vert = (GLfloat *)ptrVertexAttribArray++;
1645 memcpy( vert, v, 3 * sizeof( GLfloat ) );
1646 #if defined( __MULTITEXTURE_SUPPORT__ )
1647 memcpy( vert + 3, &currentVertexAttrib.red, 5 * sizeof( GLfloat ) );
1648 #else
1649 memcpy( vert + 4, &currentVertexAttrib.red, 3 * sizeof( GLfloat ) );
1650 #endif
1653 void glDepthMask( GLboolean flag )
1655 if( !skipnanogl )
1657 if ( nanoglState.depthmask == flag )
1659 return;
1661 nanoglState.depthmask = flag;
1662 FlushOnStateChange( );
1664 glEsImpl->glDepthMask( flag );
1667 void glBindTexture( GLenum target, GLuint texture )
1669 if( skipnanogl )
1671 glEsImpl->glBindTexture( target,texture );
1672 return;
1674 if ( activetmuState->boundtexture.value == texture )
1676 return;
1678 FlushOnStateChange( );
1679 activetmuState->boundtexture.value = texture;
1680 glEsImpl->glBindTexture( target, texture );
1683 void glGetIntegerv( GLenum pname, GLint *params )
1685 FlushOnStateChange( );
1686 glEsImpl->glGetIntegerv( pname, params );
1689 GLubyte nano_extensions_string[4096];
1690 const GLubyte *glGetString( GLenum name )
1693 if ( name == GL_EXTENSIONS )
1695 #if defined( __MULTITEXTURE_SUPPORT__ )
1696 sprintf( (char *)nano_extensions_string, "%s %s", glEsImpl->glGetString( name ), "GL_ARB_multitexture EXT_texture_env_add" );
1697 #else
1698 sprintf( (char *)nano_extensions_string, "%s %s", glEsImpl->glGetString( name ), "EXT_texture_env_add" );
1699 #endif
1700 return nano_extensions_string;
1702 return glEsImpl->glGetString( name );
1705 void glAlphaFunc( GLenum func, GLclampf ref )
1707 FlushOnStateChange( );
1708 glEsImpl->glAlphaFunc( func, ref );
1711 void glFlush( void )
1713 FlushOnStateChange( );
1714 glEsImpl->glFlush( );
1717 void glReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels )
1719 if ( format == GL_DEPTH_COMPONENT )
1721 // OpenglEs 1.1 does not support reading depth buffer without an extension
1722 memset( pixels, 0xff, 4 );
1723 return;
1725 FlushOnStateChange( );
1726 glEsImpl->glReadPixels( x, y, width, height, format, type, pixels );
1729 void glReadBuffer( GLenum /*mode*/ )
1733 void glLoadMatrixf( const GLfloat *m )
1735 FlushOnStateChange( );
1736 glEsImpl->glLoadMatrixf( m );
1739 void glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels )
1741 FlushOnStateChange( );
1742 glEsImpl->glTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels );
1745 void glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
1747 FlushOnStateChange( );
1748 glEsImpl->glClearColor( red, green, blue, alpha );
1751 GLenum glGetError( void )
1753 //FlushOnStateChange();
1754 return GL_NO_ERROR; //glEsImpl->glGetError();
1757 void glActiveTexture( GLenum texture )
1759 if( skipnanogl )
1761 glEsImpl->glActiveTexture( texture );
1762 return;
1764 if ( activetmu == texture )
1766 return;
1768 if ( delayedttmuchange )
1770 delayedttmuchange = GL_FALSE;
1772 else
1774 delayedttmuchange = GL_TRUE;
1775 delayedtmutarget = texture;
1777 if ( texture == GL_TEXTURE0 )
1779 activetmuState = &tmuState0;
1781 else
1783 activetmuState = &tmuState1;
1785 activetmu = texture;
1788 void glClientActiveTexture( GLenum texture )
1790 if( skipnanogl )
1792 glEsImpl->glClientActiveTexture( texture );
1793 return;
1795 clientactivetmu = texture;
1798 void glPolygonMode( GLenum face, GLenum mode )
1802 void glDeleteTextures( GLsizei n, const GLuint *textures )
1804 FlushOnStateChange( );
1805 glEsImpl->glDeleteTextures( n, textures );
1808 void glClearDepth( GLclampf depth )
1810 FlushOnStateChange( );
1811 glEsImpl->glClearDepthf( depth );
1814 void glClipPlane( GLenum plane, const GLdouble *equation )
1816 FlushOnStateChange( );
1817 float array[4];
1818 array[0] = ( GLfloat )( equation[0] );
1819 array[1] = ( GLfloat )( equation[1] );
1820 array[2] = ( GLfloat )( equation[2] );
1821 array[3] = ( GLfloat )( equation[3] );
1822 glEsImpl->glClipPlanef( plane, array );
1825 void glScissor( GLint x, GLint y, GLsizei width, GLsizei height )
1827 FlushOnStateChange( );
1828 glEsImpl->glScissor( x, y, width, height );
1831 void glPointSize( GLfloat size )
1833 FlushOnStateChange( );
1834 glEsImpl->glPointSize( size );
1837 void glArrayElement( GLint i )
1840 void glLineWidth( GLfloat width )
1843 void glCallList( GLuint list )
1846 void glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha )
1849 void glStencilFunc( GLenum func, GLint ref, GLuint mask )
1852 void glStencilOp( GLenum fail, GLenum zfail, GLenum zpass )
1856 struct ptrstate vertex_array;
1857 struct ptrstate color_array;
1858 struct ptrstate texture_coord_array;
1860 void glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices )
1862 if( skipnanogl )
1864 glEsImpl->glDrawElements( mode, count, type, indices );
1865 return;
1867 // ensure that all primitives specified between glBegin/glEnd pairs
1868 // are rendered first, and that we have correct tmu in use..
1869 FlushOnStateChange( );
1870 // setup correct vertex/color/texcoord pointers
1871 if ( arraysValid ||
1872 tmuState0.vertex_array.changed ||
1873 tmuState0.color_array.changed ||
1874 tmuState0.texture_coord_array.changed || tmuState0.normal_array.changed )
1876 glEsImpl->glClientActiveTexture( GL_TEXTURE0 );
1878 if ( arraysValid || tmuState0.vertex_array.changed )
1880 if ( tmuState0.vertex_array.enabled )
1882 glEsImpl->glEnableClientState( GL_VERTEX_ARRAY );
1884 else
1886 glEsImpl->glDisableClientState( GL_VERTEX_ARRAY );
1888 glEsImpl->glVertexPointer( tmuState0.vertex_array.size,
1889 tmuState0.vertex_array.type,
1890 tmuState0.vertex_array.stride,
1891 tmuState0.vertex_array.ptr );
1892 tmuState0.vertex_array.changed = GL_FALSE;
1894 if ( arraysValid || tmuState0.color_array.changed )
1896 if ( tmuState0.color_array.enabled )
1898 glEsImpl->glEnableClientState( GL_COLOR_ARRAY );
1900 else
1902 glEsImpl->glDisableClientState( GL_COLOR_ARRAY );
1904 glEsImpl->glColorPointer( tmuState0.color_array.size,
1905 tmuState0.color_array.type,
1906 tmuState0.color_array.stride,
1907 tmuState0.color_array.ptr );
1908 tmuState0.color_array.changed = GL_FALSE;
1910 if ( arraysValid || tmuState0.normal_array.changed )
1912 if ( tmuState0.normal_array.enabled )
1914 glEsImpl->glEnableClientState( GL_NORMAL_ARRAY );
1916 else
1918 glEsImpl->glDisableClientState( GL_NORMAL_ARRAY );
1920 glEsImpl->glNormalPointer( tmuState0.normal_array.type,
1921 tmuState0.normal_array.stride,
1922 tmuState0.normal_array.ptr );
1923 tmuState0.normal_array.changed = GL_FALSE;
1925 if ( arraysValid || tmuState0.texture_coord_array.changed )
1927 tmuState0.texture_coord_array.changed = GL_FALSE;
1928 if ( tmuState0.texture_coord_array.enabled )
1930 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
1932 else
1934 glEsImpl->glDisableClientState( GL_TEXTURE_COORD_ARRAY );
1936 glEsImpl->glTexCoordPointer( tmuState0.texture_coord_array.size,
1937 tmuState0.texture_coord_array.type,
1938 tmuState0.texture_coord_array.stride,
1939 tmuState0.texture_coord_array.ptr );
1942 if ( arraysValid || tmuState1.texture_coord_array.changed )
1944 tmuState1.texture_coord_array.changed = GL_FALSE;
1945 glEsImpl->glClientActiveTexture( GL_TEXTURE1 );
1946 if ( tmuState1.texture_coord_array.enabled )
1948 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
1950 else
1952 glEsImpl->glDisableClientState( GL_TEXTURE_COORD_ARRAY );
1954 glEsImpl->glTexCoordPointer( tmuState1.texture_coord_array.size,
1955 tmuState1.texture_coord_array.type,
1956 tmuState1.texture_coord_array.stride,
1957 tmuState1.texture_coord_array.ptr );
1960 arraysValid = GL_FALSE;
1961 glEsImpl->glDrawElements( mode, count, type, indices );
1964 bool vboarray;
1966 void glEnableClientState( GLenum array )
1968 if( skipnanogl )
1970 glEsImpl->glEnableClientState( array );
1971 if( array == GL_VERTEX_ARRAY )
1972 vboarray = true;
1973 return;
1975 struct nanotmuState *clientstate = NULL;
1976 if ( clientactivetmu == GL_TEXTURE0 )
1978 clientstate = &tmuState0;
1980 else if ( clientactivetmu == GL_TEXTURE1 )
1982 clientstate = &tmuState1;
1984 else
1986 return;
1988 switch ( array )
1990 case GL_VERTEX_ARRAY:
1991 if ( clientstate->vertex_array.enabled )
1993 return;
1995 clientstate->vertex_array.enabled = GL_TRUE;
1996 clientstate->vertex_array.changed = GL_TRUE;
1997 break;
1998 case GL_COLOR_ARRAY:
1999 if ( clientstate->color_array.enabled )
2001 return;
2003 clientstate->color_array.enabled = GL_TRUE;
2004 clientstate->color_array.changed = GL_TRUE;
2006 break;
2007 case GL_NORMAL_ARRAY:
2008 if ( clientstate->normal_array.enabled )
2010 return;
2012 clientstate->normal_array.enabled = GL_TRUE;
2013 clientstate->normal_array.changed = GL_TRUE;
2015 break;
2016 case GL_TEXTURE_COORD_ARRAY:
2017 if ( clientstate->texture_coord_array.enabled )
2019 return;
2021 clientstate->texture_coord_array.enabled = GL_TRUE;
2022 clientstate->texture_coord_array.changed = GL_TRUE;
2023 break;
2024 default:
2025 break;
2028 void glDisableClientState( GLenum array )
2030 if( skipnanogl )
2032 glEsImpl->glDisableClientState( array );
2033 if( array == GL_VERTEX_ARRAY )
2034 vboarray = false;
2035 return;
2037 struct nanotmuState *clientstate = NULL;
2038 if ( clientactivetmu == GL_TEXTURE0 )
2040 clientstate = &tmuState0;
2042 else if ( clientactivetmu == GL_TEXTURE1 )
2044 clientstate = &tmuState1;
2046 else
2048 return;
2050 switch ( array )
2052 case GL_VERTEX_ARRAY:
2053 if ( !clientstate->vertex_array.enabled )
2055 return;
2057 clientstate->vertex_array.enabled = GL_FALSE;
2058 clientstate->vertex_array.changed = GL_TRUE;
2059 break;
2060 case GL_COLOR_ARRAY:
2061 if ( !clientstate->color_array.enabled )
2063 return;
2065 clientstate->color_array.enabled = GL_FALSE;
2066 clientstate->color_array.changed = GL_TRUE;
2068 break;
2069 case GL_NORMAL_ARRAY:
2070 if ( !clientstate->normal_array.enabled )
2072 return;
2074 clientstate->normal_array.enabled = GL_FALSE;
2075 clientstate->normal_array.changed = GL_TRUE;
2077 break;
2078 case GL_TEXTURE_COORD_ARRAY:
2079 if ( !clientstate->texture_coord_array.enabled )
2081 return;
2083 clientstate->texture_coord_array.enabled = GL_FALSE;
2084 clientstate->texture_coord_array.changed = GL_TRUE;
2085 break;
2086 default:
2087 break;
2090 void glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
2093 if( skipnanogl )
2095 glEsImpl->glVertexPointer( size, type, stride, pointer );
2096 return;
2098 if ( tmuState0.vertex_array.size == size &&
2099 tmuState0.vertex_array.stride == stride &&
2100 tmuState0.vertex_array.type == type &&
2101 tmuState0.vertex_array.ptr == pointer )
2103 return;
2105 tmuState0.vertex_array.size = size;
2106 tmuState0.vertex_array.stride = stride;
2107 tmuState0.vertex_array.type = type;
2108 tmuState0.vertex_array.ptr = (GLvoid *)pointer;
2109 tmuState0.vertex_array.changed = GL_TRUE;
2111 void glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
2113 if( skipnanogl )
2115 glEsImpl->glTexCoordPointer( size, type, stride, pointer );
2116 return;
2118 struct nanotmuState *clientstate = NULL;
2119 if ( clientactivetmu == GL_TEXTURE0 )
2121 clientstate = &tmuState0;
2123 else if ( clientactivetmu == GL_TEXTURE1 )
2125 clientstate = &tmuState1;
2127 if ( clientstate->texture_coord_array.size == size &&
2128 clientstate->texture_coord_array.stride == stride &&
2129 clientstate->texture_coord_array.type == type &&
2130 clientstate->texture_coord_array.ptr == pointer )
2132 return;
2134 clientstate->texture_coord_array.size = size;
2135 clientstate->texture_coord_array.stride = stride;
2136 clientstate->texture_coord_array.type = type;
2137 clientstate->texture_coord_array.ptr = (GLvoid *)pointer;
2138 clientstate->texture_coord_array.changed = GL_TRUE;
2140 void glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
2142 if ( tmuState0.color_array.size == size &&
2143 tmuState0.color_array.stride == stride &&
2144 tmuState0.color_array.type == type &&
2145 tmuState0.color_array.ptr == pointer )
2147 return;
2149 tmuState0.color_array.size = size;
2150 tmuState0.color_array.stride = stride;
2151 tmuState0.color_array.type = type;
2152 tmuState0.color_array.ptr = (GLvoid *)pointer;
2153 tmuState0.color_array.changed = GL_TRUE;
2156 void glNormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
2158 int size = 0;
2159 if ( tmuState0.normal_array.size == size &&
2160 tmuState0.normal_array.stride == stride &&
2161 tmuState0.normal_array.type == type &&
2162 tmuState0.normal_array.ptr == pointer )
2164 return;
2166 tmuState0.normal_array.size = size;
2167 tmuState0.normal_array.stride = stride;
2168 tmuState0.normal_array.type = type;
2169 tmuState0.normal_array.ptr = (GLvoid *)pointer;
2170 tmuState0.normal_array.changed = GL_TRUE;
2172 void glPolygonOffset( GLfloat factor, GLfloat units )
2174 FlushOnStateChange( );
2175 glEsImpl->glPolygonOffset( factor, units );
2177 void glStencilMask( GLuint mask )
2180 void glClearStencil( GLint s )
2184 #if defined( __MULTITEXTURE_SUPPORT__ )
2186 extern "C" void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t );
2188 void glMultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t )
2190 if ( target == GL_TEXTURE0 )
2192 glTexCoord2f( s, t );
2194 else
2196 currentVertexAttrib.s_multi = s;
2197 currentVertexAttrib.t_multi = t;
2200 #endif
2202 /* Vladimir */
2203 /*void glDrawArrays( GLenum mode, int first, int count)
2205 FlushOnStateChange();
2206 glEsImpl->glDrawArrays(mode, first , count);
2207 }*/
2208 void glMultMatrixf( const GLfloat *m )
2210 FlushOnStateChange( );
2211 glEsImpl->glMultMatrixf( m );
2214 void glPixelStorei( GLenum pname, GLint param )
2216 FlushOnStateChange( );
2217 glEsImpl->glPixelStorei( pname, param );
2220 void glFogf( GLenum pname, GLfloat param )
2222 FlushOnStateChange( );
2223 glEsImpl->glFogf( pname, param );
2226 void glFogfv( GLenum pname, const GLfloat *params )
2228 FlushOnStateChange( );
2229 glEsImpl->glFogfv( pname, params );
2232 void glGetTexParameteriv( GLenum target, GLenum pname, GLint *params )
2234 FlushOnStateChange( );
2235 glEsImpl->glGetTexParameteriv( target, pname, params );
2238 // This gives: called unimplemented OpenGL ES API (Android)
2239 void glTexParameteri( GLenum target, GLenum pname, GLint param )
2241 if ( pname == GL_TEXTURE_BORDER_COLOR )
2243 return; // not supported by opengl es
2245 if ( ( pname == GL_TEXTURE_WRAP_S ||
2246 pname == GL_TEXTURE_WRAP_T ) &&
2247 param == GL_CLAMP )
2249 param = 0x812F;
2252 FlushOnStateChange( );
2253 glEsImpl->glTexParameteri( target, pname, param );
2256 void glTexParameterx( GLenum target, GLenum pname, GLfixed param )
2258 if ( pname == GL_TEXTURE_BORDER_COLOR )
2260 return; // not supported by opengl es
2262 if ( ( pname == GL_TEXTURE_WRAP_S ||
2263 pname == GL_TEXTURE_WRAP_T ) &&
2264 param == GL_CLAMP )
2266 param = 0x812F;
2268 FlushOnStateChange( );
2269 glEsImpl->glTexParameterx( target, pname, param );
2272 void glGenTextures( GLsizei n, GLuint *textures )
2274 FlushOnStateChange( );
2275 glEsImpl->glGenTextures( n, textures );
2278 void glFrontFace( GLenum mode )
2280 FlushOnStateChange( );
2281 glEsImpl->glFrontFace( mode );
2283 // End Vladimir
2285 void glTexEnvi( GLenum target, GLenum pname, GLint param )
2287 if( skipnanogl )
2289 glEsImpl->glTexEnvi( target, pname, param );
2290 return;
2292 if ( target == GL_TEXTURE_ENV )
2294 if ( pname == GL_TEXTURE_ENV_MODE )
2296 if ( param == activetmuState->texture_env_mode.value )
2298 return;
2300 else
2302 FlushOnStateChange( );
2303 glEsImpl->glTexEnvi( target, pname, param );
2304 activetmuState->texture_env_mode.value = param;
2305 return;
2309 FlushOnStateChange( );
2310 glEsImpl->glTexEnvi( target, pname, param );
2313 #ifdef __MULTITEXTURE_SUPPORT__
2314 void glMultiTexCoord3fARB( GLenum a, GLfloat b, GLfloat c, GLfloat )
2316 return glMultiTexCoord2fARB( a, b, c );
2319 void glMultiTexCoord2f( GLenum a, GLfloat b, GLfloat c )
2321 glMultiTexCoord2fARB(a,b,c);
2323 #endif
2324 void glDrawArrays( GLenum mode, GLint first, GLsizei count )
2326 if( skipnanogl )
2328 glEsImpl->glDrawArrays( mode, first, count );
2329 return;
2331 // ensure that all primitives specified between glBegin/glEnd pairs
2332 // are rendered first, and that we have correct tmu in use..
2333 if ( mode == GL_QUADS )
2334 mode = GL_TRIANGLE_FAN;
2335 FlushOnStateChange( );
2336 // setup correct vertex/color/texcoord pointers
2337 if ( arraysValid ||
2338 tmuState0.vertex_array.changed ||
2339 tmuState0.color_array.changed ||
2340 tmuState0.texture_coord_array.changed || tmuState0.normal_array.changed )
2342 glEsImpl->glClientActiveTexture( GL_TEXTURE0 );
2344 if ( arraysValid || tmuState0.vertex_array.changed )
2346 if ( tmuState0.vertex_array.enabled )
2348 glEsImpl->glEnableClientState( GL_VERTEX_ARRAY );
2350 else
2352 glEsImpl->glDisableClientState( GL_VERTEX_ARRAY );
2354 glEsImpl->glVertexPointer( tmuState0.vertex_array.size,
2355 tmuState0.vertex_array.type,
2356 tmuState0.vertex_array.stride,
2357 tmuState0.vertex_array.ptr );
2358 tmuState0.vertex_array.changed = GL_FALSE;
2360 if ( arraysValid || tmuState0.color_array.changed )
2362 if ( tmuState0.color_array.enabled )
2364 glEsImpl->glEnableClientState( GL_COLOR_ARRAY );
2366 else
2368 glEsImpl->glDisableClientState( GL_COLOR_ARRAY );
2370 glEsImpl->glColorPointer( tmuState0.color_array.size,
2371 tmuState0.color_array.type,
2372 tmuState0.color_array.stride,
2373 tmuState0.color_array.ptr );
2374 tmuState0.color_array.changed = GL_FALSE;
2376 if ( arraysValid || tmuState0.normal_array.changed )
2378 if ( tmuState0.normal_array.enabled )
2380 glEsImpl->glEnableClientState( GL_NORMAL_ARRAY );
2382 else
2384 glEsImpl->glDisableClientState( GL_NORMAL_ARRAY );
2386 glEsImpl->glNormalPointer( tmuState0.normal_array.type,
2387 tmuState0.normal_array.stride,
2388 tmuState0.normal_array.ptr );
2389 tmuState0.normal_array.changed = GL_FALSE;
2391 if ( arraysValid || tmuState0.texture_coord_array.changed )
2393 tmuState0.texture_coord_array.changed = GL_FALSE;
2394 if ( tmuState0.texture_coord_array.enabled )
2396 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
2398 else
2400 glEsImpl->glDisableClientState( GL_TEXTURE_COORD_ARRAY );
2402 glEsImpl->glTexCoordPointer( tmuState0.texture_coord_array.size,
2403 tmuState0.texture_coord_array.type,
2404 tmuState0.texture_coord_array.stride,
2405 tmuState0.texture_coord_array.ptr );
2408 if ( arraysValid || tmuState1.texture_coord_array.changed )
2410 tmuState1.texture_coord_array.changed = GL_FALSE;
2411 glEsImpl->glClientActiveTexture( GL_TEXTURE1 );
2412 if ( tmuState1.texture_coord_array.enabled )
2414 glEsImpl->glEnableClientState( GL_TEXTURE_COORD_ARRAY );
2416 else
2418 glEsImpl->glDisableClientState( GL_TEXTURE_COORD_ARRAY );
2420 glEsImpl->glTexCoordPointer( tmuState1.texture_coord_array.size,
2421 tmuState1.texture_coord_array.type,
2422 tmuState1.texture_coord_array.stride,
2423 tmuState1.texture_coord_array.ptr );
2426 arraysValid = GL_FALSE;
2427 glEsImpl->glDrawArrays( mode, first, count );
2429 /*void glNormalPointer(GLenum type, GLsizei stride, const void *ptr)
2431 glEsImpl->glNormalPointer( type, stride, ptr );
2432 }*/
2434 void glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height )
2436 FlushOnStateChange( );
2437 glEsImpl->glCopyTexSubImage2D( target, level, xoffset, yoffset, x, y, width, height );
2440 void glGenFramebuffers( GLsizei n, GLuint *framebuffers )
2442 FlushOnStateChange( );
2443 glEsImpl->glGenFramebuffers( n, framebuffers );
2446 void glGenRenderbuffers( GLsizei n, GLuint *renderbuffers )
2448 FlushOnStateChange( );
2449 glEsImpl->glGenRenderbuffers( n, renderbuffers );
2452 void glBindRenderbuffer( GLenum target, GLuint renderbuffer )
2454 FlushOnStateChange( );
2455 glEsImpl->glBindRenderbuffer( target, renderbuffer );
2458 void glBindFramebuffer( GLenum target, GLuint framebuffer )
2460 FlushOnStateChange( );
2461 glEsImpl->glBindFramebuffer( target, framebuffer );
2464 void glFramebufferRenderbuffer( GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer )
2466 FlushOnStateChange( );
2467 glEsImpl->glFramebufferRenderbuffer( target, attachment, renderbuffertarget, renderbuffer );
2470 void glDeleteFramebuffers( GLsizei n, const GLuint *framebuffers )
2472 FlushOnStateChange( );
2473 glEsImpl->glDeleteFramebuffers( n, framebuffers );
2476 void glDeleteRenderbuffers( GLsizei n, const GLuint *renderbuffers )
2478 FlushOnStateChange( );
2479 glEsImpl->glDeleteRenderbuffers( n, renderbuffers );
2481 void glFramebufferTexture2D( GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level )
2483 FlushOnStateChange( );
2484 glEsImpl->glFramebufferTexture2D( target, attachment, textarget, texture, level );
2487 void glRenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height )
2489 FlushOnStateChange( );
2490 glEsImpl->glRenderbufferStorage( target, internalformat, width, height );
2493 void glBindBufferARB( GLuint target, GLuint index )
2495 static int sindex;
2497 if( index && !sindex && !skipnanogl )
2498 FlushOnStateChange();
2499 glEsImpl->glDisableClientState( GL_COLOR_ARRAY );
2500 glEsImpl->glColor4f( currentVertexAttrib.red/255.0f, currentVertexAttrib.green/255.0f,
2501 currentVertexAttrib.blue/255.0f, currentVertexAttrib.alpha/255.0f );
2503 skipnanogl = (!!index) || vboarray;
2504 glEsImpl->glBindBuffer( target, index );
2505 if( sindex && !index )
2507 arraysValid = GL_FALSE;
2509 sindex = index;
2512 void glGenBuffersARB( GLuint count, GLuint *indexes )
2514 glEsImpl->glGenBuffers( count, indexes );
2517 void glDeleteBuffersARB( GLuint count, GLuint *indexes )
2519 glEsImpl->glDeleteBuffers( count, indexes );
2522 void glBufferDataARB( GLuint target, GLuint size, void *buffer, GLuint type )
2524 glEsImpl->glBufferData( target, size, buffer, type );
2527 void glBufferSubDataARB( GLuint target, GLsizei offset, GLsizei size, void *buffer )
2529 glEsImpl->glBufferSubData( target, offset, size, buffer );