c13aea311d72a7f902275de277d4f156227a7039
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 {
327 #ifndef USE_CORE_PROFILE
329 #endif
330 }
336 {
344 #if defined(__MULTITEXTURE_SUPPORT__)
349 #endif
351 }
356 #if defined(__MULTITEXTURE_SUPPORT__)
358 #endif
365 }
367 {
369 }
371 {
373 }
375 {
380 }
383 {
384 vertexCount+=((unsigned char*)ptrVertexAttribArray-(unsigned char*)ptrVertexAttribArrayMark)/sizeof(VertexAttrib);
386 {
388 }
390 {
392 {
401 }
404 {
407 {
412 }
413 }
416 {
423 {
427 indexCount++;
434 {
439 }
442 {
446 indexCount++;
447 }
448 }
449 else
450 {
451 //already aligned
457 {
463 }
466 {
471 indexCount++;
472 }
473 }
475 }
479 {
485 {
490 }
491 }
496 }
497 }
500 {
503 {
505 {
507 {
510 }
512 }
514 {
516 {
519 }
521 }
522 //case GL_CLIP_PLANEi
524 {
526 {
529 }
531 }
533 {
535 {
538 }
540 }
542 {
544 {
547 }
549 }
551 {
553 {
556 }
558 }
560 {
562 {
565 }
567 }
569 //case GL_LIGHTi
570 {
572 {
575 }
577 }
579 {
581 {
584 }
586 }
588 {
590 {
593 }
595 }
596 /* case GL_MATRIX_PALETTE_OES:
597 {
598 if (!nanoglState.matrix_palette_oes)
599 {
600 nanoglState.matrix_palette_oes = GL_TRUE;
601 statechanged = GL_TRUE;
602 }
603 break;
604 }*/
606 {
608 {
611 }
613 }
615 {
617 {
620 }
622 }
623 /* case GL_POINT_SPRITE_OES:
624 {
625 if (!nanoglState.point_sprite_oes)
626 {
627 nanoglState.point_sprite_oes = GL_TRUE;
628 statechanged = GL_TRUE;
629 }
630 break;
631 }*/
633 {
635 {
638 }
640 }
642 {
644 {
647 }
649 }
651 {
653 {
656 }
658 }
660 {
662 {
665 }
667 }
669 {
671 {
674 }
676 }
678 {
680 {
683 }
685 }
687 {
689 /* if (!nanoglState.stencil_test)
690 {
691 nanoglState.stencil_test = GL_TRUE;
692 statechanged = GL_TRUE;
693 }*/
695 }
697 {
699 {
704 }
706 }
709 }
712 {
715 }
716 }
719 {
722 {
724 {
726 {
729 }
731 }
733 {
735 {
738 }
740 }
741 //case GL_CLIP_PLANEi
743 {
745 {
748 }
750 }
752 {
754 {
757 }
759 }
761 {
763 {
766 }
768 }
770 {
772 {
775 }
777 }
779 {
781 {
784 }
786 }
788 //case GL_LIGHTi
789 {
791 {
794 }
796 }
798 {
800 {
803 }
805 }
807 {
809 {
812 }
814 }
815 /* case GL_MATRIX_PALETTE_OES:
816 {
817 if (nanoglState.matrix_palette_oes)
818 {
819 nanoglState.matrix_palette_oes = GL_FALSE;
820 statechanged = GL_TRUE;
821 }
822 break;
823 }*/
825 {
827 {
830 }
832 }
834 {
836 {
839 }
841 }
842 /* case GL_POINT_SPRITE_OES:
843 {
844 if (nanoglState.point_sprite_oes)
845 {
846 nanoglState.point_sprite_oes = GL_FALSE;
847 statechanged = GL_TRUE;
848 }
849 break;
850 }*/
852 {
854 {
857 }
859 }
861 {
863 {
866 }
868 }
870 {
872 {
875 }
877 }
879 {
881 {
884 }
886 }
888 {
890 {
893 }
895 }
897 {
899 {
902 }
904 }
906 {
908 /* if (nanoglState.stencil_test)
909 {
910 nanoglState.stencil_test = GL_FALSE;
911 statechanged = GL_TRUE;
912 }*/
914 }
916 {
918 {
925 }
927 }
930 }
933 {
936 }
937 }
940 {
942 }
946 {
949 {
951 }
953 }
956 {
961 }
965 {
967 }
971 {
974 }
977 {
980 }
983 {
986 }
989 {
994 }
996 void glOrtho (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
997 {
999 #ifdef USE_CORE_PROFILE
1001 #else
1003 #endif
1004 }
1007 {
1009 {
1011 }
1015 }
1018 {
1020 {
1022 }
1026 {
1028 }
1032 }
1035 {
1037 }
1039 void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
1040 {
1043 glEsImpl->glTexImage2D(target, level, internalformat, width, height,border,format,type,pixels);
1044 }
1047 {
1048 }
1051 {
1054 }
1057 {
1060 }
1063 {
1066 }
1069 {
1071 {
1073 }
1074 else
1075 {
1078 }
1080 #ifdef USE_CORE_PROFILE
1082 #else
1084 #endif
1085 }
1088 {
1090 {
1092 }
1093 else
1094 {
1096 }
1099 }
1102 {
1105 }
1108 {
1111 }
1114 {
1116 {
1118 }
1119 else
1120 {
1122 }
1125 }
1127 void glFrustum (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
1128 {
1131 }
1134 {
1137 }
1141 {
1146 #if defined(__MULTITEXTURE_SUPPORT__)
1148 #else
1150 #endif
1152 }
1155 {
1160 }
1163 {
1168 }
1171 {
1172 //*((unsigned int*)(¤tVertexAttrib.red)) = *((unsigned int*)(v));
1177 }
1180 {
1185 }
1187 //-- nicknekit: xash3d funcs --
1190 {
1195 }
1198 {
1203 }
1206 {
1209 }
1211 void glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border )
1212 {
1215 }
1217 void glTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
1218 {
1220 }
1222 void glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
1223 {
1224 glTexImage2D(GL_TEXTURE_2D, level, internalformat, width, height, border, format, type, pixels);
1225 }
1227 void glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels )
1228 {
1230 }
1236 GLenum format,
1238 {
1240 }
1245 {
1248 }
1252 {
1253 //for mirrors? not needed for original hl?
1254 }
1257 {
1258 //for mirrors? not needed for original hl?
1259 }
1261 //-- --//
1264 {
1267 }
1270 {
1272 {
1274 }
1279 }
1282 {
1285 }
1288 {
1290 {
1292 }
1296 }
1299 {
1302 }
1305 {
1307 {
1309 {
1311 {
1313 }
1314 else
1315 {
1320 }
1321 }
1322 }
1325 }
1328 {
1331 #if defined(__MULTITEXTURE_SUPPORT__)
1333 #else
1335 #endif
1336 }
1340 {
1342 {
1344 }
1348 }
1351 {
1353 {
1355 }
1359 }
1363 {
1366 }
1370 {
1373 {
1374 #if defined(__MULTITEXTURE_SUPPORT__)
1375 sprintf((char*)nano_extensions_string,"%s %s",glEsImpl->glGetString(name),"GL_ARB_multitexture EXT_texture_env_add");
1376 #else
1377 sprintf((char*)nano_extensions_string,"%s %s",glEsImpl->glGetString(name),"EXT_texture_env_add");
1378 #endif
1380 }
1382 }
1385 {
1388 }
1391 {
1394 }
1396 void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
1397 {
1399 {
1400 // OpenglEs 1.1 does not support reading depth buffer without an extension
1403 }
1406 }
1409 {
1411 }
1414 {
1417 }
1419 void glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
1420 {
1423 }
1426 {
1429 }
1432 {
1433 //FlushOnStateChange();
1435 }
1438 {
1440 {
1442 }
1444 {
1446 }
1447 else
1448 {
1451 }
1453 {
1455 }
1456 else
1457 {
1459 }
1461 }
1464 {
1466 }
1469 {
1470 }
1473 {
1476 }
1479 {
1482 }
1485 {
1493 }
1496 {
1499 }
1502 {
1505 }
1519 {
1520 // ensure that all primitives specified between glBegin/glEnd pairs
1521 // are rendered first, and that we have correct tmu in use..
1523 // setup correct vertex/color/texcoord pointers
1528 {
1530 }
1532 {
1534 {
1536 }
1537 else
1538 {
1540 }
1546 }
1548 {
1550 {
1552 }
1553 else
1554 {
1556 }
1562 }
1564 {
1567 {
1569 }
1570 else
1571 {
1573 }
1578 }
1581 {
1585 {
1587 }
1588 else
1589 {
1591 }
1596 }
1600 }
1603 {
1606 {
1608 }
1610 {
1612 }
1613 else
1614 {
1616 }
1618 {
1621 {
1623 }
1629 {
1631 }
1638 {
1640 }
1646 }
1647 }
1649 {
1652 {
1654 }
1656 {
1658 }
1659 else
1660 {
1662 }
1664 {
1667 {
1669 }
1675 {
1677 }
1684 {
1686 }
1692 }
1693 }
1695 {
1700 {
1702 }
1708 }
1710 {
1713 {
1715 }
1717 {
1719 }
1724 {
1726 }
1732 }
1734 {
1739 {
1741 }
1747 }
1749 {
1752 }
1756 #if defined(__MULTITEXTURE_SUPPORT__)
1761 {
1763 {
1765 }
1766 else
1767 {
1770 }
1771 }
1772 #endif
1774 /* Vladimir */
1776 {
1779 }
1781 {
1784 }
1787 {
1790 }
1794 {
1797 }
1800 {
1803 }
1806 {
1809 }
1812 // This gives: called unimplemented OpenGL ES API (Android)
1814 {
1817 }
1822 }
1826 }
1829 {
1832 }
1837 }
1840 }
1843 {
1846 }
1849 {
1852 }
1856 // End Vladimir