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.
30 #include "glesinterface.h"
33 #define GL_TEXTURE0_ARB 0x84C0
34 #define GL_TEXTURE1_ARB 0x84C1
40 GLboolean clip_planei
;
41 GLboolean color_logic_op
;
42 GLboolean color_material
;
49 GLboolean line_smooth
;
50 GLboolean matrix_palette_oes
;
51 GLboolean multisample
;
53 GLboolean point_smooth
;
54 GLboolean point_sprite_oes
;
55 GLboolean polygon_offset_fill
;
56 GLboolean rescale_normal
;
57 GLboolean sample_alpha_to_coverage
;
58 GLboolean sample_alpha_to_one
;
59 GLboolean sample_coverage
;
60 GLboolean scissor_test
;
61 GLboolean stencil_test
;
63 GLclampf depth_range_near
;
64 GLclampf depth_range_far
;
73 static struct nanoState nanoglState
;
75 static struct nanoState nanoglInitState
=
143 struct booleanstate texture_2d
;
144 struct floatstate texture_env_mode
;
145 struct uintstate boundtexture
;
146 struct ptrstate vertex_array
;
147 struct ptrstate color_array
;
148 struct ptrstate texture_coord_array
;
149 struct ptrstate normal_array
;
153 static struct nanotmuState tmuState0
;
154 static struct nanotmuState tmuState1
;
156 static struct nanotmuState tmuInitState
=
158 {GL_FALSE
, GL_FALSE
},
159 {GL_MODULATE
,GL_FALSE
},
160 {0x7fffffff,GL_FALSE
},
161 {4,GL_FLOAT
,0, NULL
, GL_FALSE
, GL_FALSE
},
162 {4,GL_FLOAT
,0, NULL
, GL_FALSE
, GL_FALSE
},
163 {4,GL_FLOAT
,0, NULL
, GL_FALSE
, GL_FALSE
},
164 {3,GL_FLOAT
,0, NULL
, GL_FALSE
, GL_FALSE
},
167 static struct nanotmuState
* activetmuState
= &tmuState0
;
169 extern "C++" GlESInterface
* glEsImpl
;
171 static GLenum wrapperPrimitiveMode
= GL_QUADS
;
172 GLboolean useTexCoordArray
= GL_FALSE
;
173 static GLenum activetmu
= GL_TEXTURE0
;
174 static GLenum clientactivetmu
= GL_TEXTURE0
;
176 #if defined(__MULTITEXTURE_SUPPORT__)
177 GLboolean useMultiTexCoordArray
= GL_FALSE
;
181 #if !defined (__WINS__)
182 //#define __FORCEINLINE __forceinline
183 #define __FORCEINLINE inline
185 #define __FORCEINLINE
188 static GLboolean delayedttmuchange
= GL_FALSE
;
189 static GLenum delayedtmutarget
= GL_TEXTURE0
;
196 #if !defined(__MULTITEXTURE_SUPPORT__)
206 #if defined(__MULTITEXTURE_SUPPORT__)
212 static VertexAttrib vertexattribs
[40000];
214 static GLushort indexArray
[30000];
216 static GLuint vertexCount
= 0;
217 static GLuint indexCount
= 0;
218 static GLuint vertexMark
= 0;
219 static int indexbase
= 0;
221 static VertexAttrib
* ptrVertexAttribArray
= NULL
;
222 static VertexAttrib
* ptrVertexAttribArrayMark
= NULL
;
224 static VertexAttrib currentVertexAttrib
;
225 #if defined(__MULTITEXTURE_SUPPORT__)
226 static VertexAttrib currentVertexAttribInit
= {0.0f
,0.0f
,0.0f
,
232 static VertexAttrib currentVertexAttribInit
= {0.0f
,0.0f
,0.0f
,0.0f
,
237 static GLushort
* ptrIndexArray
= NULL
;
239 static GLboolean arraysValid
= GL_FALSE
;
243 ptrVertexAttribArray
= vertexattribs
;
244 ptrVertexAttribArrayMark
= ptrVertexAttribArray
;
245 ptrIndexArray
= indexArray
;
247 memcpy(&nanoglState
, &nanoglInitState
, sizeof(struct nanoState
));
248 memcpy(&tmuState0
,&tmuInitState
,sizeof(struct nanotmuState
));
249 memcpy(&tmuState1
,&tmuInitState
,sizeof(struct nanotmuState
));
250 memcpy(¤tVertexAttrib
,¤tVertexAttribInit
,sizeof(struct VertexAttrib
));
252 activetmuState
= &tmuState0
;
253 wrapperPrimitiveMode
= GL_QUADS
;
254 useTexCoordArray
= GL_FALSE
;
255 activetmu
= GL_TEXTURE0
;
256 clientactivetmu
= GL_TEXTURE0
;
257 delayedttmuchange
= GL_FALSE
;
258 delayedtmutarget
= GL_TEXTURE0
;
263 arraysValid
= GL_FALSE
;
266 void ResetNanoState()
269 if (tmuState0
.color_array
.enabled
)
271 glEsImpl
->glEnableClientState(GL_COLOR_ARRAY
);
275 glEsImpl
->glDisableClientState(GL_COLOR_ARRAY
);
278 if (tmuState0
.vertex_array
.enabled
)
280 glEsImpl
->glEnableClientState(GL_VERTEX_ARRAY
);
284 glEsImpl
->glDisableClientState(GL_VERTEX_ARRAY
);
287 if (tmuState0
.texture_coord_array
.enabled
)
289 glEsImpl
->glEnableClientState(GL_TEXTURE_COORD_ARRAY
);
293 glEsImpl
->glDisableClientState(GL_TEXTURE_COORD_ARRAY
);
296 if (tmuState0
.normal_array
.enabled
)
298 glEsImpl
->glEnableClientState(GL_NORMAL_ARRAY
);
302 glEsImpl
->glDisableClientState(GL_NORMAL_ARRAY
);
304 glEsImpl
->glVertexPointer(tmuState0
.vertex_array
.size
,
305 tmuState0
.vertex_array
.type
,
306 tmuState0
.vertex_array
.stride
,
307 tmuState0
.vertex_array
.ptr
);
309 glEsImpl
->glTexCoordPointer(tmuState0
.texture_coord_array
.size
,
310 tmuState0
.texture_coord_array
.type
,
311 tmuState0
.texture_coord_array
.stride
,
312 tmuState0
.texture_coord_array
.ptr
);
314 glEsImpl
->glColorPointer(tmuState0
.color_array
.size
,
315 tmuState0
.color_array
.type
,
316 tmuState0
.color_array
.stride
,
317 tmuState0
.color_array
.ptr
);
319 glEsImpl
->glNormalPointer(
320 tmuState0
.normal_array
.type
,
321 tmuState0
.normal_array
.stride
,
322 tmuState0
.normal_array
.ptr
);
324 glEsImpl
->glMatrixMode(nanoglState
.matrixmode
);
328 glEsImpl
->glColor4f (currentVertexAttrib
.red
, currentVertexAttrib
.green
, currentVertexAttrib
.blue
, currentVertexAttrib
.alpha
);
330 glEsImpl
->glBlendFunc(nanoglState
.sfactor
, nanoglState
.dfactor
);
332 //glEsImpl->glBindTexture(GL_TEXTURE_2D, stackTextureState);
334 glEsImpl
->glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, activetmuState
->texture_env_mode
.value
);
336 arraysValid
= GL_FALSE
;
339 void FlushOnStateChange()
341 if (delayedttmuchange
)
343 delayedttmuchange
= GL_FALSE
;
344 #ifndef USE_CORE_PROFILE
345 glEsImpl
->glActiveTexture(delayedtmutarget
);
354 glEsImpl
->glClientActiveTexture(GL_TEXTURE0
);
355 glEsImpl
->glVertexPointer(3, GL_FLOAT
, sizeof(VertexAttrib
), &vertexattribs
[0].x
);
356 glEsImpl
->glColorPointer(4, GL_UNSIGNED_BYTE
, sizeof(VertexAttrib
), &vertexattribs
[0].red
);
357 glEsImpl
->glTexCoordPointer(2, GL_FLOAT
, sizeof(VertexAttrib
), &vertexattribs
[0].s
);
358 glEsImpl
->glEnableClientState(GL_VERTEX_ARRAY
);
359 glEsImpl
->glEnableClientState(GL_TEXTURE_COORD_ARRAY
);
360 glEsImpl
->glEnableClientState(GL_COLOR_ARRAY
);
361 #if defined(__MULTITEXTURE_SUPPORT__)
362 glEsImpl
->glClientActiveTexture(GL_TEXTURE1
);
363 glEsImpl
->glTexCoordPointer(2, GL_FLOAT
, sizeof(VertexAttrib
), &vertexattribs
[0].s_multi
);
364 glEsImpl
->glEnableClientState(GL_TEXTURE_COORD_ARRAY
);
365 glEsImpl
->glClientActiveTexture(GL_TEXTURE0
);
367 arraysValid
= GL_TRUE
;
370 glEsImpl
->glDrawElements( GL_TRIANGLES
,vertexCount
,GL_UNSIGNED_SHORT
, indexArray
);
373 #if defined(__MULTITEXTURE_SUPPORT__)
374 useMultiTexCoordArray
= GL_FALSE
;
378 ptrVertexAttribArray
= vertexattribs
;
379 ptrVertexAttribArrayMark
= ptrVertexAttribArray
;
380 ptrIndexArray
= indexArray
;
381 useTexCoordArray
= GL_FALSE
;
385 FlushOnStateChange();
391 void glBegin(GLenum mode
)
393 wrapperPrimitiveMode
= mode
;
394 vertexMark
= vertexCount
;
395 ptrVertexAttribArrayMark
= ptrVertexAttribArray
;
396 indexbase
= indexCount
;
401 vertexCount
+=((unsigned char*)ptrVertexAttribArray
-(unsigned char*)ptrVertexAttribArrayMark
)/sizeof(VertexAttrib
);
406 switch (wrapperPrimitiveMode
)
410 *ptrIndexArray
++ = indexCount
;
411 *ptrIndexArray
++ = indexCount
+1;
412 *ptrIndexArray
++ = indexCount
+2;
413 *ptrIndexArray
++ = indexCount
;
414 *ptrIndexArray
++ = indexCount
+2;
415 *ptrIndexArray
++ = indexCount
+3;
422 int vcount
= (vertexCount
-vertexMark
)/3;
423 for (int count
= 0; count
< vcount
; count
++)
425 *ptrIndexArray
++ = indexCount
;
426 *ptrIndexArray
++ = indexCount
+1;
427 *ptrIndexArray
++ = indexCount
+2;
432 case GL_TRIANGLE_STRIP
:
434 *ptrIndexArray
++ = indexCount
;
435 *ptrIndexArray
++ = indexCount
+1;
436 *ptrIndexArray
++ = indexCount
+2;
438 int vcount
= ((vertexCount
-vertexMark
)-3);
439 if (vcount
&& ((long)ptrIndexArray
& 0x02))
441 *ptrIndexArray
++ = indexCount
-1; // 2
442 *ptrIndexArray
++ = indexCount
-2; // 1
443 *ptrIndexArray
++ = indexCount
; // 3
448 unsigned int* longptr
= (unsigned int*) ptrIndexArray
;
450 for (int count
= 0; count
< vcount
; count
++)
452 *(longptr
++) = (indexCount
-2) | ((indexCount
-1)<<16);
453 *(longptr
++) = (indexCount
) | ((indexCount
)<<16);
454 *(longptr
++) = (indexCount
-1) | ((indexCount
+1)<<16);
457 ptrIndexArray
= (unsigned short*)(longptr
);
460 *ptrIndexArray
++ = indexCount
-2; // 2
461 *ptrIndexArray
++ = indexCount
-1; // 1
462 *ptrIndexArray
++ = indexCount
; // 3
471 unsigned int* longptr
= (unsigned int*) ptrIndexArray
;
473 for (int count
= 0; count
< vcount
; count
++)
475 *(longptr
++) = (indexCount
-1) | ((indexCount
-2)<<16);
476 *(longptr
++) = (indexCount
) | ((indexCount
-1)<<16);
477 *(longptr
++) = (indexCount
) | ((indexCount
+1)<<16);
481 ptrIndexArray
= (unsigned short*)(longptr
);
485 *ptrIndexArray
++ = indexCount
-1; // 2
486 *ptrIndexArray
++ = indexCount
-2; // 1
487 *ptrIndexArray
++ = indexCount
; // 3
491 vertexCount
+=(vertexCount
-vertexMark
-3)*2;
495 case GL_TRIANGLE_FAN
:
497 *ptrIndexArray
++ = indexCount
++;
498 *ptrIndexArray
++ = indexCount
++;
499 *ptrIndexArray
++ = indexCount
++;
500 int vcount
= ((vertexCount
-vertexMark
)-3);
501 for (int count
= 0; count
< vcount
; count
++)
503 *ptrIndexArray
++ = indexbase
;
504 *ptrIndexArray
++ = indexCount
-1;
505 *ptrIndexArray
++ = indexCount
++;
516 void glEnable (GLenum cap
)
518 GLboolean statechanged
= GL_FALSE
;
523 if (!nanoglState
.alpha_test
)
525 nanoglState
.alpha_test
= GL_TRUE
;
526 statechanged
= GL_TRUE
;
532 if (!nanoglState
.blend
)
534 nanoglState
.blend
= GL_TRUE
;
535 statechanged
= GL_TRUE
;
539 //case GL_CLIP_PLANEi
540 case GL_COLOR_LOGIC_OP
:
542 if (!nanoglState
.color_logic_op
)
544 nanoglState
.color_logic_op
= GL_TRUE
;
545 statechanged
= GL_TRUE
;
549 case GL_COLOR_MATERIAL
:
551 if (!nanoglState
.color_material
)
553 nanoglState
.color_material
= GL_TRUE
;
554 statechanged
= GL_TRUE
;
560 if (!nanoglState
.cull_face
)
562 nanoglState
.cull_face
= GL_TRUE
;
563 statechanged
= GL_TRUE
;
569 if (!nanoglState
.depth_test
)
571 nanoglState
.depth_test
= GL_TRUE
;
572 statechanged
= GL_TRUE
;
578 if (!nanoglState
.dither
)
580 nanoglState
.dither
= GL_TRUE
;
581 statechanged
= GL_TRUE
;
588 if (!nanoglState
.fog
)
590 nanoglState
.fog
= GL_TRUE
;
591 statechanged
= GL_TRUE
;
597 if (!nanoglState
.lighting
)
599 nanoglState
.lighting
= GL_TRUE
;
600 statechanged
= GL_TRUE
;
606 if (!nanoglState
.line_smooth
)
608 nanoglState
.line_smooth
= GL_TRUE
;
609 statechanged
= GL_TRUE
;
613 /* case GL_MATRIX_PALETTE_OES:
615 if (!nanoglState.matrix_palette_oes)
617 nanoglState.matrix_palette_oes = GL_TRUE;
618 statechanged = GL_TRUE;
624 if (!nanoglState
.multisample
)
626 nanoglState
.multisample
= GL_TRUE
;
627 statechanged
= GL_TRUE
;
633 if (!nanoglState
.normalize
)
635 nanoglState
.normalize
= GL_TRUE
;
636 statechanged
= GL_TRUE
;
640 /* case GL_POINT_SPRITE_OES:
642 if (!nanoglState.point_sprite_oes)
644 nanoglState.point_sprite_oes = GL_TRUE;
645 statechanged = GL_TRUE;
649 case GL_POLYGON_OFFSET_FILL
:
651 if (!nanoglState
.polygon_offset_fill
)
653 nanoglState
.polygon_offset_fill
= GL_TRUE
;
654 statechanged
= GL_TRUE
;
658 case GL_RESCALE_NORMAL
:
660 if (!nanoglState
.rescale_normal
)
662 nanoglState
.rescale_normal
= GL_TRUE
;
663 statechanged
= GL_TRUE
;
667 case GL_SAMPLE_ALPHA_TO_COVERAGE
:
669 if (!nanoglState
.sample_alpha_to_coverage
)
671 nanoglState
.sample_alpha_to_coverage
= GL_TRUE
;
672 statechanged
= GL_TRUE
;
676 case GL_SAMPLE_ALPHA_TO_ONE
:
678 if (!nanoglState
.sample_alpha_to_one
)
680 nanoglState
.sample_alpha_to_one
= GL_TRUE
;
681 statechanged
= GL_TRUE
;
685 case GL_SAMPLE_COVERAGE
:
687 if (!nanoglState
.sample_coverage
)
689 nanoglState
.sample_coverage
= GL_TRUE
;
690 statechanged
= GL_TRUE
;
694 case GL_SCISSOR_TEST
:
696 if (!nanoglState
.scissor_test
)
698 nanoglState
.scissor_test
= GL_TRUE
;
699 statechanged
= GL_TRUE
;
703 case GL_STENCIL_TEST
:
706 /* if (!nanoglState.stencil_test)
708 nanoglState.stencil_test = GL_TRUE;
709 statechanged = GL_TRUE;
715 if (!activetmuState
->texture_2d
.value
)
717 FlushOnStateChange();
718 glEsImpl
->glEnable(cap
);
719 activetmuState
->texture_2d
.value
= GL_TRUE
;
730 FlushOnStateChange();
731 glEsImpl
->glEnable(cap
);
735 void glDisable (GLenum cap
)
737 GLboolean statechanged
= GL_FALSE
;
742 if (nanoglState
.alpha_test
)
744 nanoglState
.alpha_test
= GL_FALSE
;
745 statechanged
= GL_TRUE
;
751 if (nanoglState
.blend
)
753 nanoglState
.blend
= GL_FALSE
;
754 statechanged
= GL_TRUE
;
758 //case GL_CLIP_PLANEi
759 case GL_COLOR_LOGIC_OP
:
761 if (nanoglState
.color_logic_op
)
763 nanoglState
.color_logic_op
= GL_FALSE
;
764 statechanged
= GL_TRUE
;
768 case GL_COLOR_MATERIAL
:
770 if (nanoglState
.color_material
)
772 nanoglState
.color_material
= GL_FALSE
;
773 statechanged
= GL_TRUE
;
779 if (nanoglState
.cull_face
)
781 nanoglState
.cull_face
= GL_FALSE
;
782 statechanged
= GL_TRUE
;
788 if (nanoglState
.depth_test
)
790 nanoglState
.depth_test
= GL_FALSE
;
791 statechanged
= GL_TRUE
;
797 if (nanoglState
.dither
)
799 nanoglState
.dither
= GL_FALSE
;
800 statechanged
= GL_TRUE
;
809 nanoglState
.fog
= GL_FALSE
;
810 statechanged
= GL_TRUE
;
816 if (nanoglState
.lighting
)
818 nanoglState
.lighting
= GL_FALSE
;
819 statechanged
= GL_TRUE
;
825 if (nanoglState
.line_smooth
)
827 nanoglState
.line_smooth
= GL_FALSE
;
828 statechanged
= GL_TRUE
;
832 /* case GL_MATRIX_PALETTE_OES:
834 if (nanoglState.matrix_palette_oes)
836 nanoglState.matrix_palette_oes = GL_FALSE;
837 statechanged = GL_TRUE;
843 if (nanoglState
.multisample
)
845 nanoglState
.multisample
= GL_FALSE
;
846 statechanged
= GL_TRUE
;
852 if (nanoglState
.normalize
)
854 nanoglState
.normalize
= GL_FALSE
;
855 statechanged
= GL_TRUE
;
859 /* case GL_POINT_SPRITE_OES:
861 if (nanoglState.point_sprite_oes)
863 nanoglState.point_sprite_oes = GL_FALSE;
864 statechanged = GL_TRUE;
868 case GL_POLYGON_OFFSET_FILL
:
870 if (nanoglState
.polygon_offset_fill
)
872 nanoglState
.polygon_offset_fill
= GL_FALSE
;
873 statechanged
= GL_TRUE
;
877 case GL_RESCALE_NORMAL
:
879 if (nanoglState
.rescale_normal
)
881 nanoglState
.rescale_normal
= GL_FALSE
;
882 statechanged
= GL_TRUE
;
886 case GL_SAMPLE_ALPHA_TO_COVERAGE
:
888 if (nanoglState
.sample_alpha_to_coverage
)
890 nanoglState
.sample_alpha_to_coverage
= GL_FALSE
;
891 statechanged
= GL_TRUE
;
895 case GL_SAMPLE_ALPHA_TO_ONE
:
897 if (nanoglState
.sample_alpha_to_one
)
899 nanoglState
.sample_alpha_to_one
= GL_FALSE
;
900 statechanged
= GL_TRUE
;
904 case GL_SAMPLE_COVERAGE
:
906 if (nanoglState
.sample_coverage
)
908 nanoglState
.sample_coverage
= GL_FALSE
;
909 statechanged
= GL_TRUE
;
913 case GL_SCISSOR_TEST
:
915 if (nanoglState
.scissor_test
)
917 nanoglState
.scissor_test
= GL_FALSE
;
918 statechanged
= GL_TRUE
;
922 case GL_STENCIL_TEST
:
925 /* if (nanoglState.stencil_test)
927 nanoglState.stencil_test = GL_FALSE;
928 statechanged = GL_TRUE;
934 if (activetmuState
->texture_2d
.value
)
936 FlushOnStateChange();
937 glEsImpl
->glDisable(cap
);
938 activetmuState
->texture_2d
.value
= GL_FALSE
;
951 FlushOnStateChange();
952 glEsImpl
->glDisable(cap
);
956 void glVertex2f(GLfloat x
, GLfloat y
)
958 glVertex3f(x
,y
,0.0f
);
962 __FORCEINLINE
unsigned int ClampTo255(float value
)
964 unsigned int retval
= (unsigned int)(value
);
972 void glColor3f( GLfloat red
, GLfloat green
, GLfloat blue
)
974 currentVertexAttrib
.red
= (unsigned char)ClampTo255(red
*255.0f
);
975 currentVertexAttrib
.green
= (unsigned char)ClampTo255(green
*255.0f
);
976 currentVertexAttrib
.blue
= (unsigned char)ClampTo255(blue
*255.0f
);
977 currentVertexAttrib
.alpha
= 255;
981 void glTexCoord2fv( const GLfloat
*v
)
983 memcpy(¤tVertexAttrib
.s
, v
, 2*sizeof(float));
987 void glTexCoord2f(GLfloat s
, GLfloat t
)
989 currentVertexAttrib
.s
= s
;
990 currentVertexAttrib
.t
= t
;
993 void glViewport (GLint x
, GLint y
, GLsizei width
, GLsizei height
)
995 FlushOnStateChange();
996 glEsImpl
->glViewport(x
,y
,width
,height
);
999 void glLoadIdentity (void)
1001 FlushOnStateChange();
1002 glEsImpl
->glLoadIdentity();
1005 void glColor4f (GLfloat red
, GLfloat green
, GLfloat blue
, GLfloat alpha
)
1007 currentVertexAttrib
.red
= (unsigned char)ClampTo255(red
*255.0f
);
1008 currentVertexAttrib
.green
= (unsigned char)ClampTo255(green
*255.0f
);
1009 currentVertexAttrib
.blue
= (unsigned char)ClampTo255(blue
*255.0f
);
1010 currentVertexAttrib
.alpha
= (unsigned char)ClampTo255(alpha
*255.0f
);
1013 void glOrtho (GLfloat left
, GLfloat right
, GLfloat bottom
, GLfloat top
, GLfloat zNear
, GLfloat zFar
)
1015 FlushOnStateChange();
1016 #ifdef USE_CORE_PROFILE
1017 glEsImpl
->glOrtho(left
,right
,bottom
,top
, zNear
,zFar
);
1019 glEsImpl
->glOrthof(left
,right
,bottom
,top
, zNear
,zFar
);
1023 void glMatrixMode (GLenum mode
)
1025 if (nanoglState
.matrixmode
== mode
)
1029 nanoglState
.matrixmode
= mode
;
1030 FlushOnStateChange();
1031 glEsImpl
->glMatrixMode(mode
);
1034 void glTexParameterf (GLenum target
, GLenum pname
, GLfloat param
)
1036 if (pname
== GL_TEXTURE_BORDER_COLOR
)
1038 return; // not supported by opengl es
1040 if ( (pname
== GL_TEXTURE_WRAP_S
||
1041 pname
== GL_TEXTURE_WRAP_T
) &&
1047 FlushOnStateChange();
1048 glEsImpl
->glTexParameterf(target
, pname
,param
);
1051 void glTexParameterfv( GLenum target
, GLenum pname
, const GLfloat
*params
)
1053 glTexParameterf(target
, pname
, params
[0]);
1056 void glTexImage2D (GLenum target
, GLint level
, GLint internalformat
, GLsizei width
, GLsizei height
, GLint border
, GLenum format
, GLenum type
, const GLvoid
*pixels
)
1058 FlushOnStateChange();
1059 internalformat
= format
;
1060 glEsImpl
->glTexImage2D(target
, level
, internalformat
, width
, height
,border
,format
,type
,pixels
);
1063 void glDrawBuffer(GLenum
/*mode*/)
1067 void glTranslatef (GLfloat x
, GLfloat y
, GLfloat z
)
1069 FlushOnStateChange();
1070 glEsImpl
->glTranslatef(x
,y
,z
);
1073 void glRotatef (GLfloat angle
, GLfloat x
, GLfloat y
, GLfloat z
)
1075 FlushOnStateChange();
1076 glEsImpl
->glRotatef(angle
, x
, y
, z
);
1079 void glScalef (GLfloat x
, GLfloat y
, GLfloat z
)
1081 FlushOnStateChange();
1082 glEsImpl
->glScalef(x
,y
,z
);
1085 void glDepthRange(GLclampf zNear
, GLclampf zFar
)
1087 if ((nanoglState
.depth_range_near
== zNear
) &&(nanoglState
.depth_range_far
== zFar
))
1093 nanoglState
.depth_range_near
= zNear
;
1094 nanoglState
.depth_range_far
= zFar
;
1096 FlushOnStateChange();
1097 #ifdef USE_CORE_PROFILE
1098 glEsImpl
->glDepthRange(zNear
, zFar
);
1100 glEsImpl
->glDepthRangef(zNear
, zFar
);
1104 void glDepthFunc (GLenum func
)
1106 if (nanoglState
.depth_func
== func
)
1112 nanoglState
.depth_func
= func
;
1114 FlushOnStateChange();
1115 glEsImpl
->glDepthFunc(func
);
1118 void glFinish (void)
1120 FlushOnStateChange();
1121 glEsImpl
->glFinish();
1124 void glGetFloatv (GLenum pname
, GLfloat
*params
)
1126 FlushOnStateChange();
1127 glEsImpl
->glGetFloatv(pname
, params
);
1130 void glCullFace (GLenum mode
)
1132 if (nanoglState
.cullface
== mode
)
1138 nanoglState
.cullface
= mode
;
1140 FlushOnStateChange();
1141 glEsImpl
->glCullFace(mode
);
1144 void glFrustum (GLfloat left
, GLfloat right
, GLfloat bottom
, GLfloat top
, GLfloat zNear
, GLfloat zFar
)
1146 FlushOnStateChange();
1147 glEsImpl
->glFrustumf(left
,right
,bottom
,top
,zNear
,zFar
);
1150 void glClear (GLbitfield mask
)
1152 FlushOnStateChange();
1153 glEsImpl
->glClear(mask
);
1157 void glVertex3f( GLfloat x
, GLfloat y
, GLfloat z
)
1159 GLfloat
* vert
= (GLfloat
*)ptrVertexAttribArray
++;
1163 #if defined(__MULTITEXTURE_SUPPORT__)
1164 memcpy(vert
, ¤tVertexAttrib
.red
, 5*sizeof(GLfloat
));
1166 memcpy(vert
+1, ¤tVertexAttrib
.red
, 3*sizeof(GLfloat
));
1171 void glColor4fv( const GLfloat
*v
)
1173 currentVertexAttrib
.red
= (unsigned char)ClampTo255(v
[0]*255.0f
);
1174 currentVertexAttrib
.green
= (unsigned char)ClampTo255(v
[1]*255.0f
);
1175 currentVertexAttrib
.blue
= (unsigned char)ClampTo255(v
[2]*255.0f
);
1176 currentVertexAttrib
.alpha
= (unsigned char)ClampTo255(v
[3]*255.0f
);
1179 void glColor3ubv( const GLubyte
* v
)
1181 currentVertexAttrib
.red
= v
[0];
1182 currentVertexAttrib
.green
= v
[1];
1183 currentVertexAttrib
.blue
= v
[2];
1184 currentVertexAttrib
.alpha
= 255;
1187 void glColor4ubv( const GLubyte
*v
)
1189 //*((unsigned int*)(¤tVertexAttrib.red)) = *((unsigned int*)(v));
1190 currentVertexAttrib
.red
= v
[0];
1191 currentVertexAttrib
.green
= v
[1];
1192 currentVertexAttrib
.blue
= v
[2];
1193 currentVertexAttrib
.alpha
= v
[3];
1196 void glColor3fv( const GLfloat
*v
)
1198 currentVertexAttrib
.red
= (unsigned char)ClampTo255(v
[0]*255.0f
);
1199 currentVertexAttrib
.green
= (unsigned char)ClampTo255(v
[1]*255.0f
);
1200 currentVertexAttrib
.blue
= (unsigned char)ClampTo255(v
[2]*255.0f
);
1201 currentVertexAttrib
.alpha
= 255;
1204 //-- nicknekit: xash3d funcs --
1206 void glColor4ub( GLubyte red
, GLubyte green
, GLubyte blue
, GLubyte alpha
)
1208 currentVertexAttrib
.red
= red
;
1209 currentVertexAttrib
.green
= green
;
1210 currentVertexAttrib
.blue
= blue
;
1211 currentVertexAttrib
.alpha
= alpha
;
1214 void glColor3ub( GLubyte red
, GLubyte green
, GLubyte blue
)
1216 currentVertexAttrib
.red
= red
;
1217 currentVertexAttrib
.green
= green
;
1218 currentVertexAttrib
.blue
= blue
;
1219 currentVertexAttrib
.alpha
= 255;
1222 void glNormal3fv( const GLfloat
*v
)
1224 FlushOnStateChange();
1225 glEsImpl
->glNormal3f(v
[0],v
[1],v
[2]);
1228 void glCopyTexImage2D( GLenum target
, GLint level
, GLenum internalformat
, GLint x
, GLint y
, GLsizei width
, GLsizei height
, GLint border
)
1230 FlushOnStateChange();
1231 glEsImpl
->glCopyTexImage2D(target
, level
, internalformat
, x
, y
, width
, height
, border
);
1234 void glTexImage1D(GLenum target
, GLint level
, GLint internalformat
, GLsizei width
, GLint border
, GLenum format
, GLenum type
, const GLvoid
*pixels
)
1236 glTexImage2D(GL_TEXTURE_2D
, level
, internalformat
, width
, 1, border
, format
, type
, pixels
);
1239 void glTexImage3D(GLenum target
, GLint level
, GLint internalformat
, GLsizei width
, GLsizei height
, GLsizei depth
, GLint border
, GLenum format
, GLenum type
, const GLvoid
*pixels
)
1241 glTexImage2D(GL_TEXTURE_2D
, level
, internalformat
, width
, height
, border
, format
, type
, pixels
);
1244 void glTexSubImage1D( GLenum target
, GLint level
, GLint xoffset
, GLsizei width
, GLenum format
, GLenum type
, const GLvoid
*pixels
)
1246 glTexSubImage2D(target
,level
,xoffset
,0,width
,1,format
,type
,pixels
);
1249 void glTexSubImage3D( GLenum target
, GLint level
,
1250 GLint xoffset
, GLint yoffset
,
1251 GLint zoffset
, GLsizei width
,
1252 GLsizei height
, GLsizei depth
,
1254 GLenum type
, const GLvoid
*pixels
)
1256 glTexSubImage2D(target
,level
,xoffset
,yoffset
,width
,height
,format
,type
,pixels
);
1261 GLboolean
glIsTexture(GLuint texture
)
1263 FlushOnStateChange();
1264 return glEsImpl
->glIsTexture(texture
);
1268 void glTexGeni( GLenum coord
, GLenum pname
, GLint param
)
1270 //for mirrors? not needed for original hl?
1273 void glTexGenfv( GLenum coord
, GLenum pname
, const GLfloat
*params
)
1275 //for mirrors? not needed for original hl?
1280 void glHint (GLenum target
, GLenum mode
)
1282 FlushOnStateChange();
1283 glEsImpl
->glHint(target
, mode
);
1286 void glBlendFunc (GLenum sfactor
, GLenum dfactor
)
1288 if ((nanoglState
.sfactor
== sfactor
) && (nanoglState
.dfactor
== dfactor
))
1292 nanoglState
.sfactor
= sfactor
;
1293 nanoglState
.dfactor
= dfactor
;
1294 FlushOnStateChange();
1295 glEsImpl
->glBlendFunc(sfactor
, dfactor
);
1298 void glPopMatrix (void)
1300 FlushOnStateChange();
1301 glEsImpl
->glPopMatrix();
1304 void glShadeModel (GLenum mode
)
1306 if (nanoglState
.shademodel
== mode
)
1310 nanoglState
.shademodel
= mode
;
1311 FlushOnStateChange();
1312 glEsImpl
->glShadeModel(mode
);
1315 void glPushMatrix (void)
1317 FlushOnStateChange();
1318 glEsImpl
->glPushMatrix();
1321 void glTexEnvf (GLenum target
, GLenum pname
, GLfloat param
)
1323 if (target
== GL_TEXTURE_ENV
)
1325 if (pname
== GL_TEXTURE_ENV_MODE
)
1327 if (param
== activetmuState
->texture_env_mode
.value
)
1333 FlushOnStateChange();
1334 glEsImpl
->glTexEnvf(target
, pname
, param
);
1335 activetmuState
->texture_env_mode
.value
= param
;
1340 FlushOnStateChange();
1341 glEsImpl
->glTexEnvf(target
, pname
, param
);
1344 void glVertex3fv( const GLfloat
*v
)
1346 GLfloat
* vert
= (GLfloat
*)ptrVertexAttribArray
++;
1347 memcpy(vert
, v
, 3*sizeof(GLfloat
));
1348 #if defined(__MULTITEXTURE_SUPPORT__)
1349 memcpy(vert
+3, ¤tVertexAttrib
.red
, 5*sizeof(GLfloat
));
1351 memcpy(vert
+4, ¤tVertexAttrib
.red
, 3*sizeof(GLfloat
));
1356 void glDepthMask (GLboolean flag
)
1358 if (nanoglState
.depthmask
== flag
)
1362 nanoglState
.depthmask
= flag
;
1363 FlushOnStateChange();
1364 glEsImpl
->glDepthMask(flag
);
1367 void glBindTexture (GLenum target
, GLuint texture
)
1369 if (activetmuState
->boundtexture
.value
== texture
)
1373 FlushOnStateChange();
1374 activetmuState
->boundtexture
.value
= texture
;
1375 glEsImpl
->glBindTexture(target
, texture
);
1379 void glGetIntegerv (GLenum pname
, GLint
*params
)
1381 FlushOnStateChange();
1382 glEsImpl
->glGetIntegerv(pname
, params
);
1385 GLubyte nano_extensions_string
[4096];
1386 const GLubyte
* glGetString (GLenum name
)
1389 if (name
== GL_EXTENSIONS
)
1391 #if defined(__MULTITEXTURE_SUPPORT__)
1392 sprintf((char*)nano_extensions_string
,"%s %s",glEsImpl
->glGetString(name
),"GL_ARB_multitexture EXT_texture_env_add");
1394 sprintf((char*)nano_extensions_string
,"%s %s",glEsImpl
->glGetString(name
),"EXT_texture_env_add");
1396 return nano_extensions_string
;
1398 return glEsImpl
->glGetString(name
);
1401 void glAlphaFunc (GLenum func
, GLclampf ref
)
1403 FlushOnStateChange();
1404 glEsImpl
->glAlphaFunc(func
,ref
);
1409 FlushOnStateChange();
1410 glEsImpl
->glFlush();
1413 void glReadPixels (GLint x
, GLint y
, GLsizei width
, GLsizei height
, GLenum format
, GLenum type
, GLvoid
*pixels
)
1415 if (format
== GL_DEPTH_COMPONENT
)
1417 // OpenglEs 1.1 does not support reading depth buffer without an extension
1418 memset(pixels
, 0xff,4);
1421 FlushOnStateChange();
1422 glEsImpl
->glReadPixels(x
,y
,width
,height
,format
,type
,pixels
);
1425 void glReadBuffer( GLenum
/*mode*/ )
1430 void glLoadMatrixf (const GLfloat
*m
)
1432 FlushOnStateChange();
1433 glEsImpl
->glLoadMatrixf(m
);
1436 void glTexSubImage2D (GLenum target
, GLint level
, GLint xoffset
, GLint yoffset
, GLsizei width
, GLsizei height
, GLenum format
, GLenum type
, const GLvoid
*pixels
)
1438 FlushOnStateChange();
1439 glEsImpl
->glTexSubImage2D(target
,level
,xoffset
,yoffset
,width
,height
,format
,type
,pixels
);
1442 void glClearColor (GLclampf red
, GLclampf green
, GLclampf blue
, GLclampf alpha
)
1444 FlushOnStateChange();
1445 glEsImpl
->glClearColor(red
,green
,blue
,alpha
);
1448 GLenum
glGetError (void)
1450 //FlushOnStateChange();
1451 return GL_NO_ERROR
;//glEsImpl->glGetError();
1454 void glActiveTexture (GLenum texture
)
1456 if (activetmu
== texture
)
1460 if (delayedttmuchange
)
1462 delayedttmuchange
= GL_FALSE
;
1466 delayedttmuchange
= GL_TRUE
;
1467 delayedtmutarget
= texture
;
1469 if (texture
== GL_TEXTURE0
)
1471 activetmuState
= &tmuState0
;
1475 activetmuState
= &tmuState1
;
1477 activetmu
= texture
;
1480 void glClientActiveTexture (GLenum texture
)
1482 clientactivetmu
= texture
;
1485 void glPolygonMode( GLenum face
, GLenum mode
)
1489 void glDeleteTextures( GLsizei n
, const GLuint
*textures
)
1491 FlushOnStateChange();
1492 glEsImpl
->glDeleteTextures(n
,textures
);
1495 void glClearDepth( GLclampf depth
)
1497 FlushOnStateChange();
1498 glEsImpl
->glClearDepthf( depth
);
1501 void glClipPlane( GLenum plane
, const GLdouble
*equation
)
1503 FlushOnStateChange();
1505 array
[0] = (GLfloat
)(equation
[0]);
1506 array
[1] = (GLfloat
)(equation
[1]);
1507 array
[2] = (GLfloat
)(equation
[2]);
1508 array
[3] = (GLfloat
)(equation
[3]);
1509 glEsImpl
->glClipPlanef( plane
, array
);
1512 void glScissor( GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1514 FlushOnStateChange();
1515 glEsImpl
->glScissor( x
, y
, width
,height
);
1518 void glPointSize( GLfloat size
)
1520 FlushOnStateChange();
1521 glEsImpl
->glPointSize( size
);
1524 void glArrayElement(GLint i
) {}
1525 void glLineWidth(GLfloat width
) {}
1526 void glCallList( GLuint list
) {}
1527 void glColorMask( GLboolean red
, GLboolean green
, GLboolean blue
, GLboolean alpha
) {}
1528 void glStencilFunc( GLenum func
, GLint ref
, GLuint mask
) {}
1529 void glStencilOp( GLenum fail
, GLenum zfail
, GLenum zpass
) {}
1531 struct ptrstate vertex_array
;
1532 struct ptrstate color_array
;
1533 struct ptrstate texture_coord_array
;
1535 void glDrawElements( GLenum mode
, GLsizei count
, GLenum type
, const GLvoid
*indices
)
1537 // ensure that all primitives specified between glBegin/glEnd pairs
1538 // are rendered first, and that we have correct tmu in use..
1539 FlushOnStateChange();
1540 // setup correct vertex/color/texcoord pointers
1542 tmuState0
.vertex_array
.changed
||
1543 tmuState0
.color_array
.changed
||
1544 tmuState0
.texture_coord_array
.changed
|| tmuState0
.normal_array
.changed
)
1546 glEsImpl
->glClientActiveTexture(GL_TEXTURE0
);
1548 if (arraysValid
|| tmuState0
.vertex_array
.changed
)
1550 if (tmuState0
.vertex_array
.enabled
)
1552 glEsImpl
->glEnableClientState(GL_VERTEX_ARRAY
);
1556 glEsImpl
->glDisableClientState(GL_VERTEX_ARRAY
);
1558 glEsImpl
->glVertexPointer(tmuState0
.vertex_array
.size
,
1559 tmuState0
.vertex_array
.type
,
1560 tmuState0
.vertex_array
.stride
,
1561 tmuState0
.vertex_array
.ptr
);
1562 tmuState0
.vertex_array
.changed
= GL_FALSE
;
1564 if (arraysValid
|| tmuState0
.color_array
.changed
)
1566 if (tmuState0
.color_array
.enabled
)
1568 glEsImpl
->glEnableClientState(GL_COLOR_ARRAY
);
1572 glEsImpl
->glDisableClientState(GL_COLOR_ARRAY
);
1574 glEsImpl
->glColorPointer(tmuState0
.color_array
.size
,
1575 tmuState0
.color_array
.type
,
1576 tmuState0
.color_array
.stride
,
1577 tmuState0
.color_array
.ptr
);
1578 tmuState0
.color_array
.changed
= GL_FALSE
;
1580 if (arraysValid
|| tmuState0
.normal_array
.changed
)
1582 if (tmuState0
.normal_array
.enabled
)
1584 glEsImpl
->glEnableClientState(GL_NORMAL_ARRAY
);
1588 glEsImpl
->glDisableClientState(GL_NORMAL_ARRAY
);
1590 glEsImpl
->glNormalPointer(tmuState0
.normal_array
.type
,
1591 tmuState0
.normal_array
.stride
,
1592 tmuState0
.normal_array
.ptr
);
1593 tmuState0
.normal_array
.changed
= GL_FALSE
;
1595 if (arraysValid
|| tmuState0
.texture_coord_array
.changed
)
1597 tmuState0
.texture_coord_array
.changed
= GL_FALSE
;
1598 if (tmuState0
.texture_coord_array
.enabled
)
1600 glEsImpl
->glEnableClientState(GL_TEXTURE_COORD_ARRAY
);
1604 glEsImpl
->glDisableClientState(GL_TEXTURE_COORD_ARRAY
);
1606 glEsImpl
->glTexCoordPointer(tmuState0
.texture_coord_array
.size
,
1607 tmuState0
.texture_coord_array
.type
,
1608 tmuState0
.texture_coord_array
.stride
,
1609 tmuState0
.texture_coord_array
.ptr
);
1612 if (arraysValid
|| tmuState1
.texture_coord_array
.changed
)
1614 tmuState1
.texture_coord_array
.changed
= GL_FALSE
;
1615 glEsImpl
->glClientActiveTexture(GL_TEXTURE1
);
1616 if (tmuState1
.texture_coord_array
.enabled
)
1618 glEsImpl
->glEnableClientState(GL_TEXTURE_COORD_ARRAY
);
1622 glEsImpl
->glDisableClientState(GL_TEXTURE_COORD_ARRAY
);
1624 glEsImpl
->glTexCoordPointer(tmuState1
.texture_coord_array
.size
,
1625 tmuState1
.texture_coord_array
.type
,
1626 tmuState1
.texture_coord_array
.stride
,
1627 tmuState1
.texture_coord_array
.ptr
);
1630 arraysValid
= GL_FALSE
;
1631 glEsImpl
->glDrawElements(mode
, count
, type
, indices
);
1634 void glEnableClientState(GLenum array
)
1636 struct nanotmuState
* clientstate
= NULL
;
1637 if (clientactivetmu
== GL_TEXTURE0
)
1639 clientstate
= &tmuState0
;
1641 else if (clientactivetmu
== GL_TEXTURE1
)
1643 clientstate
= &tmuState1
;
1651 case GL_VERTEX_ARRAY
:
1652 if (clientstate
->vertex_array
.enabled
)
1656 clientstate
->vertex_array
.enabled
= GL_TRUE
;
1657 clientstate
->vertex_array
.changed
= GL_TRUE
;
1659 case GL_COLOR_ARRAY
:
1660 if (clientstate
->color_array
.enabled
)
1664 clientstate
->color_array
.enabled
= GL_TRUE
;
1665 clientstate
->color_array
.changed
= GL_TRUE
;
1668 case GL_NORMAL_ARRAY
:
1669 if (clientstate
->normal_array
.enabled
)
1673 clientstate
->normal_array
.enabled
= GL_TRUE
;
1674 clientstate
->normal_array
.changed
= GL_TRUE
;
1677 case GL_TEXTURE_COORD_ARRAY
:
1678 if (clientstate
->texture_coord_array
.enabled
)
1682 clientstate
->texture_coord_array
.enabled
= GL_TRUE
;
1683 clientstate
->texture_coord_array
.changed
= GL_TRUE
;
1689 void glDisableClientState(GLenum array
)
1691 struct nanotmuState
* clientstate
= NULL
;
1692 if (clientactivetmu
== GL_TEXTURE0
)
1694 clientstate
= &tmuState0
;
1696 else if (clientactivetmu
== GL_TEXTURE1
)
1698 clientstate
= &tmuState1
;
1706 case GL_VERTEX_ARRAY
:
1707 if (!clientstate
->vertex_array
.enabled
)
1711 clientstate
->vertex_array
.enabled
= GL_FALSE
;
1712 clientstate
->vertex_array
.changed
= GL_TRUE
;
1714 case GL_COLOR_ARRAY
:
1715 if (!clientstate
->color_array
.enabled
)
1719 clientstate
->color_array
.enabled
= GL_FALSE
;
1720 clientstate
->color_array
.changed
= GL_TRUE
;
1723 case GL_NORMAL_ARRAY
:
1724 if (!clientstate
->normal_array
.enabled
)
1728 clientstate
->normal_array
.enabled
= GL_FALSE
;
1729 clientstate
->normal_array
.changed
= GL_TRUE
;
1732 case GL_TEXTURE_COORD_ARRAY
:
1733 if (!clientstate
->texture_coord_array
.enabled
)
1737 clientstate
->texture_coord_array
.enabled
= GL_FALSE
;
1738 clientstate
->texture_coord_array
.changed
= GL_TRUE
;
1744 void glVertexPointer( GLint size
, GLenum type
,GLsizei stride
, const GLvoid
*pointer
)
1746 if (tmuState0
.vertex_array
.size
== size
&&
1747 tmuState0
.vertex_array
.stride
== stride
&&
1748 tmuState0
.vertex_array
.type
== type
&&
1749 tmuState0
.vertex_array
.ptr
== pointer
)
1753 tmuState0
.vertex_array
.size
= size
;
1754 tmuState0
.vertex_array
.stride
= stride
;
1755 tmuState0
.vertex_array
.type
= type
;
1756 tmuState0
.vertex_array
.ptr
= (GLvoid
*)pointer
;
1757 tmuState0
.vertex_array
.changed
= GL_TRUE
;
1759 void glTexCoordPointer( GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*pointer
)
1761 struct nanotmuState
* clientstate
= NULL
;
1762 if (clientactivetmu
== GL_TEXTURE0
)
1764 clientstate
= &tmuState0
;
1766 else if (clientactivetmu
== GL_TEXTURE1
)
1768 clientstate
= &tmuState1
;
1770 if (clientstate
->texture_coord_array
.size
== size
&&
1771 clientstate
->texture_coord_array
.stride
== stride
&&
1772 clientstate
->texture_coord_array
.type
== type
&&
1773 clientstate
->texture_coord_array
.ptr
== pointer
)
1777 clientstate
->texture_coord_array
.size
= size
;
1778 clientstate
->texture_coord_array
.stride
= stride
;
1779 clientstate
->texture_coord_array
.type
= type
;
1780 clientstate
->texture_coord_array
.ptr
= (GLvoid
*)pointer
;
1781 clientstate
->texture_coord_array
.changed
= GL_TRUE
;
1783 void glColorPointer( GLint size
, GLenum type
, GLsizei stride
, const GLvoid
*pointer
)
1785 if (tmuState0
.color_array
.size
== size
&&
1786 tmuState0
.color_array
.stride
== stride
&&
1787 tmuState0
.color_array
.type
== type
&&
1788 tmuState0
.color_array
.ptr
== pointer
)
1792 tmuState0
.color_array
.size
= size
;
1793 tmuState0
.color_array
.stride
= stride
;
1794 tmuState0
.color_array
.type
= type
;
1795 tmuState0
.color_array
.ptr
= (GLvoid
*)pointer
;
1796 tmuState0
.color_array
.changed
= GL_TRUE
;
1799 void glNormalPointer( GLenum type
, GLsizei stride
, const GLvoid
*pointer
)
1802 if (tmuState0
.normal_array
.size
== size
&&
1803 tmuState0
.normal_array
.stride
== stride
&&
1804 tmuState0
.normal_array
.type
== type
&&
1805 tmuState0
.normal_array
.ptr
== pointer
)
1809 tmuState0
.normal_array
.size
= size
;
1810 tmuState0
.normal_array
.stride
= stride
;
1811 tmuState0
.normal_array
.type
= type
;
1812 tmuState0
.normal_array
.ptr
= (GLvoid
*)pointer
;
1813 tmuState0
.normal_array
.changed
= GL_TRUE
;
1815 void glPolygonOffset( GLfloat factor
, GLfloat units
)
1817 FlushOnStateChange();
1818 glEsImpl
->glPolygonOffset(factor
, units
);
1820 void glStencilMask( GLuint mask
) {}
1821 void glClearStencil( GLint s
) {}
1823 #if defined(__MULTITEXTURE_SUPPORT__)
1825 extern "C" void glMultiTexCoord2fARB( GLenum target
, GLfloat s
, GLfloat t
);
1827 void glMultiTexCoord2fARB( GLenum target
, GLfloat s
, GLfloat t
)
1829 if (target
== GL_TEXTURE0
)
1835 currentVertexAttrib
.s_multi
= s
;
1836 currentVertexAttrib
.t_multi
= t
;
1842 void glDrawArrays( GLenum mode
, int first
, int count
)
1844 FlushOnStateChange();
1845 glEsImpl
->glDrawArrays(mode
, first
, count
);
1847 void glMultMatrixf (const GLfloat
*m
)
1849 FlushOnStateChange();
1850 glEsImpl
->glMultMatrixf(m
);
1853 void glPixelStorei (GLenum pname
, GLint param
)
1855 FlushOnStateChange();
1856 glEsImpl
->glPixelStorei(pname
, param
);
1860 void glFogf (GLenum pname
, GLfloat param
)
1862 FlushOnStateChange();
1863 glEsImpl
->glFogf(pname
, param
);
1866 void glFogfv (GLenum pname
, const GLfloat
*params
)
1868 FlushOnStateChange();
1869 glEsImpl
->glFogfv(pname
, params
);
1872 void glGetTexParameteriv (GLenum target
, GLenum pname
, GLint
*params
)
1874 FlushOnStateChange();
1875 glEsImpl
->glGetTexParameteriv(target
, pname
, params
);
1879 // This gives: called unimplemented OpenGL ES API (Android)
1880 void glTexParameteri (GLenum target
, GLenum pname
, GLint param
)
1882 if (pname
== GL_TEXTURE_BORDER_COLOR
) {
1883 return; // not supported by opengl es
1885 if ( (pname
== GL_TEXTURE_WRAP_S
||
1886 pname
== GL_TEXTURE_WRAP_T
) &&
1887 param
== GL_CLAMP
) {
1891 FlushOnStateChange();
1892 glEsImpl
->glTexParameteri(target
, pname
, param
);
1895 void glTexParameterx (GLenum target
, GLenum pname
, GLfixed param
)
1897 if (pname
== GL_TEXTURE_BORDER_COLOR
) {
1898 return; // not supported by opengl es
1900 if ( (pname
== GL_TEXTURE_WRAP_S
||
1901 pname
== GL_TEXTURE_WRAP_T
) &&
1902 param
== GL_CLAMP
) {
1905 FlushOnStateChange();
1906 glEsImpl
->glTexParameterx(target
, pname
, param
);
1909 void glGenTextures (GLsizei n
, GLuint
*textures
)
1911 FlushOnStateChange();
1912 glEsImpl
->glGenTextures(n
, textures
);
1915 void glFrontFace (GLenum mode
)
1917 FlushOnStateChange();
1918 glEsImpl
->glFrontFace(mode
);
1922 void glTexEnvi (GLenum target
, GLenum pname
, GLint param
)
1924 if (target
== GL_TEXTURE_ENV
)
1926 if (pname
== GL_TEXTURE_ENV_MODE
)
1928 if (param
== activetmuState
->texture_env_mode
.value
)
1934 FlushOnStateChange();
1935 glEsImpl
->glTexEnvi(target
, pname
, param
);
1936 activetmuState
->texture_env_mode
.value
= param
;
1941 FlushOnStateChange();
1942 glEsImpl
->glTexEnvi(target
, pname
, param
);
1945 void pglMultiTexCoord3f(GLenum
, GLfloat
, GLfloat
, GLfloat
)
1950 void pglMultiTexCoord2f(GLenum
, GLfloat
, GLfloat
)
1955 /*void glNormalPointer(GLenum type, GLsizei stride, const void *ptr)
1957 glEsImpl->glNormalPointer( type, stride, ptr );
1960 void glCopyTexSubImage2D(GLenum target
, GLint level
, GLint xoffset
, GLint yoffset
, GLint x
, GLint y
, GLsizei width
, GLsizei height
)
1962 FlushOnStateChange();
1963 glEsImpl
->glCopyTexSubImage2D( target
, level
, xoffset
, yoffset
, x
, y
, width
, height
);
1966 void glGenFramebuffers (GLsizei n
, GLuint
* framebuffers
)
1968 FlushOnStateChange();
1969 glEsImpl
->glGenFramebuffers( n
, framebuffers
);
1973 void glGenRenderbuffers( GLsizei n
, GLuint
* renderbuffers
)
1975 FlushOnStateChange();
1976 glEsImpl
->glGenFramebuffers( n
, renderbuffers
);
1979 void glBindRenderbuffer(GLenum target
, GLuint renderbuffer
)
1981 FlushOnStateChange();
1982 glEsImpl
->glBindRenderbuffer( target
, renderbuffer
);
1985 void glBindFramebuffer(GLenum target
, GLuint framebuffer
)\
1987 FlushOnStateChange();
1988 glEsImpl
->glBindFramebuffer( target
, framebuffer
);
1991 void glFramebufferRenderbuffer(GLenum target
, GLenum attachment
, GLenum renderbuffertarget
, GLuint renderbuffer
)
1993 FlushOnStateChange();
1994 glEsImpl
->glFramebufferRenderbuffer( target
, attachment
, renderbuffertarget
, renderbuffer
);
1997 void glDeleteFramebuffers(GLsizei n
, const GLuint
*framebuffers
)
1999 FlushOnStateChange();
2000 glEsImpl
->glDeleteFramebuffers(n
, framebuffers
);
2003 void glDeleteRenderbuffers(GLsizei n
, const GLuint
*renderbuffers
)
2005 FlushOnStateChange();
2006 glEsImpl
->glDeleteRenderbuffers( n
, renderbuffers
);
2008 void glFramebufferTexture2D(GLenum target
, GLenum attachment
, GLenum textarget
, GLuint texture
, GLint level
)
2010 FlushOnStateChange();
2011 glEsImpl
->glFramebufferTexture2D(target
, attachment
,textarget
,texture
,level
);
2014 void glRenderbufferStorage(GLenum target
, GLenum internalformat
, GLsizei width
, GLsizei height
)
2016 FlushOnStateChange();
2017 glEsImpl
->glRenderbufferStorage(target
, internalformat
, width
, height
);