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>
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 lighti;
48 GLboolean lighting;
49 GLboolean line_smooth;
50 GLboolean matrix_palette_oes;
51 GLboolean multisample;
52 GLboolean normalize;
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;
62 GLboolean depthmask;
63 GLclampf depth_range_near;
64 GLclampf depth_range_far;
65 GLenum depth_func;
66 GLenum cullface;
67 GLenum shademodel;
68 GLenum sfactor;
69 GLenum dfactor;
70 GLenum matrixmode;
71 };
76 {
77 GL_FALSE,
78 GL_FALSE,
79 GL_FALSE,
80 GL_FALSE,
81 GL_FALSE,
82 GL_FALSE,
83 GL_FALSE,
84 GL_TRUE,
85 GL_FALSE,
86 GL_FALSE,
87 GL_FALSE,
88 GL_FALSE,
89 GL_FALSE,
90 GL_TRUE,
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_FALSE,
101 GL_TRUE,
104 GL_LESS,
105 GL_BACK,
106 GL_SMOOTH,
107 GL_ONE,
108 GL_ZERO,
109 GL_MODELVIEW,
110 };
112 struct booleanstate
113 {
114 GLboolean value;
115 GLboolean changed;
116 };
118 struct floatstate
119 {
120 GLfloat value;
121 GLboolean changed;
122 };
124 struct uintstate
125 {
126 GLuint value;
127 GLboolean changed;
128 };
130 struct ptrstate
131 {
132 GLint size;
133 GLenum type;
134 GLsizei stride;
136 GLboolean changed;
137 GLboolean enabled;
138 };
141 struct nanotmuState
142 {
149 };
155 {
162 };
173 #if defined(__MULTITEXTURE_SUPPORT__)
175 #endif
178 #if !defined (__WINS__)
179 //#define __FORCEINLINE __forceinline
180 #define __FORCEINLINE inline
181 #else
182 #define __FORCEINLINE
183 #endif
188 struct VertexAttrib
189 {
193 #if !defined(__MULTITEXTURE_SUPPORT__)
195 #endif
203 #if defined(__MULTITEXTURE_SUPPORT__)
206 #endif
207 };
222 #if defined(__MULTITEXTURE_SUPPORT__)
227 };
228 #else
232 };
233 #endif
239 {
261 }
264 {
267 {
269 }
270 else
271 {
273 }
276 {
278 }
279 else
280 {
282 }
285 {
287 }
288 else
289 {
291 }
311 glEsImpl->glColor4f (currentVertexAttrib.red, currentVertexAttrib.green, currentVertexAttrib.blue, currentVertexAttrib.alpha);
315 //glEsImpl->glBindTexture(GL_TEXTURE_2D, stackTextureState);
317 glEsImpl->glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, activetmuState->texture_env_mode.value);
320 }
323 {
325 {
328 }
334 {
342 #if defined(__MULTITEXTURE_SUPPORT__)
347 #endif
349 }
354 #if defined(__MULTITEXTURE_SUPPORT__)
356 #endif
363 }
365 {
367 }
369 {
371 }
373 {
378 }
381 {
382 vertexCount+=((unsigned char*)ptrVertexAttribArray-(unsigned char*)ptrVertexAttribArrayMark)/sizeof(VertexAttrib);
384 {
386 }
388 {
390 {
399 }
402 {
405 {
410 }
411 }
414 {
421 {
425 indexCount++;
432 {
437 }
440 {
444 indexCount++;
445 }
446 }
447 else
448 {
449 //already aligned
455 {
461 }
464 {
469 indexCount++;
470 }
471 }
473 }
477 {
483 {
488 }
489 }
494 }
495 }
498 {
501 {
503 {
505 {
508 }
510 }
512 {
514 {
517 }
519 }
520 //case GL_CLIP_PLANEi
522 {
524 {
527 }
529 }
531 {
533 {
536 }
538 }
540 {
542 {
545 }
547 }
549 {
551 {
554 }
556 }
558 {
560 {
563 }
565 }
567 //case GL_LIGHTi
568 {
570 {
573 }
575 }
577 {
579 {
582 }
584 }
586 {
588 {
591 }
593 }
594 /* case GL_MATRIX_PALETTE_OES:
595 {
596 if (!nanoglState.matrix_palette_oes)
597 {
598 nanoglState.matrix_palette_oes = GL_TRUE;
599 statechanged = GL_TRUE;
600 }
601 break;
602 }*/
604 {
606 {
609 }
611 }
613 {
615 {
618 }
620 }
621 /* case GL_POINT_SPRITE_OES:
622 {
623 if (!nanoglState.point_sprite_oes)
624 {
625 nanoglState.point_sprite_oes = GL_TRUE;
626 statechanged = GL_TRUE;
627 }
628 break;
629 }*/
631 {
633 {
636 }
638 }
640 {
642 {
645 }
647 }
649 {
651 {
654 }
656 }
658 {
660 {
663 }
665 }
667 {
669 {
672 }
674 }
676 {
678 {
681 }
683 }
685 {
687 /* if (!nanoglState.stencil_test)
688 {
689 nanoglState.stencil_test = GL_TRUE;
690 statechanged = GL_TRUE;
691 }*/
693 }
695 {
697 {
702 }
704 }
707 }
710 {
713 }
714 }
717 {
720 {
722 {
724 {
727 }
729 }
731 {
733 {
736 }
738 }
739 //case GL_CLIP_PLANEi
741 {
743 {
746 }
748 }
750 {
752 {
755 }
757 }
759 {
761 {
764 }
766 }
768 {
770 {
773 }
775 }
777 {
779 {
782 }
784 }
786 //case GL_LIGHTi
787 {
789 {
792 }
794 }
796 {
798 {
801 }
803 }
805 {
807 {
810 }
812 }
813 /* case GL_MATRIX_PALETTE_OES:
814 {
815 if (nanoglState.matrix_palette_oes)
816 {
817 nanoglState.matrix_palette_oes = GL_FALSE;
818 statechanged = GL_TRUE;
819 }
820 break;
821 }*/
823 {
825 {
828 }
830 }
832 {
834 {
837 }
839 }
840 /* case GL_POINT_SPRITE_OES:
841 {
842 if (nanoglState.point_sprite_oes)
843 {
844 nanoglState.point_sprite_oes = GL_FALSE;
845 statechanged = GL_TRUE;
846 }
847 break;
848 }*/
850 {
852 {
855 }
857 }
859 {
861 {
864 }
866 }
868 {
870 {
873 }
875 }
877 {
879 {
882 }
884 }
886 {
888 {
891 }
893 }
895 {
897 {
900 }
902 }
904 {
906 /* if (nanoglState.stencil_test)
907 {
908 nanoglState.stencil_test = GL_FALSE;
909 statechanged = GL_TRUE;
910 }*/
912 }
914 {
916 {
923 }
925 }
928 }
931 {
934 }
935 }
938 {
940 }
944 {
947 {
949 }
951 }
954 {
959 }
963 {
965 }
969 {
972 }
975 {
978 }
981 {
984 }
987 {
992 }
994 void glOrtho (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
995 {
998 }
1001 {
1003 {
1005 }
1009 }
1012 {
1014 {
1016 }
1020 {
1022 }
1026 }
1029 {
1031 }
1033 void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
1034 {
1037 glEsImpl->glTexImage2D(target, level, internalformat, width, height,border,format,type,pixels);
1038 }
1041 {
1042 }
1045 {
1048 }
1051 {
1054 }
1057 {
1060 }
1063 {
1065 {
1067 }
1068 else
1069 {
1072 }
1075 }
1078 {
1080 {
1082 }
1083 else
1084 {
1086 }
1089 }
1092 {
1095 }
1098 {
1101 }
1104 {
1106 {
1108 }
1109 else
1110 {
1112 }
1115 }
1117 void glFrustum (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
1118 {
1121 }
1124 {
1127 }
1131 {
1136 #if defined(__MULTITEXTURE_SUPPORT__)
1138 #else
1140 #endif
1142 }
1145 {
1150 }
1153 {
1158 }
1161 {
1162 //*((unsigned int*)(¤tVertexAttrib.red)) = *((unsigned int*)(v));
1167 }
1170 {
1175 }
1177 //-- nicknekit: xash3d funcs --
1180 {
1182 }
1186 {
1188 }
1191 {
1193 }
1196 {
1198 }
1201 {
1203 }
1212 {
1214 }
1217 {
1219 }
1222 {
1224 }
1227 {
1229 }
1232 {
1234 }
1236 void glDrawPixels( GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ) { }
1241 {
1243 }
1245 void glCopyTexImage1D( GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border )
1246 {
1248 }
1250 void glCopyTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width )
1251 {
1253 }
1260 {
1262 }
1265 {
1270 }
1273 {
1278 }
1281 {
1284 }
1286 void glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border )
1287 {
1290 }
1292 void glTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
1293 {
1295 }
1297 void glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
1298 {
1299 glTexImage2D(GL_TEXTURE_2D, level, internalformat, width, height, border, format, type, pixels);
1300 }
1302 void glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels )
1303 {
1305 }
1311 GLenum format,
1313 {
1315 }
1320 {
1323 }
1327 {
1328 //for mirrors? not needed for original hl?
1329 }
1332 {
1333 //for mirrors? not needed for original hl?
1334 }
1337 {
1340 }
1343 {
1345 {
1347 }
1348 }
1350 void glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height )
1351 {
1354 }
1357 {
1360 }
1363 {
1366 }
1369 {
1372 }
1375 {
1378 }
1381 {
1384 }
1386 //-- --//
1389 {
1392 }
1395 {
1397 {
1399 }
1404 }
1407 {
1410 }
1413 {
1415 {
1417 }
1421 }
1424 {
1427 }
1430 {
1432 {
1434 {
1436 {
1438 }
1439 else
1440 {
1445 }
1446 }
1447 }
1450 }
1453 {
1456 #if defined(__MULTITEXTURE_SUPPORT__)
1458 #else
1460 #endif
1461 }
1465 {
1467 {
1469 }
1473 }
1476 {
1478 {
1480 }
1484 }
1488 {
1491 }
1495 {
1498 {
1499 #if defined(__MULTITEXTURE_SUPPORT__)
1500 sprintf((char*)nano_extensions_string,"%s %s",glEsImpl->glGetString(name),"GL_ARB_multitexture EXT_texture_env_add");
1501 #else
1502 sprintf((char*)nano_extensions_string,"%s %s",glEsImpl->glGetString(name),"EXT_texture_env_add");
1503 #endif
1505 }
1507 }
1510 {
1513 }
1516 {
1519 }
1521 void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
1522 {
1524 {
1525 // OpenglEs 1.1 does not support reading depth buffer without an extension
1528 }
1531 }
1534 {
1536 }
1539 {
1542 }
1544 void glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
1545 {
1548 }
1551 {
1554 }
1557 {
1558 //FlushOnStateChange();
1560 }
1563 {
1565 {
1567 }
1569 {
1571 }
1572 else
1573 {
1576 }
1578 {
1580 }
1581 else
1582 {
1584 }
1586 }
1589 {
1591 }
1594 {
1595 }
1598 {
1601 }
1604 {
1607 }
1610 {
1618 }
1621 {
1624 }
1627 {
1630 }
1644 {
1645 // ensure that all primitives specified between glBegin/glEnd pairs
1646 // are rendered first, and that we have correct tmu in use..
1648 // setup correct vertex/color/texcoord pointers
1653 {
1655 }
1657 {
1659 {
1661 }
1662 else
1663 {
1665 }
1671 }
1673 {
1675 {
1677 }
1678 else
1679 {
1681 }
1687 }
1689 {
1692 {
1694 }
1695 else
1696 {
1698 }
1703 }
1706 {
1710 {
1712 }
1713 else
1714 {
1716 }
1721 }
1725 }
1728 {
1731 {
1733 }
1735 {
1737 }
1738 else
1739 {
1741 }
1743 {
1746 {
1748 }
1754 {
1756 }
1763 {
1765 }
1771 }
1772 }
1774 {
1777 {
1779 }
1781 {
1783 }
1784 else
1785 {
1787 }
1789 {
1792 {
1794 }
1800 {
1802 }
1809 {
1811 }
1817 }
1818 }
1820 {
1825 {
1827 }
1833 }
1835 {
1838 {
1840 }
1842 {
1844 }
1849 {
1851 }
1857 }
1859 {
1864 {
1866 }
1872 }
1874 {
1877 }
1881 #if defined(__MULTITEXTURE_SUPPORT__)
1886 {
1888 {
1890 }
1891 else
1892 {
1895 }
1896 }
1897 #endif
1899 /* Vladimir */
1901 {
1904 }
1906 {
1909 }
1912 {
1915 }
1919 {
1922 }
1925 {
1928 }
1931 {
1934 }
1937 // This gives: called unimplemented OpenGL ES API (Android)
1939 {
1942 }
1947 }
1951 }
1954 {
1957 }
1962 }
1965 }
1968 {
1971 }
1974 {
1977 }
1981 // End Vladimir