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 {
151 };
157 {
165 };
176 #if defined(__MULTITEXTURE_SUPPORT__)
178 #endif
181 #if !defined (__WINS__)
182 //#define __FORCEINLINE __forceinline
183 #define __FORCEINLINE inline
184 #else
185 #define __FORCEINLINE
186 #endif
191 struct VertexAttrib
192 {
196 #if !defined(__MULTITEXTURE_SUPPORT__)
198 #endif
206 #if defined(__MULTITEXTURE_SUPPORT__)
209 #endif
210 };
225 #if defined(__MULTITEXTURE_SUPPORT__)
230 };
231 #else
235 };
236 #endif
242 {
264 }
267 {
270 {
272 }
273 else
274 {
276 }
279 {
281 }
282 else
283 {
285 }
288 {
290 }
291 else
292 {
294 }
297 {
299 }
300 else
301 {
303 }
328 glEsImpl->glColor4f (currentVertexAttrib.red, currentVertexAttrib.green, currentVertexAttrib.blue, currentVertexAttrib.alpha);
332 //glEsImpl->glBindTexture(GL_TEXTURE_2D, stackTextureState);
334 glEsImpl->glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, activetmuState->texture_env_mode.value);
337 }
340 {
342 {
344 #ifndef USE_CORE_PROFILE
346 #endif
347 }
353 {
361 #if defined(__MULTITEXTURE_SUPPORT__)
366 #endif
368 }
373 #if defined(__MULTITEXTURE_SUPPORT__)
375 #endif
382 }
384 {
386 }
388 {
390 }
392 {
397 }
400 {
401 vertexCount+=((unsigned char*)ptrVertexAttribArray-(unsigned char*)ptrVertexAttribArrayMark)/sizeof(VertexAttrib);
403 {
405 }
407 {
409 {
418 }
421 {
424 {
429 }
430 }
433 {
440 {
444 indexCount++;
451 {
456 }
459 {
463 indexCount++;
464 }
465 }
466 else
467 {
468 //already aligned
474 {
480 }
483 {
488 indexCount++;
489 }
490 }
492 }
496 {
502 {
507 }
508 }
513 }
517 }
520 {
523 {
525 {
527 {
530 }
532 }
534 {
536 {
539 }
541 }
542 //case GL_CLIP_PLANEi
544 {
546 {
549 }
551 }
553 {
555 {
558 }
560 }
562 {
564 {
567 }
569 }
571 {
573 {
576 }
578 }
580 {
582 {
585 }
587 }
589 //case GL_LIGHTi
590 {
592 {
595 }
597 }
599 {
601 {
604 }
606 }
608 {
610 {
613 }
615 }
616 /* case GL_MATRIX_PALETTE_OES:
617 {
618 if (!nanoglState.matrix_palette_oes)
619 {
620 nanoglState.matrix_palette_oes = GL_TRUE;
621 statechanged = GL_TRUE;
622 }
623 break;
624 }*/
626 {
628 {
631 }
633 }
635 {
637 {
640 }
642 }
643 /* case GL_POINT_SPRITE_OES:
644 {
645 if (!nanoglState.point_sprite_oes)
646 {
647 nanoglState.point_sprite_oes = GL_TRUE;
648 statechanged = GL_TRUE;
649 }
650 break;
651 }*/
653 {
655 {
658 }
660 }
662 {
664 {
667 }
669 }
671 {
673 {
676 }
678 }
680 {
682 {
685 }
687 }
689 {
691 {
694 }
696 }
698 {
700 {
703 }
705 }
707 {
709 /* if (!nanoglState.stencil_test)
710 {
711 nanoglState.stencil_test = GL_TRUE;
712 statechanged = GL_TRUE;
713 }*/
715 }
717 {
719 {
724 }
726 }
729 }
732 {
735 }
736 }
739 {
742 {
744 {
746 {
749 }
751 }
753 {
755 {
758 }
760 }
761 //case GL_CLIP_PLANEi
763 {
765 {
768 }
770 }
772 {
774 {
777 }
779 }
781 {
783 {
786 }
788 }
790 {
792 {
795 }
797 }
799 {
801 {
804 }
806 }
808 //case GL_LIGHTi
809 {
811 {
814 }
816 }
818 {
820 {
823 }
825 }
827 {
829 {
832 }
834 }
835 /* case GL_MATRIX_PALETTE_OES:
836 {
837 if (nanoglState.matrix_palette_oes)
838 {
839 nanoglState.matrix_palette_oes = GL_FALSE;
840 statechanged = GL_TRUE;
841 }
842 break;
843 }*/
845 {
847 {
850 }
852 }
854 {
856 {
859 }
861 }
862 /* case GL_POINT_SPRITE_OES:
863 {
864 if (nanoglState.point_sprite_oes)
865 {
866 nanoglState.point_sprite_oes = GL_FALSE;
867 statechanged = GL_TRUE;
868 }
869 break;
870 }*/
872 {
874 {
877 }
879 }
881 {
883 {
886 }
888 }
890 {
892 {
895 }
897 }
899 {
901 {
904 }
906 }
908 {
910 {
913 }
915 }
917 {
919 {
922 }
924 }
926 {
928 /* if (nanoglState.stencil_test)
929 {
930 nanoglState.stencil_test = GL_FALSE;
931 statechanged = GL_TRUE;
932 }*/
934 }
936 {
938 {
945 }
947 }
950 }
953 {
956 }
957 }
960 {
962 }
966 {
969 {
971 }
973 }
976 {
981 }
985 {
987 }
991 {
994 }
997 {
1000 }
1003 {
1006 }
1009 {
1014 }
1016 void glOrtho (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
1017 {
1019 #ifdef USE_CORE_PROFILE
1021 #else
1023 #endif
1024 }
1027 {
1029 {
1031 }
1035 }
1038 {
1040 {
1042 }
1046 {
1048 }
1052 }
1055 {
1057 }
1059 void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
1060 {
1063 glEsImpl->glTexImage2D(target, level, internalformat, width, height,border,format,type,pixels);
1064 }
1067 {
1068 }
1071 {
1074 }
1077 {
1080 }
1083 {
1086 }
1089 {
1091 {
1093 }
1094 else
1095 {
1098 }
1100 #ifdef USE_CORE_PROFILE
1102 #else
1104 #endif
1105 }
1108 {
1110 {
1112 }
1113 else
1114 {
1116 }
1119 }
1122 {
1125 }
1128 {
1131 }
1134 {
1136 {
1138 }
1139 else
1140 {
1142 }
1145 }
1147 void glFrustum (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
1148 {
1151 }
1154 {
1157 }
1161 {
1166 #if defined(__MULTITEXTURE_SUPPORT__)
1168 #else
1170 #endif
1172 }
1175 {
1180 }
1183 {
1188 }
1191 {
1192 //*((unsigned int*)(¤tVertexAttrib.red)) = *((unsigned int*)(v));
1197 }
1200 {
1205 }
1207 //-- nicknekit: xash3d funcs --
1210 {
1215 }
1218 {
1223 }
1226 {
1229 }
1231 void glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border )
1232 {
1235 }
1237 void glTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
1238 {
1240 }
1242 void glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
1243 {
1244 glTexImage2D(GL_TEXTURE_2D, level, internalformat, width, height, border, format, type, pixels);
1245 }
1247 void glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels )
1248 {
1250 }
1256 GLenum format,
1258 {
1260 }
1265 {
1268 }
1272 {
1273 //for mirrors? not needed for original hl?
1274 }
1277 {
1278 //for mirrors? not needed for original hl?
1279 }
1281 //-- --//
1284 {
1287 }
1290 {
1292 {
1294 }
1299 }
1302 {
1305 }
1308 {
1310 {
1312 }
1316 }
1319 {
1322 }
1325 {
1327 {
1329 {
1331 {
1333 }
1334 else
1335 {
1340 }
1341 }
1342 }
1345 }
1348 {
1351 #if defined(__MULTITEXTURE_SUPPORT__)
1353 #else
1355 #endif
1356 }
1360 {
1362 {
1364 }
1368 }
1371 {
1373 {
1375 }
1379 }
1383 {
1386 }
1390 {
1393 {
1394 #if defined(__MULTITEXTURE_SUPPORT__)
1395 sprintf((char*)nano_extensions_string,"%s %s",glEsImpl->glGetString(name),"GL_ARB_multitexture EXT_texture_env_add");
1396 #else
1397 sprintf((char*)nano_extensions_string,"%s %s",glEsImpl->glGetString(name),"EXT_texture_env_add");
1398 #endif
1400 }
1402 }
1405 {
1408 }
1411 {
1414 }
1416 void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
1417 {
1419 {
1420 // OpenglEs 1.1 does not support reading depth buffer without an extension
1423 }
1426 }
1429 {
1431 }
1434 {
1437 }
1439 void glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
1440 {
1443 }
1446 {
1449 }
1452 {
1453 //FlushOnStateChange();
1455 }
1458 {
1460 {
1462 }
1464 {
1466 }
1467 else
1468 {
1471 }
1473 {
1475 }
1476 else
1477 {
1479 }
1481 }
1484 {
1486 }
1489 {
1490 }
1493 {
1496 }
1499 {
1502 }
1505 {
1513 }
1516 {
1519 }
1522 {
1525 }
1539 {
1540 // ensure that all primitives specified between glBegin/glEnd pairs
1541 // are rendered first, and that we have correct tmu in use..
1543 // setup correct vertex/color/texcoord pointers
1548 {
1550 }
1552 {
1554 {
1556 }
1557 else
1558 {
1560 }
1566 }
1568 {
1570 {
1572 }
1573 else
1574 {
1576 }
1582 }
1584 {
1586 {
1588 }
1589 else
1590 {
1592 }
1597 }
1599 {
1602 {
1604 }
1605 else
1606 {
1608 }
1613 }
1616 {
1620 {
1622 }
1623 else
1624 {
1626 }
1631 }
1635 }
1638 {
1641 {
1643 }
1645 {
1647 }
1648 else
1649 {
1651 }
1653 {
1656 {
1658 }
1664 {
1666 }
1673 {
1675 }
1682 {
1684 }
1690 }
1691 }
1693 {
1696 {
1698 }
1700 {
1702 }
1703 else
1704 {
1706 }
1708 {
1711 {
1713 }
1719 {
1721 }
1728 {
1730 }
1737 {
1739 }
1745 }
1746 }
1748 {
1753 {
1755 }
1761 }
1763 {
1766 {
1768 }
1770 {
1772 }
1777 {
1779 }
1785 }
1787 {
1792 {
1794 }
1800 }
1803 {
1809 {
1811 }
1817 }
1819 {
1822 }
1826 #if defined(__MULTITEXTURE_SUPPORT__)
1831 {
1833 {
1835 }
1836 else
1837 {
1840 }
1841 }
1842 #endif
1844 /* Vladimir */
1845 /*void glDrawArrays( GLenum mode, int first, int count)
1846 {
1847 FlushOnStateChange();
1848 glEsImpl->glDrawArrays(mode, first , count);
1849 }*/
1851 {
1854 }
1857 {
1860 }
1864 {
1867 }
1870 {
1873 }
1876 {
1879 }
1882 // This gives: called unimplemented OpenGL ES API (Android)
1884 {
1887 }
1892 }
1896 }
1899 {
1902 }
1907 }
1910 }
1913 {
1916 }
1919 {
1922 }
1923 // End Vladimir
1926 {
1928 {
1930 {
1932 {
1934 }
1935 else
1936 {
1941 }
1942 }
1943 }
1946 }
1949 {
1951 }
1954 {
1956 }
1958 {
1959 // ensure that all primitives specified between glBegin/glEnd pairs
1960 // are rendered first, and that we have correct tmu in use..
1963 // setup correct vertex/color/texcoord pointers
1968 {
1970 }
1972 {
1974 {
1976 }
1977 else
1978 {
1980 }
1986 }
1988 {
1990 {
1992 }
1993 else
1994 {
1996 }
2002 }
2004 {
2006 {
2008 }
2009 else
2010 {
2012 }
2017 }
2019 {
2022 {
2024 }
2025 else
2026 {
2028 }
2033 }
2036 {
2040 {
2042 }
2043 else
2044 {
2046 }
2051 }
2055 }
2056 /*void glNormalPointer(GLenum type, GLsizei stride, const void *ptr)
2057 {
2058 glEsImpl->glNormalPointer( type, stride, ptr );
2059 }*/
2061 void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
2062 {
2065 }
2068 {
2071 }
2075 {
2078 }
2081 {
2084 }
2087 {
2090 }
2092 void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
2093 {
2096 }
2099 {
2102 }
2105 {
2108 }
2109 void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
2110 {
2113 }
2115 void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
2116 {
2119 }