b9097386b430fd2920a8f23e63a567b96f2292b1
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 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 GLclampd depth_range_near;
71 GLclampd depth_range_far;
72 GLenum depth_func;
73 GLenum cullface;
74 GLenum shademodel;
75 GLenum sfactor;
76 GLenum dfactor;
77 GLenum matrixmode;
78 };
83 {
84 GL_FALSE,
85 GL_FALSE,
86 GL_FALSE,
87 GL_FALSE,
88 GL_FALSE,
89 GL_FALSE,
90 GL_FALSE,
91 GL_TRUE,
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_FALSE,
102 GL_FALSE,
103 GL_FALSE,
104 GL_TRUE,
105 GL_FALSE,
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_TRUE,
118 GL_LESS,
119 GL_BACK,
120 GL_SMOOTH,
121 GL_ONE,
122 GL_ZERO,
123 GL_MODELVIEW,
124 };
126 struct booleanstate
127 {
128 GLboolean value;
129 GLboolean changed;
130 };
132 struct floatstate
133 {
134 GLfloat value;
135 GLboolean changed;
136 };
138 struct uintstate
139 {
140 GLuint value;
141 GLboolean changed;
142 };
144 struct ptrstate
145 {
146 GLint size;
147 GLenum type;
148 GLsizei stride;
150 GLboolean changed;
151 GLboolean enabled;
152 };
154 struct nanotmuState
155 {
163 };
169 {
177 };
188 #if defined( __MULTITEXTURE_SUPPORT__ )
190 #endif
192 #if !defined( __WINS__ )
193 //#define __FORCEINLINE __forceinline
194 #define __FORCEINLINE inline
195 #else
196 #define __FORCEINLINE
197 #endif
202 struct VertexAttrib
203 {
207 #if !defined( __MULTITEXTURE_SUPPORT__ )
209 #endif
217 #if defined( __MULTITEXTURE_SUPPORT__ )
220 #endif
221 };
236 #if defined( __MULTITEXTURE_SUPPORT__ )
237 static VertexAttrib currentVertexAttribInit = {0.0f, 0.0f, 0.0f, 255, 255, 255, 255, 0.0f, 0.0f, 0.0f, 0.0f};
238 #else
241 };
242 #endif
250 {
272 }
275 {
278 {
280 }
281 else
282 {
284 }
287 {
289 }
290 else
291 {
293 }
296 {
298 }
299 else
300 {
302 }
305 {
307 }
308 else
309 {
311 }
339 //glEsImpl->glBindTexture(GL_TEXTURE_2D, stackTextureState);
341 glEsImpl->glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, activetmuState->texture_env_mode.value );
345 }
348 {
352 {
354 #ifndef USE_CORE_PROFILE
356 #endif
357 }
363 {
371 #if defined( __MULTITEXTURE_SUPPORT__ )
376 #endif
378 }
382 #if defined( __MULTITEXTURE_SUPPORT__ )
384 #endif
391 }
393 {
395 }
397 {
399 }
401 {
406 }
409 {
410 vertexCount += ( (unsigned char *)ptrVertexAttribArray - (unsigned char *)ptrVertexAttribArrayMark ) / sizeof( VertexAttrib );
412 {
414 }
416 {
418 {
427 }
430 {
433 {
438 }
439 }
442 {
449 {
453 indexCount++;
460 {
465 }
468 {
472 indexCount++;
473 }
474 }
475 else
476 {
477 //already aligned
483 {
488 }
491 {
496 indexCount++;
497 }
498 }
500 }
504 {
510 {
515 }
516 }
521 }
525 }
528 {
530 {
533 }
536 {
538 {
540 {
543 }
545 }
547 {
549 {
552 }
554 }
555 //case GL_CLIP_PLANEi
557 {
559 {
562 }
564 }
566 {
568 {
571 }
573 }
575 {
577 {
580 }
582 }
584 {
586 {
589 }
591 }
593 {
595 {
598 }
600 }
602 {
604 {
607 }
609 }
611 {
613 {
616 }
618 }
620 {
622 {
625 }
627 }
629 {
631 {
634 }
636 }
638 {
640 {
643 }
645 }
647 {
649 {
652 }
654 }
656 {
658 {
661 }
663 }
665 {
667 {
670 }
672 }
674 {
676 {
679 }
681 }
683 {
685 {
688 }
690 }
692 {
694 {
697 }
699 }
700 /* case GL_MATRIX_PALETTE_OES:
701 {
702 if (!nanoglState.matrix_palette_oes)
703 {
704 nanoglState.matrix_palette_oes = GL_TRUE;
705 statechanged = GL_TRUE;
706 }
707 break;
708 }*/
710 {
712 {
715 }
717 }
719 {
721 {
724 }
726 }
727 /* case GL_POINT_SPRITE_OES:
728 {
729 if (!nanoglState.point_sprite_oes)
730 {
731 nanoglState.point_sprite_oes = GL_TRUE;
732 statechanged = GL_TRUE;
733 }
734 break;
735 }*/
737 {
739 {
742 }
744 }
746 {
748 {
751 }
753 }
755 {
757 {
760 }
762 }
764 {
766 {
769 }
771 }
773 {
775 {
778 }
780 }
782 {
784 {
787 }
789 }
791 {
794 {
797 }
799 }
801 {
803 {
808 }
810 }
816 {
820 }
821 #endif
824 }
827 {
830 }
831 }
834 {
836 {
839 }
842 {
844 {
846 {
849 }
851 }
853 {
855 {
858 }
860 }
861 //case GL_CLIP_PLANEi
863 {
865 {
868 }
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 {
931 }
933 }
935 {
937 {
940 }
942 }
944 {
946 {
949 }
951 }
953 {
955 {
958 }
960 }
962 {
964 {
967 }
969 }
971 {
973 {
976 }
978 }
980 {
982 {
985 }
987 }
989 {
991 {
994 }
996 }
998 {
1000 {
1003 }
1005 }
1006 /* case GL_MATRIX_PALETTE_OES:
1007 {
1008 if (nanoglState.matrix_palette_oes)
1009 {
1010 nanoglState.matrix_palette_oes = GL_FALSE;
1011 statechanged = GL_TRUE;
1012 }
1013 break;
1014 }*/
1016 {
1018 {
1021 }
1023 }
1025 {
1027 {
1030 }
1032 }
1033 /* case GL_POINT_SPRITE_OES:
1034 {
1035 if (nanoglState.point_sprite_oes)
1036 {
1037 nanoglState.point_sprite_oes = GL_FALSE;
1038 statechanged = GL_TRUE;
1039 }
1040 break;
1041 }*/
1043 {
1045 {
1048 }
1050 }
1052 {
1054 {
1057 }
1059 }
1061 {
1063 {
1066 }
1068 }
1070 {
1072 {
1075 }
1077 }
1079 {
1081 {
1084 }
1086 }
1088 {
1090 {
1093 }
1095 }
1097 {
1100 {
1103 }
1105 }
1107 {
1109 {
1114 }
1116 }
1117 #if 0
1122 {
1126 }
1127 #endif
1130 }
1133 {
1136 }
1137 }
1140 {
1142 }
1145 {
1148 {
1150 }
1152 }
1155 {
1160 }
1163 {
1165 }
1168 {
1171 }
1174 {
1177 }
1180 {
1183 }
1186 {
1191 }
1193 void glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar )
1194 {
1196 #ifdef USE_CORE_PROFILE
1198 #else
1200 #endif
1201 }
1203 // Rikku2000: Light
1205 {
1209 }
1211 {
1215 }
1217 {
1221 }
1223 {
1227 }
1229 {
1233 }
1235 {
1239 }
1241 {
1245 }
1248 {
1250 {
1252 }
1256 }
1259 {
1261 {
1263 }
1267 {
1269 }
1273 }
1276 {
1278 }
1280 void glTexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
1281 {
1285 {
1292 {
1295 }
1296 }
1299 glEsImpl->glTexImage2D( target, level, internalformat, width, height, border, format, type, data );
1303 }
1306 {
1307 }
1310 {
1313 }
1316 {
1319 }
1322 {
1325 }
1328 {
1330 {
1332 }
1333 else
1334 {
1337 }
1339 #ifdef USE_CORE_PROFILE
1341 #else
1343 #endif
1344 }
1347 {
1349 {
1351 }
1352 else
1353 {
1355 }
1358 }
1361 {
1364 }
1367 {
1370 }
1373 {
1375 {
1377 }
1378 else
1379 {
1381 }
1384 }
1386 void glFrustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar )
1387 {
1390 }
1393 {
1396 }
1399 {
1404 #if defined( __MULTITEXTURE_SUPPORT__ )
1406 #else
1408 #endif
1409 }
1412 {
1420 }
1423 {
1431 }
1434 {
1435 //*((unsigned int*)(¤tVertexAttrib.red)) = *((unsigned int*)(v));
1443 }
1446 {
1454 }
1456 //-- nicknekit: xash3d funcs --
1459 {
1467 }
1470 {
1478 }
1481 {
1484 }
1486 void glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border )
1487 {
1490 }
1492 void glTexImage1D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
1493 {
1495 }
1497 void glTexImage3D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
1498 {
1499 glTexImage2D( GL_TEXTURE_2D, level, internalformat, width, height, border, format, type, pixels );
1500 }
1502 void glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels )
1503 {
1505 }
1511 GLenum format,
1513 {
1515 }
1518 {
1521 }
1523 // TODO: add native normal/reflection map texgen support
1526 {
1528 //glEsImpl->glTexGeniOES( coord, pname, param );
1529 }
1532 {
1534 //glEsImpl->glTexGenfvOES( coord, pname, params );
1535 }
1537 //-- --//
1540 {
1543 }
1546 {
1548 {
1551 }
1553 {
1555 }
1561 }
1564 {
1567 }
1570 {
1572 {
1574 }
1578 }
1581 {
1584 }
1587 {
1589 {
1592 }
1594 {
1596 {
1598 {
1600 }
1601 else
1602 {
1607 }
1608 }
1609 }
1612 }
1615 {
1618 #if defined( __MULTITEXTURE_SUPPORT__ )
1620 #else
1622 #endif
1623 }
1626 {
1628 {
1630 {
1632 }
1635 }
1637 }
1640 {
1642 {
1645 }
1647 {
1649 }
1653 }
1656 {
1659 }
1663 {
1666 {
1667 #if defined( __MULTITEXTURE_SUPPORT__ )
1668 sprintf( (char *)nano_extensions_string, "%s %s", glEsImpl->glGetString( name ), "GL_ARB_multitexture EXT_texture_env_add" );
1669 #else
1670 sprintf( (char *)nano_extensions_string, "%s %s", glEsImpl->glGetString( name ), "EXT_texture_env_add" );
1671 #endif
1673 }
1675 }
1678 {
1681 }
1684 {
1687 }
1689 void glReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels )
1690 {
1692 {
1693 // OpenglEs 1.1 does not support reading depth buffer without an extension
1696 }
1699 }
1702 {
1703 }
1706 {
1709 }
1711 void glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels )
1712 {
1714 glEsImpl->glTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels );
1715 }
1718 {
1721 }
1724 {
1725 //FlushOnStateChange();
1727 }
1730 {
1732 {
1735 }
1737 {
1739 }
1741 {
1743 }
1744 else
1745 {
1748 }
1750 {
1752 }
1753 else
1754 {
1756 }
1758 }
1761 {
1763 {
1766 }
1768 {
1770 }
1772 {
1774 }
1775 else
1776 {
1779 }
1781 {
1783 }
1784 else
1785 {
1787 }
1789 }
1792 {
1794 {
1797 }
1799 }
1801 {
1803 {
1806 }
1808 }
1812 {
1813 }
1816 {
1819 }
1822 {
1825 }
1828 {
1836 }
1839 {
1842 }
1845 {
1848 }
1851 {
1852 }
1854 {
1855 }
1857 {
1858 }
1860 {
1861 }
1863 {
1864 }
1866 {
1867 }
1874 {
1876 {
1879 }
1880 // ensure that all primitives specified between glBegin/glEnd pairs
1881 // are rendered first, and that we have correct tmu in use..
1883 // setup correct vertex/color/texcoord pointers
1888 {
1890 }
1892 {
1894 {
1896 }
1897 else
1898 {
1900 }
1906 }
1908 {
1910 {
1912 }
1913 else
1914 {
1919 }
1925 }
1927 {
1929 {
1931 }
1932 else
1933 {
1935 }
1940 }
1942 {
1945 {
1947 }
1948 else
1949 {
1951 }
1956 }
1959 {
1963 {
1965 }
1966 else
1967 {
1969 }
1974 }
1978 }
1983 {
1985 {
1990 }
1993 {
1995 }
1997 {
1999 }
2000 else
2001 {
2003 }
2005 {
2008 {
2010 }
2016 {
2018 }
2025 {
2027 }
2034 {
2036 }
2042 }
2043 }
2045 {
2047 {
2052 }
2055 {
2057 }
2059 {
2061 }
2062 else
2063 {
2065 }
2067 {
2070 {
2072 }
2078 {
2080 }
2087 {
2089 }
2096 {
2098 }
2104 }
2105 }
2107 {
2110 {
2113 }
2118 {
2120 }
2126 }
2128 {
2130 {
2133 }
2136 {
2138 }
2140 {
2142 }
2147 {
2149 }
2155 }
2157 {
2162 {
2164 }
2170 }
2173 {
2179 {
2181 }
2187 }
2189 {
2192 }
2194 {
2195 }
2197 {
2198 }
2200 #if defined( __MULTITEXTURE_SUPPORT__ )
2205 {
2207 {
2209 }
2210 else
2211 {
2214 }
2215 }
2216 #endif
2218 /* Vladimir */
2219 /*void glDrawArrays( GLenum mode, int first, int count)
2220 {
2221 FlushOnStateChange();
2222 glEsImpl->glDrawArrays(mode, first , count);
2223 }*/
2225 {
2228 }
2231 {
2234 }
2237 {
2240 }
2243 {
2246 }
2249 {
2252 }
2255 {
2258 }
2260 // This gives: called unimplemented OpenGL ES API (Android)
2262 {
2264 {
2266 }
2270 {
2272 }
2276 }
2279 {
2281 {
2283 }
2287 {
2289 }
2292 }
2295 {
2298 }
2301 {
2304 }
2305 // End Vladimir
2308 {
2310 {
2313 }
2315 {
2317 {
2319 {
2321 }
2322 else
2323 {
2328 }
2329 }
2330 }
2333 }
2335 #ifdef __MULTITEXTURE_SUPPORT__
2337 {
2339 }
2342 {
2344 }
2345 #endif
2347 {
2349 {
2352 }
2353 // ensure that all primitives specified between glBegin/glEnd pairs
2354 // are rendered first, and that we have correct tmu in use..
2358 // setup correct vertex/color/texcoord pointers
2363 {
2365 }
2367 {
2369 {
2371 }
2372 else
2373 {
2375 }
2381 }
2383 {
2385 {
2387 }
2388 else
2389 {
2394 }
2400 }
2402 {
2404 {
2406 }
2407 else
2408 {
2410 }
2415 }
2417 {
2420 {
2422 }
2423 else
2424 {
2426 }
2431 }
2434 {
2438 {
2440 }
2441 else
2442 {
2444 }
2449 }
2453 }
2454 /*void glNormalPointer(GLenum type, GLsizei stride, const void *ptr)
2455 {
2456 glEsImpl->glNormalPointer( type, stride, ptr );
2457 }*/
2459 void glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height )
2460 {
2463 }
2466 {
2469 }
2472 {
2475 }
2478 {
2481 }
2484 {
2487 }
2489 void glFramebufferRenderbuffer( GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer )
2490 {
2493 }
2496 {
2499 }
2502 {
2505 }
2506 void glFramebufferTexture2D( GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level )
2507 {
2510 }
2512 void glRenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height )
2513 {
2516 }
2519 {
2531 {
2533 }
2535 }
2538 {
2540 }
2543 {
2545 }
2548 {
2550 }
2553 {
2555 }