b193a7a4fb8fb624505aa64a839f0018b2dacebe
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 {
1185 }
1188 {
1193 }
1196 {
1199 }
1201 void glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border )
1202 {
1205 }
1207 void glTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
1208 {
1210 }
1212 void glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
1213 {
1214 glTexImage2D(GL_TEXTURE_2D, level, internalformat, width, height, border, format, type, pixels);
1215 }
1217 void glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels )
1218 {
1220 }
1226 GLenum format,
1228 {
1230 }
1235 {
1238 }
1242 {
1243 //for mirrors? not needed for original hl?
1244 }
1247 {
1248 //for mirrors? not needed for original hl?
1249 }
1251 //-- --//
1254 {
1257 }
1260 {
1262 {
1264 }
1269 }
1272 {
1275 }
1278 {
1280 {
1282 }
1286 }
1289 {
1292 }
1295 {
1297 {
1299 {
1301 {
1303 }
1304 else
1305 {
1310 }
1311 }
1312 }
1315 }
1318 {
1321 #if defined(__MULTITEXTURE_SUPPORT__)
1323 #else
1325 #endif
1326 }
1330 {
1332 {
1334 }
1338 }
1341 {
1343 {
1345 }
1349 }
1353 {
1356 }
1360 {
1363 {
1364 #if defined(__MULTITEXTURE_SUPPORT__)
1365 sprintf((char*)nano_extensions_string,"%s %s",glEsImpl->glGetString(name),"GL_ARB_multitexture EXT_texture_env_add");
1366 #else
1367 sprintf((char*)nano_extensions_string,"%s %s",glEsImpl->glGetString(name),"EXT_texture_env_add");
1368 #endif
1370 }
1372 }
1375 {
1378 }
1381 {
1384 }
1386 void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
1387 {
1389 {
1390 // OpenglEs 1.1 does not support reading depth buffer without an extension
1393 }
1396 }
1399 {
1401 }
1404 {
1407 }
1409 void glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels)
1410 {
1413 }
1416 {
1419 }
1422 {
1423 //FlushOnStateChange();
1425 }
1428 {
1430 {
1432 }
1434 {
1436 }
1437 else
1438 {
1441 }
1443 {
1445 }
1446 else
1447 {
1449 }
1451 }
1454 {
1456 }
1459 {
1460 }
1463 {
1466 }
1469 {
1472 }
1475 {
1483 }
1486 {
1489 }
1492 {
1495 }
1509 {
1510 // ensure that all primitives specified between glBegin/glEnd pairs
1511 // are rendered first, and that we have correct tmu in use..
1513 // setup correct vertex/color/texcoord pointers
1518 {
1520 }
1522 {
1524 {
1526 }
1527 else
1528 {
1530 }
1536 }
1538 {
1540 {
1542 }
1543 else
1544 {
1546 }
1552 }
1554 {
1557 {
1559 }
1560 else
1561 {
1563 }
1568 }
1571 {
1575 {
1577 }
1578 else
1579 {
1581 }
1586 }
1590 }
1593 {
1596 {
1598 }
1600 {
1602 }
1603 else
1604 {
1606 }
1608 {
1611 {
1613 }
1619 {
1621 }
1628 {
1630 }
1636 }
1637 }
1639 {
1642 {
1644 }
1646 {
1648 }
1649 else
1650 {
1652 }
1654 {
1657 {
1659 }
1665 {
1667 }
1674 {
1676 }
1682 }
1683 }
1685 {
1690 {
1692 }
1698 }
1700 {
1703 {
1705 }
1707 {
1709 }
1714 {
1716 }
1722 }
1724 {
1729 {
1731 }
1737 }
1739 {
1742 }
1746 #if defined(__MULTITEXTURE_SUPPORT__)
1751 {
1753 {
1755 }
1756 else
1757 {
1760 }
1761 }
1762 #endif
1764 /* Vladimir */
1766 {
1769 }
1771 {
1774 }
1777 {
1780 }
1784 {
1787 }
1790 {
1793 }
1796 {
1799 }
1802 // This gives: called unimplemented OpenGL ES API (Android)
1804 {
1807 }
1812 }
1816 }
1819 {
1822 }
1827 }
1830 }
1833 {
1836 }
1839 {
1842 }
1846 // End Vladimir