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>
32 #define GL_TEXTURE0_ARB 0x84C0
33 #define GL_TEXTURE1_ARB 0x84C1
35 struct nanoState
36 {
37 GLboolean alpha_test;
38 GLboolean blend;
39 GLboolean clip_planei;
40 GLboolean color_logic_op;
41 GLboolean color_material;
42 GLboolean cull_face;
43 GLboolean depth_test;
44 GLboolean dither;
45 GLboolean fog;
46 GLboolean lighti;
47 GLboolean lighting;
48 GLboolean line_smooth;
49 GLboolean matrix_palette_oes;
50 GLboolean multisample;
51 GLboolean normalize;
52 GLboolean point_smooth;
53 GLboolean point_sprite_oes;
54 GLboolean polygon_offset_fill;
55 GLboolean rescale_normal;
56 GLboolean sample_alpha_to_coverage;
57 GLboolean sample_alpha_to_one;
58 GLboolean sample_coverage;
59 GLboolean scissor_test;
60 GLboolean stencil_test;
61 GLboolean depthmask;
62 GLclampf depth_range_near;
63 GLclampf depth_range_far;
64 GLenum depth_func;
65 GLenum cullface;
66 GLenum shademodel;
67 GLenum sfactor;
68 GLenum dfactor;
69 GLenum matrixmode;
70 };
75 {
76 GL_FALSE,
77 GL_FALSE,
78 GL_FALSE,
79 GL_FALSE,
80 GL_FALSE,
81 GL_FALSE,
82 GL_FALSE,
83 GL_TRUE,
84 GL_FALSE,
85 GL_FALSE,
86 GL_FALSE,
87 GL_FALSE,
88 GL_FALSE,
89 GL_TRUE,
90 GL_FALSE,
91 GL_FALSE,
92 GL_FALSE,
93 GL_FALSE,
94 GL_FALSE,
95 GL_FALSE,
96 GL_FALSE,
97 GL_FALSE,
98 GL_FALSE,
99 GL_FALSE,
100 GL_TRUE,
103 GL_LESS,
104 GL_BACK,
105 GL_SMOOTH,
106 GL_ONE,
107 GL_ZERO,
108 GL_MODELVIEW,
109 };
111 struct booleanstate
112 {
113 GLboolean value;
114 GLboolean changed;
115 };
117 struct floatstate
118 {
119 GLfloat value;
120 GLboolean changed;
121 };
123 struct uintstate
124 {
125 GLuint value;
126 GLboolean changed;
127 };
129 struct ptrstate
130 {
131 GLint size;
132 GLenum type;
133 GLsizei stride;
135 GLboolean changed;
136 GLboolean enabled;
137 };
140 struct nanotmuState
141 {
148 };
154 {
161 };
172 #if defined(__MULTITEXTURE_SUPPORT__)
174 #endif
177 #if !defined (__WINS__)
178 //#define __FORCEINLINE __forceinline
179 #define __FORCEINLINE inline
180 #else
181 #define __FORCEINLINE
182 #endif
187 struct VertexAttrib
188 {
192 #if !defined(__MULTITEXTURE_SUPPORT__)
194 #endif
202 #if defined(__MULTITEXTURE_SUPPORT__)
205 #endif
206 };
221 #if defined(__MULTITEXTURE_SUPPORT__)
226 };
227 #else
231 };
232 #endif
238 {
260 }
263 {
266 {
268 }
269 else
270 {
272 }
275 {
277 }
278 else
279 {
281 }
284 {
286 }
287 else
288 {
290 }
310 glEsImpl->glColor4f (currentVertexAttrib.red, currentVertexAttrib.green, currentVertexAttrib.blue, currentVertexAttrib.alpha);
314 //glEsImpl->glBindTexture(GL_TEXTURE_2D, stackTextureState);
316 glEsImpl->glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, activetmuState->texture_env_mode.value);
319 }
322 {
324 {
327 }
333 {
341 #if defined(__MULTITEXTURE_SUPPORT__)
346 #endif
348 }
353 #if defined(__MULTITEXTURE_SUPPORT__)
355 #endif
362 }
365 {
370 }
373 {
374 vertexCount+=((unsigned char*)ptrVertexAttribArray-(unsigned char*)ptrVertexAttribArrayMark)/sizeof(VertexAttrib);
376 {
378 }
380 {
382 {
391 }
394 {
397 {
402 }
403 }
406 {
413 {
417 indexCount++;
424 {
429 }
432 {
436 indexCount++;
437 }
438 }
439 else
440 {
441 //already aligned
447 {
453 }
456 {
461 indexCount++;
462 }
463 }
465 }
469 {
475 {
480 }
481 }
486 }
487 }
490 {
493 {
495 {
497 {
500 }
502 }
504 {
506 {
509 }
511 }
512 //case GL_CLIP_PLANEi
514 {
516 {
519 }
521 }
523 {
525 {
528 }
530 }
532 {
534 {
537 }
539 }
541 {
543 {
546 }
548 }
550 {
552 {
555 }
557 }
559 //case GL_LIGHTi
560 {
562 {
565 }
567 }
569 {
571 {
574 }
576 }
578 {
580 {
583 }
585 }
586 /* case GL_MATRIX_PALETTE_OES:
587 {
588 if (!nanoglState.matrix_palette_oes)
589 {
590 nanoglState.matrix_palette_oes = GL_TRUE;
591 statechanged = GL_TRUE;
592 }
593 break;
594 }*/
596 {
598 {
601 }
603 }
605 {
607 {
610 }
612 }
613 /* case GL_POINT_SPRITE_OES:
614 {
615 if (!nanoglState.point_sprite_oes)
616 {
617 nanoglState.point_sprite_oes = GL_TRUE;
618 statechanged = GL_TRUE;
619 }
620 break;
621 }*/
623 {
625 {
628 }
630 }
632 {
634 {
637 }
639 }
641 {
643 {
646 }
648 }
650 {
652 {
655 }
657 }
659 {
661 {
664 }
666 }
668 {
670 {
673 }
675 }
677 {
679 /* if (!nanoglState.stencil_test)
680 {
681 nanoglState.stencil_test = GL_TRUE;
682 statechanged = GL_TRUE;
683 }*/
685 }
687 {
689 {
694 }
696 }
699 }
702 {
705 }
706 }
709 {
712 {
714 {
716 {
719 }
721 }
723 {
725 {
728 }
730 }
731 //case GL_CLIP_PLANEi
733 {
735 {
738 }
740 }
742 {
744 {
747 }
749 }
751 {
753 {
756 }
758 }
760 {
762 {
765 }
767 }
769 {
771 {
774 }
776 }
778 //case GL_LIGHTi
779 {
781 {
784 }
786 }
788 {
790 {
793 }
795 }
797 {
799 {
802 }
804 }
805 /* case GL_MATRIX_PALETTE_OES:
806 {
807 if (nanoglState.matrix_palette_oes)
808 {
809 nanoglState.matrix_palette_oes = GL_FALSE;
810 statechanged = GL_TRUE;
811 }
812 break;
813 }*/
815 {
817 {
820 }
822 }
824 {
826 {
829 }
831 }
832 /* case GL_POINT_SPRITE_OES:
833 {
834 if (nanoglState.point_sprite_oes)
835 {
836 nanoglState.point_sprite_oes = GL_FALSE;
837 statechanged = GL_TRUE;
838 }
839 break;
840 }*/
842 {
844 {
847 }
849 }
851 {
853 {
856 }
858 }
860 {
862 {
865 }
867 }
869 {
871 {
874 }
876 }
878 {
880 {
883 }
885 }
887 {
889 {
892 }
894 }
896 {
898 /* if (nanoglState.stencil_test)
899 {
900 nanoglState.stencil_test = GL_FALSE;
901 statechanged = GL_TRUE;
902 }*/
904 }
906 {
908 {
915 }
917 }
920 }
923 {
926 }
927 }
930 {
932 }
936 {
939 {
941 }
943 }
946 {
951 }
955 {
957 }
961 {
964 }
967 {
970 }
973 {
976 }
979 {
984 }
986 void glOrtho (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
987 {
990 }
993 {
995 {
997 }
1001 }
1004 {
1006 {
1008 }
1012 {
1014 }
1018 }
1021 {
1023 }
1025 void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
1026 {
1029 glEsImpl->glTexImage2D(target, level, internalformat, width, height,border,format,type,pixels);
1030 }
1033 {
1034 }
1037 {
1040 }
1043 {
1046 }
1049 {
1052 }
1055 {
1057 {
1059 }
1060 else
1061 {
1064 }
1067 }
1070 {
1072 {
1074 }
1075 else
1076 {
1078 }
1081 }
1084 {
1087 }
1090 {
1093 }
1096 {
1098 {
1100 }
1101 else
1102 {
1104 }
1107 }
1109 void glFrustum (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
1110 {
1113 }
1116 {
1119 }
1123 {
1128 #if defined(__MULTITEXTURE_SUPPORT__)
1130 #else
1132 #endif
1134 }
1137 {
1142 }
1145 {
1150 }
1153 {
1154 //*((unsigned int*)(¤tVertexAttrib.red)) = *((unsigned int*)(v));
1159 }
1162 {
1167 }
1169 //-- nicknekit: xash3d funcs --
1172 {
1177 }
1180 {
1185 }
1188 {
1191 }
1193 void glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border )
1194 {
1197 }
1199 void glTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
1200 {
1202 }
1204 void glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
1205 {
1206 glTexImage2D(GL_TEXTURE_2D, level, internalformat, width, height, border, format, type, pixels);
1207 }
1209 void glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels )
1210 {
1212 }
1218 GLenum format,
1220 {
1222 }
1227 {
1230 }
1234 {
1235 //for mirrors? not needed for original hl?
1236 }
1239 {
1240 //for mirrors? not needed for original hl?
1241 }
1243 //-- --//
1246 {
1249 }
1252 {
1254 {
1256 }
1261 }
1264 {
1267 }
1270 {
1272 {
1274 }
1278 }
1281 {
1284 }
1287 {
1289 {
1291 {
1293 {
1295 }
1296 else
1297 {
1302 }
1303 }
1304 }
1307 }
1310 {
1313 #if defined(__MULTITEXTURE_SUPPORT__)
1315 #else
1317 #endif
1318 }
1322 {
1324 {
1326 }
1330 }
1333 {
1335 {
1337 }
1341 }
1345 {
1348 }
1352 {
1355 {
1356 #if defined(__MULTITEXTURE_SUPPORT__)
1357 sprintf((char*)nano_extensions_string,"%s %s",glEsImpl->glGetString(name),"GL_ARB_multitexture EXT_texture_env_add");
1358 #else
1359 sprintf((char*)nano_extensions_string,"%s %s",glEsImpl->glGetString(name),"EXT_texture_env_add");
1360 #endif
1362 }
1364 }
1367 {
1370 }
1373 {
1376 }
1378 void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
1379 {
1381 {
1382 // OpenglEs 1.1 does not support reading depth buffer without an extension
1385 }
1388 }
1391 {
1393 }
1396 {
1399 }
1401 void glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
1402 {
1405 }
1408 {
1411 }
1414 {
1417 }
1420 {
1422 {
1424 }
1426 {
1428 }
1429 else
1430 {
1433 }
1435 {
1437 }
1438 else
1439 {
1441 }
1443 }
1446 {
1448 }
1451 {
1452 }
1455 {
1458 }
1461 {
1464 }
1467 {
1475 }
1478 {
1481 }
1484 {
1487 }
1501 {
1502 // ensure that all primitives specified between glBegin/glEnd pairs
1503 // are rendered first, and that we have correct tmu in use..
1505 // setup correct vertex/color/texcoord pointers
1510 {
1512 }
1514 {
1516 {
1518 }
1519 else
1520 {
1522 }
1528 }
1530 {
1532 {
1534 }
1535 else
1536 {
1538 }
1544 }
1546 {
1549 {
1551 }
1552 else
1553 {
1555 }
1560 }
1563 {
1567 {
1569 }
1570 else
1571 {
1573 }
1578 }
1582 }
1585 {
1588 {
1590 }
1592 {
1594 }
1595 else
1596 {
1598 }
1600 {
1603 {
1605 }
1611 {
1613 }
1620 {
1622 }
1628 }
1629 }
1631 {
1634 {
1636 }
1638 {
1640 }
1641 else
1642 {
1644 }
1646 {
1649 {
1651 }
1657 {
1659 }
1666 {
1668 }
1674 }
1675 }
1677 {
1682 {
1684 }
1690 }
1692 {
1695 {
1697 }
1699 {
1701 }
1706 {
1708 }
1714 }
1716 {
1721 {
1723 }
1729 }
1731 {
1734 }
1738 #if defined(__MULTITEXTURE_SUPPORT__)
1743 {
1745 {
1747 }
1748 else
1749 {
1752 }
1753 }
1754 #endif
1756 /* Vladimir */
1758 {
1761 }
1763 {
1766 }
1769 {
1772 }
1776 {
1779 }
1782 {
1785 }
1788 {
1791 }
1794 // This gives: called unimplemented OpenGL ES API (Android)
1796 {
1799 }
1804 }
1808 }
1811 {
1814 }
1819 }
1822 }
1825 {
1828 }
1831 {
1834 }
1838 // End Vladimir