3e88b0f8150d9c6a2b16dc5388ec49c16c0e525f
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 GLboolean stupidglesbug;
71 GLclampf depth_range_near;
72 GLclampf depth_range_far;
73 GLenum depth_func;
74 GLenum cullface;
75 GLenum shademodel;
76 GLenum sfactor;
77 GLenum dfactor;
78 GLenum matrixmode;
79 };
84 {
85 GL_FALSE,
86 GL_FALSE,
87 GL_FALSE,
88 GL_FALSE,
89 GL_FALSE,
90 GL_FALSE,
91 GL_FALSE,
92 GL_TRUE,
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_FALSE,
105 GL_TRUE,
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_FALSE,
116 GL_TRUE,
117 GL_FALSE,
120 GL_LESS,
121 GL_BACK,
122 GL_SMOOTH,
123 GL_ONE,
124 GL_ZERO,
125 GL_MODELVIEW,
126 };
128 struct booleanstate
129 {
130 GLboolean value;
131 GLboolean changed;
132 };
134 struct floatstate
135 {
136 GLfloat value;
137 GLboolean changed;
138 };
140 struct uintstate
141 {
142 GLuint value;
143 GLboolean changed;
144 };
146 struct ptrstate
147 {
148 GLint size;
149 GLenum type;
150 GLsizei stride;
152 GLboolean changed;
153 GLboolean enabled;
154 };
156 struct nanotmuState
157 {
165 };
171 {
179 };
190 #if defined( __MULTITEXTURE_SUPPORT__ )
192 #endif
194 #if !defined( __WINS__ )
195 //#define __FORCEINLINE __forceinline
196 #define __FORCEINLINE inline
197 #else
198 #define __FORCEINLINE
199 #endif
204 struct VertexAttrib
205 {
209 #if !defined( __MULTITEXTURE_SUPPORT__ )
211 #endif
219 #if defined( __MULTITEXTURE_SUPPORT__ )
222 #endif
223 };
238 #if defined( __MULTITEXTURE_SUPPORT__ )
239 static VertexAttrib currentVertexAttribInit = {0.0f, 0.0f, 0.0f, 255, 255, 255, 255, 0.0f, 0.0f, 0.0f, 0.0f};
240 #else
243 };
244 #endif
252 {
274 }
277 {
280 {
282 }
283 else
284 {
286 }
289 {
291 }
292 else
293 {
295 }
298 {
300 }
301 else
302 {
304 }
307 {
309 }
310 else
311 {
313 }
341 //glEsImpl->glBindTexture(GL_TEXTURE_2D, stackTextureState);
343 glEsImpl->glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, activetmuState->texture_env_mode.value );
347 }
350 {
354 {
356 #ifndef USE_CORE_PROFILE
358 #endif
359 }
365 {
373 #if defined( __MULTITEXTURE_SUPPORT__ )
378 #endif
380 }
384 #if defined( __MULTITEXTURE_SUPPORT__ )
386 #endif
393 }
395 {
397 }
399 {
401 }
403 {
408 }
411 {
412 vertexCount += ( (unsigned char *)ptrVertexAttribArray - (unsigned char *)ptrVertexAttribArrayMark ) / sizeof( VertexAttrib );
414 {
416 }
418 {
420 {
429 }
432 {
435 {
440 }
441 }
444 {
451 {
455 indexCount++;
462 {
467 }
470 {
474 indexCount++;
475 }
476 }
477 else
478 {
479 //already aligned
485 {
490 }
493 {
498 indexCount++;
499 }
500 }
502 }
506 {
512 {
517 }
518 }
523 }
527 }
530 {
532 {
535 }
538 {
540 {
542 {
545 }
547 }
549 {
551 {
554 }
556 }
557 //case GL_CLIP_PLANEi
559 {
561 {
564 }
566 }
568 {
570 {
573 }
575 }
577 {
579 {
582 }
584 }
586 {
588 {
591 }
593 }
595 {
597 {
600 }
602 }
604 {
606 {
609 }
611 }
613 {
615 {
618 }
620 }
622 {
624 {
627 }
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 {
690 }
692 }
694 {
696 {
699 }
701 }
702 /* case GL_MATRIX_PALETTE_OES:
703 {
704 if (!nanoglState.matrix_palette_oes)
705 {
706 nanoglState.matrix_palette_oes = GL_TRUE;
707 statechanged = GL_TRUE;
708 }
709 break;
710 }*/
712 {
714 {
717 }
719 }
721 {
723 {
726 }
728 }
729 /* case GL_POINT_SPRITE_OES:
730 {
731 if (!nanoglState.point_sprite_oes)
732 {
733 nanoglState.point_sprite_oes = GL_TRUE;
734 statechanged = GL_TRUE;
735 }
736 break;
737 }*/
739 {
741 {
744 }
746 }
748 {
750 {
753 }
755 }
757 {
759 {
762 }
764 }
766 {
768 {
771 }
773 }
775 {
777 {
780 }
782 }
784 {
786 {
789 }
791 }
793 {
796 {
799 }
801 }
803 {
805 {
810 }
812 }
818 {
822 }
823 #endif
826 }
829 {
832 }
833 }
836 {
838 {
841 }
844 {
846 {
848 {
851 }
853 }
855 {
857 {
860 }
862 }
863 //case GL_CLIP_PLANEi
865 {
867 {
870 }
872 }
874 {
876 {
879 }
881 }
883 {
885 {
888 }
890 }
892 {
894 {
897 }
899 }
901 {
903 {
906 }
908 }
910 {
912 {
915 }
917 }
919 {
921 {
924 }
926 }
928 {
930 {
933 }
935 }
937 {
939 {
942 }
944 }
946 {
948 {
951 }
953 }
955 {
957 {
960 }
962 }
964 {
966 {
969 }
971 }
973 {
975 {
978 }
980 }
982 {
984 {
987 }
989 }
991 {
993 {
996 }
998 }
1000 {
1002 {
1005 }
1007 }
1008 /* case GL_MATRIX_PALETTE_OES:
1009 {
1010 if (nanoglState.matrix_palette_oes)
1011 {
1012 nanoglState.matrix_palette_oes = GL_FALSE;
1013 statechanged = GL_TRUE;
1014 }
1015 break;
1016 }*/
1018 {
1020 {
1023 }
1025 }
1027 {
1029 {
1032 }
1034 }
1035 /* case GL_POINT_SPRITE_OES:
1036 {
1037 if (nanoglState.point_sprite_oes)
1038 {
1039 nanoglState.point_sprite_oes = GL_FALSE;
1040 statechanged = GL_TRUE;
1041 }
1042 break;
1043 }*/
1045 {
1047 {
1050 }
1052 }
1054 {
1056 {
1059 }
1061 }
1063 {
1065 {
1068 }
1070 }
1072 {
1074 {
1077 }
1079 }
1081 {
1083 {
1086 }
1088 }
1090 {
1092 {
1095 }
1097 }
1099 {
1102 {
1105 }
1107 }
1109 {
1111 {
1116 }
1118 }
1119 #if 0
1124 {
1128 }
1129 #endif
1132 }
1135 {
1138 }
1139 }
1142 {
1144 }
1147 {
1150 {
1152 }
1154 }
1157 {
1162 }
1165 {
1167 }
1170 {
1173 }
1176 {
1179 }
1182 {
1185 }
1188 {
1190 {
1194 }
1195 else
1196 {
1200 }
1202 }
1204 void glOrtho( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar )
1205 {
1207 #ifdef USE_CORE_PROFILE
1209 #else
1211 #endif
1212 }
1214 // Rikku2000: Light
1216 {
1220 }
1222 {
1226 }
1228 {
1232 }
1234 {
1238 }
1240 {
1244 }
1246 {
1250 }
1252 {
1256 }
1259 {
1261 {
1263 }
1267 }
1270 {
1272 {
1274 }
1278 {
1280 }
1284 }
1287 {
1289 }
1291 void glTexImage2D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
1292 {
1295 glEsImpl->glTexImage2D( target, level, internalformat, width, height, border, format, type, pixels );
1296 }
1299 {
1300 }
1303 {
1306 }
1309 {
1312 }
1315 {
1318 }
1321 {
1323 {
1325 }
1326 else
1327 {
1330 }
1332 #ifdef USE_CORE_PROFILE
1334 #else
1336 #endif
1337 }
1340 {
1342 {
1344 }
1345 else
1346 {
1348 }
1351 }
1354 {
1357 }
1360 {
1363 }
1366 {
1368 {
1370 }
1371 else
1372 {
1374 }
1377 }
1379 void glFrustum( GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar )
1380 {
1383 }
1386 {
1389 }
1392 {
1397 #if defined( __MULTITEXTURE_SUPPORT__ )
1399 #else
1401 #endif
1402 }
1405 {
1407 {
1411 }
1412 else
1413 {
1417 }
1422 }
1425 {
1433 }
1436 {
1437 //*((unsigned int*)(¤tVertexAttrib.red)) = *((unsigned int*)(v));
1439 {
1443 }
1444 else
1445 {
1449 }
1454 }
1457 {
1465 }
1467 //-- nicknekit: xash3d funcs --
1470 {
1472 {
1476 }
1477 else
1478 {
1482 }
1487 }
1490 {
1498 }
1501 {
1504 }
1506 void glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border )
1507 {
1510 }
1512 void glTexImage1D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
1513 {
1515 }
1517 void glTexImage3D( GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels )
1518 {
1519 glTexImage2D( GL_TEXTURE_2D, level, internalformat, width, height, border, format, type, pixels );
1520 }
1522 void glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels )
1523 {
1525 }
1531 GLenum format,
1533 {
1535 }
1538 {
1541 }
1543 // TODO: add native normal/reflection map texgen support
1546 {
1548 //glEsImpl->glTexGeniOES( coord, pname, param );
1549 }
1552 {
1554 //glEsImpl->glTexGenfvOES( coord, pname, params );
1555 }
1557 //-- --//
1560 {
1563 }
1566 {
1568 {
1571 }
1573 {
1575 }
1578 {
1581 }
1582 else
1589 }
1592 {
1595 }
1598 {
1600 {
1602 }
1606 }
1609 {
1612 }
1615 {
1617 {
1620 }
1622 {
1624 {
1626 {
1628 }
1629 else
1630 {
1635 }
1636 }
1637 }
1640 }
1643 {
1646 #if defined( __MULTITEXTURE_SUPPORT__ )
1648 #else
1650 #endif
1651 }
1654 {
1656 {
1658 {
1660 }
1663 }
1665 }
1668 {
1670 {
1673 }
1675 {
1677 }
1681 }
1684 {
1687 }
1691 {
1694 {
1695 #if defined( __MULTITEXTURE_SUPPORT__ )
1696 sprintf( (char *)nano_extensions_string, "%s %s", glEsImpl->glGetString( name ), "GL_ARB_multitexture EXT_texture_env_add" );
1697 #else
1698 sprintf( (char *)nano_extensions_string, "%s %s", glEsImpl->glGetString( name ), "EXT_texture_env_add" );
1699 #endif
1701 }
1703 }
1706 {
1709 }
1712 {
1715 }
1717 void glReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels )
1718 {
1720 {
1721 // OpenglEs 1.1 does not support reading depth buffer without an extension
1724 }
1727 }
1730 {
1731 }
1734 {
1737 }
1739 void glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels )
1740 {
1742 glEsImpl->glTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels );
1743 }
1746 {
1749 }
1752 {
1753 //FlushOnStateChange();
1755 }
1758 {
1760 {
1763 }
1765 {
1767 }
1769 {
1771 }
1772 else
1773 {
1776 }
1778 {
1780 }
1781 else
1782 {
1784 }
1786 }
1789 {
1791 {
1794 }
1796 }
1799 {
1800 }
1803 {
1806 }
1809 {
1812 }
1815 {
1823 }
1826 {
1829 }
1832 {
1835 }
1838 {
1839 }
1841 {
1842 }
1844 {
1845 }
1847 {
1848 }
1850 {
1851 }
1853 {
1854 }
1861 {
1863 {
1866 }
1867 // ensure that all primitives specified between glBegin/glEnd pairs
1868 // are rendered first, and that we have correct tmu in use..
1870 // setup correct vertex/color/texcoord pointers
1875 {
1877 }
1879 {
1881 {
1883 }
1884 else
1885 {
1887 }
1893 }
1895 {
1897 {
1899 }
1900 else
1901 {
1903 }
1909 }
1911 {
1913 {
1915 }
1916 else
1917 {
1919 }
1924 }
1926 {
1929 {
1931 }
1932 else
1933 {
1935 }
1940 }
1943 {
1947 {
1949 }
1950 else
1951 {
1953 }
1958 }
1962 }
1967 {
1969 {
1974 }
1977 {
1979 }
1981 {
1983 }
1984 else
1985 {
1987 }
1989 {
1992 {
1994 }
2000 {
2002 }
2009 {
2011 }
2018 {
2020 }
2026 }
2027 }
2029 {
2031 {
2036 }
2039 {
2041 }
2043 {
2045 }
2046 else
2047 {
2049 }
2051 {
2054 {
2056 }
2062 {
2064 }
2071 {
2073 }
2080 {
2082 }
2088 }
2089 }
2091 {
2094 {
2097 }
2102 {
2104 }
2110 }
2112 {
2114 {
2117 }
2120 {
2122 }
2124 {
2126 }
2131 {
2133 }
2139 }
2141 {
2146 {
2148 }
2154 }
2157 {
2163 {
2165 }
2171 }
2173 {
2176 }
2178 {
2179 }
2181 {
2182 }
2184 #if defined( __MULTITEXTURE_SUPPORT__ )
2189 {
2191 {
2193 }
2194 else
2195 {
2198 }
2199 }
2200 #endif
2202 /* Vladimir */
2203 /*void glDrawArrays( GLenum mode, int first, int count)
2204 {
2205 FlushOnStateChange();
2206 glEsImpl->glDrawArrays(mode, first , count);
2207 }*/
2209 {
2212 }
2215 {
2218 }
2221 {
2224 }
2227 {
2230 }
2233 {
2236 }
2238 // This gives: called unimplemented OpenGL ES API (Android)
2240 {
2242 {
2244 }
2248 {
2250 }
2254 }
2257 {
2259 {
2261 }
2265 {
2267 }
2270 }
2273 {
2276 }
2279 {
2282 }
2283 // End Vladimir
2286 {
2288 {
2291 }
2293 {
2295 {
2297 {
2299 }
2300 else
2301 {
2306 }
2307 }
2308 }
2311 }
2313 #ifdef __MULTITEXTURE_SUPPORT__
2315 {
2317 }
2320 {
2322 }
2323 #endif
2325 {
2327 {
2330 }
2331 // ensure that all primitives specified between glBegin/glEnd pairs
2332 // are rendered first, and that we have correct tmu in use..
2336 // setup correct vertex/color/texcoord pointers
2341 {
2343 }
2345 {
2347 {
2349 }
2350 else
2351 {
2353 }
2359 }
2361 {
2363 {
2365 }
2366 else
2367 {
2369 }
2375 }
2377 {
2379 {
2381 }
2382 else
2383 {
2385 }
2390 }
2392 {
2395 {
2397 }
2398 else
2399 {
2401 }
2406 }
2409 {
2413 {
2415 }
2416 else
2417 {
2419 }
2424 }
2428 }
2429 /*void glNormalPointer(GLenum type, GLsizei stride, const void *ptr)
2430 {
2431 glEsImpl->glNormalPointer( type, stride, ptr );
2432 }*/
2434 void glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height )
2435 {
2438 }
2441 {
2444 }
2447 {
2450 }
2453 {
2456 }
2459 {
2462 }
2464 void glFramebufferRenderbuffer( GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer )
2465 {
2468 }
2471 {
2474 }
2477 {
2480 }
2481 void glFramebufferTexture2D( GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level )
2482 {
2485 }
2487 void glRenderbufferStorage( GLenum target, GLenum internalformat, GLsizei width, GLsizei height )
2488 {
2491 }
2494 {
2506 {
2508 }
2510 }
2513 {
2515 }
2518 {
2520 }
2523 {
2525 }
2528 {
2530 }