From 01f80730b8e08c7efe8f86d9baac92057e19999d Mon Sep 17 00:00:00 2001
From: Dan Rosser <danoli3@gmail.com>
Date: Fri, 28 Jul 2023 00:43:35 +1000
Subject: [PATCH] iOS / Android Patch Fix

---
 Include/tesselator.h | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/Include/tesselator.h b/Include/tesselator.h
index 3d43155..519fbeb 100755
--- a/Include/tesselator.h
+++ b/Include/tesselator.h
@@ -38,6 +38,10 @@ extern "C" {
 
 // See OpenGL Red Book for description of the winding rules
 // http://www.glprogramming.com/red/chapter11.html
+#if defined( __APPLE_CC__)
+	#include <TargetConditionals.h>
+#endif
+
 enum TessWindingRule
 {
 	TESS_WINDING_ODD,
@@ -130,11 +134,17 @@ enum TessOption
 };
 
 typedef float TESSreal;
-typedef int TESSindex;
+//note this shouldn't be defined(TARGET_OS_IPHONE) as its always defined either 0 or 1
+#if TARGET_OS_IPHONE || ANDROID || __ARMEL__
+typedef unsigned short TESSindex;
+#else
+typedef unsigned int TESSindex;
+#endif
+
 typedef struct TESStesselator TESStesselator;
 typedef struct TESSalloc TESSalloc;
 
-#define TESS_UNDEF (~(TESSindex)0)
+#define TESS_UNDEF ((TESSindex)(~(TESSindex)0))
 
 #define TESS_NOTUSED(v) do { (void)(1 ? (void)0 : ( (void)(v) ) ); } while(0)