ソースを参照

Replaced int with int32_t and made some declarations static.

David Piuva 3 週間 前
コミット
11a84ab32c
99 ファイル変更1460 行追加1460 行削除
  1. 5 5
      Source/DFPSR/api/configAPI.cpp
  2. 4 4
      Source/DFPSR/api/drawAPI.h
  3. 72 72
      Source/DFPSR/api/filterAPI.cpp
  4. 16 16
      Source/DFPSR/api/filterAPI.h
  5. 18 18
      Source/DFPSR/api/guiAPI.cpp
  6. 14 14
      Source/DFPSR/api/guiAPI.h
  7. 34 34
      Source/DFPSR/api/imageAPI.cpp
  8. 3 3
      Source/DFPSR/api/imageAPI.h
  9. 47 47
      Source/DFPSR/api/mediaMachineAPI.cpp
  10. 39 39
      Source/DFPSR/api/mediaMachineAPI.h
  11. 31 31
      Source/DFPSR/api/modelAPI.cpp
  12. 28 28
      Source/DFPSR/api/modelAPI.h
  13. 57 57
      Source/DFPSR/api/rendererAPI.cpp
  14. 6 6
      Source/DFPSR/api/soundAPI.cpp
  15. 1 1
      Source/DFPSR/api/textureAPI.cpp
  16. 1 1
      Source/DFPSR/api/textureAPI.h
  17. 4 4
      Source/DFPSR/base/heap.cpp
  18. 4 4
      Source/DFPSR/base/simd.h
  19. 49 49
      Source/DFPSR/base/threading.cpp
  20. 8 8
      Source/DFPSR/base/threading.h
  21. 1 1
      Source/DFPSR/base/virtualStack.cpp
  22. 4 4
      Source/DFPSR/implementation/font/Font.cpp
  23. 1 1
      Source/DFPSR/implementation/gui/BackendWindow.cpp
  24. 8 8
      Source/DFPSR/implementation/gui/BackendWindow.h
  25. 13 13
      Source/DFPSR/implementation/gui/DsrWindow.cpp
  26. 10 10
      Source/DFPSR/implementation/gui/DsrWindow.h
  27. 1 1
      Source/DFPSR/implementation/gui/FlexRegion.cpp
  28. 2 2
      Source/DFPSR/implementation/gui/FlexRegion.h
  29. 5 5
      Source/DFPSR/implementation/gui/InputEvent.h
  30. 25 25
      Source/DFPSR/implementation/gui/VisualComponent.cpp
  31. 7 7
      Source/DFPSR/implementation/gui/VisualComponent.h
  32. 19 19
      Source/DFPSR/implementation/gui/VisualTheme.cpp
  33. 3 3
      Source/DFPSR/implementation/gui/VisualTheme.h
  34. 6 6
      Source/DFPSR/implementation/gui/components/Button.cpp
  35. 1 1
      Source/DFPSR/implementation/gui/components/Button.h
  36. 1 1
      Source/DFPSR/implementation/gui/components/Label.cpp
  37. 2 2
      Source/DFPSR/implementation/gui/components/ListBox.cpp
  38. 1 1
      Source/DFPSR/implementation/gui/components/ListBox.h
  39. 28 28
      Source/DFPSR/implementation/gui/components/Menu.cpp
  40. 2 2
      Source/DFPSR/implementation/gui/components/Menu.h
  41. 2 2
      Source/DFPSR/implementation/gui/components/Panel.cpp
  42. 1 1
      Source/DFPSR/implementation/gui/components/Panel.h
  43. 2 2
      Source/DFPSR/implementation/gui/components/Picture.cpp
  44. 1 1
      Source/DFPSR/implementation/gui/components/TextBox.h
  45. 14 14
      Source/DFPSR/implementation/gui/components/Toolbar.cpp
  46. 1 1
      Source/DFPSR/implementation/gui/components/Toolbar.h
  47. 2 2
      Source/DFPSR/implementation/gui/components/helpers/ScrollBarImpl.h
  48. 2 2
      Source/DFPSR/implementation/image/Color.h
  49. 8 8
      Source/DFPSR/implementation/image/stbImage/stbImageWrapper.cpp
  50. 2 2
      Source/DFPSR/implementation/image/stbImage/stbImageWrapper.h
  51. 39 39
      Source/DFPSR/implementation/machine/VirtualMachine.cpp
  52. 32 32
      Source/DFPSR/implementation/machine/VirtualMachine.h
  53. 10 10
      Source/DFPSR/implementation/persistent/ClassFactory.cpp
  54. 3 3
      Source/DFPSR/implementation/persistent/ClassFactory.h
  55. 1 1
      Source/DFPSR/implementation/persistent/atomic/PersistentColor.h
  56. 17 17
      Source/DFPSR/implementation/persistent/atomic/PersistentImage.cpp
  57. 3 3
      Source/DFPSR/implementation/persistent/atomic/PersistentStringList.cpp
  58. 15 15
      Source/DFPSR/implementation/render/Camera.h
  59. 18 18
      Source/DFPSR/implementation/render/ITriangle2D.cpp
  60. 6 6
      Source/DFPSR/implementation/render/ITriangle2D.h
  61. 7 7
      Source/DFPSR/implementation/render/ResourcePool.cpp
  62. 2 2
      Source/DFPSR/implementation/render/ResourcePool.h
  63. 2 2
      Source/DFPSR/implementation/render/constants.h
  64. 47 47
      Source/DFPSR/implementation/render/model/Model.cpp
  65. 32 32
      Source/DFPSR/implementation/render/model/Model.h
  66. 26 26
      Source/DFPSR/implementation/render/model/format/dmf1.cpp
  67. 1 1
      Source/DFPSR/implementation/render/model/format/dmf1.h
  68. 58 58
      Source/DFPSR/implementation/render/renderCore.cpp
  69. 1 1
      Source/DFPSR/implementation/render/renderCore.h
  70. 26 26
      Source/DFPSR/implementation/render/shader/fillerTemplates.h
  71. 1 1
      Source/SDK/SoundEngine/Envelope.h
  72. 17 17
      Source/SDK/SoundEngine/soundEngine.cpp
  73. 1 1
      Source/SDK/SpriteEngine/DirtyRectangles.h
  74. 17 17
      Source/SDK/SpriteEngine/Octree.h
  75. 25 25
      Source/SDK/SpriteEngine/importer.cpp
  76. 1 1
      Source/SDK/SpriteEngine/importer.h
  77. 23 23
      Source/SDK/SpriteEngine/lightAPI.cpp
  78. 10 10
      Source/SDK/SpriteEngine/orthoAPI.cpp
  79. 16 16
      Source/SDK/SpriteEngine/orthoAPI.h
  80. 130 130
      Source/SDK/SpriteEngine/spriteAPI.cpp
  81. 14 14
      Source/SDK/SpriteEngine/spriteAPI.h
  82. 4 4
      Source/SDK/camera/main.cpp
  83. 4 4
      Source/SDK/cube/main.cpp
  84. 2 2
      Source/SDK/fileFinder/main.cpp
  85. 9 9
      Source/SDK/guiExample/main.cpp
  86. 2 2
      Source/SDK/integrationTest/Test.cpp
  87. 2 2
      Source/SDK/integrationTest/Test.h
  88. 1 1
      Source/SDK/integrationTest/main.cpp
  89. 1 1
      Source/SDK/integrationTest/tests/inputTest.cpp
  90. 1 1
      Source/SDK/integrationTest/tests/inputTest.h
  91. 14 14
      Source/SDK/music/main.cpp
  92. 24 24
      Source/SDK/sandbox/sandbox.cpp
  93. 60 60
      Source/SDK/sandbox/tool.cpp
  94. 37 37
      Source/SDK/terrain/main.cpp
  95. 5 5
      Source/tools/wizard/main.cpp
  96. 18 18
      Source/windowManagers/CocoaWindow.mm
  97. 1 1
      Source/windowManagers/NoWindow.cpp
  98. 27 27
      Source/windowManagers/Win32Window.cpp
  99. 31 31
      Source/windowManagers/X11Window.cpp

+ 5 - 5
Source/DFPSR/api/configAPI.cpp

@@ -28,23 +28,23 @@ using namespace dsr;
 void dsr::config_parse_ini(const ReadableString& content, ConfigIniCallback receiverLambda) {
 void dsr::config_parse_ini(const ReadableString& content, ConfigIniCallback receiverLambda) {
 	List<String> lines = string_split(content, U'\n');
 	List<String> lines = string_split(content, U'\n');
 	String block = U"";
 	String block = U"";
-	for (int l = 0; l < lines.length(); l++) {
+	for (int32_t l = 0; l < lines.length(); l++) {
 		// Get the current line
 		// Get the current line
 		String command = lines[l];
 		String command = lines[l];
 		// Skip comments
 		// Skip comments
-		int commentIndex = string_findFirst(command, U';');
+		int32_t commentIndex = string_findFirst(command, U';');
 		if (commentIndex > -1) {
 		if (commentIndex > -1) {
 			string_before(command, commentIndex);
 			string_before(command, commentIndex);
 		}
 		}
 		// Find assignments
 		// Find assignments
-		int assignmentIndex = string_findFirst(command, U'=');
+		int32_t assignmentIndex = string_findFirst(command, U'=');
 		if (assignmentIndex > -1) {
 		if (assignmentIndex > -1) {
 			String key = string_removeOuterWhiteSpace(string_before(command, assignmentIndex));
 			String key = string_removeOuterWhiteSpace(string_before(command, assignmentIndex));
 			String value = string_removeOuterWhiteSpace(string_after(command, assignmentIndex));
 			String value = string_removeOuterWhiteSpace(string_after(command, assignmentIndex));
 			receiverLambda(block, key, value);
 			receiverLambda(block, key, value);
 		} else {
 		} else {
-			int blockStartIndex = string_findFirst(command, U'[');
-			int blockEndIndex = string_findFirst(command, U']');
+			int32_t blockStartIndex = string_findFirst(command, U'[');
+			int32_t blockEndIndex = string_findFirst(command, U']');
 			if (blockStartIndex > -1 && blockEndIndex > -1) {
 			if (blockStartIndex > -1 && blockEndIndex > -1) {
 				block = string_removeOuterWhiteSpace(string_inclusiveRange(command, blockStartIndex + 1, blockEndIndex - 1));
 				block = string_removeOuterWhiteSpace(string_inclusiveRange(command, blockStartIndex + 1, blockEndIndex - 1));
 			}
 			}

+ 4 - 4
Source/DFPSR/api/drawAPI.h

@@ -65,8 +65,8 @@ namespace dsr {
 
 
 // Drawing shapes
 // Drawing shapes
 	// TODO: Create wrappers taking left, top, width, height to reduce clutter from the IRect constructor.
 	// TODO: Create wrappers taking left, top, width, height to reduce clutter from the IRect constructor.
-	void draw_rectangle(const ImageU8& image, const IRect& bound, int color);
-	void draw_rectangle(const ImageU16& image, const IRect& bound, int color);
+	void draw_rectangle(const ImageU8& image, const IRect& bound, int32_t color);
+	void draw_rectangle(const ImageU16& image, const IRect& bound, int32_t color);
 	void draw_rectangle(const ImageF32& image, const IRect& bound, float color);
 	void draw_rectangle(const ImageF32& image, const IRect& bound, float color);
 	void draw_rectangle(const ImageRgbaU8& image, const IRect& bound, const ColorRgbaI32& color);
 	void draw_rectangle(const ImageRgbaU8& image, const IRect& bound, const ColorRgbaI32& color);
 	// Draw using a color that has been packed in advance with the same pack order using the image_saturateAndPack function.
 	// Draw using a color that has been packed in advance with the same pack order using the image_saturateAndPack function.
@@ -74,8 +74,8 @@ namespace dsr {
 	void draw_rectangle(const ImageRgbaU8& image, const IRect& bound, uint32_t packedColor);
 	void draw_rectangle(const ImageRgbaU8& image, const IRect& bound, uint32_t packedColor);
 
 
 	// TODO: Also take two IVector2D as inlined wrapper functions.
 	// TODO: Also take two IVector2D as inlined wrapper functions.
-	void draw_line(const ImageU8& image, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int color);
-	void draw_line(const ImageU16& image, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int color);
+	void draw_line(const ImageU8& image, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t color);
+	void draw_line(const ImageU16& image, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t color);
 	void draw_line(const ImageF32& image, int32_t x1, int32_t y1, int32_t x2, int32_t y2, float color);
 	void draw_line(const ImageF32& image, int32_t x1, int32_t y1, int32_t x2, int32_t y2, float color);
 	void draw_line(const ImageRgbaU8& image, int32_t x1, int32_t y1, int32_t x2, int32_t y2, const ColorRgbaI32& color);
 	void draw_line(const ImageRgbaU8& image, int32_t x1, int32_t y1, int32_t x2, int32_t y2, const ColorRgbaI32& color);
 	// Draw using a color that has been packed in advance with the same pack order using the image_saturateAndPack function.
 	// Draw using a color that has been packed in advance with the same pack order using the image_saturateAndPack function.

+ 72 - 72
Source/DFPSR/api/filterAPI.cpp

@@ -300,8 +300,8 @@ void resizeToTarget(IMAGE_TYPE& target, const IMAGE_TYPE& source, bool interpola
 	IRect scaleRegion = image_getBound(target);
 	IRect scaleRegion = image_getBound(target);
 	if (image_getWidth(target) != image_getWidth(source) && image_getHeight(target) > image_getHeight(source)) {
 	if (image_getWidth(target) != image_getWidth(source) && image_getHeight(target) > image_getHeight(source)) {
 		// Upscaling is faster in two steps by both reusing the horizontal interpolation and vectorizing the vertical interpolation.
 		// Upscaling is faster in two steps by both reusing the horizontal interpolation and vectorizing the vertical interpolation.
-		int tempWidth = image_getWidth(target);
-		int tempHeight = image_getHeight(source);
+		int32_t tempWidth = image_getWidth(target);
+		int32_t tempHeight = image_getHeight(source);
 		IRect tempScaleRegion = IRect(scaleRegion.left(), 0, scaleRegion.width(), image_getHeight(source));
 		IRect tempScaleRegion = IRect(scaleRegion.left(), 0, scaleRegion.width(), image_getHeight(source));
 		// Create a temporary buffer.
 		// Create a temporary buffer.
 		IMAGE_TYPE newTempImage = createWithSamePackOrder(target, tempWidth, tempHeight);
 		IMAGE_TYPE newTempImage = createWithSamePackOrder(target, tempWidth, tempHeight);
@@ -314,7 +314,7 @@ void resizeToTarget(IMAGE_TYPE& target, const IMAGE_TYPE& source, bool interpola
 }
 }
 
 
 template <bool CONVERT_COLOR>
 template <bool CONVERT_COLOR>
-static inline uint32_t convertRead(const ImageRgbaU8& target, const ImageRgbaU8& source, int x, int y) {
+static inline uint32_t convertRead(const ImageRgbaU8& target, const ImageRgbaU8& source, int32_t x, int32_t y) {
 	uint32_t result = image_readPixel_clamp_packed(source, x, y);
 	uint32_t result = image_readPixel_clamp_packed(source, x, y);
 	if (CONVERT_COLOR) {
 	if (CONVERT_COLOR) {
 		result = image_truncateAndPack(target, image_unpack(source, result));
 		result = image_truncateAndPack(target, image_unpack(source, result));
@@ -323,11 +323,11 @@ static inline uint32_t convertRead(const ImageRgbaU8& target, const ImageRgbaU8&
 }
 }
 
 
 // Used for drawing large pixels
 // Used for drawing large pixels
-static inline void fillRectangle(const ImageRgbaU8& target, int pixelLeft, int pixelRight, int pixelTop, int pixelBottom, const uint32_t& packedColor) {
+static inline void fillRectangle(const ImageRgbaU8& target, int32_t pixelLeft, int32_t pixelRight, int32_t pixelTop, int32_t pixelBottom, const uint32_t& packedColor) {
 	SafePointer<uint32_t> targetRow = image_getSafePointer<uint32_t>(target, pixelTop) + pixelLeft;
 	SafePointer<uint32_t> targetRow = image_getSafePointer<uint32_t>(target, pixelTop) + pixelLeft;
-	for (int y = pixelTop; y < pixelBottom; y++) {
+	for (int32_t y = pixelTop; y < pixelBottom; y++) {
 		SafePointer<uint32_t> targetPixel = targetRow;
 		SafePointer<uint32_t> targetPixel = targetRow;
-		for (int x = pixelLeft; x < pixelRight; x++) {
+		for (int32_t x = pixelLeft; x < pixelRight; x++) {
 			*targetPixel = packedColor;
 			*targetPixel = packedColor;
 			targetPixel += 1;
 			targetPixel += 1;
 		}
 		}
@@ -338,14 +338,14 @@ static inline void fillRectangle(const ImageRgbaU8& target, int pixelLeft, int p
 template <bool CONVERT_COLOR>
 template <bool CONVERT_COLOR>
 static void blockMagnify_reference(
 static void blockMagnify_reference(
   const ImageRgbaU8& target, const ImageRgbaU8& source,
   const ImageRgbaU8& target, const ImageRgbaU8& source,
-  int pixelWidth, int pixelHeight, int clipWidth, int clipHeight) {
-	int sourceY = 0;
-	int maxSourceX = image_getWidth(source) - 1;
-	int maxSourceY = image_getHeight(source) - 1;
+  int32_t pixelWidth, int32_t pixelHeight, int32_t clipWidth, int32_t clipHeight) {
+	int32_t sourceY = 0;
+	int32_t maxSourceX = image_getWidth(source) - 1;
+	int32_t maxSourceY = image_getHeight(source) - 1;
 	if (clipWidth > image_getWidth(target)) { clipWidth = image_getWidth(target); }
 	if (clipWidth > image_getWidth(target)) { clipWidth = image_getWidth(target); }
 	if (clipHeight > image_getHeight(target)) { clipHeight = image_getHeight(target); }
 	if (clipHeight > image_getHeight(target)) { clipHeight = image_getHeight(target); }
 	for (int32_t pixelTop = 0; pixelTop < clipHeight; pixelTop += pixelHeight) {
 	for (int32_t pixelTop = 0; pixelTop < clipHeight; pixelTop += pixelHeight) {
-		int sourceX = 0;
+		int32_t sourceX = 0;
 		for (int32_t pixelLeft = 0; pixelLeft < clipWidth; pixelLeft += pixelWidth) {
 		for (int32_t pixelLeft = 0; pixelLeft < clipWidth; pixelLeft += pixelWidth) {
 			// Read the pixel once
 			// Read the pixel once
 			uint32_t sourceColor = convertRead<CONVERT_COLOR>(target, source, sourceX, sourceY);
 			uint32_t sourceColor = convertRead<CONVERT_COLOR>(target, source, sourceX, sourceY);
@@ -366,18 +366,18 @@ static void blockMagnify_reference(
 //   * Both source and target are 16-byte aligned, but does not have to own their padding
 //   * Both source and target are 16-byte aligned, but does not have to own their padding
 //   * clipWidth % 2 == 0
 //   * clipWidth % 2 == 0
 //   * clipHeight % 2 == 0
 //   * clipHeight % 2 == 0
-static void blockMagnify_2x2(const ImageRgbaU8& target, const ImageRgbaU8& source, int clipWidth, int clipHeight) {
+static void blockMagnify_2x2(const ImageRgbaU8& target, const ImageRgbaU8& source, int32_t clipWidth, int32_t clipHeight) {
 	SafePointer<const uint32_t> sourceRow = image_getSafePointer<uint32_t>(source);
 	SafePointer<const uint32_t> sourceRow = image_getSafePointer<uint32_t>(source);
 	SafePointer<uint32_t> targetRowA = image_getSafePointer<uint32_t>(target, 0);
 	SafePointer<uint32_t> targetRowA = image_getSafePointer<uint32_t>(target, 0);
 	SafePointer<uint32_t> targetRowB = image_getSafePointer<uint32_t>(target, 1);
 	SafePointer<uint32_t> targetRowB = image_getSafePointer<uint32_t>(target, 1);
-	int blockTargetStride = image_getStride(target) * 2;
-	for (int upperTargetY = 0; upperTargetY + 2 <= clipHeight; upperTargetY+=2) {
+	int32_t blockTargetStride = image_getStride(target) * 2;
+	for (int32_t upperTargetY = 0; upperTargetY + 2 <= clipHeight; upperTargetY+=2) {
 		// Carriage return
 		// Carriage return
 		SafePointer<const uint32_t> sourcePixel = sourceRow;
 		SafePointer<const uint32_t> sourcePixel = sourceRow;
 		SafePointer<uint32_t> targetPixelA = targetRowA;
 		SafePointer<uint32_t> targetPixelA = targetRowA;
 		SafePointer<uint32_t> targetPixelB = targetRowB;
 		SafePointer<uint32_t> targetPixelB = targetRowB;
 		// Write to whole multiples of 8 pixels
 		// Write to whole multiples of 8 pixels
-		int writeLeftX = 0;
+		int32_t writeLeftX = 0;
 		while (writeLeftX + 2 <= clipWidth) {
 		while (writeLeftX + 2 <= clipWidth) {
 			// Read one pixel at a time
 			// Read one pixel at a time
 			uint32_t scalarValue = *sourcePixel;
 			uint32_t scalarValue = *sourcePixel;
@@ -402,19 +402,19 @@ static void blockMagnify_2x2(const ImageRgbaU8& target, const ImageRgbaU8& sourc
 //   * Both source and target are 16-byte aligned, but does not have to own their padding
 //   * Both source and target are 16-byte aligned, but does not have to own their padding
 //   * clipWidth % 3 == 0
 //   * clipWidth % 3 == 0
 //   * clipHeight % 3 == 0
 //   * clipHeight % 3 == 0
-static void blockMagnify_3x3(const ImageRgbaU8& target, const ImageRgbaU8& source, int clipWidth, int clipHeight) {
+static void blockMagnify_3x3(const ImageRgbaU8& target, const ImageRgbaU8& source, int32_t clipWidth, int32_t clipHeight) {
 	SafePointer<const uint32_t> sourceRow = image_getSafePointer<uint32_t>(source);
 	SafePointer<const uint32_t> sourceRow = image_getSafePointer<uint32_t>(source);
 	SafePointer<uint32_t> targetRowA = image_getSafePointer<uint32_t>(target, 0);
 	SafePointer<uint32_t> targetRowA = image_getSafePointer<uint32_t>(target, 0);
 	SafePointer<uint32_t> targetRowB = image_getSafePointer<uint32_t>(target, 1);
 	SafePointer<uint32_t> targetRowB = image_getSafePointer<uint32_t>(target, 1);
 	SafePointer<uint32_t> targetRowC = image_getSafePointer<uint32_t>(target, 2);
 	SafePointer<uint32_t> targetRowC = image_getSafePointer<uint32_t>(target, 2);
-	int blockTargetStride = image_getStride(target) * 3;
-	for (int upperTargetY = 0; upperTargetY + 3 <= clipHeight; upperTargetY+=3) {
+	int32_t blockTargetStride = image_getStride(target) * 3;
+	for (int32_t upperTargetY = 0; upperTargetY + 3 <= clipHeight; upperTargetY+=3) {
 		// Carriage return
 		// Carriage return
 		SafePointer<const uint32_t> sourcePixel = sourceRow;
 		SafePointer<const uint32_t> sourcePixel = sourceRow;
 		SafePointer<uint32_t> targetPixelA = targetRowA;
 		SafePointer<uint32_t> targetPixelA = targetRowA;
 		SafePointer<uint32_t> targetPixelB = targetRowB;
 		SafePointer<uint32_t> targetPixelB = targetRowB;
 		SafePointer<uint32_t> targetPixelC = targetRowC;
 		SafePointer<uint32_t> targetPixelC = targetRowC;
-		int writeLeftX = 0;
+		int32_t writeLeftX = 0;
 		while (writeLeftX + 3 <= clipWidth) {
 		while (writeLeftX + 3 <= clipWidth) {
 			// Read one pixel at a time
 			// Read one pixel at a time
 			uint32_t scalarValue = *sourcePixel;
 			uint32_t scalarValue = *sourcePixel;
@@ -442,21 +442,21 @@ static void blockMagnify_3x3(const ImageRgbaU8& target, const ImageRgbaU8& sourc
 //   * Both source and target are 16-byte aligned, but does not have to own their padding
 //   * Both source and target are 16-byte aligned, but does not have to own their padding
 //   * clipWidth % 4 == 0
 //   * clipWidth % 4 == 0
 //   * clipHeight % 4 == 0
 //   * clipHeight % 4 == 0
-static void blockMagnify_4x4(const ImageRgbaU8& target, const ImageRgbaU8& source, int clipWidth, int clipHeight) {
+static void blockMagnify_4x4(const ImageRgbaU8& target, const ImageRgbaU8& source, int32_t clipWidth, int32_t clipHeight) {
 	SafePointer<const uint32_t> sourceRow = image_getSafePointer<uint32_t>(source);
 	SafePointer<const uint32_t> sourceRow = image_getSafePointer<uint32_t>(source);
 	SafePointer<uint32_t> targetRowA = image_getSafePointer<uint32_t>(target, 0);
 	SafePointer<uint32_t> targetRowA = image_getSafePointer<uint32_t>(target, 0);
 	SafePointer<uint32_t> targetRowB = image_getSafePointer<uint32_t>(target, 1);
 	SafePointer<uint32_t> targetRowB = image_getSafePointer<uint32_t>(target, 1);
 	SafePointer<uint32_t> targetRowC = image_getSafePointer<uint32_t>(target, 2);
 	SafePointer<uint32_t> targetRowC = image_getSafePointer<uint32_t>(target, 2);
 	SafePointer<uint32_t> targetRowD = image_getSafePointer<uint32_t>(target, 3);
 	SafePointer<uint32_t> targetRowD = image_getSafePointer<uint32_t>(target, 3);
-	int quadTargetStride = image_getStride(target) * 4;
-	for (int upperTargetY = 0; upperTargetY + 4 <= clipHeight; upperTargetY+=4) {
+	int32_t quadTargetStride = image_getStride(target) * 4;
+	for (int32_t upperTargetY = 0; upperTargetY + 4 <= clipHeight; upperTargetY+=4) {
 		// Carriage return
 		// Carriage return
 		SafePointer<const uint32_t> sourcePixel = sourceRow;
 		SafePointer<const uint32_t> sourcePixel = sourceRow;
 		SafePointer<uint32_t> targetPixelA = targetRowA;
 		SafePointer<uint32_t> targetPixelA = targetRowA;
 		SafePointer<uint32_t> targetPixelB = targetRowB;
 		SafePointer<uint32_t> targetPixelB = targetRowB;
 		SafePointer<uint32_t> targetPixelC = targetRowC;
 		SafePointer<uint32_t> targetPixelC = targetRowC;
 		SafePointer<uint32_t> targetPixelD = targetRowD;
 		SafePointer<uint32_t> targetPixelD = targetRowD;
-		int writeLeftX = 0;
+		int32_t writeLeftX = 0;
 		while (writeLeftX + 4 <= clipWidth) {
 		while (writeLeftX + 4 <= clipWidth) {
 			// Read one pixel at a time
 			// Read one pixel at a time
 			uint32_t scalarValue = *sourcePixel;
 			uint32_t scalarValue = *sourcePixel;
@@ -489,15 +489,15 @@ static void blockMagnify_4x4(const ImageRgbaU8& target, const ImageRgbaU8& sourc
 //   * Both source and target are 16-byte aligned, but does not have to own their padding
 //   * Both source and target are 16-byte aligned, but does not have to own their padding
 //   * clipWidth % 5 == 0
 //   * clipWidth % 5 == 0
 //   * clipHeight % 5 == 0
 //   * clipHeight % 5 == 0
-static void blockMagnify_5x5(const ImageRgbaU8& target, const ImageRgbaU8& source, int clipWidth, int clipHeight) {
+static void blockMagnify_5x5(const ImageRgbaU8& target, const ImageRgbaU8& source, int32_t clipWidth, int32_t clipHeight) {
 	SafePointer<const uint32_t> sourceRow = image_getSafePointer<uint32_t>(source);
 	SafePointer<const uint32_t> sourceRow = image_getSafePointer<uint32_t>(source);
 	SafePointer<uint32_t> targetRowA = image_getSafePointer<uint32_t>(target, 0);
 	SafePointer<uint32_t> targetRowA = image_getSafePointer<uint32_t>(target, 0);
 	SafePointer<uint32_t> targetRowB = image_getSafePointer<uint32_t>(target, 1);
 	SafePointer<uint32_t> targetRowB = image_getSafePointer<uint32_t>(target, 1);
 	SafePointer<uint32_t> targetRowC = image_getSafePointer<uint32_t>(target, 2);
 	SafePointer<uint32_t> targetRowC = image_getSafePointer<uint32_t>(target, 2);
 	SafePointer<uint32_t> targetRowD = image_getSafePointer<uint32_t>(target, 3);
 	SafePointer<uint32_t> targetRowD = image_getSafePointer<uint32_t>(target, 3);
 	SafePointer<uint32_t> targetRowE = image_getSafePointer<uint32_t>(target, 4);
 	SafePointer<uint32_t> targetRowE = image_getSafePointer<uint32_t>(target, 4);
-	int blockTargetStride = image_getStride(target) * 5;
-	for (int upperTargetY = 0; upperTargetY + 5 <= clipHeight; upperTargetY+=5) {
+	int32_t blockTargetStride = image_getStride(target) * 5;
+	for (int32_t upperTargetY = 0; upperTargetY + 5 <= clipHeight; upperTargetY+=5) {
 		// Carriage return
 		// Carriage return
 		SafePointer<const uint32_t> sourcePixel = sourceRow;
 		SafePointer<const uint32_t> sourcePixel = sourceRow;
 		SafePointer<uint32_t> targetPixelA = targetRowA;
 		SafePointer<uint32_t> targetPixelA = targetRowA;
@@ -505,7 +505,7 @@ static void blockMagnify_5x5(const ImageRgbaU8& target, const ImageRgbaU8& sourc
 		SafePointer<uint32_t> targetPixelC = targetRowC;
 		SafePointer<uint32_t> targetPixelC = targetRowC;
 		SafePointer<uint32_t> targetPixelD = targetRowD;
 		SafePointer<uint32_t> targetPixelD = targetRowD;
 		SafePointer<uint32_t> targetPixelE = targetRowE;
 		SafePointer<uint32_t> targetPixelE = targetRowE;
-		int writeLeftX = 0;
+		int32_t writeLeftX = 0;
 		while (writeLeftX + 5 <= clipWidth) {
 		while (writeLeftX + 5 <= clipWidth) {
 			// Read one pixel at a time
 			// Read one pixel at a time
 			uint32_t scalarValue = *sourcePixel;
 			uint32_t scalarValue = *sourcePixel;
@@ -539,7 +539,7 @@ static void blockMagnify_5x5(const ImageRgbaU8& target, const ImageRgbaU8& sourc
 //   * Both source and target are 16-byte aligned, but does not have to own their padding
 //   * Both source and target are 16-byte aligned, but does not have to own their padding
 //   * clipWidth % 6 == 0
 //   * clipWidth % 6 == 0
 //   * clipHeight % 6 == 0
 //   * clipHeight % 6 == 0
-static void blockMagnify_6x6(const ImageRgbaU8& target, const ImageRgbaU8& source, int clipWidth, int clipHeight) {
+static void blockMagnify_6x6(const ImageRgbaU8& target, const ImageRgbaU8& source, int32_t clipWidth, int32_t clipHeight) {
 	SafePointer<const uint32_t> sourceRow = image_getSafePointer<uint32_t>(source);
 	SafePointer<const uint32_t> sourceRow = image_getSafePointer<uint32_t>(source);
 	SafePointer<uint32_t> targetRowA = image_getSafePointer<uint32_t>(target, 0);
 	SafePointer<uint32_t> targetRowA = image_getSafePointer<uint32_t>(target, 0);
 	SafePointer<uint32_t> targetRowB = image_getSafePointer<uint32_t>(target, 1);
 	SafePointer<uint32_t> targetRowB = image_getSafePointer<uint32_t>(target, 1);
@@ -547,8 +547,8 @@ static void blockMagnify_6x6(const ImageRgbaU8& target, const ImageRgbaU8& sourc
 	SafePointer<uint32_t> targetRowD = image_getSafePointer<uint32_t>(target, 3);
 	SafePointer<uint32_t> targetRowD = image_getSafePointer<uint32_t>(target, 3);
 	SafePointer<uint32_t> targetRowE = image_getSafePointer<uint32_t>(target, 4);
 	SafePointer<uint32_t> targetRowE = image_getSafePointer<uint32_t>(target, 4);
 	SafePointer<uint32_t> targetRowF = image_getSafePointer<uint32_t>(target, 5);
 	SafePointer<uint32_t> targetRowF = image_getSafePointer<uint32_t>(target, 5);
-	int blockTargetStride = image_getStride(target) * 6;
-	for (int upperTargetY = 0; upperTargetY + 6 <= clipHeight; upperTargetY+=6) {
+	int32_t blockTargetStride = image_getStride(target) * 6;
+	for (int32_t upperTargetY = 0; upperTargetY + 6 <= clipHeight; upperTargetY+=6) {
 		// Carriage return
 		// Carriage return
 		SafePointer<const uint32_t> sourcePixel = sourceRow;
 		SafePointer<const uint32_t> sourcePixel = sourceRow;
 		SafePointer<uint32_t> targetPixelA = targetRowA;
 		SafePointer<uint32_t> targetPixelA = targetRowA;
@@ -557,7 +557,7 @@ static void blockMagnify_6x6(const ImageRgbaU8& target, const ImageRgbaU8& sourc
 		SafePointer<uint32_t> targetPixelD = targetRowD;
 		SafePointer<uint32_t> targetPixelD = targetRowD;
 		SafePointer<uint32_t> targetPixelE = targetRowE;
 		SafePointer<uint32_t> targetPixelE = targetRowE;
 		SafePointer<uint32_t> targetPixelF = targetRowF;
 		SafePointer<uint32_t> targetPixelF = targetRowF;
-		int writeLeftX = 0;
+		int32_t writeLeftX = 0;
 		while (writeLeftX + 6 <= clipWidth) {
 		while (writeLeftX + 6 <= clipWidth) {
 			// Read one pixel at a time
 			// Read one pixel at a time
 			uint32_t scalarValue = *sourcePixel;
 			uint32_t scalarValue = *sourcePixel;
@@ -594,7 +594,7 @@ static void blockMagnify_6x6(const ImageRgbaU8& target, const ImageRgbaU8& sourc
 //   * Both source and target are 16-byte aligned, but does not have to own their padding
 //   * Both source and target are 16-byte aligned, but does not have to own their padding
 //   * clipWidth % 7 == 0
 //   * clipWidth % 7 == 0
 //   * clipHeight % 7 == 0
 //   * clipHeight % 7 == 0
-static void blockMagnify_7x7(const ImageRgbaU8& target, const ImageRgbaU8& source, int clipWidth, int clipHeight) {
+static void blockMagnify_7x7(const ImageRgbaU8& target, const ImageRgbaU8& source, int32_t clipWidth, int32_t clipHeight) {
 	SafePointer<const uint32_t> sourceRow = image_getSafePointer<uint32_t>(source);
 	SafePointer<const uint32_t> sourceRow = image_getSafePointer<uint32_t>(source);
 	SafePointer<uint32_t> targetRowA = image_getSafePointer<uint32_t>(target, 0);
 	SafePointer<uint32_t> targetRowA = image_getSafePointer<uint32_t>(target, 0);
 	SafePointer<uint32_t> targetRowB = image_getSafePointer<uint32_t>(target, 1);
 	SafePointer<uint32_t> targetRowB = image_getSafePointer<uint32_t>(target, 1);
@@ -603,8 +603,8 @@ static void blockMagnify_7x7(const ImageRgbaU8& target, const ImageRgbaU8& sourc
 	SafePointer<uint32_t> targetRowE = image_getSafePointer<uint32_t>(target, 4);
 	SafePointer<uint32_t> targetRowE = image_getSafePointer<uint32_t>(target, 4);
 	SafePointer<uint32_t> targetRowF = image_getSafePointer<uint32_t>(target, 5);
 	SafePointer<uint32_t> targetRowF = image_getSafePointer<uint32_t>(target, 5);
 	SafePointer<uint32_t> targetRowG = image_getSafePointer<uint32_t>(target, 6);
 	SafePointer<uint32_t> targetRowG = image_getSafePointer<uint32_t>(target, 6);
-	int blockTargetStride = image_getStride(target) * 7;
-	for (int upperTargetY = 0; upperTargetY + 7 <= clipHeight; upperTargetY+=7) {
+	int32_t blockTargetStride = image_getStride(target) * 7;
+	for (int32_t upperTargetY = 0; upperTargetY + 7 <= clipHeight; upperTargetY+=7) {
 		// Carriage return
 		// Carriage return
 		SafePointer<const uint32_t> sourcePixel = sourceRow;
 		SafePointer<const uint32_t> sourcePixel = sourceRow;
 		SafePointer<uint32_t> targetPixelA = targetRowA;
 		SafePointer<uint32_t> targetPixelA = targetRowA;
@@ -614,7 +614,7 @@ static void blockMagnify_7x7(const ImageRgbaU8& target, const ImageRgbaU8& sourc
 		SafePointer<uint32_t> targetPixelE = targetRowE;
 		SafePointer<uint32_t> targetPixelE = targetRowE;
 		SafePointer<uint32_t> targetPixelF = targetRowF;
 		SafePointer<uint32_t> targetPixelF = targetRowF;
 		SafePointer<uint32_t> targetPixelG = targetRowG;
 		SafePointer<uint32_t> targetPixelG = targetRowG;
-		int writeLeftX = 0;
+		int32_t writeLeftX = 0;
 		while (writeLeftX + 7 <= clipWidth) {
 		while (writeLeftX + 7 <= clipWidth) {
 			// Read one pixel at a time
 			// Read one pixel at a time
 			uint32_t scalarValue = *sourcePixel;
 			uint32_t scalarValue = *sourcePixel;
@@ -654,7 +654,7 @@ static void blockMagnify_7x7(const ImageRgbaU8& target, const ImageRgbaU8& sourc
 //   * Both source and target are 16-byte aligned, but does not have to own their padding
 //   * Both source and target are 16-byte aligned, but does not have to own their padding
 //   * clipWidth % 8 == 0
 //   * clipWidth % 8 == 0
 //   * clipHeight % 8 == 0
 //   * clipHeight % 8 == 0
-static void blockMagnify_8x8(const ImageRgbaU8& target, const ImageRgbaU8& source, int clipWidth, int clipHeight) {
+static void blockMagnify_8x8(const ImageRgbaU8& target, const ImageRgbaU8& source, int32_t clipWidth, int32_t clipHeight) {
 	SafePointer<const uint32_t> sourceRow = image_getSafePointer<uint32_t>(source);
 	SafePointer<const uint32_t> sourceRow = image_getSafePointer<uint32_t>(source);
 	SafePointer<uint32_t> targetRowA = image_getSafePointer<uint32_t>(target, 0);
 	SafePointer<uint32_t> targetRowA = image_getSafePointer<uint32_t>(target, 0);
 	SafePointer<uint32_t> targetRowB = image_getSafePointer<uint32_t>(target, 1);
 	SafePointer<uint32_t> targetRowB = image_getSafePointer<uint32_t>(target, 1);
@@ -664,8 +664,8 @@ static void blockMagnify_8x8(const ImageRgbaU8& target, const ImageRgbaU8& sourc
 	SafePointer<uint32_t> targetRowF = image_getSafePointer<uint32_t>(target, 5);
 	SafePointer<uint32_t> targetRowF = image_getSafePointer<uint32_t>(target, 5);
 	SafePointer<uint32_t> targetRowG = image_getSafePointer<uint32_t>(target, 6);
 	SafePointer<uint32_t> targetRowG = image_getSafePointer<uint32_t>(target, 6);
 	SafePointer<uint32_t> targetRowH = image_getSafePointer<uint32_t>(target, 7);
 	SafePointer<uint32_t> targetRowH = image_getSafePointer<uint32_t>(target, 7);
-	int blockTargetStride = image_getStride(target) * 8;
-	for (int upperTargetY = 0; upperTargetY + 8 <= clipHeight; upperTargetY+=8) {
+	int32_t blockTargetStride = image_getStride(target) * 8;
+	for (int32_t upperTargetY = 0; upperTargetY + 8 <= clipHeight; upperTargetY+=8) {
 		// Carriage return
 		// Carriage return
 		SafePointer<const uint32_t> sourcePixel = sourceRow;
 		SafePointer<const uint32_t> sourcePixel = sourceRow;
 		SafePointer<uint32_t> targetPixelA = targetRowA;
 		SafePointer<uint32_t> targetPixelA = targetRowA;
@@ -676,7 +676,7 @@ static void blockMagnify_8x8(const ImageRgbaU8& target, const ImageRgbaU8& sourc
 		SafePointer<uint32_t> targetPixelF = targetRowF;
 		SafePointer<uint32_t> targetPixelF = targetRowF;
 		SafePointer<uint32_t> targetPixelG = targetRowG;
 		SafePointer<uint32_t> targetPixelG = targetRowG;
 		SafePointer<uint32_t> targetPixelH = targetRowH;
 		SafePointer<uint32_t> targetPixelH = targetRowH;
-		int writeLeftX = 0;
+		int32_t writeLeftX = 0;
 		while (writeLeftX + 8 <= clipWidth) {
 		while (writeLeftX + 8 <= clipWidth) {
 			// Read one pixel at a time
 			// Read one pixel at a time
 			uint32_t scalarValue = *sourcePixel;
 			uint32_t scalarValue = *sourcePixel;
@@ -714,20 +714,20 @@ static void blockMagnify_8x8(const ImageRgbaU8& target, const ImageRgbaU8& sourc
 	}
 	}
 }
 }
 
 
-static void blackEdges(const ImageRgbaU8& target, int excludedWidth, int excludedHeight) {
+static void blackEdges(const ImageRgbaU8& target, int32_t excludedWidth, int32_t excludedHeight) {
 	// Right side
 	// Right side
 	draw_rectangle(target, IRect(excludedWidth, 0, image_getWidth(target) - excludedWidth, excludedHeight), 0);
 	draw_rectangle(target, IRect(excludedWidth, 0, image_getWidth(target) - excludedWidth, excludedHeight), 0);
 	// Bottom and corner
 	// Bottom and corner
 	draw_rectangle(target, IRect(0, excludedHeight, image_getWidth(target), image_getHeight(target) - excludedHeight), 0);
 	draw_rectangle(target, IRect(0, excludedHeight, image_getWidth(target), image_getHeight(target) - excludedHeight), 0);
 }
 }
 
 
-static void imageImpl_blockMagnify(const ImageRgbaU8& target, const ImageRgbaU8& source, int pixelWidth, int pixelHeight) {
+static void imageImpl_blockMagnify(const ImageRgbaU8& target, const ImageRgbaU8& source, int32_t pixelWidth, int32_t pixelHeight) {
 	if (pixelWidth < 1) { pixelWidth = 1; }
 	if (pixelWidth < 1) { pixelWidth = 1; }
 	if (pixelHeight < 1) { pixelHeight = 1; }
 	if (pixelHeight < 1) { pixelHeight = 1; }
 	bool sameOrder = image_getPackOrderIndex(target) == image_getPackOrderIndex(source);
 	bool sameOrder = image_getPackOrderIndex(target) == image_getPackOrderIndex(source);
 	// Find the part of source which fits into target with whole pixels
 	// Find the part of source which fits into target with whole pixels
-	int clipWidth = roundDown(min(image_getWidth(target), image_getWidth(source) * pixelWidth), pixelWidth);
-	int clipHeight = roundDown(min(image_getHeight(target), image_getHeight(source) * pixelHeight), pixelHeight);
+	int32_t clipWidth = roundDown(min(image_getWidth(target), image_getWidth(source) * pixelWidth), pixelWidth);
+	int32_t clipHeight = roundDown(min(image_getHeight(target), image_getHeight(source) * pixelHeight), pixelHeight);
 	if (sameOrder) {
 	if (sameOrder) {
 		if (!(image_isSubImage(source) || image_isSubImage(target))) {
 		if (!(image_isSubImage(source) || image_isSubImage(target))) {
 			if (pixelWidth == 2 && pixelHeight == 2) {
 			if (pixelWidth == 2 && pixelHeight == 2) {
@@ -756,41 +756,41 @@ static void imageImpl_blockMagnify(const ImageRgbaU8& target, const ImageRgbaU8&
 	blackEdges(target, clipWidth, clipHeight);
 	blackEdges(target, clipWidth, clipHeight);
 }
 }
 
 
-static void mapRgbaU8(const ImageRgbaU8& target, const ImageGenRgbaU8& lambda, int startX, int startY) {
-	const int targetWidth = image_getWidth(target);
-	const int targetHeight = image_getHeight(target);
-	const int targetStride = image_getStride(target);
+static void mapRgbaU8(const ImageRgbaU8& target, const ImageGenRgbaU8& lambda, int32_t startX, int32_t startY) {
+	const int32_t targetWidth = image_getWidth(target);
+	const int32_t targetHeight = image_getHeight(target);
+	const int32_t targetStride = image_getStride(target);
 	SafePointer<uint32_t> targetRow = image_getSafePointer<uint32_t>(target);
 	SafePointer<uint32_t> targetRow = image_getSafePointer<uint32_t>(target);
-	for (int y = startY; y < targetHeight + startY; y++) {
+	for (int32_t y = startY; y < targetHeight + startY; y++) {
 		SafePointer<uint32_t> targetPixel = targetRow;
 		SafePointer<uint32_t> targetPixel = targetRow;
-		for (int x = startX; x < targetWidth + startX; x++) {
+		for (int32_t x = startX; x < targetWidth + startX; x++) {
 			*targetPixel = image_saturateAndPack(target, lambda(x, y));
 			*targetPixel = image_saturateAndPack(target, lambda(x, y));
 			targetPixel += 1;
 			targetPixel += 1;
 		}
 		}
 		targetRow.increaseBytes(targetStride);
 		targetRow.increaseBytes(targetStride);
 	}
 	}
 }
 }
-void filter_mapRgbaU8(const ImageRgbaU8 &target, const ImageGenRgbaU8& lambda, int startX, int startY) {
+void filter_mapRgbaU8(const ImageRgbaU8 &target, const ImageGenRgbaU8& lambda, int32_t startX, int32_t startY) {
 	if (image_exists(target)) {
 	if (image_exists(target)) {
 		mapRgbaU8(target, lambda, startX, startY);
 		mapRgbaU8(target, lambda, startX, startY);
 	}
 	}
 }
 }
-OrderedImageRgbaU8 filter_generateRgbaU8(int width, int height, const ImageGenRgbaU8& lambda, int startX, int startY) {
+OrderedImageRgbaU8 filter_generateRgbaU8(int32_t width, int32_t height, const ImageGenRgbaU8& lambda, int32_t startX, int32_t startY) {
 	OrderedImageRgbaU8 result = image_create_RgbaU8(width, height, false);
 	OrderedImageRgbaU8 result = image_create_RgbaU8(width, height, false);
 	filter_mapRgbaU8(result, lambda, startX, startY);
 	filter_mapRgbaU8(result, lambda, startX, startY);
 	return result;
 	return result;
 }
 }
 
 
-template <typename IMAGE_TYPE, typename PIXEL_TYPE, int MIN_VALUE, int MAX_VALUE>
-static void mapMonochrome(const IMAGE_TYPE& target, const ImageGenI32& lambda, int startX, int startY) {
-	const int targetWidth = image_getWidth(target);
-	const int targetHeight = image_getHeight(target);
-	const int targetStride = image_getStride(target);
+template <typename IMAGE_TYPE, typename PIXEL_TYPE, int32_t MIN_VALUE, int32_t MAX_VALUE>
+static void mapMonochrome(const IMAGE_TYPE& target, const ImageGenI32& lambda, int32_t startX, int32_t startY) {
+	const int32_t targetWidth = image_getWidth(target);
+	const int32_t targetHeight = image_getHeight(target);
+	const int32_t targetStride = image_getStride(target);
 	SafePointer<PIXEL_TYPE> targetRow = image_getSafePointer<PIXEL_TYPE>(target);
 	SafePointer<PIXEL_TYPE> targetRow = image_getSafePointer<PIXEL_TYPE>(target);
-	for (int y = startY; y < targetHeight + startY; y++) {
+	for (int32_t y = startY; y < targetHeight + startY; y++) {
 		SafePointer<PIXEL_TYPE> targetPixel = targetRow;
 		SafePointer<PIXEL_TYPE> targetPixel = targetRow;
-		for (int x = startX; x < targetWidth + startX; x++) {
-			int output = lambda(x, y);
+		for (int32_t x = startX; x < targetWidth + startX; x++) {
+			int32_t output = lambda(x, y);
 			if (output < MIN_VALUE) { output = MIN_VALUE; }
 			if (output < MIN_VALUE) { output = MIN_VALUE; }
 			if (output > MAX_VALUE) { output = MAX_VALUE; }
 			if (output > MAX_VALUE) { output = MAX_VALUE; }
 			*targetPixel = output;
 			*targetPixel = output;
@@ -799,47 +799,47 @@ static void mapMonochrome(const IMAGE_TYPE& target, const ImageGenI32& lambda, i
 		targetRow.increaseBytes(targetStride);
 		targetRow.increaseBytes(targetStride);
 	}
 	}
 }
 }
-void filter_mapU8(const ImageU8 &target, const ImageGenI32& lambda, int startX, int startY) {
+void filter_mapU8(const ImageU8 &target, const ImageGenI32& lambda, int32_t startX, int32_t startY) {
 	if (image_exists(target)) {
 	if (image_exists(target)) {
 		mapMonochrome<ImageU8, uint8_t, 0, 255>(target, lambda, startX, startY);
 		mapMonochrome<ImageU8, uint8_t, 0, 255>(target, lambda, startX, startY);
 	}
 	}
 }
 }
-AlignedImageU8 filter_generateU8(int width, int height, const ImageGenI32& lambda, int startX, int startY) {
+AlignedImageU8 filter_generateU8(int32_t width, int32_t height, const ImageGenI32& lambda, int32_t startX, int32_t startY) {
 	AlignedImageU8 result = image_create_U8(width, height, false);
 	AlignedImageU8 result = image_create_U8(width, height, false);
 	filter_mapU8(result, lambda, startX, startY);
 	filter_mapU8(result, lambda, startX, startY);
 	return result;
 	return result;
 }
 }
-void filter_mapU16(const ImageU16 &target, const ImageGenI32& lambda, int startX, int startY) {
+void filter_mapU16(const ImageU16 &target, const ImageGenI32& lambda, int32_t startX, int32_t startY) {
 	if (image_exists(target)) {
 	if (image_exists(target)) {
 		mapMonochrome<ImageU16, uint16_t, 0, 65535>(target, lambda, startX, startY);
 		mapMonochrome<ImageU16, uint16_t, 0, 65535>(target, lambda, startX, startY);
 	}
 	}
 }
 }
-AlignedImageU16 filter_generateU16(int width, int height, const ImageGenI32& lambda, int startX, int startY) {
+AlignedImageU16 filter_generateU16(int32_t width, int32_t height, const ImageGenI32& lambda, int32_t startX, int32_t startY) {
 	AlignedImageU16 result = image_create_U16(width, height, false);
 	AlignedImageU16 result = image_create_U16(width, height, false);
 	filter_mapU16(result, lambda, startX, startY);
 	filter_mapU16(result, lambda, startX, startY);
 	return result;
 	return result;
 }
 }
 
 
-static void mapF32(const ImageF32& target, const ImageGenF32& lambda, int startX, int startY) {
-	const int targetWidth = image_getWidth(target);
-	const int targetHeight = image_getHeight(target);
-	const int targetStride = image_getStride(target);
+static void mapF32(const ImageF32& target, const ImageGenF32& lambda, int32_t startX, int32_t startY) {
+	const int32_t targetWidth = image_getWidth(target);
+	const int32_t targetHeight = image_getHeight(target);
+	const int32_t targetStride = image_getStride(target);
 	SafePointer<float> targetRow = image_getSafePointer<float>(target);
 	SafePointer<float> targetRow = image_getSafePointer<float>(target);
-	for (int y = startY; y < targetHeight + startY; y++) {
+	for (int32_t y = startY; y < targetHeight + startY; y++) {
 		SafePointer<float> targetPixel = targetRow;
 		SafePointer<float> targetPixel = targetRow;
-		for (int x = startX; x < targetWidth + startX; x++) {
+		for (int32_t x = startX; x < targetWidth + startX; x++) {
 			*targetPixel = lambda(x, y);
 			*targetPixel = lambda(x, y);
 			targetPixel += 1;
 			targetPixel += 1;
 		}
 		}
 		targetRow.increaseBytes(targetStride);
 		targetRow.increaseBytes(targetStride);
 	}
 	}
 }
 }
-void filter_mapF32(const ImageF32 &target, const ImageGenF32& lambda, int startX, int startY) {
+void filter_mapF32(const ImageF32 &target, const ImageGenF32& lambda, int32_t startX, int32_t startY) {
 	if (image_exists(target)) {
 	if (image_exists(target)) {
 		mapF32(target, lambda, startX, startY);
 		mapF32(target, lambda, startX, startY);
 	}
 	}
 }
 }
-AlignedImageF32 filter_generateF32(int width, int height, const ImageGenF32& lambda, int startX, int startY) {
+AlignedImageF32 filter_generateF32(int32_t width, int32_t height, const ImageGenF32& lambda, int32_t startX, int32_t startY) {
 	AlignedImageF32 result = image_create_F32(width, height, false);
 	AlignedImageF32 result = image_create_F32(width, height, false);
 	filter_mapF32(result, lambda, startX, startY);
 	filter_mapF32(result, lambda, startX, startY);
 	return result;
 	return result;
@@ -869,7 +869,7 @@ AlignedImageU8 filter_resize(const ImageU8 &source, Sampler interpolation, int32
 	}
 	}
 }
 }
 
 
-void filter_blockMagnify(const ImageRgbaU8 &target, const ImageRgbaU8& source, int pixelWidth, int pixelHeight) {
+void filter_blockMagnify(const ImageRgbaU8 &target, const ImageRgbaU8& source, int32_t pixelWidth, int32_t pixelHeight) {
 	if (image_exists(target) && image_exists(source)) {
 	if (image_exists(target) && image_exists(source)) {
 		imageImpl_blockMagnify(target, source, pixelWidth, pixelHeight);
 		imageImpl_blockMagnify(target, source, pixelWidth, pixelHeight);
 	}
 	}

+ 16 - 16
Source/DFPSR/api/filterAPI.h

@@ -45,36 +45,36 @@ namespace dsr {
 	//   If source is too small, transparent black pixels (0, 0, 0, 0) fills the outside.
 	//   If source is too small, transparent black pixels (0, 0, 0, 0) fills the outside.
 	//   If source is too large, partial pixels will be cropped away completely and replaced by the black border.
 	//   If source is too large, partial pixels will be cropped away completely and replaced by the black border.
 	//   Letting the images have the same pack order and be aligned to 16-bytes will increase speed.
 	//   Letting the images have the same pack order and be aligned to 16-bytes will increase speed.
-	void filter_blockMagnify(const ImageRgbaU8 &target, const ImageRgbaU8 &source, int pixelWidth, int pixelHeight);
+	void filter_blockMagnify(const ImageRgbaU8 &target, const ImageRgbaU8 &source, int32_t pixelWidth, int32_t pixelHeight);
 
 
 // Image generation and filtering
 // Image generation and filtering
 //   Create images from Lambda expressions when speed is not critical.
 //   Create images from Lambda expressions when speed is not critical.
 //     Capture images within [] and sample pixels from them using image_readPixel_border, image_readPixel_clamp and image_readPixel_tile.
 //     Capture images within [] and sample pixels from them using image_readPixel_border, image_readPixel_clamp and image_readPixel_tile.
 	// Lambda expressions for generating integer images.
 	// Lambda expressions for generating integer images.
-	using ImageGenRgbaU8 = std::function<ColorRgbaI32(int x, int y)>;
-	using ImageGenI32 = std::function<int32_t(int x, int y)>; // Used for U8 and U16 images using different saturations.
-	using ImageGenF32 = std::function<float(int x, int y)>;
+	using ImageGenRgbaU8 = std::function<ColorRgbaI32(int32_t x, int32_t y)>;
+	using ImageGenI32 = std::function<int32_t(int32_t x, int32_t y)>; // Used for U8 and U16 images using different saturations.
+	using ImageGenF32 = std::function<float(int32_t x, int32_t y)>;
 	// In-place image generation to an existing image.
 	// In-place image generation to an existing image.
 	//   The pixel at the upper left corner gets (startX, startY) as x and y arguments to the function.
 	//   The pixel at the upper left corner gets (startX, startY) as x and y arguments to the function.
-	void filter_mapRgbaU8(const ImageRgbaU8 &target, const ImageGenRgbaU8& lambda, int startX = 0, int startY = 0);
-	void filter_mapU8(const ImageU8 &target, const ImageGenI32& lambda, int startX = 0, int startY = 0);
-	void filter_mapU16(const ImageU16 &target, const ImageGenI32& lambda, int startX = 0, int startY = 0);
-	void filter_mapF32(const ImageF32 &target, const ImageGenF32& lambda, int startX = 0, int startY = 0);
+	void filter_mapRgbaU8(const ImageRgbaU8 &target, const ImageGenRgbaU8& lambda, int32_t startX = 0, int32_t startY = 0);
+	void filter_mapU8(const ImageU8 &target, const ImageGenI32& lambda, int32_t startX = 0, int32_t startY = 0);
+	void filter_mapU16(const ImageU16 &target, const ImageGenI32& lambda, int32_t startX = 0, int32_t startY = 0);
+	void filter_mapF32(const ImageF32 &target, const ImageGenF32& lambda, int32_t startX = 0, int32_t startY = 0);
 	// A simpler image generation that constructs the image as a result.
 	// A simpler image generation that constructs the image as a result.
 	// Example:
 	// Example:
-	//     int width = 64;
-	//     int height = 64;
-	//     ImageRgbaU8 fadeImage = filter_generateRgbaU8(width, height, [](int x, int y)->ColorRgbaI32 {
+	//     int32_t width = 64;
+	//     int32_t height = 64;
+	//     ImageRgbaU8 fadeImage = filter_generateRgbaU8(width, height, [](int32_t x, int32_t y)->ColorRgbaI32 {
 	//         return ColorRgbaI32(x * 4, y * 4, 0, 255);
 	//         return ColorRgbaI32(x * 4, y * 4, 0, 255);
 	//     });
 	//     });
-	//     ImageRgbaU8 brighterImage = filter_generateRgbaU8(width, height, [fadeImage](int x, int y)->ColorRgbaI32 {
+	//     ImageRgbaU8 brighterImage = filter_generateRgbaU8(width, height, [fadeImage](int32_t x, int32_t y)->ColorRgbaI32 {
 	//	       ColorRgbaI32 source = image_readPixel_clamp(fadeImage, x, y);
 	//	       ColorRgbaI32 source = image_readPixel_clamp(fadeImage, x, y);
 	//	       return ColorRgbaI32(source.red * 2, source.green * 2, source.blue * 2, source.alpha);
 	//	       return ColorRgbaI32(source.red * 2, source.green * 2, source.blue * 2, source.alpha);
 	//     });
 	//     });
-	OrderedImageRgbaU8 filter_generateRgbaU8(int width, int height, const ImageGenRgbaU8& lambda, int startX = 0, int startY = 0);
-	AlignedImageU8 filter_generateU8(int width, int height, const ImageGenI32& lambda, int startX = 0, int startY = 0);
-	AlignedImageU16 filter_generateU16(int width, int height, const ImageGenI32& lambda, int startX = 0, int startY = 0);
-	AlignedImageF32 filter_generateF32(int width, int height, const ImageGenF32& lambda, int startX = 0, int startY = 0);
+	OrderedImageRgbaU8 filter_generateRgbaU8(int32_t width, int32_t height, const ImageGenRgbaU8& lambda, int32_t startX = 0, int32_t startY = 0);
+	AlignedImageU8 filter_generateU8(int32_t width, int32_t height, const ImageGenI32& lambda, int32_t startX = 0, int32_t startY = 0);
+	AlignedImageU16 filter_generateU16(int32_t width, int32_t height, const ImageGenI32& lambda, int32_t startX = 0, int32_t startY = 0);
+	AlignedImageF32 filter_generateF32(int32_t width, int32_t height, const ImageGenF32& lambda, int32_t startX = 0, int32_t startY = 0);
 
 
 }
 }
 
 

+ 18 - 18
Source/DFPSR/api/guiAPI.cpp

@@ -32,7 +32,7 @@
 using namespace dsr;
 using namespace dsr;
 
 
 // To be implemented outside of the core framework
 // To be implemented outside of the core framework
-Handle<dsr::BackendWindow> createBackendWindow(const dsr::String& title, int width, int height);
+Handle<dsr::BackendWindow> createBackendWindow(const dsr::String& title, int32_t width, int32_t height);
 
 
 #define MUST_EXIST(OBJECT, METHOD) if (OBJECT.isNull()) { throwError("The " #OBJECT " handle was null in " #METHOD "\n"); }
 #define MUST_EXIST(OBJECT, METHOD) if (OBJECT.isNull()) { throwError("The " #OBJECT " handle was null in " #METHOD "\n"); }
 
 
@@ -107,7 +107,7 @@ Component dsr::component_findChildByName(const Component& parent, const Readable
 	return parent->findChildByName(name);
 	return parent->findChildByName(name);
 }
 }
 
 
-Component dsr::component_findChildByNameAndIndex(const Component& parent, const ReadableString& name, int index, bool mustExist) {
+Component dsr::component_findChildByNameAndIndex(const Component& parent, const ReadableString& name, int32_t index, bool mustExist) {
 	MUST_EXIST(parent, component_findChildByNameAndIndex);
 	MUST_EXIST(parent, component_findChildByNameAndIndex);
 	return parent->findChildByNameAndIndex(name, index);
 	return parent->findChildByNameAndIndex(name, index);
 }
 }
@@ -121,7 +121,7 @@ Component dsr::window_findComponentByName(const Window& window, const ReadableSt
 	return result;
 	return result;
 }
 }
 
 
-Component dsr::window_findComponentByNameAndIndex(const Window& window, const ReadableString& name, int index, bool mustExist) {
+Component dsr::window_findComponentByNameAndIndex(const Window& window, const ReadableString& name, int32_t index, bool mustExist) {
 	MUST_EXIST(window, window_findComponentByNameAndIndex);
 	MUST_EXIST(window, window_findComponentByNameAndIndex);
 	Component result = window->findComponentByNameAndIndex(name, index);
 	Component result = window->findComponentByNameAndIndex(name, index);
 	if (mustExist && result.isNull()) {
 	if (mustExist && result.isNull()) {
@@ -130,7 +130,7 @@ Component dsr::window_findComponentByNameAndIndex(const Window& window, const Re
 	return result;
 	return result;
 }
 }
 
 
-int dsr::component_getChildCount(const Component& parent) {
+int32_t dsr::component_getChildCount(const Component& parent) {
 	if (parent.getUnsafe()) {
 	if (parent.getUnsafe()) {
 		return parent->getChildCount();
 		return parent->getChildCount();
 	} else {
 	} else {
@@ -138,7 +138,7 @@ int dsr::component_getChildCount(const Component& parent) {
 	}
 	}
 }
 }
 
 
-Component dsr::component_getChild(const Component& parent, int childIndex) {
+Component dsr::component_getChild(const Component& parent, int32_t childIndex) {
 	if (parent.getUnsafe()) {
 	if (parent.getUnsafe()) {
 		return handle_dynamicCast<VisualComponent>(parent->getChild(childIndex));
 		return handle_dynamicCast<VisualComponent>(parent->getChild(childIndex));
 	} else {
 	} else {
@@ -146,20 +146,20 @@ Component dsr::component_getChild(const Component& parent, int childIndex) {
 	}
 	}
 }
 }
 
 
-static void findAllComponentsByName(const Component& component, const ReadableString& name, std::function<void(Component, int)> callback) {
+static void findAllComponentsByName(const Component& component, const ReadableString& name, std::function<void(Component, int32_t)> callback) {
 	if (component_exists(component)) {
 	if (component_exists(component)) {
 		// Check if the current component matches
 		// Check if the current component matches
 		if (string_match(component->getName(), name)) {
 		if (string_match(component->getName(), name)) {
 			callback(component, component->getIndex());
 			callback(component, component->getIndex());
 		}
 		}
 		// Search among child components
 		// Search among child components
-		int childCount = component_getChildCount(component);
-		for (int childIndex = childCount - 1; childIndex >= 0; childIndex--) {
+		int32_t childCount = component_getChildCount(component);
+		for (int32_t childIndex = childCount - 1; childIndex >= 0; childIndex--) {
 			findAllComponentsByName(component_getChild(component, childIndex), name, callback);
 			findAllComponentsByName(component_getChild(component, childIndex), name, callback);
 		}
 		}
 	}
 	}
 }
 }
-void dsr::window_findAllComponentsByName(const Window& window, const ReadableString& name, std::function<void(Component, int)> callback) {
+void dsr::window_findAllComponentsByName(const Window& window, const ReadableString& name, std::function<void(Component, int32_t)> callback) {
 	MUST_EXIST(window, window_findAllComponentsByName);
 	MUST_EXIST(window, window_findAllComponentsByName);
 	findAllComponentsByName(window->getRootComponent(), name, callback);
 	findAllComponentsByName(window->getRootComponent(), name, callback);
 }
 }
@@ -182,11 +182,11 @@ void dsr::window_showCanvas(const Window& window) {
 	window->showCanvas();
 	window->showCanvas();
 }
 }
 
 
-int dsr::window_getPixelScale(const Window& window) {
+int32_t dsr::window_getPixelScale(const Window& window) {
 	MUST_EXIST(window, window_getPixelScale);
 	MUST_EXIST(window, window_getPixelScale);
 	return window->getPixelScale();
 	return window->getPixelScale();
 }
 }
-void dsr::window_setPixelScale(const Window& window, int scale) {
+void dsr::window_setPixelScale(const Window& window, int32_t scale) {
 	MUST_EXIST(window, window_setPixelScale);
 	MUST_EXIST(window, window_setPixelScale);
 	window->setPixelScale(scale);
 	window->setPixelScale(scale);
 }
 }
@@ -201,9 +201,9 @@ bool dsr::window_getCursorVisibility(const Window& window) {
 	return window->backend->visibleCursor;
 	return window->backend->visibleCursor;
 }
 }
 
 
-bool dsr::window_setCursorPosition(const Window& window, int x, int y) {
+bool dsr::window_setCursorPosition(const Window& window, int32_t x, int32_t y) {
 	MUST_EXIST(window, window_setCursorPosition);
 	MUST_EXIST(window, window_setCursorPosition);
-	int pixelScale = window->getPixelScale();
+	int32_t pixelScale = window->getPixelScale();
 	return window->backend->setCursorPosition(x * pixelScale, y * pixelScale);
 	return window->backend->setCursorPosition(x * pixelScale, y * pixelScale);
 }
 }
 
 
@@ -225,19 +225,19 @@ AlignedImageF32 dsr::window_getDepthBuffer(const Window& window) {
 	return window->getDepthBuffer();
 	return window->getDepthBuffer();
 }
 }
 
 
-int dsr::window_getCanvasWidth(const Window& window) {
+int32_t dsr::window_getCanvasWidth(const Window& window) {
 	MUST_EXIST(window, window_getCanvasWidth);
 	MUST_EXIST(window, window_getCanvasWidth);
 	return window->getCanvasWidth();
 	return window->getCanvasWidth();
 }
 }
-int dsr::window_getCanvasHeight(const Window& window) {
+int32_t dsr::window_getCanvasHeight(const Window& window) {
 	MUST_EXIST(window, window_getCanvasHeight);
 	MUST_EXIST(window, window_getCanvasHeight);
 	return window->getCanvasHeight();
 	return window->getCanvasHeight();
 }
 }
-int dsr::window_getInnerWidth(const Window& window) {
+int32_t dsr::window_getInnerWidth(const Window& window) {
 	MUST_EXIST(window, window_getInnerWidth);
 	MUST_EXIST(window, window_getInnerWidth);
 	return window->getInnerWidth();
 	return window->getInnerWidth();
 }
 }
-int dsr::window_getInnerHeight(const Window& window) {
+int32_t dsr::window_getInnerHeight(const Window& window) {
 	MUST_EXIST(window, window_getInnerHeight);
 	MUST_EXIST(window, window_getInnerHeight);
 	return window->getInnerHeight();
 	return window->getInnerHeight();
 }
 }
@@ -483,7 +483,7 @@ void dsr::component_detachFromParent(const Component& component) {
 	component->detach = true;
 	component->detach = true;
 }
 }
 
 
-Component dsr::component_create(const Component& parent, const ReadableString& className, const ReadableString& identifierName, int index) {
+Component dsr::component_create(const Component& parent, const ReadableString& className, const ReadableString& identifierName, int32_t index) {
 	// Making sure that the default components exist before trying to create a component manually.
 	// Making sure that the default components exist before trying to create a component manually.
 	gui_initialize();
 	gui_initialize();
 	// Creating a component from the name
 	// Creating a component from the name

+ 14 - 14
Source/DFPSR/api/guiAPI.h

@@ -33,7 +33,7 @@
 
 
 // createBackendWindow should be implemented outside of the core framework
 // createBackendWindow should be implemented outside of the core framework
 //   Choose one of the window backends in SDK/native to compile and link with your application.
 //   Choose one of the window backends in SDK/native to compile and link with your application.
-// Handle<dsr::BackendWindow> createBackendWindow(const dsr::String& title, int width, int height);
+// Handle<dsr::BackendWindow> createBackendWindow(const dsr::String& title, int32_t width, int32_t height);
 
 
 // Constness on handles doesn't propagate to any inner types
 // Constness on handles doesn't propagate to any inner types
 //   "const Comopnent&" only means that the writable Component handle can be created from a sub-expression
 //   "const Comopnent&" only means that the writable Component handle can be created from a sub-expression
@@ -119,7 +119,7 @@ namespace dsr {
 	// If mustExist is true, not finding any component with the name throws an exception.
 	// If mustExist is true, not finding any component with the name throws an exception.
 	// Raises an exception if window doesn't exist.
 	// Raises an exception if window doesn't exist.
 	// Component names are case sensitive to reduce the risk of accidental naming conflicts among many components.
 	// Component names are case sensitive to reduce the risk of accidental naming conflicts among many components.
-	Component window_findComponentByNameAndIndex(const Window& window, const ReadableString& name, int index, bool mustExist = true);
+	Component window_findComponentByNameAndIndex(const Window& window, const ReadableString& name, int32_t index, bool mustExist = true);
 	// Calls back with the component handle and index for each match of the name.
 	// Calls back with the component handle and index for each match of the name.
 	//   Can be used to count the number of components by incrementing a counter for each match.
 	//   Can be used to count the number of components by incrementing a counter for each match.
 	//   Can be used to detach all the matching components and have them automatically garbage collected by reference counting.
 	//   Can be used to detach all the matching components and have them automatically garbage collected by reference counting.
@@ -127,7 +127,7 @@ namespace dsr {
 	// To allow detaching components while iterating over the list of children, order is reversed for child components.
 	// To allow detaching components while iterating over the list of children, order is reversed for child components.
 	// Raises an exception if window doesn't exist.
 	// Raises an exception if window doesn't exist.
 	// Component names are case sensitive to reduce the risk of accidental naming conflicts among many components.
 	// Component names are case sensitive to reduce the risk of accidental naming conflicts among many components.
-	void window_findAllComponentsByName(const Window& window, const ReadableString& name, std::function<void(Component component, int index)> callback);
+	void window_findAllComponentsByName(const Window& window, const ReadableString& name, std::function<void(Component component, int32_t index)> callback);
 
 
 // The three main events to run in a loop at the end of the main function
 // The three main events to run in a loop at the end of the main function
 	// If the window's event queue contained any resize of the window, the canvas and the depth buffer will be replaced during this call.
 	// If the window's event queue contained any resize of the window, the canvas and the depth buffer will be replaced during this call.
@@ -166,12 +166,12 @@ namespace dsr {
 //     The backend window will receive the upscaled image to display over the whole window.
 //     The backend window will receive the upscaled image to display over the whole window.
 	// Gets the current pixel scale.
 	// Gets the current pixel scale.
 	//   Raises an exception if window doesn't exist.
 	//   Raises an exception if window doesn't exist.
-	int window_getPixelScale(const Window& window);
+	int32_t window_getPixelScale(const Window& window);
 	// Assigns a new pixel scale.
 	// Assigns a new pixel scale.
 	//   Raises an exception if window doesn't exist.
 	//   Raises an exception if window doesn't exist.
 	//   Just like when handling a window resize, this will replace the canvas and depth buffer.
 	//   Just like when handling a window resize, this will replace the canvas and depth buffer.
 	//     Any old handles to canvas and depth buffer will become useless, so fetch new image handles from the window to avoid black flickering.
 	//     Any old handles to canvas and depth buffer will become useless, so fetch new image handles from the window to avoid black flickering.
-	void window_setPixelScale(const Window& window, int scale);
+	void window_setPixelScale(const Window& window, int32_t scale);
 
 
 // Cursor
 // Cursor
 	// Sets the cursor visibility for window, hiding if visible is false and showing if visible is true.
 	// Sets the cursor visibility for window, hiding if visible is false and showing if visible is true.
@@ -201,7 +201,7 @@ namespace dsr {
 	//   Only use this in full-screen mode to prevent getting stuck outside of the window.
 	//   Only use this in full-screen mode to prevent getting stuck outside of the window.
 	// WARNING!
 	// WARNING!
 	//   Due to potential race-conditions, you can not assume that the next mouse move event is generated by this call.
 	//   Due to potential race-conditions, you can not assume that the next mouse move event is generated by this call.
-	bool window_setCursorPosition(const Window& window, int x, int y);
+	bool window_setCursorPosition(const Window& window, int32_t x, int32_t y);
 
 
 // Full screen
 // Full screen
 	void window_setFullScreen(const Window& window, bool enabled);
 	void window_setFullScreen(const Window& window, bool enabled);
@@ -225,17 +225,17 @@ namespace dsr {
 // Because component are drawn to the canvas and affected by upscaling.
 // Because component are drawn to the canvas and affected by upscaling.
 	// Returns the width of the canvas.
 	// Returns the width of the canvas.
 	//   Raises an exception if window doesn't exist.
 	//   Raises an exception if window doesn't exist.
-	int window_getCanvasWidth(const Window& window);
+	int32_t window_getCanvasWidth(const Window& window);
 	// Returns the height of the canvas.
 	// Returns the height of the canvas.
 	//   Raises an exception if window doesn't exist.
 	//   Raises an exception if window doesn't exist.
-	int window_getCanvasHeight(const Window& window);
+	int32_t window_getCanvasHeight(const Window& window);
 // The window's inner dimensions are relative to mouse events received directly from the window at full pixel resolution.
 // The window's inner dimensions are relative to mouse events received directly from the window at full pixel resolution.
 	// Returns the inner width of the window.
 	// Returns the inner width of the window.
 	//   Raises an exception if window doesn't exist.
 	//   Raises an exception if window doesn't exist.
-	int window_getInnerWidth(const Window& window);
+	int32_t window_getInnerWidth(const Window& window);
 	// Returns the inner height of the window.
 	// Returns the inner height of the window.
 	//   Raises an exception if window doesn't exist.
 	//   Raises an exception if window doesn't exist.
-	int window_getInnerHeight(const Window& window);
+	int32_t window_getInnerHeight(const Window& window);
 
 
 // Direct window events
 // Direct window events
 	// Listen to window mouse events.
 	// Listen to window mouse events.
@@ -259,7 +259,7 @@ namespace dsr {
 	// className must be the name of a registered persistent class inheriting from VisualComponent.
 	// className must be the name of a registered persistent class inheriting from VisualComponent.
 	// identifierName is used to find the component.
 	// identifierName is used to find the component.
 	// index can be used to identify multiple components with the same name without having to generate numbered names.
 	// index can be used to identify multiple components with the same name without having to generate numbered names.
-	Component component_create(const Component& parent, const ReadableString& className, const ReadableString& identifierName, int index = 0);
+	Component component_create(const Component& parent, const ReadableString& className, const ReadableString& identifierName, int32_t index = 0);
 	// An alternative to window_loadInterfaceFromString when you want the interface loaded into a panel instead of the whole window.
 	// An alternative to window_loadInterfaceFromString when you want the interface loaded into a panel instead of the whole window.
 	// Useful for dynamically creating and destroying interfaces to save memory and load the application faster.
 	// Useful for dynamically creating and destroying interfaces to save memory and load the application faster.
 	// Loading an interface by parsing a layout file's content, with any external resources loaded relative to fromPath.
 	// Loading an interface by parsing a layout file's content, with any external resources loaded relative to fromPath.
@@ -276,11 +276,11 @@ namespace dsr {
 	//   Deferring the removal makes sure that no event's callback is called from inside of another event.
 	//   Deferring the removal makes sure that no event's callback is called from inside of another event.
 	void component_detachFromParent(const Component& component);
 	void component_detachFromParent(const Component& component);
 	// Returns the number of direct (non-recursive) child components attached to parent, or -1 if parent is a null handle.
 	// Returns the number of direct (non-recursive) child components attached to parent, or -1 if parent is a null handle.
-	int component_getChildCount(const Component& parent);
+	int32_t component_getChildCount(const Component& parent);
 	// Returns the child at childIndex from parent, or an empty handle if parent does not exist or childIndex is out of bound.
 	// Returns the child at childIndex from parent, or an empty handle if parent does not exist or childIndex is out of bound.
 	//   Child indices go from 0 to count - 1.
 	//   Child indices go from 0 to count - 1.
 	//   The child index refers to the parent's list of children, not the child's index attribute.
 	//   The child index refers to the parent's list of children, not the child's index attribute.
-	Component component_getChild(const Component& parent, int childIndex);
+	Component component_getChild(const Component& parent, int32_t childIndex);
 	// Returns a handle to the first matching component of the name in parent recursively.
 	// Returns a handle to the first matching component of the name in parent recursively.
 	// Can be used instead of window_findComponentByName to further reduce the risk of name collisions, by only looking for recursive child components of a specific parent component.
 	// Can be used instead of window_findComponentByName to further reduce the risk of name collisions, by only looking for recursive child components of a specific parent component.
 	// If mustExist is true, not finding any component with the name within parent throws an exception.
 	// If mustExist is true, not finding any component with the name within parent throws an exception.
@@ -291,7 +291,7 @@ namespace dsr {
 	// If mustExist is true, not finding any component with the name within parent throws an exception.
 	// If mustExist is true, not finding any component with the name within parent throws an exception.
 	// Raises an exception if parent doesn't exist.
 	// Raises an exception if parent doesn't exist.
 	// Component names are case sensitive to reduce the risk of accidental naming conflicts among many components.
 	// Component names are case sensitive to reduce the risk of accidental naming conflicts among many components.
-	Component component_findChildByNameAndIndex(const Component& parent, const ReadableString& name, int index, bool mustExist = true);
+	Component component_findChildByNameAndIndex(const Component& parent, const ReadableString& name, int32_t index, bool mustExist = true);
 	// Returns true iff propertyName exists in component.
 	// Returns true iff propertyName exists in component.
 	//   Property names are case insensitive, to give more flexibility for the few property names.
 	//   Property names are case insensitive, to give more flexibility for the few property names.
 	bool component_hasProperty(const Component& component, const ReadableString& propertyName);
 	bool component_hasProperty(const Component& component, const ReadableString& propertyName);

+ 34 - 34
Source/DFPSR/api/imageAPI.cpp

@@ -83,7 +83,7 @@ inline bool imageIsPadded(const IMAGE_TYPE &image) {
 }
 }
 
 
 // Loading from data pointer
 // Loading from data pointer
-OrderedImageRgbaU8 image_decode_RgbaU8(SafePointer<const uint8_t> data, int size) {
+OrderedImageRgbaU8 image_decode_RgbaU8(SafePointer<const uint8_t> data, int32_t size) {
 	if (data.isNotNull()) {
 	if (data.isNotNull()) {
 		return image_stb_decode_RgbaU8(data, size);
 		return image_stb_decode_RgbaU8(data, size);
 	} else {
 	} else {
@@ -107,7 +107,7 @@ OrderedImageRgbaU8 image_load_RgbaU8(const ReadableString& filename, bool mustEx
 	return result;
 	return result;
 }
 }
 
 
-Buffer image_encode(const ImageRgbaU8 &image, ImageFileFormat format, int quality) {
+Buffer image_encode(const ImageRgbaU8 &image, ImageFileFormat format, int32_t quality) {
 	if (image_exists(image)) {
 	if (image_exists(image)) {
 		ImageRgbaU8 orderedImage;
 		ImageRgbaU8 orderedImage;
 		if (image_getPackOrderIndex(image) != PackOrderIndex::RGBA) {
 		if (image_getPackOrderIndex(image) != PackOrderIndex::RGBA) {
@@ -131,7 +131,7 @@ Buffer image_encode(const ImageRgbaU8 &image, ImageFileFormat format, int qualit
 
 
 static ImageFileFormat detectImageFileExtension(const ReadableString& filename) {
 static ImageFileFormat detectImageFileExtension(const ReadableString& filename) {
 	ImageFileFormat result = ImageFileFormat::Unknown;
 	ImageFileFormat result = ImageFileFormat::Unknown;
-	int lastDotIndex = string_findLast(filename, U'.');
+	int32_t lastDotIndex = string_findLast(filename, U'.');
 	if (lastDotIndex != -1) {
 	if (lastDotIndex != -1) {
 		String extension = string_upperCase(file_getExtension(filename));
 		String extension = string_upperCase(file_getExtension(filename));
 		if (string_match(extension, U"JPG") || string_match(extension, U"JPEG")) {
 		if (string_match(extension, U"JPG") || string_match(extension, U"JPEG")) {
@@ -147,7 +147,7 @@ static ImageFileFormat detectImageFileExtension(const ReadableString& filename)
 	return result;
 	return result;
 }
 }
 
 
-bool image_save(const ImageRgbaU8 &image, const ReadableString& filename, bool mustWork, int quality) {
+bool image_save(const ImageRgbaU8 &image, const ReadableString& filename, bool mustWork, int32_t quality) {
 	ImageFileFormat extension = detectImageFileExtension(filename);
 	ImageFileFormat extension = detectImageFileExtension(filename);
 	Buffer buffer;
 	Buffer buffer;
 	if (extension == ImageFileFormat::Unknown) {
 	if (extension == ImageFileFormat::Unknown) {
@@ -242,13 +242,13 @@ ImageRgbaU8 image_removePadding(const ImageRgbaU8& image) {
 	}
 	}
 }
 }
 
 
-static void extractChannel(SafePointer<uint8_t> targetData, int targetStride, SafePointer<const uint8_t> sourceData, int sourceStride, int sourceChannels, int channelIndex, int width, int height) {
+static void extractChannel(SafePointer<uint8_t> targetData, int32_t targetStride, SafePointer<const uint8_t> sourceData, int32_t sourceStride, int32_t sourceChannels, int32_t channelIndex, int32_t width, int32_t height) {
 	SafePointer<const uint8_t> sourceRow = sourceData + channelIndex;
 	SafePointer<const uint8_t> sourceRow = sourceData + channelIndex;
 	SafePointer<uint8_t> targetRow = targetData;
 	SafePointer<uint8_t> targetRow = targetData;
-	for (int y = 0; y < height; y++) {
+	for (int32_t y = 0; y < height; y++) {
 		SafePointer<const uint8_t> sourceElement = sourceRow;
 		SafePointer<const uint8_t> sourceElement = sourceRow;
 		SafePointer<uint8_t> targetElement = targetRow;
 		SafePointer<uint8_t> targetElement = targetRow;
-		for (int x = 0; x < width; x++) {
+		for (int32_t x = 0; x < width; x++) {
 			*targetElement = *sourceElement; // Copy one channel from the soruce
 			*targetElement = *sourceElement; // Copy one channel from the soruce
 			sourceElement += sourceChannels; // Jump to the same channel in the next source pixel
 			sourceElement += sourceChannels; // Jump to the same channel in the next source pixel
 			targetElement += 1; // Jump to the next monochrome target pixel
 			targetElement += 1; // Jump to the next monochrome target pixel
@@ -260,7 +260,7 @@ static void extractChannel(SafePointer<uint8_t> targetData, int targetStride, Sa
 
 
 static AlignedImageU8 getChannel(const ImageRgbaU8 image, int32_t channelIndex) {
 static AlignedImageU8 getChannel(const ImageRgbaU8 image, int32_t channelIndex) {
 	// Warning for debug mode
 	// Warning for debug mode
-	static int channelCount = 4;
+	static int32_t channelCount = 4;
 	assert(0 <= channelIndex && channelIndex < channelCount);
 	assert(0 <= channelIndex && channelIndex < channelCount);
 	AlignedImageU8 result = image_create_U8(image_getWidth(image), image_getHeight(image));
 	AlignedImageU8 result = image_create_U8(image_getWidth(image), image_getHeight(image));
 	extractChannel(image_getSafePointer<uint8_t>(result), image_getStride(result), image_getSafePointer<uint8_t>(image), image_getStride(image), channelCount, channelIndex, image_getWidth(image), image_getHeight(image));
 	extractChannel(image_getSafePointer<uint8_t>(result), image_getStride(result), image_getSafePointer<uint8_t>(image), image_getStride(image), channelCount, channelIndex, image_getWidth(image), image_getHeight(image));
@@ -296,17 +296,17 @@ AlignedImageU8 image_get_alpha(const ImageRgbaU8& image) {
 	}
 	}
 }
 }
 
 
-static inline int32_t readColor(const ImageU8& channel, int x, int y) {
+static inline int32_t readColor(const ImageU8& channel, int32_t x, int32_t y) {
 	return image_accessPixel(channel, x, y);
 	return image_accessPixel(channel, x, y);
 }
 }
-static inline int32_t readColor(int32_t color, int x, int y) {
+static inline int32_t readColor(int32_t color, int32_t x, int32_t y) {
 	return color;
 	return color;
 }
 }
 template <typename R, typename G, typename B, typename A>
 template <typename R, typename G, typename B, typename A>
 static OrderedImageRgbaU8 pack_template(int32_t width, int32_t height, R red, G green, B blue, A alpha) {
 static OrderedImageRgbaU8 pack_template(int32_t width, int32_t height, R red, G green, B blue, A alpha) {
 	OrderedImageRgbaU8 result = image_create_RgbaU8(width, height);
 	OrderedImageRgbaU8 result = image_create_RgbaU8(width, height);
-	for (int y = 0; y < height; y++) {
-		for (int x = 0; x < width; x++) {
+	for (int32_t y = 0; y < height; y++) {
+		for (int32_t x = 0; x < width; x++) {
 			ColorRgbaI32 color = ColorRgbaI32(readColor(red, x, y), readColor(green, x, y), readColor(blue, x, y), readColor(alpha, x, y));
 			ColorRgbaI32 color = ColorRgbaI32(readColor(red, x, y), readColor(green, x, y), readColor(blue, x, y), readColor(alpha, x, y));
 			image_writePixel(result, x, y, color);
 			image_writePixel(result, x, y, color);
 		}
 		}
@@ -384,27 +384,27 @@ String image_toAscii(const ImageU8& image, const String& alphabet) {
 	}
 	}
 	String result;
 	String result;
 	char alphabetMap[256];
 	char alphabetMap[256];
-	int alphabetSize = string_length(alphabet);
-	int width = image_getWidth(image);
-	int height = image_getHeight(image);
+	int32_t alphabetSize = string_length(alphabet);
+	int32_t width = image_getWidth(image);
+	int32_t height = image_getHeight(image);
 	string_reserve(result, ((width + 4) * height) + alphabetSize + 5);
 	string_reserve(result, ((width + 4) * height) + alphabetSize + 5);
 	double scale = (double)(alphabetSize - 1) / 255.0;
 	double scale = (double)(alphabetSize - 1) / 255.0;
 	double output = 0.49;
 	double output = 0.49;
-	for (int rawValue = 0; rawValue < 256; rawValue++) {
-		int charIndex = (int)output;
+	for (int32_t rawValue = 0; rawValue < 256; rawValue++) {
+		int32_t charIndex = (int32_t)output;
 		if (charIndex < 0) charIndex = 0;
 		if (charIndex < 0) charIndex = 0;
 		if (charIndex > alphabetSize - 1) charIndex = alphabetSize - 1;
 		if (charIndex > alphabetSize - 1) charIndex = alphabetSize - 1;
 		alphabetMap[rawValue] = alphabet[charIndex];
 		alphabetMap[rawValue] = alphabet[charIndex];
 		output += scale;
 		output += scale;
 	}
 	}
 	string_appendChar(result, U'<');
 	string_appendChar(result, U'<');
-	for (int charIndex = 0; charIndex < alphabetSize; charIndex++) {
+	for (int32_t charIndex = 0; charIndex < alphabetSize; charIndex++) {
 		string_appendChar(result, alphabet[charIndex]);
 		string_appendChar(result, alphabet[charIndex]);
 	}
 	}
 	string_append(result, U">\n");
 	string_append(result, U">\n");
-	for (int y = 0; y < height; y++) {
+	for (int32_t y = 0; y < height; y++) {
 		string_appendChar(result, U'<');
 		string_appendChar(result, U'<');
-		for (int x = 0; x < width; x++) {
+		for (int32_t x = 0; x < width; x++) {
 			string_appendChar(result, alphabetMap[image_readPixel_clamp(image, x, y)]);
 			string_appendChar(result, alphabetMap[image_readPixel_clamp(image, x, y)]);
 		}
 		}
 		string_append(result, U">\n");
 		string_append(result, U">\n");
@@ -422,14 +422,14 @@ AlignedImageU8 image_fromAscii(const String& content) {
 	char alphabet[128];
 	char alphabet[128];
 	uint8_t alphabetMap[128];
 	uint8_t alphabetMap[128];
 	char current;
 	char current;
-	int x = 0;
-	int y = -1;
-	int width = 0;
-	int height = 0;
-	int alphabetSize = 0;
-	int contentSize = string_length(content);
+	int32_t x = 0;
+	int32_t y = -1;
+	int32_t width = 0;
+	int32_t height = 0;
+	int32_t alphabetSize = 0;
+	int32_t contentSize = string_length(content);
 	bool quoted = false;
 	bool quoted = false;
-	int i = 0;
+	int32_t i = 0;
 	while (i < contentSize && ((current = content[i]) != '\0')) {
 	while (i < contentSize && ((current = content[i]) != '\0')) {
 		if (quoted) {
 		if (quoted) {
 			if (y < 0) {
 			if (y < 0) {
@@ -466,14 +466,14 @@ AlignedImageU8 image_fromAscii(const String& content) {
 		alphabetMap[i] = 0;
 		alphabetMap[i] = 0;
 	}
 	}
 	for (i = 0; i < alphabetSize; i++) {
 	for (i = 0; i < alphabetSize; i++) {
-		int code = (int)(alphabet[i]);
+		int32_t code = (int32_t)(alphabet[i]);
 		if (code < 32 || code > 126) {
 		if (code < 32 || code > 126) {
 			throwError(U"Ascii image contained non-printable standard ascii! Use codes 32 to 126.");
 			throwError(U"Ascii image contained non-printable standard ascii! Use codes 32 to 126.");
 		}
 		}
 		if (alphabetMap[code] > 0) {
 		if (alphabetMap[code] > 0) {
 			throwError(U"A character in the alphabet was used more than once!");
 			throwError(U"A character in the alphabet was used more than once!");
 		}
 		}
-		int value = (int)(((double)i) * (255.0f / ((double)(alphabetSize - 1))));
+		int32_t value = (int32_t)(((double)i) * (255.0f / ((double)(alphabetSize - 1))));
 		if (value < 0) value = 0;
 		if (value < 0) value = 0;
 		if (value > 255) value = 255;
 		if (value > 255) value = 255;
 		alphabetMap[code] = value;
 		alphabetMap[code] = value;
@@ -495,7 +495,7 @@ AlignedImageU8 image_fromAscii(const String& content) {
 				y++;
 				y++;
 				x = 0;
 				x = 0;
 			} else if (y >= 0) {
 			} else if (y >= 0) {
-				int code = (int)current;
+				int32_t code = (int32_t)current;
 				if (code < 0) code = 0;
 				if (code < 0) code = 0;
 				if (code > 127) code = 127;
 				if (code > 127) code = 127;
 				image_writePixel(result, x, y, alphabetMap[code]);
 				image_writePixel(result, x, y, alphabetMap[code]);
@@ -509,7 +509,7 @@ AlignedImageU8 image_fromAscii(const String& content) {
 	return result;
 	return result;
 }
 }
 
 
-template <typename IMAGE_TYPE, int CHANNELS, typename ELEMENT_TYPE>
+template <typename IMAGE_TYPE, int32_t CHANNELS, typename ELEMENT_TYPE>
 ELEMENT_TYPE maxDifference_template(const IMAGE_TYPE& imageA, const IMAGE_TYPE& imageB) {
 ELEMENT_TYPE maxDifference_template(const IMAGE_TYPE& imageA, const IMAGE_TYPE& imageB) {
 	if (image_getWidth(imageA) != image_getWidth(imageB) || image_getHeight(imageA) != image_getHeight(imageB)) {
 	if (image_getWidth(imageA) != image_getWidth(imageB) || image_getHeight(imageA) != image_getHeight(imageB)) {
 		return std::numeric_limits<ELEMENT_TYPE>::max();
 		return std::numeric_limits<ELEMENT_TYPE>::max();
@@ -519,11 +519,11 @@ ELEMENT_TYPE maxDifference_template(const IMAGE_TYPE& imageA, const IMAGE_TYPE&
 		ELEMENT_TYPE maxDifference = 0;
 		ELEMENT_TYPE maxDifference = 0;
 		SafePointer<const ELEMENT_TYPE> rowDataA = image_getSafePointer<ELEMENT_TYPE>(imageA);
 		SafePointer<const ELEMENT_TYPE> rowDataA = image_getSafePointer<ELEMENT_TYPE>(imageA);
 		SafePointer<const ELEMENT_TYPE> rowDataB = image_getSafePointer<ELEMENT_TYPE>(imageB);
 		SafePointer<const ELEMENT_TYPE> rowDataB = image_getSafePointer<ELEMENT_TYPE>(imageB);
-		for (int y = 0; y < image_getHeight(imageA); y++) {
+		for (int32_t y = 0; y < image_getHeight(imageA); y++) {
 			SafePointer<const ELEMENT_TYPE> pixelDataA = rowDataA;
 			SafePointer<const ELEMENT_TYPE> pixelDataA = rowDataA;
 			SafePointer<const ELEMENT_TYPE> pixelDataB = rowDataB;
 			SafePointer<const ELEMENT_TYPE> pixelDataB = rowDataB;
-			for (int x = 0; x < image_getWidth(imageA); x++) {
-				for (int c = 0; c < CHANNELS; c++) {
+			for (int32_t x = 0; x < image_getWidth(imageA); x++) {
+				for (int32_t c = 0; c < CHANNELS; c++) {
 					ELEMENT_TYPE difference = absDiff(*pixelDataA, *pixelDataB);
 					ELEMENT_TYPE difference = absDiff(*pixelDataA, *pixelDataB);
 					if (difference > maxDifference) {
 					if (difference > maxDifference) {
 						maxDifference = difference;
 						maxDifference = difference;

+ 3 - 3
Source/DFPSR/api/imageAPI.h

@@ -352,7 +352,7 @@ namespace dsr {
 	// A faster and more flexible way to load compressed images from memory.
 	// A faster and more flexible way to load compressed images from memory.
 	// If you just want to point directly to a memory location to avoid allocating many small buffers, you can use a safe pointer and a size in bytes.
 	// If you just want to point directly to a memory location to avoid allocating many small buffers, you can use a safe pointer and a size in bytes.
 	// Failure will return an empty handle.
 	// Failure will return an empty handle.
-	OrderedImageRgbaU8 image_decode_RgbaU8(SafePointer<const uint8_t> data, int size);
+	OrderedImageRgbaU8 image_decode_RgbaU8(SafePointer<const uint8_t> data, int32_t size);
 
 
 // Saving
 // Saving
 	// Save the image to the path specified by filename and return true iff the operation was successful.
 	// Save the image to the path specified by filename and return true iff the operation was successful.
@@ -365,12 +365,12 @@ namespace dsr {
 	// If mustWork is true, an exception will be raised on failure.
 	// If mustWork is true, an exception will be raised on failure.
 	// If mustWork is false, failure will return false.
 	// If mustWork is false, failure will return false.
 	// The optional quality setting goes from 1% to 100% and is at the maximum by default.
 	// The optional quality setting goes from 1% to 100% and is at the maximum by default.
-	bool image_save(const ImageRgbaU8 &image, const ReadableString& filename, bool mustWork = true, int quality = 100);
+	bool image_save(const ImageRgbaU8 &image, const ReadableString& filename, bool mustWork = true, int32_t quality = 100);
 	// Save the image to a memory buffer.
 	// Save the image to a memory buffer.
 	// Post-condition: Returns a buffer with the encoded image format as it would be saved to a file, or empty on failure.
 	// Post-condition: Returns a buffer with the encoded image format as it would be saved to a file, or empty on failure.
 	//                 No exceptions will be raised on failure, because an error message without a filename would not explain much.
 	//                 No exceptions will be raised on failure, because an error message without a filename would not explain much.
 	// The optional quality setting goes from 1% to 100% and is at the maximum by default.
 	// The optional quality setting goes from 1% to 100% and is at the maximum by default.
-	Buffer image_encode(const ImageRgbaU8 &image, ImageFileFormat format, int quality = 90);
+	Buffer image_encode(const ImageRgbaU8 &image, ImageFileFormat format, int32_t quality = 90);
 
 
 // Fill all pixels with a uniform color
 // Fill all pixels with a uniform color
 	void image_fill(const ImageU8& image, int32_t color);
 	void image_fill(const ImageU8& image, int32_t color);

+ 47 - 47
Source/DFPSR/api/mediaMachineAPI.cpp

@@ -52,7 +52,7 @@ public:
 	MemoryPlane<AlignedImageU8> AlignedImageU8Memory;
 	MemoryPlane<AlignedImageU8> AlignedImageU8Memory;
 	MemoryPlane<OrderedImageRgbaU8> OrderedImageRgbaU8Memory;
 	MemoryPlane<OrderedImageRgbaU8> OrderedImageRgbaU8Memory;
 	MediaMemory() : FixedPointMemory(1024), AlignedImageU8Memory(1024), OrderedImageRgbaU8Memory(512) {}
 	MediaMemory() : FixedPointMemory(1024), AlignedImageU8Memory(1024), OrderedImageRgbaU8Memory(512) {}
-	void store(int targetStackIndex, const VMA& sourceArg, int sourceFramePointer, DataType type) override {
+	void store(int32_t targetStackIndex, const VMA& sourceArg, int32_t sourceFramePointer, DataType type) override {
 		switch(type) {
 		switch(type) {
 			case DataType_FixedPoint:
 			case DataType_FixedPoint:
 				if (sourceArg.argType == ArgumentType::Immediate) {
 				if (sourceArg.argType == ArgumentType::Immediate) {
@@ -61,7 +61,7 @@ public:
 					#endif
 					#endif
 					this->FixedPointMemory.accessByStackIndex(targetStackIndex) = sourceArg.value;
 					this->FixedPointMemory.accessByStackIndex(targetStackIndex) = sourceArg.value;
 				} else {
 				} else {
-					int globalIndex = sourceArg.value.getMantissa();
+					int32_t globalIndex = sourceArg.value.getMantissa();
 					FixedPoint value = this->FixedPointMemory.accessByGlobalIndex(globalIndex, sourceFramePointer);
 					FixedPoint value = this->FixedPointMemory.accessByGlobalIndex(globalIndex, sourceFramePointer);
 					#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 					#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 						if (globalIndex < 0) {
 						if (globalIndex < 0) {
@@ -84,8 +84,8 @@ public:
 			break;
 			break;
 		}
 		}
 	}
 	}
-	void load(int sourceStackIndex, const VMA& targetArg, int targetFramePointer, DataType type) override {
-		int globalIndex = targetArg.value.getMantissa();
+	void load(int32_t sourceStackIndex, const VMA& targetArg, int32_t targetFramePointer, DataType type) override {
+		int32_t globalIndex = targetArg.value.getMantissa();
 		switch(type) {
 		switch(type) {
 			case DataType_FixedPoint:
 			case DataType_FixedPoint:
 				this->FixedPointMemory.accessByGlobalIndex(globalIndex, targetFramePointer) = this->FixedPointMemory.accessByStackIndex(sourceStackIndex);
 				this->FixedPointMemory.accessByGlobalIndex(globalIndex, targetFramePointer) = this->FixedPointMemory.accessByStackIndex(sourceStackIndex);
@@ -108,24 +108,24 @@ public:
 // Type definitions
 // Type definitions
 static const VMTypeDef mediaMachineTypes[] = {
 static const VMTypeDef mediaMachineTypes[] = {
 	VMTypeDef(U"FixedPoint", DataType_FixedPoint, true,
 	VMTypeDef(U"FixedPoint", DataType_FixedPoint, true,
-	[](VirtualMachine& machine, int globalIndex, const ReadableString& defaultValueText){
+	[](VirtualMachine& machine, int32_t globalIndex, const ReadableString& defaultValueText){
 		FixedPoint defaultValue = string_length(defaultValueText) > 0 ? FixedPoint::fromText(defaultValueText) : FixedPoint();
 		FixedPoint defaultValue = string_length(defaultValueText) > 0 ? FixedPoint::fromText(defaultValueText) : FixedPoint();
 		List<VMA> args;
 		List<VMA> args;
 		args.pushConstruct(DataType_FixedPoint, globalIndex);
 		args.pushConstruct(DataType_FixedPoint, globalIndex);
 		args.pushConstruct(defaultValue);
 		args.pushConstruct(defaultValue);
 		machine.interpretCommand(U"Load", args);
 		machine.interpretCommand(U"Load", args);
 	},
 	},
-	[](PlanarMemory& memory, Variable& variable, int globalIndex, int32_t* framePointer, bool fullContent) {
+	[](PlanarMemory& memory, Variable& variable, int32_t globalIndex, int32_t* framePointer, bool fullContent) {
 		FixedPoint value = MEDIA_MEMORY.FixedPointMemory.accessByGlobalIndex(globalIndex, framePointer[DataType_FixedPoint]);
 		FixedPoint value = MEDIA_MEMORY.FixedPointMemory.accessByGlobalIndex(globalIndex, framePointer[DataType_FixedPoint]);
 		printText(variable.name, "(", value, ")");
 		printText(variable.name, "(", value, ")");
 	}),
 	}),
 	VMTypeDef(U"ImageU8", DataType_ImageU8, false,
 	VMTypeDef(U"ImageU8", DataType_ImageU8, false,
-	[](VirtualMachine& machine, int globalIndex, const ReadableString& defaultValueText){
+	[](VirtualMachine& machine, int32_t globalIndex, const ReadableString& defaultValueText){
 		List<VMA> args;
 		List<VMA> args;
 		args.pushConstruct(DataType_ImageU8, globalIndex);
 		args.pushConstruct(DataType_ImageU8, globalIndex);
 		machine.interpretCommand(U"Reset", args);
 		machine.interpretCommand(U"Reset", args);
 	},
 	},
-	[](PlanarMemory& memory, Variable& variable, int globalIndex, int32_t* framePointer, bool fullContent) {
+	[](PlanarMemory& memory, Variable& variable, int32_t globalIndex, int32_t* framePointer, bool fullContent) {
 		AlignedImageU8 value = MEDIA_MEMORY.AlignedImageU8Memory.accessByGlobalIndex(globalIndex, framePointer[DataType_ImageU8]);
 		AlignedImageU8 value = MEDIA_MEMORY.AlignedImageU8Memory.accessByGlobalIndex(globalIndex, framePointer[DataType_ImageU8]);
 		printText(variable.name, " ImageU8");
 		printText(variable.name, " ImageU8");
 		if (image_exists(value)) {
 		if (image_exists(value)) {
@@ -139,12 +139,12 @@ static const VMTypeDef mediaMachineTypes[] = {
 		}
 		}
 	}),
 	}),
 	VMTypeDef(U"ImageRgbaU8", DataType_ImageRgbaU8, false,
 	VMTypeDef(U"ImageRgbaU8", DataType_ImageRgbaU8, false,
-	[](VirtualMachine& machine, int globalIndex, const ReadableString& defaultValueText){
+	[](VirtualMachine& machine, int32_t globalIndex, const ReadableString& defaultValueText){
 		List<VMA> args;
 		List<VMA> args;
 		args.pushConstruct(DataType_ImageRgbaU8, globalIndex);
 		args.pushConstruct(DataType_ImageRgbaU8, globalIndex);
 		machine.interpretCommand(U"Reset", args);
 		machine.interpretCommand(U"Reset", args);
 	},
 	},
-	[](PlanarMemory& memory, Variable& variable, int globalIndex, int32_t* framePointer, bool fullContent) {
+	[](PlanarMemory& memory, Variable& variable, int32_t globalIndex, int32_t* framePointer, bool fullContent) {
 		OrderedImageRgbaU8 value = MEDIA_MEMORY.OrderedImageRgbaU8Memory.accessByGlobalIndex(globalIndex, framePointer[DataType_ImageRgbaU8]);
 		OrderedImageRgbaU8 value = MEDIA_MEMORY.OrderedImageRgbaU8Memory.accessByGlobalIndex(globalIndex, framePointer[DataType_ImageRgbaU8]);
 		printText(variable.name, " ImageRgbaU8");
 		printText(variable.name, " ImageRgbaU8");
 		if (image_exists(value)) {
 		if (image_exists(value)) {
@@ -320,8 +320,8 @@ static const InsSig mediaMachineInstructions[] = {
 	),
 	),
 	InsSig::create(U"CREATE", 1,
 	InsSig::create(U"CREATE", 1,
 		[](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
 		[](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
-			int width = INT_VALUE(1);
-			int height = INT_VALUE(2);
+			int32_t width = INT_VALUE(1);
+			int32_t height = INT_VALUE(2);
 			if (width < 1 || height < 1) {
 			if (width < 1 || height < 1) {
 				throwError("Images must allocate at least one pixel to be created.");
 				throwError("Images must allocate at least one pixel to be created.");
 			}
 			}
@@ -334,8 +334,8 @@ static const InsSig mediaMachineInstructions[] = {
 	),
 	),
 	InsSig::create(U"CREATE", 1,
 	InsSig::create(U"CREATE", 1,
 		[](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
 		[](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
-			int width = INT_VALUE(1);
-			int height = INT_VALUE(2);
+			int32_t width = INT_VALUE(1);
+			int32_t height = INT_VALUE(2);
 			if (width < 1 || height < 1) {
 			if (width < 1 || height < 1) {
 				throwError("Images must allocate at least one pixel to be created.");
 				throwError("Images must allocate at least one pixel to be created.");
 			}
 			}
@@ -514,8 +514,8 @@ static const InsSig mediaMachineInstructions[] = {
 	),
 	),
 	InsSig::create(U"RESIZE_BILINEAR", 1,
 	InsSig::create(U"RESIZE_BILINEAR", 1,
 		[](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
 		[](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
-			int width = INT_VALUE(1); if (width < 1) width = 1;
-			int height = INT_VALUE(2); if (height < 1) height = 1;
+			int32_t width = INT_VALUE(1); if (width < 1) width = 1;
+			int32_t height = INT_VALUE(2); if (height < 1) height = 1;
 			IMAGE_U8_REF(0) = filter_resize(IMAGE_U8_REF(3), Sampler::Linear, width, height);
 			IMAGE_U8_REF(0) = filter_resize(IMAGE_U8_REF(3), Sampler::Linear, width, height);
 			NEXT_INSTRUCTION
 			NEXT_INSTRUCTION
 		},
 		},
@@ -526,8 +526,8 @@ static const InsSig mediaMachineInstructions[] = {
 	),
 	),
 	InsSig::create(U"RESIZE_BILINEAR", 1,
 	InsSig::create(U"RESIZE_BILINEAR", 1,
 		[](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
 		[](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
-			int width = INT_VALUE(1); if (width < 1) width = 1;
-			int height = INT_VALUE(2); if (height < 1) height = 1;
+			int32_t width = INT_VALUE(1); if (width < 1) width = 1;
+			int32_t height = INT_VALUE(2); if (height < 1) height = 1;
 			IMAGE_RGBAU8_REF(0) = filter_resize(IMAGE_RGBAU8_REF(3), Sampler::Linear, width, height);
 			IMAGE_RGBAU8_REF(0) = filter_resize(IMAGE_RGBAU8_REF(3), Sampler::Linear, width, height);
 			NEXT_INSTRUCTION
 			NEXT_INSTRUCTION
 		},
 		},
@@ -538,8 +538,8 @@ static const InsSig mediaMachineInstructions[] = {
 	),
 	),
 	InsSig::create(U"RESIZE_BILINEAR", 1,
 	InsSig::create(U"RESIZE_BILINEAR", 1,
 		[](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
 		[](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
-			int width = INT_VALUE(1); if (width < 1) width = 1;
-			int height = INT_VALUE(2); if (height < 1) height = 1;
+			int32_t width = INT_VALUE(1); if (width < 1) width = 1;
+			int32_t height = INT_VALUE(2); if (height < 1) height = 1;
 			IMAGE_U8_REF(0) = filter_resize(image_getSubImage(IMAGE_U8_REF(3), IRect(INT_VALUE(4), INT_VALUE(5), INT_VALUE(6), INT_VALUE(7))), Sampler::Linear, width, height);
 			IMAGE_U8_REF(0) = filter_resize(image_getSubImage(IMAGE_U8_REF(3), IRect(INT_VALUE(4), INT_VALUE(5), INT_VALUE(6), INT_VALUE(7))), Sampler::Linear, width, height);
 			NEXT_INSTRUCTION
 			NEXT_INSTRUCTION
 		},
 		},
@@ -555,8 +555,8 @@ static const InsSig mediaMachineInstructions[] = {
 	),
 	),
 	InsSig::create(U"RESIZE_BILINEAR", 1,
 	InsSig::create(U"RESIZE_BILINEAR", 1,
 		[](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
 		[](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
-			int width = INT_VALUE(1); if (width < 1) width = 1;
-			int height = INT_VALUE(2); if (height < 1) height = 1;
+			int32_t width = INT_VALUE(1); if (width < 1) width = 1;
+			int32_t height = INT_VALUE(2); if (height < 1) height = 1;
 			IMAGE_RGBAU8_REF(0) = filter_resize(image_getSubImage(IMAGE_RGBAU8_REF(3), IRect(INT_VALUE(4), INT_VALUE(5), INT_VALUE(6), INT_VALUE(7))), Sampler::Linear, width, height);
 			IMAGE_RGBAU8_REF(0) = filter_resize(image_getSubImage(IMAGE_RGBAU8_REF(3), IRect(INT_VALUE(4), INT_VALUE(5), INT_VALUE(6), INT_VALUE(7))), Sampler::Linear, width, height);
 			NEXT_INSTRUCTION
 			NEXT_INSTRUCTION
 		},
 		},
@@ -1049,7 +1049,7 @@ static void checkMachine(const MediaMachine& machine) {
 	}
 	}
 }
 }
 
 
-static void checkMethodIndex(const MediaMachine& machine, int methodIndex) {
+static void checkMethodIndex(const MediaMachine& machine, int32_t methodIndex) {
 	checkMachine(machine);
 	checkMachine(machine);
 	if (methodIndex < 0 || methodIndex >= machine->methods.length()) {
 	if (methodIndex < 0 || methodIndex >= machine->methods.length()) {
 		throwError("Invalid method index ", methodIndex, " of 0..", (machine->methods.length() - 1), "!");
 		throwError("Invalid method index ", methodIndex, " of 0..", (machine->methods.length() - 1), "!");
@@ -1058,18 +1058,18 @@ static void checkMethodIndex(const MediaMachine& machine, int methodIndex) {
 
 
 MediaMachine machine_create(const ReadableString& code) {
 MediaMachine machine_create(const ReadableString& code) {
 	Handle<PlanarMemory> memory = handle_create<MediaMemory>().setName("MediaMemory");
 	Handle<PlanarMemory> memory = handle_create<MediaMemory>().setName("MediaMemory");
-	static const int mediaMachineInstructionCount = sizeof(mediaMachineInstructions) / sizeof(InsSig);
-	static const int mediaMachineTypeCount = sizeof(mediaMachineTypes) / sizeof(VMTypeDef);
+	static const int32_t mediaMachineInstructionCount = sizeof(mediaMachineInstructions) / sizeof(InsSig);
+	static const int32_t mediaMachineTypeCount = sizeof(mediaMachineTypes) / sizeof(VMTypeDef);
 	return MediaMachine(handle_create<VirtualMachine>(code, memory, mediaMachineInstructions, mediaMachineInstructionCount, mediaMachineTypes, mediaMachineTypeCount).setName("MediaMachine"));
 	return MediaMachine(handle_create<VirtualMachine>(code, memory, mediaMachineInstructions, mediaMachineInstructionCount, mediaMachineTypes, mediaMachineTypeCount).setName("MediaMachine"));
 }
 }
 
 
-void machine_executeMethod(MediaMachine& machine, int methodIndex) {
+void machine_executeMethod(MediaMachine& machine, int32_t methodIndex) {
 	checkMethodIndex(machine, methodIndex);
 	checkMethodIndex(machine, methodIndex);
 	machine->executeMethod(methodIndex);
 	machine->executeMethod(methodIndex);
 }
 }
 
 
 template <typename T>
 template <typename T>
-static void setInputByIndex(MemoryPlane<T>& stack, int framePointer, Method& method, DataType givenType, int inputIndex, const T& value) {
+static void setInputByIndex(MemoryPlane<T>& stack, int32_t framePointer, Method& method, DataType givenType, int32_t inputIndex, const T& value) {
 	if (inputIndex < 0 || inputIndex >= method.inputCount) {
 	if (inputIndex < 0 || inputIndex >= method.inputCount) {
 		throwError("Invalid input index ", inputIndex, " of 0..", (method.inputCount - 1), ".");
 		throwError("Invalid input index ", inputIndex, " of 0..", (method.inputCount - 1), ".");
 	}
 	}
@@ -1081,7 +1081,7 @@ static void setInputByIndex(MemoryPlane<T>& stack, int framePointer, Method& met
 	stack.accessByStackIndex(framePointer + variable->typeLocalIndex) = value;
 	stack.accessByStackIndex(framePointer + variable->typeLocalIndex) = value;
 }
 }
 template <typename T>
 template <typename T>
-static T& accessOutputByIndex(MemoryPlane<T>& stack, int framePointer, Method& method, DataType wantedType, int outputIndex) {
+static T& accessOutputByIndex(MemoryPlane<T>& stack, int32_t framePointer, Method& method, DataType wantedType, int32_t outputIndex) {
 	if (outputIndex < 0 || outputIndex >= method.outputCount) {
 	if (outputIndex < 0 || outputIndex >= method.outputCount) {
 		throwError("Invalid output index ", outputIndex, " of 0..", (method.outputCount - 1), ".");
 		throwError("Invalid output index ", outputIndex, " of 0..", (method.outputCount - 1), ".");
 	}
 	}
@@ -1095,28 +1095,28 @@ static T& accessOutputByIndex(MemoryPlane<T>& stack, int framePointer, Method& m
 
 
 // Set input by argument index
 // Set input by argument index
 //   Indexed arguments are confirmed to be inputs during compilation of the script
 //   Indexed arguments are confirmed to be inputs during compilation of the script
-void machine_setInputByIndex(MediaMachine& machine, int methodIndex, int inputIndex, int32_t input) {
+void machine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, int32_t input) {
 	#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 	#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 		printText("Input ", inputIndex, " of ", machine->methods[methodIndex].inputCount, " (", machine->methods[methodIndex].locals[inputIndex].name, ") to ", machine->methods[methodIndex].name, " = ", input, "\n");
 		printText("Input ", inputIndex, " of ", machine->methods[methodIndex].inputCount, " (", machine->methods[methodIndex].locals[inputIndex].name, ") to ", machine->methods[methodIndex].name, " = ", input, "\n");
 	#endif
 	#endif
 	checkMethodIndex(machine, methodIndex);
 	checkMethodIndex(machine, methodIndex);
 	setInputByIndex(((MediaMemory*)machine->memory.getUnsafe())->FixedPointMemory, machine->memory->current.framePointer[DataType_FixedPoint], machine->methods[methodIndex], DataType_FixedPoint, inputIndex, FixedPoint::fromWhole(input));
 	setInputByIndex(((MediaMemory*)machine->memory.getUnsafe())->FixedPointMemory, machine->memory->current.framePointer[DataType_FixedPoint], machine->methods[methodIndex], DataType_FixedPoint, inputIndex, FixedPoint::fromWhole(input));
 }
 }
-void machine_setInputByIndex(MediaMachine& machine, int methodIndex, int inputIndex, const FixedPoint& input) {
+void machine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, const FixedPoint& input) {
 	#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 	#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 		printText("Input ", inputIndex, " of ", machine->methods[methodIndex].inputCount, " (", machine->methods[methodIndex].locals[inputIndex].name, ") to ", machine->methods[methodIndex].name, " = ", input, "\n");
 		printText("Input ", inputIndex, " of ", machine->methods[methodIndex].inputCount, " (", machine->methods[methodIndex].locals[inputIndex].name, ") to ", machine->methods[methodIndex].name, " = ", input, "\n");
 	#endif
 	#endif
 	checkMethodIndex(machine, methodIndex);
 	checkMethodIndex(machine, methodIndex);
 	setInputByIndex(((MediaMemory*)machine->memory.getUnsafe())->FixedPointMemory, machine->memory->current.framePointer[DataType_FixedPoint], machine->methods[methodIndex], DataType_FixedPoint, inputIndex, input);
 	setInputByIndex(((MediaMemory*)machine->memory.getUnsafe())->FixedPointMemory, machine->memory->current.framePointer[DataType_FixedPoint], machine->methods[methodIndex], DataType_FixedPoint, inputIndex, input);
 }
 }
-void machine_setInputByIndex(MediaMachine& machine, int methodIndex, int inputIndex, const AlignedImageU8& input) {
+void machine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, const AlignedImageU8& input) {
 	#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 	#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 		printText("Input ", inputIndex, " of ", machine->methods[methodIndex].inputCount, " (", machine->methods[methodIndex].locals[inputIndex].name, ") to ", machine->methods[methodIndex].name, " = monochrome image of ", image_getWidth(input), "x", image_getHeight(input), " pixels\n");
 		printText("Input ", inputIndex, " of ", machine->methods[methodIndex].inputCount, " (", machine->methods[methodIndex].locals[inputIndex].name, ") to ", machine->methods[methodIndex].name, " = monochrome image of ", image_getWidth(input), "x", image_getHeight(input), " pixels\n");
 	#endif
 	#endif
 	checkMethodIndex(machine, methodIndex);
 	checkMethodIndex(machine, methodIndex);
 	setInputByIndex(((MediaMemory*)machine->memory.getUnsafe())->AlignedImageU8Memory, machine->memory->current.framePointer[DataType_ImageU8], machine->methods[methodIndex], DataType_ImageU8, inputIndex, input);
 	setInputByIndex(((MediaMemory*)machine->memory.getUnsafe())->AlignedImageU8Memory, machine->memory->current.framePointer[DataType_ImageU8], machine->methods[methodIndex], DataType_ImageU8, inputIndex, input);
 }
 }
-void machine_setInputByIndex(MediaMachine& machine, int methodIndex, int inputIndex, const OrderedImageRgbaU8& input) {
+void machine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, const OrderedImageRgbaU8& input) {
 	#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 	#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 		printText("Input ", inputIndex, " of ", machine->methods[methodIndex].inputCount, " (", machine->methods[methodIndex].locals[inputIndex].name, ") to ", machine->methods[methodIndex].name, " = rgba image of ", image_getWidth(input), "x", image_getHeight(input), " pixels\n");
 		printText("Input ", inputIndex, " of ", machine->methods[methodIndex].inputCount, " (", machine->methods[methodIndex].locals[inputIndex].name, ") to ", machine->methods[methodIndex].name, " = rgba image of ", image_getWidth(input), "x", image_getHeight(input), " pixels\n");
 	#endif
 	#endif
@@ -1125,15 +1125,15 @@ void machine_setInputByIndex(MediaMachine& machine, int methodIndex, int inputIn
 }
 }
 
 
 // Get output by index
 // Get output by index
-FixedPoint machine_getFixedPointOutputByIndex(const MediaMachine& machine, int methodIndex, int outputIndex) {
+FixedPoint machine_getFixedPointOutputByIndex(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex) {
 	checkMethodIndex(machine, methodIndex);
 	checkMethodIndex(machine, methodIndex);
 	return accessOutputByIndex<FixedPoint>(((MediaMemory*)machine->memory.getUnsafe())->FixedPointMemory, machine->memory->current.framePointer[DataType_FixedPoint], machine->methods[methodIndex], DataType_FixedPoint, outputIndex);
 	return accessOutputByIndex<FixedPoint>(((MediaMemory*)machine->memory.getUnsafe())->FixedPointMemory, machine->memory->current.framePointer[DataType_FixedPoint], machine->methods[methodIndex], DataType_FixedPoint, outputIndex);
 }
 }
-AlignedImageU8 machine_getImageU8OutputByIndex(const MediaMachine& machine, int methodIndex, int outputIndex) {
+AlignedImageU8 machine_getImageU8OutputByIndex(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex) {
 	checkMethodIndex(machine, methodIndex);
 	checkMethodIndex(machine, methodIndex);
 	return accessOutputByIndex<AlignedImageU8>(((MediaMemory*)machine->memory.getUnsafe())->AlignedImageU8Memory, machine->memory->current.framePointer[DataType_ImageU8], machine->methods[methodIndex], DataType_ImageU8, outputIndex);
 	return accessOutputByIndex<AlignedImageU8>(((MediaMemory*)machine->memory.getUnsafe())->AlignedImageU8Memory, machine->memory->current.framePointer[DataType_ImageU8], machine->methods[methodIndex], DataType_ImageU8, outputIndex);
 }
 }
-OrderedImageRgbaU8 machine_getImageRgbaU8OutputByIndex(const MediaMachine& machine, int methodIndex, int outputIndex) {
+OrderedImageRgbaU8 machine_getImageRgbaU8OutputByIndex(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex) {
 	checkMethodIndex(machine, methodIndex);
 	checkMethodIndex(machine, methodIndex);
 	return accessOutputByIndex<OrderedImageRgbaU8>(((MediaMemory*)machine->memory.getUnsafe())->OrderedImageRgbaU8Memory, machine->memory->current.framePointer[DataType_ImageRgbaU8], machine->methods[methodIndex], DataType_ImageRgbaU8, outputIndex);
 	return accessOutputByIndex<OrderedImageRgbaU8>(((MediaMemory*)machine->memory.getUnsafe())->OrderedImageRgbaU8Memory, machine->memory->current.framePointer[DataType_ImageRgbaU8], machine->methods[methodIndex], DataType_ImageRgbaU8, outputIndex);
 }
 }
@@ -1142,7 +1142,7 @@ bool machine_exists(const MediaMachine& machine) {
 	return machine.isNotNull();
 	return machine.isNotNull();
 }
 }
 
 
-int machine_findMethod(const MediaMachine& machine, const ReadableString& methodName) {
+int32_t machine_findMethod(const MediaMachine& machine, const ReadableString& methodName) {
 	if (!machine_exists(machine)) {
 	if (!machine_exists(machine)) {
 		throwError(U"Can not look for ", methodName, U" in a media machine that does not exist!\n");
 		throwError(U"Can not look for ", methodName, U" in a media machine that does not exist!\n");
 		return -1;
 		return -1;
@@ -1151,35 +1151,35 @@ int machine_findMethod(const MediaMachine& machine, const ReadableString& method
 	}
 	}
 }
 }
 
 
-MediaMethod machine_getMethod(MediaMachine& machine, const ReadableString& methodName, int contextIndex, bool mustExist) {
-	int methodIndex = machine_findMethod(machine, methodName);
+MediaMethod machine_getMethod(MediaMachine& machine, const ReadableString& methodName, int32_t contextIndex, bool mustExist) {
+	int32_t methodIndex = machine_findMethod(machine, methodName);
 	if (mustExist && methodIndex == -1) {
 	if (mustExist && methodIndex == -1) {
 		throwError(U"The method name ", methodName, U" could not be found in the media machine!\n");
 		throwError(U"The method name ", methodName, U" could not be found in the media machine!\n");
 	}
 	}
 	return MediaMethod(machine, methodIndex, contextIndex);
 	return MediaMethod(machine, methodIndex, contextIndex);
 }
 }
 
 
-String machine_getMethodName(const MediaMachine& machine, int methodIndex) {
+String machine_getMethodName(const MediaMachine& machine, int32_t methodIndex) {
 	checkMethodIndex(machine, methodIndex);
 	checkMethodIndex(machine, methodIndex);
 	return machine->methods[methodIndex].name;
 	return machine->methods[methodIndex].name;
 }
 }
 
 
-int machine_getMethodCount(const MediaMachine& machine) {
+int32_t machine_getMethodCount(const MediaMachine& machine) {
 	checkMachine(machine);
 	checkMachine(machine);
 	return machine->methods.length();
 	return machine->methods.length();
 }
 }
 
 
-int machine_getInputCount(const MediaMachine& machine, int methodIndex) {
+int32_t machine_getInputCount(const MediaMachine& machine, int32_t methodIndex) {
 	checkMethodIndex(machine, methodIndex);
 	checkMethodIndex(machine, methodIndex);
 	return machine->methods[methodIndex].inputCount;
 	return machine->methods[methodIndex].inputCount;
 }
 }
 
 
-int machine_getOutputCount(const MediaMachine& machine, int methodIndex) {
+int32_t machine_getOutputCount(const MediaMachine& machine, int32_t methodIndex) {
 	checkMethodIndex(machine, methodIndex);
 	checkMethodIndex(machine, methodIndex);
 	return machine->methods[methodIndex].outputCount;
 	return machine->methods[methodIndex].outputCount;
 }
 }
 
 
-String machine_getInputName(const MediaMachine& machine, int methodIndex, int inputIndex) {
+String machine_getInputName(const MediaMachine& machine, int32_t methodIndex, int32_t inputIndex) {
 	checkMethodIndex(machine, methodIndex);
 	checkMethodIndex(machine, methodIndex);
 	Method *method = &(machine->methods[methodIndex]);
 	Method *method = &(machine->methods[methodIndex]);
 	if (inputIndex < 0 || inputIndex >= method->inputCount) {
 	if (inputIndex < 0 || inputIndex >= method->inputCount) {
@@ -1188,7 +1188,7 @@ String machine_getInputName(const MediaMachine& machine, int methodIndex, int in
 	return method->locals[inputIndex].name;
 	return method->locals[inputIndex].name;
 }
 }
 
 
-String machine_getOutputName(const MediaMachine& machine, int methodIndex, int outputIndex) {
+String machine_getOutputName(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex) {
 	checkMethodIndex(machine, methodIndex);
 	checkMethodIndex(machine, methodIndex);
 	Method *method = &(machine->methods[methodIndex]);
 	Method *method = &(machine->methods[methodIndex]);
 	if (outputIndex < 0 || outputIndex >= method->outputCount) {
 	if (outputIndex < 0 || outputIndex >= method->outputCount) {
@@ -1197,14 +1197,14 @@ String machine_getOutputName(const MediaMachine& machine, int methodIndex, int o
 	return method->locals[method->inputCount + outputIndex].name;
 	return method->locals[method->inputCount + outputIndex].name;
 }
 }
 
 
-MediaResult MediaMethod::callUsingKeywords(std::function<void(MediaMachine &machine, int methodIndex, int inputIndex, const ReadableString &argumentName)> setInputAction) {
+MediaResult MediaMethod::callUsingKeywords(std::function<void(MediaMachine &machine, int32_t methodIndex, int32_t inputIndex, const ReadableString &argumentName)> setInputAction) {
 	if (this->methodIndex < 0 || this->methodIndex >= this->machine->methods.length()) {
 	if (this->methodIndex < 0 || this->methodIndex >= this->machine->methods.length()) {
 		throwError(U"Method index ", this->methodIndex, U" is out of bound 0..", this->machine->methods.length() - 1, U"\n");
 		throwError(U"Method index ", this->methodIndex, U" is out of bound 0..", this->machine->methods.length() - 1, U"\n");
 	}
 	}
 	Method *method = &(this->machine->methods[this->methodIndex]);
 	Method *method = &(this->machine->methods[this->methodIndex]);
-	int inputCount = method->inputCount;
+	int32_t inputCount = method->inputCount;
 	// TODO: Make sure that input arguments are assigned default arguments before assigning inputs as keywords.
 	// TODO: Make sure that input arguments are assigned default arguments before assigning inputs as keywords.
-	for (int i = 0; i < inputCount; i++) {
+	for (int32_t i = 0; i < inputCount; i++) {
 		setInputAction(this->machine, this->methodIndex, i, method->locals[i].name);
 		setInputAction(this->machine, this->methodIndex, i, method->locals[i].name);
 	}
 	}
 	machine_executeMethod(this->machine, this->methodIndex);
 	machine_executeMethod(this->machine, this->methodIndex);

+ 39 - 39
Source/DFPSR/api/mediaMachineAPI.h

@@ -50,7 +50,7 @@ bool machine_exists(const MediaMachine& machine);
 //   * The machine must exist.
 //   * The machine must exist.
 //     machine_exists(machine)
 //     machine_exists(machine)
 // Returns the index to the method who's name matches methodName with case insensitivity in machine, or -1 if it does not exist in machine.
 // Returns the index to the method who's name matches methodName with case insensitivity in machine, or -1 if it does not exist in machine.
-int machine_findMethod(const MediaMachine& machine, const ReadableString& methodName);
+int32_t machine_findMethod(const MediaMachine& machine, const ReadableString& methodName);
 
 
 // Assign an input argument of a method before your call to machine_executeMethod.
 // Assign an input argument of a method before your call to machine_executeMethod.
 // Pre-condition:
 // Pre-condition:
@@ -61,10 +61,10 @@ int machine_findMethod(const MediaMachine& machine, const ReadableString& method
 //   * inputIndex must refer to an input of the method in machine.
 //   * inputIndex must refer to an input of the method in machine.
 //     0 <= inputIndex < machine_getInputCount(machine, methodIndex)
 //     0 <= inputIndex < machine_getInputCount(machine, methodIndex)
 // Side-effect: Sets the input at inputIndex in machine's method at methodIndex to input.
 // Side-effect: Sets the input at inputIndex in machine's method at methodIndex to input.
-void machine_setInputByIndex(MediaMachine& machine, int methodIndex, int inputIndex, int32_t input);
-void machine_setInputByIndex(MediaMachine& machine, int methodIndex, int inputIndex, const FixedPoint& input);
-void machine_setInputByIndex(MediaMachine& machine, int methodIndex, int inputIndex, const AlignedImageU8& input);
-void machine_setInputByIndex(MediaMachine& machine, int methodIndex, int inputIndex, const OrderedImageRgbaU8& input);
+void machine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, int32_t input);
+void machine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, const FixedPoint& input);
+void machine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, const AlignedImageU8& input);
+void machine_setInputByIndex(MediaMachine& machine, int32_t methodIndex, int32_t inputIndex, const OrderedImageRgbaU8& input);
 
 
 // Call a method in the media machine, reading from input registers and writing to output registers.
 // Call a method in the media machine, reading from input registers and writing to output registers.
 // Pre-condition:
 // Pre-condition:
@@ -74,7 +74,7 @@ void machine_setInputByIndex(MediaMachine& machine, int methodIndex, int inputIn
 //   * methodIndex must refer to the method to call in machine.
 //   * methodIndex must refer to the method to call in machine.
 //     0 <= methodIndex < machine_getMethodCount(machine)
 //     0 <= methodIndex < machine_getMethodCount(machine)
 // Side-effect: Writes the results to output arguments.
 // Side-effect: Writes the results to output arguments.
-void machine_executeMethod(MediaMachine& machine, int methodIndex);
+void machine_executeMethod(MediaMachine& machine, int32_t methodIndex);
 
 
 // Read output register at outputIndex
 // Read output register at outputIndex
 // Pre-condition:
 // Pre-condition:
@@ -85,15 +85,15 @@ void machine_executeMethod(MediaMachine& machine, int methodIndex);
 //   * The output index must be within range.
 //   * The output index must be within range.
 //     0 <= outputIndex < machine_getOutputCount(machine, methodIndex)
 //     0 <= outputIndex < machine_getOutputCount(machine, methodIndex)
 // Post-condition: Returns the output at outputIndex.
 // Post-condition: Returns the output at outputIndex.
-FixedPoint machine_getFixedPointOutputByIndex(const MediaMachine& machine, int methodIndex, int outputIndex);
-AlignedImageU8 machine_getImageU8OutputByIndex(const MediaMachine& machine, int methodIndex, int outputIndex);
-OrderedImageRgbaU8 machine_getImageRgbaU8OutputByIndex(const MediaMachine& machine, int methodIndex, int outputIndex);
+FixedPoint machine_getFixedPointOutputByIndex(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex);
+AlignedImageU8 machine_getImageU8OutputByIndex(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex);
+OrderedImageRgbaU8 machine_getImageRgbaU8OutputByIndex(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex);
 
 
 // Pre-condition:
 // Pre-condition:
 //   * The machine must exist.
 //   * The machine must exist.
 //     machine_exists(machine)
 //     machine_exists(machine)
 // Post-condition: Returns the number of methods in machine.
 // Post-condition: Returns the number of methods in machine.
-int machine_getMethodCount(const MediaMachine& machine);
+int32_t machine_getMethodCount(const MediaMachine& machine);
 
 
 // Pre-condition:
 // Pre-condition:
 //   * The machine must exist.
 //   * The machine must exist.
@@ -101,7 +101,7 @@ int machine_getMethodCount(const MediaMachine& machine);
 //   * methodIndex must refer to the method that you want to get the name from.
 //   * methodIndex must refer to the method that you want to get the name from.
 //     0 <= methodIndex < machine_getMethodCount(machine)
 //     0 <= methodIndex < machine_getMethodCount(machine)
 // Post-condition: Returns the name of the method at methodIndex in machine.
 // Post-condition: Returns the name of the method at methodIndex in machine.
-String machine_getMethodName(const MediaMachine& machine, int methodIndex);
+String machine_getMethodName(const MediaMachine& machine, int32_t methodIndex);
 
 
 // Pre-condition:
 // Pre-condition:
 //   * The machine must exist.
 //   * The machine must exist.
@@ -109,7 +109,7 @@ String machine_getMethodName(const MediaMachine& machine, int methodIndex);
 //   * methodIndex must refer to the method that you want to get the input count from.
 //   * methodIndex must refer to the method that you want to get the input count from.
 //     0 <= methodIndex < machine_getMethodCount(machine)
 //     0 <= methodIndex < machine_getMethodCount(machine)
 // Post-condition: Returns the input argument count for the method at methodIndex in machine.
 // Post-condition: Returns the input argument count for the method at methodIndex in machine.
-int machine_getInputCount(const MediaMachine& machine, int methodIndex);
+int32_t machine_getInputCount(const MediaMachine& machine, int32_t methodIndex);
 
 
 // Pre-condition:
 // Pre-condition:
 //   * The machine must exist.
 //   * The machine must exist.
@@ -117,7 +117,7 @@ int machine_getInputCount(const MediaMachine& machine, int methodIndex);
 //   * methodIndex must refer to the method that you want to get the output count from.
 //   * methodIndex must refer to the method that you want to get the output count from.
 //     0 <= methodIndex < machine_getMethodCount(machine)
 //     0 <= methodIndex < machine_getMethodCount(machine)
 // Post-condition: Returns the output argument count for the method at methodIndex in machine.
 // Post-condition: Returns the output argument count for the method at methodIndex in machine.
-int machine_getOutputCount(const MediaMachine& machine, int methodIndex);
+int32_t machine_getOutputCount(const MediaMachine& machine, int32_t methodIndex);
 
 
 // Pre-condition:
 // Pre-condition:
 //   * The machine must exist.
 //   * The machine must exist.
@@ -127,7 +127,7 @@ int machine_getOutputCount(const MediaMachine& machine, int methodIndex);
 //   * The inputIndex must refer to the input argument that you want to get the name of.
 //   * The inputIndex must refer to the input argument that you want to get the name of.
 //     0 <= inputIndex < machine_getInputCount(machine, methodIndex)
 //     0 <= inputIndex < machine_getInputCount(machine, methodIndex)
 // Post-condition: Returns the input argument name at inputIndex for the method at methodIndex in machine.
 // Post-condition: Returns the input argument name at inputIndex for the method at methodIndex in machine.
-String machine_getInputName(const MediaMachine& machine, int methodIndex, int inputIndex);
+String machine_getInputName(const MediaMachine& machine, int32_t methodIndex, int32_t inputIndex);
 
 
 // Pre-condition:
 // Pre-condition:
 //   * The machine must exist.
 //   * The machine must exist.
@@ -137,14 +137,14 @@ String machine_getInputName(const MediaMachine& machine, int methodIndex, int in
 //   * The outputIndex must refer to the output argument that you want to get the name of.
 //   * The outputIndex must refer to the output argument that you want to get the name of.
 //     0 <= outputIndex < machine_getOutputCount(machine, methodIndex)
 //     0 <= outputIndex < machine_getOutputCount(machine, methodIndex)
 // Post-condition: Returns the output argument name at outputIndex for the method at methodIndex in machine.
 // Post-condition: Returns the output argument name at outputIndex for the method at methodIndex in machine.
-String machine_getOutputName(const MediaMachine& machine, int methodIndex, int outputIndex);
+String machine_getOutputName(const MediaMachine& machine, int32_t methodIndex, int32_t outputIndex);
 
 
 // Helper function counting the number of arguments given to it.
 // Helper function counting the number of arguments given to it.
-inline constexpr int machine_argCount() {
+inline constexpr int32_t machine_argCount() {
 	return 0;
 	return 0;
 }
 }
 template<typename HEAD, typename... TAIL>
 template<typename HEAD, typename... TAIL>
-inline constexpr int machine_argCount(HEAD& first, TAIL&... args) {
+inline constexpr int32_t machine_argCount(HEAD& first, TAIL&... args) {
 	return machine_argCount(args...) + 1;
 	return machine_argCount(args...) + 1;
 }
 }
 
 
@@ -155,42 +155,42 @@ private:
 	//   because it may not be used after other calls to the machine.
 	//   because it may not be used after other calls to the machine.
 	// It is only used to assign outputs with the () operator.
 	// It is only used to assign outputs with the () operator.
 	MediaMachine &machine;
 	MediaMachine &machine;
-	int methodIndex;
-	void writeResult(int outputIndex, int8_t& target) {
+	int32_t methodIndex;
+	void writeResult(int32_t outputIndex, int8_t& target) {
 		target = fixedPoint_round(machine_getFixedPointOutputByIndex(this->machine, this->methodIndex, outputIndex));
 		target = fixedPoint_round(machine_getFixedPointOutputByIndex(this->machine, this->methodIndex, outputIndex));
 	}
 	}
-	void writeResult(int outputIndex, int16_t& target) {
+	void writeResult(int32_t outputIndex, int16_t& target) {
 		target = fixedPoint_round(machine_getFixedPointOutputByIndex(this->machine, this->methodIndex, outputIndex));
 		target = fixedPoint_round(machine_getFixedPointOutputByIndex(this->machine, this->methodIndex, outputIndex));
 	}
 	}
-	void writeResult(int outputIndex, int32_t& target) {
+	void writeResult(int32_t outputIndex, int32_t& target) {
 		target = fixedPoint_round(machine_getFixedPointOutputByIndex(this->machine, this->methodIndex, outputIndex));
 		target = fixedPoint_round(machine_getFixedPointOutputByIndex(this->machine, this->methodIndex, outputIndex));
 	}
 	}
-	void writeResult(int outputIndex, int64_t& target) {
+	void writeResult(int32_t outputIndex, int64_t& target) {
 		target = fixedPoint_round(machine_getFixedPointOutputByIndex(this->machine, this->methodIndex, outputIndex));
 		target = fixedPoint_round(machine_getFixedPointOutputByIndex(this->machine, this->methodIndex, outputIndex));
 	}
 	}
-	void writeResult(int outputIndex, FixedPoint& target) {
+	void writeResult(int32_t outputIndex, FixedPoint& target) {
 		target = machine_getFixedPointOutputByIndex(this->machine, this->methodIndex, outputIndex);
 		target = machine_getFixedPointOutputByIndex(this->machine, this->methodIndex, outputIndex);
 	}
 	}
-	void writeResult(int outputIndex, AlignedImageU8& target) {
+	void writeResult(int32_t outputIndex, AlignedImageU8& target) {
 		target = machine_getImageU8OutputByIndex(this->machine, this->methodIndex, outputIndex);
 		target = machine_getImageU8OutputByIndex(this->machine, this->methodIndex, outputIndex);
 	}
 	}
-	void writeResult(int outputIndex, OrderedImageRgbaU8& target) {
+	void writeResult(int32_t outputIndex, OrderedImageRgbaU8& target) {
 		target = machine_getImageRgbaU8OutputByIndex(this->machine, this->methodIndex, outputIndex);
 		target = machine_getImageRgbaU8OutputByIndex(this->machine, this->methodIndex, outputIndex);
 	}
 	}
-	inline void writeResults(int firstInputIndex) {}
+	inline void writeResults(int32_t firstInputIndex) {}
 	template<typename HEAD, typename... TAIL>
 	template<typename HEAD, typename... TAIL>
-	inline void writeResults(int firstInputIndex, HEAD& first, TAIL&... args) {
+	inline void writeResults(int32_t firstInputIndex, HEAD& first, TAIL&... args) {
 		this->writeResult(firstInputIndex, first);
 		this->writeResult(firstInputIndex, first);
 		this->writeResults(firstInputIndex + 1, args...);
 		this->writeResults(firstInputIndex + 1, args...);
 	}
 	}
 public:
 public:
-	MediaResult(MediaMachine& machine, int methodIndex)
+	MediaResult(MediaMachine& machine, int32_t methodIndex)
  	: machine(machine), methodIndex(methodIndex) {}
  	: machine(machine), methodIndex(methodIndex) {}
 	// Write target references within () after a call to assign multiple outputs
 	// Write target references within () after a call to assign multiple outputs
 	template <typename... ARGS>
 	template <typename... ARGS>
 	void operator () (ARGS&... args) {
 	void operator () (ARGS&... args) {
-		int givenCount = machine_argCount(args...);
-		int expectedCount = machine_getOutputCount(this->machine, this->methodIndex);
+		int32_t givenCount = machine_argCount(args...);
+		int32_t expectedCount = machine_getOutputCount(this->machine, this->methodIndex);
 		if (givenCount != expectedCount) {
 		if (givenCount != expectedCount) {
 			throwError("The call to ", machine_getMethodName(this->machine, this->methodIndex), " expected ", expectedCount, " outputs, but ", givenCount, " references were assigned.\n");
 			throwError("The call to ", machine_getMethodName(this->machine, this->methodIndex), " expected ", expectedCount, " outputs, but ", givenCount, " references were assigned.\n");
 		}
 		}
@@ -208,26 +208,26 @@ public:
 class MediaMethod {
 class MediaMethod {
 public:
 public:
 	MediaMachine machine;
 	MediaMachine machine;
-	int methodIndex; // Index of the method being called.
-	int contextIndex; // Index used to know from which context implicit variables are being fetched.
+	int32_t methodIndex; // Index of the method being called.
+	int32_t contextIndex; // Index used to know from which context implicit variables are being fetched.
 private:
 private:
-	inline void setInputs(int firstInputIndex) {}
+	inline void setInputs(int32_t firstInputIndex) {}
 	template<typename HEAD, typename... TAIL>
 	template<typename HEAD, typename... TAIL>
-	inline void setInputs(int firstInputIndex, const HEAD &first, TAIL&&... args) {
+	inline void setInputs(int32_t firstInputIndex, const HEAD &first, TAIL&&... args) {
 		machine_setInputByIndex(this->machine, this->methodIndex, firstInputIndex, first);
 		machine_setInputByIndex(this->machine, this->methodIndex, firstInputIndex, first);
 		this->setInputs(firstInputIndex + 1, args...);
 		this->setInputs(firstInputIndex + 1, args...);
 	}
 	}
 public:
 public:
 	MediaMethod()
 	MediaMethod()
  	: methodIndex(-1), contextIndex(0) {}
  	: methodIndex(-1), contextIndex(0) {}
-	MediaMethod(const MediaMachine& machine, int methodIndex, int contextIndex)
+	MediaMethod(const MediaMachine& machine, int32_t methodIndex, int32_t contextIndex)
  	: machine(machine), methodIndex(methodIndex), contextIndex(contextIndex) {}
  	: machine(machine), methodIndex(methodIndex), contextIndex(contextIndex) {}
 	// MediaMethod can be called like a function using arguments, returning MediaResult for assigning outputs by reference. 
 	// MediaMethod can be called like a function using arguments, returning MediaResult for assigning outputs by reference. 
 	// Useful when you know the arguments in advance.
 	// Useful when you know the arguments in advance.
 	template <typename... ARGS>
 	template <typename... ARGS>
 	MediaResult operator () (ARGS&&... args) {
 	MediaResult operator () (ARGS&&... args) {
-		int givenCount = machine_argCount(args...);
-		int expectedCount = machine_getInputCount(this->machine, this->methodIndex);
+		int32_t givenCount = machine_argCount(args...);
+		int32_t expectedCount = machine_getInputCount(this->machine, this->methodIndex);
 		if (givenCount != expectedCount) {
 		if (givenCount != expectedCount) {
 			throwError("The call to ", machine_getMethodName(this->machine, this->methodIndex), " expected ", expectedCount, " inputs, but ", givenCount, " values were given.\n");
 			throwError("The call to ", machine_getMethodName(this->machine, this->methodIndex), " expected ", expectedCount, " inputs, but ", givenCount, " values were given.\n");
 		}
 		}
@@ -239,11 +239,11 @@ public:
 	// The function setInputAction should simply make a call to machine_setInputByIndex with the provided machine, methodIndex, inputIndex and the value corresponding to argumentName in setInputAction.
 	// The function setInputAction should simply make a call to machine_setInputByIndex with the provided machine, methodIndex, inputIndex and the value corresponding to argumentName in setInputAction.
 	// If you don't recognize argumentName, then throw an exception because default input arguments are currently not implemented.
 	// If you don't recognize argumentName, then throw an exception because default input arguments are currently not implemented.
 	// Useful when the called function can be extended or reduced with only the arguments needed.
 	// Useful when the called function can be extended or reduced with only the arguments needed.
-	MediaResult callUsingKeywords(std::function<void(MediaMachine &machine, int methodIndex, int inputIndex, const ReadableString &argumentName)> setInputAction);
+	MediaResult callUsingKeywords(std::function<void(MediaMachine &machine, int32_t methodIndex, int32_t inputIndex, const ReadableString &argumentName)> setInputAction);
 };
 };
 
 
 // Post-condition: Returns a MediaMethod structure, which can be stored as a reference counting function pointer that keeps the virtual machine alive.
 // Post-condition: Returns a MediaMethod structure, which can be stored as a reference counting function pointer that keeps the virtual machine alive.
-MediaMethod machine_getMethod(MediaMachine& machine, const ReadableString& methodName, int contextIndex, bool mustExist = true);
+MediaMethod machine_getMethod(MediaMachine& machine, const ReadableString& methodName, int32_t contextIndex, bool mustExist = true);
 
 
 }
 }
 
 

+ 31 - 31
Source/DFPSR/api/modelAPI.cpp

@@ -58,137 +58,137 @@ bool model_exists(const Model& model) {
 	return model.isNotNull();
 	return model.isNotNull();
 }
 }
 
 
-int model_addEmptyPart(Model& model, const String &name) {
+int32_t model_addEmptyPart(Model& model, const String &name) {
 	MUST_EXIST(model,model_addEmptyPart);
 	MUST_EXIST(model,model_addEmptyPart);
 	return model->addEmptyPart(name);
 	return model->addEmptyPart(name);
 }
 }
 
 
-int model_getNumberOfParts(const Model& model) {
+int32_t model_getNumberOfParts(const Model& model) {
 	MUST_EXIST(model,model_getNumberOfParts);
 	MUST_EXIST(model,model_getNumberOfParts);
 	return model->getNumberOfParts();
 	return model->getNumberOfParts();
 }
 }
 
 
-void model_setPartName(Model& model, int partIndex, const String &name) {
+void model_setPartName(Model& model, int32_t partIndex, const String &name) {
 	MUST_EXIST(model,model_setPartName);
 	MUST_EXIST(model,model_setPartName);
 	model->setPartName(partIndex, name);
 	model->setPartName(partIndex, name);
 }
 }
 
 
-String model_getPartName(const Model& model, int partIndex) {
+String model_getPartName(const Model& model, int32_t partIndex) {
 	MUST_EXIST(model,model_getPartName);
 	MUST_EXIST(model,model_getPartName);
 	return model->getPartName(partIndex);
 	return model->getPartName(partIndex);
 }
 }
 
 
-int model_getNumberOfPoints(const Model& model) {
+int32_t model_getNumberOfPoints(const Model& model) {
 	MUST_EXIST(model,model_getNumberOfPoints);
 	MUST_EXIST(model,model_getNumberOfPoints);
 	return model->getNumberOfPoints();
 	return model->getNumberOfPoints();
 }
 }
 
 
-FVector3D model_getPoint(const Model& model, int pointIndex) {
+FVector3D model_getPoint(const Model& model, int32_t pointIndex) {
 	MUST_EXIST(model,model_getPoint);
 	MUST_EXIST(model,model_getPoint);
 	return model->getPoint(pointIndex);
 	return model->getPoint(pointIndex);
 }
 }
 
 
-void model_setPoint(Model& model, int pointIndex, const FVector3D& position) {
+void model_setPoint(Model& model, int32_t pointIndex, const FVector3D& position) {
 	MUST_EXIST(model,model_setPoint);
 	MUST_EXIST(model,model_setPoint);
 	model->setPoint(pointIndex, position);
 	model->setPoint(pointIndex, position);
 }
 }
 
 
-int model_findPoint(const Model& model, const FVector3D &position, float threshold) {
+int32_t model_findPoint(const Model& model, const FVector3D &position, float threshold) {
 	MUST_EXIST(model,model_findPoint);
 	MUST_EXIST(model,model_findPoint);
 	return model->findPoint(position, threshold);
 	return model->findPoint(position, threshold);
 }
 }
 
 
-int model_addPoint(const Model& model, const FVector3D &position) {
+int32_t model_addPoint(const Model& model, const FVector3D &position) {
 	MUST_EXIST(model,model_addPoint);
 	MUST_EXIST(model,model_addPoint);
 	return model->addPoint(position);
 	return model->addPoint(position);
 }
 }
 
 
-int model_addPointIfNeeded(Model& model, const FVector3D &position, float threshold) {
+int32_t model_addPointIfNeeded(Model& model, const FVector3D &position, float threshold) {
 	MUST_EXIST(model,model_addPointIfNeeded);
 	MUST_EXIST(model,model_addPointIfNeeded);
 	return model->addPointIfNeeded(position, threshold);
 	return model->addPointIfNeeded(position, threshold);
 }
 }
 
 
-int model_getVertexPointIndex(const Model& model, int partIndex, int polygonIndex, int vertexIndex) {
+int32_t model_getVertexPointIndex(const Model& model, int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex) {
 	MUST_EXIST(model,model_getVertexPointIndex);
 	MUST_EXIST(model,model_getVertexPointIndex);
 	return model->getVertexPointIndex(partIndex, polygonIndex, vertexIndex);
 	return model->getVertexPointIndex(partIndex, polygonIndex, vertexIndex);
 }
 }
 
 
-void model_setVertexPointIndex(Model& model, int partIndex, int polygonIndex, int vertexIndex, int pointIndex) {
+void model_setVertexPointIndex(Model& model, int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex, int32_t pointIndex) {
 	MUST_EXIST(model,model_setVertexPointIndex);
 	MUST_EXIST(model,model_setVertexPointIndex);
 	model->setVertexPointIndex(partIndex, polygonIndex, vertexIndex, pointIndex);
 	model->setVertexPointIndex(partIndex, polygonIndex, vertexIndex, pointIndex);
 }
 }
 
 
-FVector3D model_getVertexPosition(const Model& model, int partIndex, int polygonIndex, int vertexIndex) {
+FVector3D model_getVertexPosition(const Model& model, int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex) {
 	MUST_EXIST(model,model_getVertexPosition);
 	MUST_EXIST(model,model_getVertexPosition);
 	return model->getVertexPosition(partIndex, polygonIndex, vertexIndex);
 	return model->getVertexPosition(partIndex, polygonIndex, vertexIndex);
 }
 }
 
 
-FVector4D model_getVertexColor(const Model& model, int partIndex, int polygonIndex, int vertexIndex) {
+FVector4D model_getVertexColor(const Model& model, int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex) {
 	MUST_EXIST(model,model_getVertexColor);
 	MUST_EXIST(model,model_getVertexColor);
 	return model->getVertexColor(partIndex, polygonIndex, vertexIndex);
 	return model->getVertexColor(partIndex, polygonIndex, vertexIndex);
 }
 }
 
 
-void model_setVertexColor(Model& model, int partIndex, int polygonIndex, int vertexIndex, const FVector4D& color) {
+void model_setVertexColor(Model& model, int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex, const FVector4D& color) {
 	MUST_EXIST(model,model_setVertexColor);
 	MUST_EXIST(model,model_setVertexColor);
 	model->setVertexColor(partIndex, polygonIndex, vertexIndex, color);
 	model->setVertexColor(partIndex, polygonIndex, vertexIndex, color);
 }
 }
 
 
-FVector4D model_getTexCoord(const Model& model, int partIndex, int polygonIndex, int vertexIndex) {
+FVector4D model_getTexCoord(const Model& model, int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex) {
 	MUST_EXIST(model,model_getTexCoord);
 	MUST_EXIST(model,model_getTexCoord);
 	return model->getTexCoord(partIndex, polygonIndex, vertexIndex);
 	return model->getTexCoord(partIndex, polygonIndex, vertexIndex);
 }
 }
 
 
-void model_setTexCoord(Model& model, int partIndex, int polygonIndex, int vertexIndex, const FVector4D& texCoord) {
+void model_setTexCoord(Model& model, int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex, const FVector4D& texCoord) {
 	MUST_EXIST(model,model_setTexCoord);
 	MUST_EXIST(model,model_setTexCoord);
 	model->setTexCoord(partIndex, polygonIndex, vertexIndex, texCoord);
 	model->setTexCoord(partIndex, polygonIndex, vertexIndex, texCoord);
 }
 }
 
 
-int model_addTriangle(Model& model, int partIndex, int pointA, int pointB, int pointC) {
+int32_t model_addTriangle(Model& model, int32_t partIndex, int32_t pointA, int32_t pointB, int32_t pointC) {
 	MUST_EXIST(model,model_addTriangle);
 	MUST_EXIST(model,model_addTriangle);
 	return model->addPolygon(Polygon(pointA, pointB, pointC), partIndex);
 	return model->addPolygon(Polygon(pointA, pointB, pointC), partIndex);
 }
 }
 
 
-int model_addQuad(Model& model, int partIndex, int pointA, int pointB, int pointC, int pointD) {
+int32_t model_addQuad(Model& model, int32_t partIndex, int32_t pointA, int32_t pointB, int32_t pointC, int32_t pointD) {
 	MUST_EXIST(model,model_addQuad);
 	MUST_EXIST(model,model_addQuad);
 	return model->addPolygon(Polygon(pointA, pointB, pointC, pointD), partIndex);
 	return model->addPolygon(Polygon(pointA, pointB, pointC, pointD), partIndex);
 }
 }
 
 
-int model_getNumberOfPolygons(const Model& model, int partIndex) {
+int32_t model_getNumberOfPolygons(const Model& model, int32_t partIndex) {
 	MUST_EXIST(model,model_getNumberOfPolygons);
 	MUST_EXIST(model,model_getNumberOfPolygons);
 	return model->getNumberOfPolygons(partIndex);
 	return model->getNumberOfPolygons(partIndex);
 }
 }
 
 
-int model_getPolygonVertexCount(const Model& model, int partIndex, int polygonIndex) {
+int32_t model_getPolygonVertexCount(const Model& model, int32_t partIndex, int32_t polygonIndex) {
 	MUST_EXIST(model,model_getPolygonVertexCount);
 	MUST_EXIST(model,model_getPolygonVertexCount);
 	return model->getPolygonVertexCount(partIndex, polygonIndex);
 	return model->getPolygonVertexCount(partIndex, polygonIndex);
 }
 }
 
 
-TextureRgbaU8 model_getDiffuseMap(const Model& model, int partIndex) {
+TextureRgbaU8 model_getDiffuseMap(const Model& model, int32_t partIndex) {
 	MUST_EXIST(model,model_getDiffuseMap);
 	MUST_EXIST(model,model_getDiffuseMap);
 	return model->getDiffuseMap(partIndex);
 	return model->getDiffuseMap(partIndex);
 }
 }
 
 
-void model_setDiffuseMap(Model& model, int partIndex, const TextureRgbaU8 &diffuseMap) {
+void model_setDiffuseMap(Model& model, int32_t partIndex, const TextureRgbaU8 &diffuseMap) {
 	MUST_EXIST(model,model_setDiffuseMap);
 	MUST_EXIST(model,model_setDiffuseMap);
 	model->setDiffuseMap(diffuseMap, partIndex);
 	model->setDiffuseMap(diffuseMap, partIndex);
 }
 }
 
 
-void model_setDiffuseMapByName(Model& model, int partIndex, ResourcePool &pool, const String &filename) {
+void model_setDiffuseMapByName(Model& model, int32_t partIndex, ResourcePool &pool, const String &filename) {
 	MUST_EXIST(model,model_setDiffuseMapByName);
 	MUST_EXIST(model,model_setDiffuseMapByName);
 	model->setDiffuseMapByName(pool, filename, partIndex);
 	model->setDiffuseMapByName(pool, filename, partIndex);
 }
 }
 
 
-TextureRgbaU8 model_getLightMap(Model& model, int partIndex) {
+TextureRgbaU8 model_getLightMap(Model& model, int32_t partIndex) {
 	MUST_EXIST(model,model_getLightMap);
 	MUST_EXIST(model,model_getLightMap);
 	return model->getLightMap(partIndex);
 	return model->getLightMap(partIndex);
 }
 }
 
 
-void model_setLightMap(Model& model, int partIndex, const TextureRgbaU8 &lightMap) {
+void model_setLightMap(Model& model, int32_t partIndex, const TextureRgbaU8 &lightMap) {
 	MUST_EXIST(model,model_setLightMap);
 	MUST_EXIST(model,model_setLightMap);
 	model->setLightMap(lightMap, partIndex);
 	model->setLightMap(lightMap, partIndex);
 }
 }
 
 
-void model_setLightMapByName(Model& model, int partIndex, ResourcePool &pool, const String &filename) {
+void model_setLightMapByName(Model& model, int32_t partIndex, ResourcePool &pool, const String &filename) {
 	MUST_EXIST(model,model_setLightMapByName);
 	MUST_EXIST(model,model_setLightMapByName);
 	model->setLightMapByName(pool, filename, partIndex);
 	model->setLightMapByName(pool, filename, partIndex);
 }
 }
@@ -235,18 +235,18 @@ void model_render_threaded(const Model& model, const Transform3D &modelToWorldTr
 	// Get the filter.
 	// Get the filter.
 	Filter filter = model->filter;
 	Filter filter = model->filter;
 	// Transform and project all vertices.
 	// Transform and project all vertices.
-	int positionCount = model->positionBuffer.length();
+	int32_t positionCount = model->positionBuffer.length();
 	VirtualStackAllocation<ProjectedPoint> projected(positionCount, "Projected points in renderer_giveTask");
 	VirtualStackAllocation<ProjectedPoint> projected(positionCount, "Projected points in renderer_giveTask");
-	for (int vert = 0; vert < positionCount; vert++) {
+	for (int32_t vert = 0; vert < positionCount; vert++) {
 		projected[vert] = camera.worldToScreen(modelToWorldTransform.transformPoint(model->positionBuffer[vert]));
 		projected[vert] = camera.worldToScreen(modelToWorldTransform.transformPoint(model->positionBuffer[vert]));
 	}
 	}
-	for (int partIndex = 0; partIndex < model->partBuffer.length(); partIndex++) {
+	for (int32_t partIndex = 0; partIndex < model->partBuffer.length(); partIndex++) {
 		// Get a pointer to the current part.
 		// Get a pointer to the current part.
 		Part *part = &(model->partBuffer[partIndex]);
 		Part *part = &(model->partBuffer[partIndex]);
 		// Get textures.
 		// Get textures.
 		const TextureRgbaU8 diffuse = part->diffuseMap;
 		const TextureRgbaU8 diffuse = part->diffuseMap;
 		const TextureRgbaU8 light = part->lightMap;
 		const TextureRgbaU8 light = part->lightMap;
-		for (int p = 0; p < part->polygonBuffer.length(); p++) {
+		for (int32_t p = 0; p < part->polygonBuffer.length(); p++) {
 			Polygon polygon = part->polygonBuffer[p];
 			Polygon polygon = part->polygonBuffer[p];
 			// Render first triangle in the polygon of indices 0, 1, 2.
 			// Render first triangle in the polygon of indices 0, 1, 2.
 			renderer_giveTask_triangle(renderer,
 			renderer_giveTask_triangle(renderer,

+ 28 - 28
Source/DFPSR/api/modelAPI.h

@@ -90,38 +90,38 @@ namespace dsr {
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Side-effect: Adds an empty part without any polygons and returns its new local part index.
 	// Side-effect: Adds an empty part without any polygons and returns its new local part index.
 	// The returned part index is relative to the model and goes from 0 to model_getNumberOfParts(model) - 1.
 	// The returned part index is relative to the model and goes from 0 to model_getNumberOfParts(model) - 1.
-	int model_addEmptyPart(Model& model, const String &name);
+	int32_t model_addEmptyPart(Model& model, const String &name);
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Post-condition: Returns the number of parts in model.
 	// Post-condition: Returns the number of parts in model.
-	int model_getNumberOfParts(const Model& model);
+	int32_t model_getNumberOfParts(const Model& model);
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Side-effect: Sets the part at partIndex in model to the new name.
 	// Side-effect: Sets the part at partIndex in model to the new name.
-	void model_setPartName(Model& model, int partIndex, const String &name);
+	void model_setPartName(Model& model, int32_t partIndex, const String &name);
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Post-condition: Returns the name of the part at partIndex in model.
 	// Post-condition: Returns the name of the part at partIndex in model.
-	String model_getPartName(const Model& model, int partIndex);
+	String model_getPartName(const Model& model, int32_t partIndex);
 
 
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Post-condition: Returns the number of points in model.
 	// Post-condition: Returns the number of points in model.
-	int model_getNumberOfPoints(const Model& model);
+	int32_t model_getNumberOfPoints(const Model& model);
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Post-condition: Returns the 3D position of the point at pointIndex in model.
 	// Post-condition: Returns the 3D position of the point at pointIndex in model.
-	FVector3D model_getPoint(const Model& model, int pointIndex);
+	FVector3D model_getPoint(const Model& model, int32_t pointIndex);
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
-	void model_setPoint(Model& model, int pointIndex, const FVector3D& position);
+	void model_setPoint(Model& model, int32_t pointIndex, const FVector3D& position);
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Post-condition:
 	// Post-condition:
 	//   Returns an index to the closest point in model relative to position in euclidean distance.
 	//   Returns an index to the closest point in model relative to position in euclidean distance.
 	//   Returns -1 if none was inside of threshold.
 	//   Returns -1 if none was inside of threshold.
 	// A point p is inside of threshold iff |p - position| < threshold.
 	// A point p is inside of threshold iff |p - position| < threshold.
 	// If multiple points have the same distance approximated, the point with the lowest index will be preferred.
 	// If multiple points have the same distance approximated, the point with the lowest index will be preferred.
-	int model_findPoint(const Model& model, const FVector3D &position, float threshold);
+	int32_t model_findPoint(const Model& model, const FVector3D &position, float threshold);
 	// Add a point even if it overlaps an existing point.
 	// Add a point even if it overlaps an existing point.
 	// Can be used for animation where the initial position might not always be the same.
 	// Can be used for animation where the initial position might not always be the same.
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Side-effect: Adds a new point to model at position.
 	// Side-effect: Adds a new point to model at position.
 	// Post-condition: Returns a local index to the new point.
 	// Post-condition: Returns a local index to the new point.
-	int model_addPoint(const Model& model, const FVector3D &position);
+	int32_t model_addPoint(const Model& model, const FVector3D &position);
 	// Add a point, only if it does not overlap.
 	// Add a point, only if it does not overlap.
 	// Can be used to seal small gaps and reduce the time needed to transform vertex positions.
 	// Can be used to seal small gaps and reduce the time needed to transform vertex positions.
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
@@ -132,7 +132,7 @@ namespace dsr {
 	//   then the index of the closest existing point in euclidean distance is returned.
 	//   then the index of the closest existing point in euclidean distance is returned.
 	//   If multiple existing points are within the same distance,
 	//   If multiple existing points are within the same distance,
 	//   then the point with the lowest index is preferred, just like in model_findPoint.
 	//   then the point with the lowest index is preferred, just like in model_findPoint.
-	int model_addPointIfNeeded(Model& model, const FVector3D &position, float threshold);
+	int32_t model_addPointIfNeeded(Model& model, const FVector3D &position, float threshold);
 	// Get the bounding box, which expands automatically when adding or moving points in the model.
 	// Get the bounding box, which expands automatically when adding or moving points in the model.
 	// Side-effect: Writes model's bounding box to minimum and maximum by reference.
 	// Side-effect: Writes model's bounding box to minimum and maximum by reference.
 	void model_getBoundingBox(const Model& model, FVector3D& minimum, FVector3D& maximum);
 	void model_getBoundingBox(const Model& model, FVector3D& minimum, FVector3D& maximum);
@@ -140,14 +140,14 @@ namespace dsr {
 	// Get the vertex position's index, which refers to a shared point in the model.
 	// Get the vertex position's index, which refers to a shared point in the model.
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Post-condition: Returns the position index of the vertex. (At vertexIndex in the polygon at polygonIndex in the part at partIndex in model.)
 	// Post-condition: Returns the position index of the vertex. (At vertexIndex in the polygon at polygonIndex in the part at partIndex in model.)
-	int model_getVertexPointIndex(const Model& model, int partIndex, int polygonIndex, int vertexIndex);
+	int32_t model_getVertexPointIndex(const Model& model, int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex);
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Side-effect: Sets the position index of the vertex to pointIndex. (At vertexIndex in the polygon at polygonIndex in the part at partIndex in model.)
 	// Side-effect: Sets the position index of the vertex to pointIndex. (At vertexIndex in the polygon at polygonIndex in the part at partIndex in model.)
-	void model_setVertexPointIndex(Model& model, int partIndex, int polygonIndex, int vertexIndex, int pointIndex);
+	void model_setVertexPointIndex(Model& model, int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex, int32_t pointIndex);
 	// Get the vertex position directly, without having to look it up by index using model_getPoint.
 	// Get the vertex position directly, without having to look it up by index using model_getPoint.
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Post-condition: Returns the position of the vertex. (At vertexIndex in the polygon at polygonIndex in the part at partIndex in model.)
 	// Post-condition: Returns the position of the vertex. (At vertexIndex in the polygon at polygonIndex in the part at partIndex in model.)
-	FVector3D model_getVertexPosition(const Model& model, int partIndex, int polygonIndex, int vertexIndex);
+	FVector3D model_getVertexPosition(const Model& model, int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex);
 	// Get the vertex color, which is not shared with any other polygons. (Red, green, blue, alpha) channels are packed as (x, y, z, w) in FVector4D.
 	// Get the vertex color, which is not shared with any other polygons. (Red, green, blue, alpha) channels are packed as (x, y, z, w) in FVector4D.
 	// Vertex colors use a normalized scale from 0.0f to 1.0f.
 	// Vertex colors use a normalized scale from 0.0f to 1.0f.
 	//   Transparent black is FVector4D(0.0f, 0.0f, 0.0f, 0.0f).
 	//   Transparent black is FVector4D(0.0f, 0.0f, 0.0f, 0.0f).
@@ -157,21 +157,21 @@ namespace dsr {
 	//   Half opaque orange is FVector4D(1.0f, 0.5f, 0.0f, 0.5f).
 	//   Half opaque orange is FVector4D(1.0f, 0.5f, 0.0f, 0.5f).
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Post-condition: Returns the color of the vertex. (At vertexIndex in the polygon at polygonIndex in the part at partIndex in model.)
 	// Post-condition: Returns the color of the vertex. (At vertexIndex in the polygon at polygonIndex in the part at partIndex in model.)
-	FVector4D model_getVertexColor(const Model& model, int partIndex, int polygonIndex, int vertexIndex);
+	FVector4D model_getVertexColor(const Model& model, int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex);
 	// Set the vertex color using the same system as model_getVertexColor.
 	// Set the vertex color using the same system as model_getVertexColor.
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Side-effect: Sets the color of the vertex to color. (At vertexIndex in the polygon at polygonIndex in the part at partIndex in model.)
 	// Side-effect: Sets the color of the vertex to color. (At vertexIndex in the polygon at polygonIndex in the part at partIndex in model.)
-	void model_setVertexColor(Model& model, int partIndex, int polygonIndex, int vertexIndex, const FVector4D& color);
+	void model_setVertexColor(Model& model, int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex, const FVector4D& color);
 	// Get (U1, V1, U2, V2) texture coordinates packed as (x, y, z, w) in FVector4D.
 	// Get (U1, V1, U2, V2) texture coordinates packed as (x, y, z, w) in FVector4D.
 	// UV1 coordinates (x, y) refers to normalized texture sampling coordinates for the diffuse-map.
 	// UV1 coordinates (x, y) refers to normalized texture sampling coordinates for the diffuse-map.
 	// UV2 coordinates (z, w) refers to normalized texture sampling coordinates for the light-map.
 	// UV2 coordinates (z, w) refers to normalized texture sampling coordinates for the light-map.
 	//   Light-maps do not use mip-map layers, which allow generating light-maps dynamically.
 	//   Light-maps do not use mip-map layers, which allow generating light-maps dynamically.
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
-	FVector4D model_getTexCoord(const Model& model, int partIndex, int polygonIndex, int vertexIndex);
+	FVector4D model_getTexCoord(const Model& model, int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex);
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Side-effect: Sets the texture coordinates of the vertex to texCoord for both UV1 and UV2.
 	// Side-effect: Sets the texture coordinates of the vertex to texCoord for both UV1 and UV2.
 	//              (At vertexIndex in the polygon at polygonIndex in the part at partIndex in model.)
 	//              (At vertexIndex in the polygon at polygonIndex in the part at partIndex in model.)
-	void model_setTexCoord(Model& model, int partIndex, int polygonIndex, int vertexIndex, const FVector4D& texCoord);
+	void model_setTexCoord(Model& model, int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex, const FVector4D& texCoord);
 
 
 	// Create a triangle surface at given position indices.
 	// Create a triangle surface at given position indices.
 	//   The fourth vertex is used as padding, so quads and triangles take the same amount of memory per polygon.
 	//   The fourth vertex is used as padding, so quads and triangles take the same amount of memory per polygon.
@@ -184,7 +184,7 @@ namespace dsr {
 	//   Each new vertex has the color set to solid white using (1.0f, 1.0f, 1.0f, 1.0f).
 	//   Each new vertex has the color set to solid white using (1.0f, 1.0f, 1.0f, 1.0f).
 	// Post-condition:
 	// Post-condition:
 	//   Returns the new polygon's local index within the part at partIndex in model.
 	//   Returns the new polygon's local index within the part at partIndex in model.
-	int model_addTriangle(Model& model, int partIndex, int pointA, int pointB, int pointC);
+	int32_t model_addTriangle(Model& model, int32_t partIndex, int32_t pointA, int32_t pointB, int32_t pointC);
 	// Create a quad surface at given position indices.
 	// Create a quad surface at given position indices.
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Side-effect:
 	// Side-effect:
@@ -194,20 +194,20 @@ namespace dsr {
 	//   Each new vertex has the color set to solid white using (1.0f, 1.0f, 1.0f, 1.0f).
 	//   Each new vertex has the color set to solid white using (1.0f, 1.0f, 1.0f, 1.0f).
 	// Post-condition:
 	// Post-condition:
 	//   Returns the new polygon's local index within the part at partIndex in model.
 	//   Returns the new polygon's local index within the part at partIndex in model.
-	int model_addQuad(Model& model, int partIndex, int pointA, int pointB, int pointC, int pointD);
+	int32_t model_addQuad(Model& model, int32_t partIndex, int32_t pointA, int32_t pointB, int32_t pointC, int32_t pointD);
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Post-condition: Returns the number of polygons (triangles + quads) in the part at partIndex in model.
 	// Post-condition: Returns the number of polygons (triangles + quads) in the part at partIndex in model.
-	int model_getNumberOfPolygons(const Model& model, int partIndex);
+	int32_t model_getNumberOfPolygons(const Model& model, int32_t partIndex);
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Post-condition: Returns the number of vertices in the polygon at polygonIndex in the part at partIndex in model.
 	// Post-condition: Returns the number of vertices in the polygon at polygonIndex in the part at partIndex in model.
-	int model_getPolygonVertexCount(const Model& model, int partIndex, int polygonIndex);
+	int32_t model_getPolygonVertexCount(const Model& model, int32_t partIndex, int32_t polygonIndex);
 
 
 	// Get the part's diffuse texture.
 	// Get the part's diffuse texture.
 	// Pre-condition: model must refer to an existing model.
 	// Pre-condition: model must refer to an existing model.
 	// Post-condition:
 	// Post-condition:
 	//   Returns an image handle to the diffuse texture in the part at partIndex in model.
 	//   Returns an image handle to the diffuse texture in the part at partIndex in model.
 	//   If the part has no diffuse image then an empth handle is returned.
 	//   If the part has no diffuse image then an empth handle is returned.
-	TextureRgbaU8 model_getDiffuseMap(const Model& model, int partIndex);
+	TextureRgbaU8 model_getDiffuseMap(const Model& model, int32_t partIndex);
 	// Set the part's diffuse texture.
 	// Set the part's diffuse texture.
 	//   A texture is just an image fulfilling the criterias of image_isTexture to allow fast texture sampling and pyramid generation.
 	//   A texture is just an image fulfilling the criterias of image_isTexture to allow fast texture sampling and pyramid generation.
 	// Pre-condition:
 	// Pre-condition:
@@ -216,7 +216,7 @@ namespace dsr {
 	// Side-effect:
 	// Side-effect:
 	//   Sets the diffuse texture in the part at partIndex in model to diffuseMap.
 	//   Sets the diffuse texture in the part at partIndex in model to diffuseMap.
 	//   If diffuseMap is an empty image handle, then the diffuse texture will be replaced by the default solid white color.
 	//   If diffuseMap is an empty image handle, then the diffuse texture will be replaced by the default solid white color.
-	void model_setDiffuseMap(Model& model, int partIndex, const TextureRgbaU8 &diffuseMap);
+	void model_setDiffuseMap(Model& model, int32_t partIndex, const TextureRgbaU8 &diffuseMap);
 	// Automatically find the diffuse texture by name in the resource pool and assign it.
 	// Automatically find the diffuse texture by name in the resource pool and assign it.
 	// Pre-condition:
 	// Pre-condition:
 	//   model must refer to an existing model.
 	//   model must refer to an existing model.
@@ -229,14 +229,14 @@ namespace dsr {
 	//     "Car_1.2" is rejected for using a dot in the actual name, just to catch more mistakes with file extensions.
 	//     "Car_1.2" is rejected for using a dot in the actual name, just to catch more mistakes with file extensions.
 	// Side-effect:
 	// Side-effect:
 	//   Sets the diffuse texture in the part at partIndex in model to the image looked up by filename in pool.
 	//   Sets the diffuse texture in the part at partIndex in model to the image looked up by filename in pool.
-	void model_setDiffuseMapByName(Model& model, int partIndex, ResourcePool &pool, const String &filename);
+	void model_setDiffuseMapByName(Model& model, int32_t partIndex, ResourcePool &pool, const String &filename);
 	// Get the part's light texture.
 	// Get the part's light texture.
 	// Pre-condition:
 	// Pre-condition:
 	//   model must refer to an existing model.
 	//   model must refer to an existing model.
 	// Post-condition:
 	// Post-condition:
 	//   Returns an image handle to the light texture in the part at partIndex in model.
 	//   Returns an image handle to the light texture in the part at partIndex in model.
 	//   If the part has no light image then an empth handle is returned.
 	//   If the part has no light image then an empth handle is returned.
-	TextureRgbaU8 model_getLightMap(Model& model, int partIndex);
+	TextureRgbaU8 model_getLightMap(Model& model, int32_t partIndex);
 	// Set the part's light texture.
 	// Set the part's light texture.
 	//   A texture is just an image fulfilling the criterias of image_isTexture to allow fast texture sampling.
 	//   A texture is just an image fulfilling the criterias of image_isTexture to allow fast texture sampling.
 	//   Even though no texture-pyramid is used for light-maps, it still has to look up
 	//   Even though no texture-pyramid is used for light-maps, it still has to look up
@@ -247,7 +247,7 @@ namespace dsr {
 	// Side-effect:
 	// Side-effect:
 	//   Sets the diffuse texture in the part at partIndex in model to diffuseMap.
 	//   Sets the diffuse texture in the part at partIndex in model to diffuseMap.
 	//   If diffuseMap is an empty image handle, then the diffuse texture will be replaced by the default solid white color.
 	//   If diffuseMap is an empty image handle, then the diffuse texture will be replaced by the default solid white color.
-	void model_setLightMap(Model& model, int partIndex, const TextureRgbaU8 &lightMap);
+	void model_setLightMap(Model& model, int32_t partIndex, const TextureRgbaU8 &lightMap);
 	// Automatically find the light texture by name in the resource pool and assign it.
 	// Automatically find the light texture by name in the resource pool and assign it.
 	// Pre-condition:
 	// Pre-condition:
 	//   model must refer to an existing model.
 	//   model must refer to an existing model.
@@ -255,7 +255,7 @@ namespace dsr {
 	//   filename must be the image's filename without any extension nor path.
 	//   filename must be the image's filename without any extension nor path.
 	// Side-effect:
 	// Side-effect:
 	//   Sets the light texture in the part at partIndex in model to the image looked up by filename in pool.
 	//   Sets the light texture in the part at partIndex in model to the image looked up by filename in pool.
-	void model_setLightMapByName(Model& model, int partIndex, ResourcePool &pool, const String &filename);
+	void model_setLightMapByName(Model& model, int32_t partIndex, ResourcePool &pool, const String &filename);
 
 
 	// In order to draw two adjacent polygons without any missing pixels along the seam, they must:
 	// In order to draw two adjacent polygons without any missing pixels along the seam, they must:
 	//   * Share two position indices in opposite directions.
 	//   * Share two position indices in opposite directions.
@@ -316,7 +316,7 @@ namespace dsr {
 	//       Remove any textures that are not used by the shaders.
 	//       Remove any textures that are not used by the shaders.
 	//       The fixed pipeline only checks which textures are used.
 	//       The fixed pipeline only checks which textures are used.
 	//   * Make sure that texture names are spelled case sensitive or they might not be found on some operating systems like Linux.
 	//   * Make sure that texture names are spelled case sensitive or they might not be found on some operating systems like Linux.
-	Model importFromContent_DMF1(const String &fileContent, ResourcePool &pool, int detailLevel = 2);
+	Model importFromContent_DMF1(const String &fileContent, ResourcePool &pool, int32_t detailLevel = 2);
 
 
 }
 }
 
 

+ 57 - 57
Source/DFPSR/api/rendererAPI.cpp

@@ -34,7 +34,7 @@
 
 
 namespace dsr {
 namespace dsr {
 
 
-static const int cellSize = 16;
+static const int32_t cellSize = 16;
 
 
 static bool counterClockwise(const ProjectedPoint& p, const ProjectedPoint& q, const ProjectedPoint& r) {
 static bool counterClockwise(const ProjectedPoint& p, const ProjectedPoint& q, const ProjectedPoint& r) {
 	return (q.flat.y - p.flat.y) * (r.flat.x - q.flat.x) - (q.flat.x - p.flat.x) * (r.flat.y - q.flat.y) < 0;
 	return (q.flat.y - p.flat.y) * (r.flat.x - q.flat.x) - (q.flat.x - p.flat.x) * (r.flat.y - q.flat.y) < 0;
@@ -42,29 +42,29 @@ static bool counterClockwise(const ProjectedPoint& p, const ProjectedPoint& q, c
 
 
 // outputHullCorners must be at least as big as inputHullCorners, so that it can hold the worst case output size.
 // outputHullCorners must be at least as big as inputHullCorners, so that it can hold the worst case output size.
 // Instead of not allowing less than three points, it copies the input as output when it happens to reduce pre-conditions.
 // Instead of not allowing less than three points, it copies the input as output when it happens to reduce pre-conditions.
-static void jarvisConvexHullAlgorithm(ProjectedPoint* outputHullCorners, int& outputCornerCount, const ProjectedPoint* inputHullCorners, int inputCornerCount) {
+static void jarvisConvexHullAlgorithm(ProjectedPoint* outputHullCorners, int32_t& outputCornerCount, const ProjectedPoint* inputHullCorners, int32_t inputCornerCount) {
 	if (inputCornerCount < 3) {
 	if (inputCornerCount < 3) {
 		outputCornerCount = inputCornerCount;
 		outputCornerCount = inputCornerCount;
-		for (int p = 0; p < inputCornerCount; p++) {
+		for (int32_t p = 0; p < inputCornerCount; p++) {
 			outputHullCorners[p] = inputHullCorners[p];
 			outputHullCorners[p] = inputHullCorners[p];
 		}
 		}
 	} else {
 	} else {
-		int l = 0;
+		int32_t l = 0;
 		outputCornerCount = 0;
 		outputCornerCount = 0;
-		for (int i = 1; i < inputCornerCount; i++) {
+		for (int32_t i = 1; i < inputCornerCount; i++) {
 			if (inputHullCorners[i].flat.x < inputHullCorners[l].flat.x) {
 			if (inputHullCorners[i].flat.x < inputHullCorners[l].flat.x) {
 				l = i;
 				l = i;
 			}
 			}
 		}
 		}
-		int p = l;
+		int32_t p = l;
 		do {
 		do {
 			if (outputCornerCount >= inputCornerCount) {
 			if (outputCornerCount >= inputCornerCount) {
 				// Prevent getting stuck in an infinite loop from overflow
 				// Prevent getting stuck in an infinite loop from overflow
 				return;
 				return;
 			}
 			}
 			outputHullCorners[outputCornerCount] = inputHullCorners[p]; outputCornerCount++;
 			outputHullCorners[outputCornerCount] = inputHullCorners[p]; outputCornerCount++;
-			int q = (p + 1) % inputCornerCount;
-			for (int i = 0; i < inputCornerCount; i++) {
+			int32_t q = (p + 1) % inputCornerCount;
+			for (int32_t i = 0; i < inputCornerCount; i++) {
 				if (counterClockwise(inputHullCorners[p], inputHullCorners[i], inputHullCorners[q])) {
 				if (counterClockwise(inputHullCorners[p], inputHullCorners[i], inputHullCorners[q])) {
 					q = i;
 					q = i;
 				}
 				}
@@ -76,12 +76,12 @@ static void jarvisConvexHullAlgorithm(ProjectedPoint* outputHullCorners, int& ou
 
 
 // Transform and project the corners of a hull, so that the output can be given to the convex hull algorithm and used for occluding
 // Transform and project the corners of a hull, so that the output can be given to the convex hull algorithm and used for occluding
 // Returns true if occluder culling passed, which may skip occluders that could have been visible
 // Returns true if occluder culling passed, which may skip occluders that could have been visible
-static bool projectHull(ProjectedPoint* outputHullCorners, const FVector3D* inputHullCorners, int cornerCount, const Transform3D &modelToWorldTransform, const Camera &camera) {
-	for (int p = 0; p < cornerCount; p++) {
+static bool projectHull(ProjectedPoint* outputHullCorners, const FVector3D* inputHullCorners, int32_t cornerCount, const Transform3D &modelToWorldTransform, const Camera &camera) {
+	for (int32_t p = 0; p < cornerCount; p++) {
 		FVector3D worldPoint = modelToWorldTransform.transformPoint(inputHullCorners[p]);
 		FVector3D worldPoint = modelToWorldTransform.transformPoint(inputHullCorners[p]);
 		FVector3D cameraPoint = camera.worldToCamera(worldPoint);
 		FVector3D cameraPoint = camera.worldToCamera(worldPoint);
 		FVector3D narrowPoint = cameraPoint * FVector3D(0.5f, 0.5f, 1.0f);
 		FVector3D narrowPoint = cameraPoint * FVector3D(0.5f, 0.5f, 1.0f);
-		for (int s = 0; s < camera.cullFrustum.getPlaneCount(); s++) {
+		for (int32_t s = 0; s < camera.cullFrustum.getPlaneCount(); s++) {
 			FPlane3D plane = camera.cullFrustum.getPlane(s);
 			FPlane3D plane = camera.cullFrustum.getPlane(s);
 			if (!plane.inside(narrowPoint)) {
 			if (!plane.inside(narrowPoint)) {
 				return false;
 				return false;
@@ -92,9 +92,9 @@ static bool projectHull(ProjectedPoint* outputHullCorners, const FVector3D* inpu
 	return true;
 	return true;
 }
 }
 
 
-static IRect getPixelBoundFromProjection(const ProjectedPoint* convexHullCorners, int cornerCount) {
+static IRect getPixelBoundFromProjection(const ProjectedPoint* convexHullCorners, int32_t cornerCount) {
 	IRect result = IRect(convexHullCorners[0].flat.x / constants::unitsPerPixel, convexHullCorners[0].flat.y / constants::unitsPerPixel, 1, 1);
 	IRect result = IRect(convexHullCorners[0].flat.x / constants::unitsPerPixel, convexHullCorners[0].flat.y / constants::unitsPerPixel, 1, 1);
-	for (int p = 1; p < cornerCount; p++) {
+	for (int32_t p = 1; p < cornerCount; p++) {
 		result = IRect::merge(result, IRect(convexHullCorners[p].flat.x / constants::unitsPerPixel, convexHullCorners[p].flat.y / constants::unitsPerPixel, 1, 1));
 		result = IRect::merge(result, IRect(convexHullCorners[p].flat.x / constants::unitsPerPixel, convexHullCorners[p].flat.y / constants::unitsPerPixel, 1, 1));
 	}
 	}
 	return result;
 	return result;
@@ -108,9 +108,9 @@ static bool pointInsideOfEdge(const LVector2D &edgeA, const LVector2D &edgeB, co
 
 
 // Returns true iff the point is inside of the hull
 // Returns true iff the point is inside of the hull
 // convexHullCorners from 0 to cornerCount-1 must be sorted clockwise and may not include any concave corners
 // convexHullCorners from 0 to cornerCount-1 must be sorted clockwise and may not include any concave corners
-static bool pointInsideOfHull(const ProjectedPoint* convexHullCorners, int cornerCount, const LVector2D &point) {
-	for (int c = 0; c < cornerCount; c++) {
-		int nc = c + 1;
+static bool pointInsideOfHull(const ProjectedPoint* convexHullCorners, int32_t cornerCount, const LVector2D &point) {
+	for (int32_t c = 0; c < cornerCount; c++) {
+		int32_t nc = c + 1;
 		if (nc == cornerCount) {
 		if (nc == cornerCount) {
 			nc = 0;
 			nc = 0;
 		}
 		}
@@ -124,7 +124,7 @@ static bool pointInsideOfHull(const ProjectedPoint* convexHullCorners, int corne
 }
 }
 
 
 // Returns true iff all corners of the rectangle are inside of the hull
 // Returns true iff all corners of the rectangle are inside of the hull
-static bool rectangleInsideOfHull(const ProjectedPoint* convexHullCorners, int cornerCount, const IRect &rectangle) {
+static bool rectangleInsideOfHull(const ProjectedPoint* convexHullCorners, int32_t cornerCount, const IRect &rectangle) {
 	return pointInsideOfHull(convexHullCorners, cornerCount, LVector2D(rectangle.left(), rectangle.top()))
 	return pointInsideOfHull(convexHullCorners, cornerCount, LVector2D(rectangle.left(), rectangle.top()))
 		&& pointInsideOfHull(convexHullCorners, cornerCount, LVector2D(rectangle.right(), rectangle.top()))
 		&& pointInsideOfHull(convexHullCorners, cornerCount, LVector2D(rectangle.right(), rectangle.top()))
 		&& pointInsideOfHull(convexHullCorners, cornerCount, LVector2D(rectangle.left(), rectangle.bottom()))
 		&& pointInsideOfHull(convexHullCorners, cornerCount, LVector2D(rectangle.left(), rectangle.bottom()))
@@ -146,7 +146,7 @@ struct RendererImpl {
 	ImageF32 depthGrid; // An occlusion grid of cellSize² cells representing the longest linear depth where something might be visible
 	ImageF32 depthGrid; // An occlusion grid of cellSize² cells representing the longest linear depth where something might be visible
 	CommandQueue commandQueue; // Triangles to be drawn
 	CommandQueue commandQueue; // Triangles to be drawn
 	List<DebugLine> debugLines; // Additional lines to be drawn as an overlay for debugging occlusion
 	List<DebugLine> debugLines; // Additional lines to be drawn as an overlay for debugging occlusion
-	int width = 0, height = 0, gridWidth = 0, gridHeight = 0;
+	int32_t width = 0, height = 0, gridWidth = 0, gridHeight = 0;
 	bool occluded = false;
 	bool occluded = false;
 	RendererImpl() {}
 	RendererImpl() {}
 	void beginFrame(ImageRgbaU8& colorBuffer, ImageF32& depthBuffer) {
 	void beginFrame(ImageRgbaU8& colorBuffer, ImageF32& depthBuffer) {
@@ -168,10 +168,10 @@ struct RendererImpl {
 		this->occluded = false;
 		this->occluded = false;
 	}
 	}
 	IRect getOuterCellBound(const IRect &pixelBound) const {
 	IRect getOuterCellBound(const IRect &pixelBound) const {
-		int minCellX = pixelBound.left() / cellSize;
-		int maxCellX = pixelBound.right() / cellSize + 1;
-		int minCellY = pixelBound.top() / cellSize;
-		int maxCellY = pixelBound.bottom() / cellSize + 1;
+		int32_t minCellX = pixelBound.left() / cellSize;
+		int32_t maxCellX = pixelBound.right() / cellSize + 1;
+		int32_t minCellY = pixelBound.top() / cellSize;
+		int32_t maxCellY = pixelBound.bottom() / cellSize + 1;
 		if (minCellX < 0) { minCellX = 0; }
 		if (minCellX < 0) { minCellX = 0; }
 		if (minCellY < 0) { minCellY = 0; }
 		if (minCellY < 0) { minCellY = 0; }
 		if (maxCellX > this->gridWidth) { maxCellX = this->gridWidth; }
 		if (maxCellX > this->gridWidth) { maxCellX = this->gridWidth; }
@@ -193,12 +193,12 @@ struct RendererImpl {
 	// If any occluder has been used during this pass, all triangles in the buffer will be filtered based using depthGrid
 	// If any occluder has been used during this pass, all triangles in the buffer will be filtered based using depthGrid
 	void completeOcclusion() {
 	void completeOcclusion() {
 		if (this->occluded) {
 		if (this->occluded) {
-			for (int t = this->commandQueue.buffer.length() - 1; t >= 0; t--) {
+			for (int32_t t = this->commandQueue.buffer.length() - 1; t >= 0; t--) {
 				bool anyVisible = false;
 				bool anyVisible = false;
 				ITriangle2D triangle = this->commandQueue.buffer[t].triangle;
 				ITriangle2D triangle = this->commandQueue.buffer[t].triangle;
 				IRect outerBound = getOuterCellBound(triangle.wholeBound);
 				IRect outerBound = getOuterCellBound(triangle.wholeBound);
-				for (int cellY = outerBound.top(); cellY < outerBound.bottom(); cellY++) {
-					for (int cellX = outerBound.left(); cellX < outerBound.right(); cellX++) {
+				for (int32_t cellY = outerBound.top(); cellY < outerBound.bottom(); cellY++) {
+					for (int32_t cellX = outerBound.left(); cellX < outerBound.right(); cellX++) {
 						// TODO: Optimize access using SafePointer iteration
 						// TODO: Optimize access using SafePointer iteration
 						float backgroundDepth = image_readPixel_clamp(this->depthGrid, cellX, cellY);
 						float backgroundDepth = image_readPixel_clamp(this->depthGrid, cellX, cellY);
 						float triangleDepth = triangle.position[0].cs.z;
 						float triangleDepth = triangle.position[0].cs.z;
@@ -216,17 +216,17 @@ struct RendererImpl {
 			}
 			}
 		}
 		}
 	}
 	}
-	void occludeFromSortedHull(const ProjectedPoint* convexHullCorners, int cornerCount, const IRect& pixelBound) {
+	void occludeFromSortedHull(const ProjectedPoint* convexHullCorners, int32_t cornerCount, const IRect& pixelBound) {
 		// Loop over the outer bound
 		// Loop over the outer bound
 		if (pixelBound.width() > cellSize && pixelBound.height() > cellSize) {
 		if (pixelBound.width() > cellSize && pixelBound.height() > cellSize) {
 			float distance = 0.0f;
 			float distance = 0.0f;
-			for (int c = 0; c < cornerCount; c++) {
+			for (int32_t c = 0; c < cornerCount; c++) {
 				replaceWithLarger(distance, convexHullCorners[c].cs.z);
 				replaceWithLarger(distance, convexHullCorners[c].cs.z);
 			}
 			}
 			// Loop over all cells within the bound
 			// Loop over all cells within the bound
 			IRect outerBound = getOuterCellBound(pixelBound);
 			IRect outerBound = getOuterCellBound(pixelBound);
-			for (int cellY = outerBound.top(); cellY < outerBound.bottom(); cellY++) {
-				for (int cellX = outerBound.left(); cellX < outerBound.right(); cellX++) {
+			for (int32_t cellY = outerBound.top(); cellY < outerBound.bottom(); cellY++) {
+				for (int32_t cellX = outerBound.left(); cellX < outerBound.right(); cellX++) {
 					IRect pixelRegion = IRect(cellX * cellSize, cellY * cellSize, cellSize, cellSize);
 					IRect pixelRegion = IRect(cellX * cellSize, cellY * cellSize, cellSize, cellSize);
 					IRect subPixelRegion = pixelRegion * constants::unitsPerPixel;
 					IRect subPixelRegion = pixelRegion * constants::unitsPerPixel;
 					if (rectangleInsideOfHull(convexHullCorners, cornerCount, subPixelRegion)) {
 					if (rectangleInsideOfHull(convexHullCorners, cornerCount, subPixelRegion)) {
@@ -239,7 +239,7 @@ struct RendererImpl {
 			}
 			}
 		}
 		}
 	}
 	}
-	void occludeFromSortedHull(const ProjectedPoint* convexHullCorners, int cornerCount) {
+	void occludeFromSortedHull(const ProjectedPoint* convexHullCorners, int32_t cornerCount) {
 		occludeFromSortedHull(convexHullCorners, cornerCount, getPixelBoundFromProjection(convexHullCorners, cornerCount));
 		occludeFromSortedHull(convexHullCorners, cornerCount, getPixelBoundFromProjection(convexHullCorners, cornerCount));
 	}
 	}
 	void occludeFromExistingTriangles() {
 	void occludeFromExistingTriangles() {
@@ -249,7 +249,7 @@ struct RendererImpl {
 		prepareForOcclusion();
 		prepareForOcclusion();
 		// Generate a depth grid to remove many small triangles behind larger triangles
 		// Generate a depth grid to remove many small triangles behind larger triangles
 		//   This will leave triangles along seams but at least begin to remove the worst unwanted drawing
 		//   This will leave triangles along seams but at least begin to remove the worst unwanted drawing
-		for (int t = 0; t < this->commandQueue.buffer.length(); t++) {
+		for (int32_t t = 0; t < this->commandQueue.buffer.length(); t++) {
 			// Get the current triangle from the queue
 			// Get the current triangle from the queue
 			Filter filter = this->commandQueue.buffer[t].filter;
 			Filter filter = this->commandQueue.buffer[t].filter;
 			if (filter == Filter::Solid) {
 			if (filter == Filter::Solid) {
@@ -273,20 +273,20 @@ struct RendererImpl {
 			throwError("Cannot call renderer_occludeFromBox without first calling renderer_begin!\n");
 			throwError("Cannot call renderer_occludeFromBox without first calling renderer_begin!\n");
 		}
 		}
 		prepareForOcclusion();
 		prepareForOcclusion();
-		static const int pointCount = 8;
+		static const int32_t pointCount = 8;
 		FVector3D localPoints[pointCount];
 		FVector3D localPoints[pointCount];
 		ProjectedPoint projections[pointCount];
 		ProjectedPoint projections[pointCount];
 		ProjectedPoint edgeCorners[pointCount];
 		ProjectedPoint edgeCorners[pointCount];
 		GENERATE_BOX_CORNERS(localPoints, minimum, maximum)
 		GENERATE_BOX_CORNERS(localPoints, minimum, maximum)
 		if (projectHull(projections, localPoints, 8, modelToWorldTransform, camera)) {
 		if (projectHull(projections, localPoints, 8, modelToWorldTransform, camera)) {
 			// Get a 2D convex hull from the projected corners
 			// Get a 2D convex hull from the projected corners
-			int edgeCornerCount = 0;
+			int32_t edgeCornerCount = 0;
 			jarvisConvexHullAlgorithm(edgeCorners, edgeCornerCount, projections, 8);
 			jarvisConvexHullAlgorithm(edgeCorners, edgeCornerCount, projections, 8);
 			occludeFromSortedHull(edgeCorners, edgeCornerCount);
 			occludeFromSortedHull(edgeCorners, edgeCornerCount);
 			// Allow saving the 2D silhouette for debugging
 			// Allow saving the 2D silhouette for debugging
 			if (debugSilhouette) {
 			if (debugSilhouette) {
-				for (int p = 0; p < edgeCornerCount; p++) {
-					int q = (p + 1) % edgeCornerCount;
+				for (int32_t p = 0; p < edgeCornerCount; p++) {
+					int32_t q = (p + 1) % edgeCornerCount;
 					if (projections[p].cs.z > camera.nearClip) {
 					if (projections[p].cs.z > camera.nearClip) {
 						this->debugLines.pushConstruct(
 						this->debugLines.pushConstruct(
 						  edgeCorners[p].flat.x / constants::unitsPerPixel, edgeCorners[p].flat.y / constants::unitsPerPixel,
 						  edgeCorners[p].flat.x / constants::unitsPerPixel, edgeCorners[p].flat.y / constants::unitsPerPixel,
@@ -300,17 +300,17 @@ struct RendererImpl {
 	}
 	}
 	// Occlusion test for whole model bounds.
 	// Occlusion test for whole model bounds.
 	// Returns false if the convex hull of the corners has a chance to be seen from the camera.
 	// Returns false if the convex hull of the corners has a chance to be seen from the camera.
-	bool isHullOccluded(ProjectedPoint* outputHullCorners, const FVector3D* inputHullCorners, int cornerCount, const Transform3D &modelToWorldTransform, const Camera &camera) const {
+	bool isHullOccluded(ProjectedPoint* outputHullCorners, const FVector3D* inputHullCorners, int32_t cornerCount, const Transform3D &modelToWorldTransform, const Camera &camera) const {
 		VirtualStackAllocation<FVector3D> cameraPoints(cornerCount);
 		VirtualStackAllocation<FVector3D> cameraPoints(cornerCount);
-		for (int p = 0; p < cornerCount; p++) {
+		for (int32_t p = 0; p < cornerCount; p++) {
 			cameraPoints[p] = camera.worldToCamera(modelToWorldTransform.transformPoint(inputHullCorners[p]));
 			cameraPoints[p] = camera.worldToCamera(modelToWorldTransform.transformPoint(inputHullCorners[p]));
 			outputHullCorners[p] = camera.cameraToScreen(cameraPoints[p]);
 			outputHullCorners[p] = camera.cameraToScreen(cameraPoints[p]);
 		}
 		}
 		// Culling test to see if all points are outside of the same plane of the view frustum.
 		// Culling test to see if all points are outside of the same plane of the view frustum.
-		for (int s = 0; s < camera.cullFrustum.getPlaneCount(); s++) {
+		for (int32_t s = 0; s < camera.cullFrustum.getPlaneCount(); s++) {
 			bool allOutside = true; // True until prooven false.
 			bool allOutside = true; // True until prooven false.
 			FPlane3D plane = camera.cullFrustum.getPlane(s);
 			FPlane3D plane = camera.cullFrustum.getPlane(s);
-			for (int p = 0; p < cornerCount; p++) {
+			for (int32_t p = 0; p < cornerCount; p++) {
 				if (plane.inside(cameraPoints[p])) {
 				if (plane.inside(cameraPoints[p])) {
 					// One point was inside of this plane, so it can not guarantee that all interpolated points between the corners are outside.
 					// One point was inside of this plane, so it can not guarantee that all interpolated points between the corners are outside.
 					allOutside = false;
 					allOutside = false;
@@ -325,13 +325,13 @@ struct RendererImpl {
 		}
 		}
 		IRect pixelBound = getPixelBoundFromProjection(outputHullCorners, cornerCount);
 		IRect pixelBound = getPixelBoundFromProjection(outputHullCorners, cornerCount);
 		float closestDistance = std::numeric_limits<float>::infinity();
 		float closestDistance = std::numeric_limits<float>::infinity();
-		for (int c = 0; c < cornerCount; c++) {
+		for (int32_t c = 0; c < cornerCount; c++) {
 			replaceWithSmaller(closestDistance, outputHullCorners[c].cs.z);
 			replaceWithSmaller(closestDistance, outputHullCorners[c].cs.z);
 		}
 		}
 		// Loop over all cells within the bound
 		// Loop over all cells within the bound
 		IRect outerBound = getOuterCellBound(pixelBound);
 		IRect outerBound = getOuterCellBound(pixelBound);
-		for (int cellY = outerBound.top(); cellY < outerBound.bottom(); cellY++) {
-			for (int cellX = outerBound.left(); cellX < outerBound.right(); cellX++) {
+		for (int32_t cellY = outerBound.top(); cellY < outerBound.bottom(); cellY++) {
+			for (int32_t cellX = outerBound.left(); cellX < outerBound.right(); cellX++) {
 				if (closestDistance < image_readPixel_clamp(this->depthGrid, cellX, cellY)) {
 				if (closestDistance < image_readPixel_clamp(this->depthGrid, cellX, cellY)) {
 					return false; // Visible because one cell had a more distant maximum depth.
 					return false; // Visible because one cell had a more distant maximum depth.
 				}
 				}
@@ -362,17 +362,17 @@ struct RendererImpl {
 			// Debug drawn triangles
 			// Debug drawn triangles
 			if (debugWireframe) {
 			if (debugWireframe) {
 				/*if (image_exists(this->depthGrid)) {
 				/*if (image_exists(this->depthGrid)) {
-					for (int cellY = 0; cellY < this->gridHeight; cellY++) {
-						for (int cellX = 0; cellX < this->gridWidth; cellX++) {
+					for (int32_t cellY = 0; cellY < this->gridHeight; cellY++) {
+						for (int32_t cellX = 0; cellX < this->gridWidth; cellX++) {
 							float depth = image_readPixel_clamp(this->depthGrid, cellX, cellY);
 							float depth = image_readPixel_clamp(this->depthGrid, cellX, cellY);
 							if (depth < std::numeric_limits<float>::infinity()) {
 							if (depth < std::numeric_limits<float>::infinity()) {
-								int intensity = depth;
+								int32_t intensity = depth;
 								draw_rectangle(this->colorBuffer, IRect(cellX * cellSize + 4, cellY * cellSize + 4, cellSize - 8, cellSize - 8), ColorRgbaI32(intensity, intensity, 0, 255));
 								draw_rectangle(this->colorBuffer, IRect(cellX * cellSize + 4, cellY * cellSize + 4, cellSize - 8, cellSize - 8), ColorRgbaI32(intensity, intensity, 0, 255));
 							}
 							}
 						}
 						}
 					}
 					}
 				}*/
 				}*/
-				for (int t = 0; t < this->commandQueue.buffer.length(); t++) {
+				for (int32_t t = 0; t < this->commandQueue.buffer.length(); t++) {
 					if (!this->commandQueue.buffer[t].occluded) {
 					if (!this->commandQueue.buffer[t].occluded) {
 						ITriangle2D *triangle = &(this->commandQueue.buffer[t].triangle);
 						ITriangle2D *triangle = &(this->commandQueue.buffer[t].triangle);
 						draw_line(this->colorBuffer,
 						draw_line(this->colorBuffer,
@@ -394,7 +394,7 @@ struct RendererImpl {
 				}
 				}
 			}
 			}
 			// Debug anything else added to debugLines
 			// Debug anything else added to debugLines
-			for (int l = 0; l < this->debugLines.length(); l++) {
+			for (int32_t l = 0; l < this->debugLines.length(); l++) {
 				draw_line(this->colorBuffer, this->debugLines[l].x1, this->debugLines[l].y1, this->debugLines[l].x2, this->debugLines[l].y2, this->debugLines[l].color);
 				draw_line(this->colorBuffer, this->debugLines[l].x1, this->debugLines[l].y1, this->debugLines[l].x2, this->debugLines[l].y2, this->debugLines[l].color);
 			}
 			}
 			this->debugLines.clear();
 			this->debugLines.clear();
@@ -411,19 +411,19 @@ struct RendererImpl {
 			throwError("Cannot call renderer_occludeFromTopRows without having given a depth buffer in renderer_begin!\n");
 			throwError("Cannot call renderer_occludeFromTopRows without having given a depth buffer in renderer_begin!\n");
 		}
 		}
 		SafePointer<float> depthRow = image_getSafePointer(this->depthBuffer);
 		SafePointer<float> depthRow = image_getSafePointer(this->depthBuffer);
-		int depthStride = image_getStride(this->depthBuffer);
+		int32_t depthStride = image_getStride(this->depthBuffer);
 		SafePointer<float> gridRow = image_getSafePointer(this->depthGrid);
 		SafePointer<float> gridRow = image_getSafePointer(this->depthGrid);
-		int gridStride = image_getStride(this->depthGrid);
+		int32_t gridStride = image_getStride(this->depthGrid);
 		if (camera.perspective) {
 		if (camera.perspective) {
 			// Perspective case using 1/depth for the depth buffer.
 			// Perspective case using 1/depth for the depth buffer.
-			for (int y = 0; y < this->height; y += cellSize) {
+			for (int32_t y = 0; y < this->height; y += cellSize) {
 				SafePointer<float> gridPixel = gridRow;
 				SafePointer<float> gridPixel = gridRow;
 				SafePointer<float> depthPixel = depthRow;
 				SafePointer<float> depthPixel = depthRow;
-				int x = 0;
-				int right = cellSize - 1;
+				int32_t x = 0;
+				int32_t right = cellSize - 1;
 				float maxInvDistance;
 				float maxInvDistance;
 				// Scan bottom row of whole cell width
 				// Scan bottom row of whole cell width
-				for (int gridX = 0; gridX < this->gridWidth; gridX++) {
+				for (int32_t gridX = 0; gridX < this->gridWidth; gridX++) {
 					maxInvDistance = std::numeric_limits<float>::infinity();
 					maxInvDistance = std::numeric_limits<float>::infinity();
 					if (right >= this->width) { right = this->width; }
 					if (right >= this->width) { right = this->width; }
 					while (x < right) {
 					while (x < right) {
@@ -447,14 +447,14 @@ struct RendererImpl {
 		} else {
 		} else {
 			// Orthogonal case where linear depth is used for both grid and depth buffer.
 			// Orthogonal case where linear depth is used for both grid and depth buffer.
 			// TODO: Create test cases for many ways to use occlusion, even these strange cases like isometric occlusion where plain culling does not leave many occluded models.
 			// TODO: Create test cases for many ways to use occlusion, even these strange cases like isometric occlusion where plain culling does not leave many occluded models.
-			for (int y = 0; y < this->height; y += cellSize) {
+			for (int32_t y = 0; y < this->height; y += cellSize) {
 				SafePointer<float> gridPixel = gridRow;
 				SafePointer<float> gridPixel = gridRow;
 				SafePointer<float> depthPixel = depthRow;
 				SafePointer<float> depthPixel = depthRow;
-				int x = 0;
-				int right = cellSize - 1;
+				int32_t x = 0;
+				int32_t right = cellSize - 1;
 				float maxDistance;
 				float maxDistance;
 				// Scan bottom row of whole cell width
 				// Scan bottom row of whole cell width
-				for (int gridX = 0; gridX < this->gridWidth; gridX++) {
+				for (int32_t gridX = 0; gridX < this->gridWidth; gridX++) {
 					maxDistance = 0.0f;
 					maxDistance = 0.0f;
 					if (right >= this->width) { right = this->width; }
 					if (right >= this->width) { right = this->width; }
 					while (x < right) {
 					while (x < right) {

+ 6 - 6
Source/DFPSR/api/soundAPI.cpp

@@ -83,12 +83,12 @@ static double fromIntegerScaleI32 = 1.0 / toIntegerScaleI32;
 
 
 // TODO: Create a folder for implementations of sound formats.
 // TODO: Create a folder for implementations of sound formats.
 
 
-static const int fmtOffset_audioFormat = 0;
-static const int fmtOffset_channelCount = 2;
-static const int fmtOffset_sampleRate = 4;
-static const int fmtOffset_bytesPerSecond = 8;
-static const int fmtOffset_blockAlign = 12;
-static const int fmtOffset_bitsPerSample = 14;
+static const int32_t fmtOffset_audioFormat = 0;
+static const int32_t fmtOffset_channelCount = 2;
+static const int32_t fmtOffset_sampleRate = 4;
+static const int32_t fmtOffset_bytesPerSecond = 8;
+static const int32_t fmtOffset_blockAlign = 12;
+static const int32_t fmtOffset_bitsPerSample = 14;
 
 
 static uint32_t getSampleBits(RiffWaveFormat format) {
 static uint32_t getSampleBits(RiffWaveFormat format) {
 	if (format == RiffWaveFormat::RawU8) {
 	if (format == RiffWaveFormat::RawU8) {

+ 1 - 1
Source/DFPSR/api/textureAPI.cpp

@@ -28,7 +28,7 @@
 
 
 namespace dsr {
 namespace dsr {
 
 
-static int findLog2Size(uint32_t size) {
+static int32_t findLog2Size(uint32_t size) {
 	static const uint32_t maxLog2Size = 15; // 32768 pixels
 	static const uint32_t maxLog2Size = 15; // 32768 pixels
 	for (uint32_t log2Size = 0; log2Size < maxLog2Size; log2Size++) {
 	for (uint32_t log2Size = 0; log2Size < maxLog2Size; log2Size++) {
 		if ((uint32_t(1u) << log2Size) >= size) {
 		if ((uint32_t(1u) << log2Size) >= size) {

+ 1 - 1
Source/DFPSR/api/textureAPI.h

@@ -481,7 +481,7 @@ namespace dsr {
 		float offsetU = max(offsetUX, offsetUY) * source.impl_floatMaxWidth;
 		float offsetU = max(offsetUX, offsetUY) * source.impl_floatMaxWidth;
 		float offsetV = max(offsetVX, offsetVY) * source.impl_floatMaxHeight;
 		float offsetV = max(offsetVX, offsetVY) * source.impl_floatMaxHeight;
 		float offset = max(offsetU, offsetV);
 		float offset = max(offsetU, offsetV);
-		int result = 0;
+		int32_t result = 0;
 		// TODO: Can count leading zeroes be used with integers to use all available mip levels?
 		// TODO: Can count leading zeroes be used with integers to use all available mip levels?
 		//       It would make MIP_INSIDE useless for optimization.
 		//       It would make MIP_INSIDE useless for optimization.
 		if (offset >  2.0f) { result = 1; }
 		if (offset >  2.0f) { result = 1; }

+ 4 - 4
Source/DFPSR/base/heap.cpp

@@ -289,7 +289,7 @@ namespace dsr {
 	}
 	}
 
 
 	// Calculates the largest power of two allocation size that does not overflow a pointer on the target platform.
 	// Calculates the largest power of two allocation size that does not overflow a pointer on the target platform.
-	constexpr int calculateBinCount() {
+	constexpr int32_t calculateBinCount() {
 		intptr_t p = 0;
 		intptr_t p = 0;
 		while (true) {
 		while (true) {
 			uintptr_t result = getBinSize(p);
 			uintptr_t result = getBinSize(p);
@@ -302,7 +302,7 @@ namespace dsr {
 	}
 	}
 
 
 	// The index of the last used bin.
 	// The index of the last used bin.
-	static const int MAX_BIN_COUNT = calculateBinCount();
+	static const int32_t MAX_BIN_COUNT = calculateBinCount();
 
 
 	static BinIndex getBinIndex(uintptr_t minimumSize, intptr_t minimumBin) {
 	static BinIndex getBinIndex(uintptr_t minimumSize, intptr_t minimumBin) {
 		for (intptr_t p = minimumBin; p < MAX_BIN_COUNT; p++) {
 		for (intptr_t p = minimumBin; p < MAX_BIN_COUNT; p++) {
@@ -316,7 +316,7 @@ namespace dsr {
 	}
 	}
 
 
 	// The index of the first used bin, which is also the number of unused bins.
 	// The index of the first used bin, which is also the number of unused bins.
-	static const int MIN_BIN_COUNT = getBinIndex(heap_getHeapAlignment(), 0);
+	static const int32_t MIN_BIN_COUNT = getBinIndex(heap_getHeapAlignment(), 0);
 
 
 	static const HeapFlag heapFlag_recycled = 1 << 0;
 	static const HeapFlag heapFlag_recycled = 1 << 0;
 	struct HeapHeader : public AllocationHeader {
 	struct HeapHeader : public AllocationHeader {
@@ -761,7 +761,7 @@ namespace dsr {
 				}
 				}
 				// Remove the destructor so that it is not called again for the next allocation.
 				// Remove the destructor so that it is not called again for the next allocation.
 				header->destructor = HeapDestructor();
 				header->destructor = HeapDestructor();
-				int binIndex = header->binIndex;
+				int32_t binIndex = header->binIndex;
 				if (binIndex >= MAX_BIN_COUNT) {
 				if (binIndex >= MAX_BIN_COUNT) {
 					printf("Heap error: Out of bound recycling bin index in corrupted head of freed allocation!\n");
 					printf("Heap error: Out of bound recycling bin index in corrupted head of freed allocation!\n");
 				} else {
 				} else {

+ 4 - 4
Source/DFPSR/base/simd.h

@@ -4084,9 +4084,9 @@
 
 
 	// How many lanes do the longest available vector have for a specified lane size.
 	// How many lanes do the longest available vector have for a specified lane size.
 	//   Used to iterate indices and pointers using whole elements.
 	//   Used to iterate indices and pointers using whole elements.
-	static const int laneCountX_32Bit = DSR_DEFAULT_VECTOR_SIZE / 4;
-	static const int laneCountX_16Bit = DSR_DEFAULT_VECTOR_SIZE / 2;
-	static const int laneCountX_8Bit = DSR_DEFAULT_VECTOR_SIZE;
+	static const int32_t laneCountX_32Bit = DSR_DEFAULT_VECTOR_SIZE / 4;
+	static const int32_t laneCountX_16Bit = DSR_DEFAULT_VECTOR_SIZE / 2;
+	static const int32_t laneCountX_8Bit = DSR_DEFAULT_VECTOR_SIZE;
 
 
 	// TODO: Let SVE define completely separate types for dynamic vectors.
 	// TODO: Let SVE define completely separate types for dynamic vectors.
 	// The F vector using the longest SIMD length that is efficient to use when only processing float values, even if no integer types are available in the same size.
 	// The F vector using the longest SIMD length that is efficient to use when only processing float values, even if no integer types are available in the same size.
@@ -4105,7 +4105,7 @@
 		using F32xF = F32x4;
 		using F32xF = F32x4;
 	#endif
 	#endif
 	// Used to iterate over float pointers when using F32xF.
 	// Used to iterate over float pointers when using F32xF.
-	static const int laneCountF = DSR_FLOAT_VECTOR_SIZE / 4;
+	static const int32_t laneCountF = DSR_FLOAT_VECTOR_SIZE / 4;
 
 
 	// Define traits.
 	// Define traits.
 	DSR_APPLY_PROPERTY(DsrTrait_Any_U8 , U8x16)
 	DSR_APPLY_PROPERTY(DsrTrait_Any_U8 , U8x16)

+ 49 - 49
Source/DFPSR/base/threading.cpp

@@ -41,18 +41,18 @@ namespace dsr {
 	static std::mutex getTaskLock;
 	static std::mutex getTaskLock;
 #endif
 #endif
 
 
-int getThreadCount() {
+int32_t getThreadCount() {
 	#ifndef DISABLE_MULTI_THREADING
 	#ifndef DISABLE_MULTI_THREADING
-		return (int)std::thread::hardware_concurrency();
+		return (int32_t)std::thread::hardware_concurrency();
 	#else
 	#else
 		return 1;
 		return 1;
 	#endif
 	#endif
 }
 }
 
 
-void threadedWorkByIndex(std::function<void(void *context, int jobIndex)> job, void *context, int jobCount, int maxThreadCount) {
+void threadedWorkByIndex(std::function<void(void *context, int32_t jobIndex)> job, void *context, int32_t jobCount, int32_t maxThreadCount) {
 	#ifdef DISABLE_MULTI_THREADING
 	#ifdef DISABLE_MULTI_THREADING
 		// Reference implementation
 		// Reference implementation
-		for (int i = 0; i < jobCount; i++) {
+		for (int32_t i = 0; i < jobCount; i++) {
 			job(context, i);
 			job(context, i);
 		}
 		}
 	#else
 	#else
@@ -67,25 +67,25 @@ void threadedWorkByIndex(std::function<void(void *context, int jobIndex)> job, v
 			}
 			}
 			// When having more than one thread, one should be reserved for fast responses.
 			// When having more than one thread, one should be reserved for fast responses.
 			//   Otherwise one thread will keep the others waiting while struggling to manage interrupts with expensive context switches.
 			//   Otherwise one thread will keep the others waiting while struggling to manage interrupts with expensive context switches.
-			int availableThreads = max(getThreadCount() - 1, 1);
-			int workerCount = min(availableThreads, maxThreadCount, jobCount); // All used threads
-			int helperCount = workerCount - 1; // Excluding the main thread
+			int32_t availableThreads = max(getThreadCount() - 1, 1);
+			int32_t workerCount = min(availableThreads, maxThreadCount, jobCount); // All used threads
+			int32_t helperCount = workerCount - 1; // Excluding the main thread
 			// Multi-threaded work loop
 			// Multi-threaded work loop
 			if (workerCount == 1) {
 			if (workerCount == 1) {
 				// Run on the main thread if there is only one.
 				// Run on the main thread if there is only one.
-				for (int i = 0; i < jobCount; i++) {
+				for (int32_t i = 0; i < jobCount; i++) {
 					job(context, i);
 					job(context, i);
 				}
 				}
 			} else {
 			} else {
 				// A shared counter protected by getTaskLock.
 				// A shared counter protected by getTaskLock.
-				int nextJobIndex = 0;
+				int32_t nextJobIndex = 0;
 				DestructibleVirtualStackAllocation<std::function<void()>> workers(workerCount);
 				DestructibleVirtualStackAllocation<std::function<void()>> workers(workerCount);
 				DestructibleVirtualStackAllocation<std::future<void>> helpers(helperCount);
 				DestructibleVirtualStackAllocation<std::future<void>> helpers(helperCount);
-				for (int w = 0; w < workerCount; w++) {
+				for (int32_t w = 0; w < workerCount; w++) {
 					workers[w] = [&nextJobIndex, context, job, jobCount]() {
 					workers[w] = [&nextJobIndex, context, job, jobCount]() {
 						while (true) {
 						while (true) {
 							getTaskLock.lock();
 							getTaskLock.lock();
-							int taskIndex = nextJobIndex;
+							int32_t taskIndex = nextJobIndex;
 							nextJobIndex++;
 							nextJobIndex++;
 							getTaskLock.unlock();
 							getTaskLock.unlock();
 							if (taskIndex < jobCount) {
 							if (taskIndex < jobCount) {
@@ -97,13 +97,13 @@ void threadedWorkByIndex(std::function<void(void *context, int jobIndex)> job, v
 					};
 					};
 				}
 				}
 				// Start working in the helper threads
 				// Start working in the helper threads
-				for (int h = 0; h < helperCount; h++) {
+				for (int32_t h = 0; h < helperCount; h++) {
 					helpers[h] = std::async(std::launch::async, workers[h]);
 					helpers[h] = std::async(std::launch::async, workers[h]);
 				}
 				}
 				// Perform the same work on the main thread
 				// Perform the same work on the main thread
 				workers[workerCount - 1]();
 				workers[workerCount - 1]();
 				// Wait for all helpers to complete their work once all tasks have been handed out
 				// Wait for all helpers to complete their work once all tasks have been handed out
-				for (int h = 0; h < helperCount; h++) {
+				for (int32_t h = 0; h < helperCount; h++) {
 					if (helpers[h].valid()) {
 					if (helpers[h].valid()) {
 						helpers[h].wait();
 						helpers[h].wait();
 					}
 					}
@@ -113,10 +113,10 @@ void threadedWorkByIndex(std::function<void(void *context, int jobIndex)> job, v
 	#endif
 	#endif
 }
 }
 
 
-void threadedWorkFromArray(std::function<void()>* jobs, int jobCount, int maxThreadCount) {
+void threadedWorkFromArray(std::function<void()>* jobs, int32_t jobCount, int32_t maxThreadCount) {
 	#ifdef DISABLE_MULTI_THREADING
 	#ifdef DISABLE_MULTI_THREADING
 		// Reference implementation
 		// Reference implementation
-		for (int i = 0; i < jobCount; i++) {
+		for (int32_t i = 0; i < jobCount; i++) {
 			jobs[i]();
 			jobs[i]();
 		}
 		}
 	#else
 	#else
@@ -131,25 +131,25 @@ void threadedWorkFromArray(std::function<void()>* jobs, int jobCount, int maxThr
 			}
 			}
 			// When having more than one thread, one should be reserved for fast responses.
 			// When having more than one thread, one should be reserved for fast responses.
 			//   Otherwise one thread will keep the others waiting while struggling to manage interrupts with expensive context switches.
 			//   Otherwise one thread will keep the others waiting while struggling to manage interrupts with expensive context switches.
-			int availableThreads = max(getThreadCount() - 1, 1);
-			int workerCount = min(availableThreads, maxThreadCount, jobCount); // All used threads
-			int helperCount = workerCount - 1; // Excluding the main thread
+			int32_t availableThreads = max(getThreadCount() - 1, 1);
+			int32_t workerCount = min(availableThreads, maxThreadCount, jobCount); // All used threads
+			int32_t helperCount = workerCount - 1; // Excluding the main thread
 			// Multi-threaded work loop
 			// Multi-threaded work loop
 			if (workerCount == 1) {
 			if (workerCount == 1) {
 				// Run on the main thread if there is only one.
 				// Run on the main thread if there is only one.
-				for (int i = 0; i < jobCount; i++) {
+				for (int32_t i = 0; i < jobCount; i++) {
 					jobs[i]();
 					jobs[i]();
 				}
 				}
 			} else {
 			} else {
 				// A shared counter protected by getTaskLock.
 				// A shared counter protected by getTaskLock.
-				int nextJobIndex = 0;
+				int32_t nextJobIndex = 0;
 				DestructibleVirtualStackAllocation<std::function<void()>> workers(workerCount);
 				DestructibleVirtualStackAllocation<std::function<void()>> workers(workerCount);
 				DestructibleVirtualStackAllocation<std::future<void>> helpers(helperCount);
 				DestructibleVirtualStackAllocation<std::future<void>> helpers(helperCount);
-				for (int w = 0; w < workerCount; w++) {
+				for (int32_t w = 0; w < workerCount; w++) {
 					workers[w] = [&nextJobIndex, jobs, jobCount]() {
 					workers[w] = [&nextJobIndex, jobs, jobCount]() {
 						while (true) {
 						while (true) {
 							getTaskLock.lock();
 							getTaskLock.lock();
-							int taskIndex = nextJobIndex;
+							int32_t taskIndex = nextJobIndex;
 							nextJobIndex++;
 							nextJobIndex++;
 							getTaskLock.unlock();
 							getTaskLock.unlock();
 							if (taskIndex < jobCount) {
 							if (taskIndex < jobCount) {
@@ -161,13 +161,13 @@ void threadedWorkFromArray(std::function<void()>* jobs, int jobCount, int maxThr
 					};
 					};
 				}
 				}
 				// Start working in the helper threads
 				// Start working in the helper threads
-				for (int h = 0; h < helperCount; h++) {
+				for (int32_t h = 0; h < helperCount; h++) {
 					helpers[h] = std::async(std::launch::async, workers[h]);
 					helpers[h] = std::async(std::launch::async, workers[h]);
 				}
 				}
 				// Perform the same work on the main thread
 				// Perform the same work on the main thread
 				workers[workerCount - 1]();
 				workers[workerCount - 1]();
 				// Wait for all helpers to complete their work once all tasks have been handed out
 				// Wait for all helpers to complete their work once all tasks have been handed out
-				for (int h = 0; h < helperCount; h++) {
+				for (int32_t h = 0; h < helperCount; h++) {
 					if (helpers[h].valid()) {
 					if (helpers[h].valid()) {
 						helpers[h].wait();
 						helpers[h].wait();
 					}
 					}
@@ -177,26 +177,26 @@ void threadedWorkFromArray(std::function<void()>* jobs, int jobCount, int maxThr
 	#endif
 	#endif
 }
 }
 
 
-void threadedWorkFromArray(SafePointer<std::function<void()>> jobs, int jobCount, int maxThreadCount) {
+void threadedWorkFromArray(SafePointer<std::function<void()>> jobs, int32_t jobCount, int32_t maxThreadCount) {
 	threadedWorkFromArray(jobs.getUnsafe(), jobCount, maxThreadCount);
 	threadedWorkFromArray(jobs.getUnsafe(), jobCount, maxThreadCount);
 }
 }
 
 
-void threadedWorkFromList(List<std::function<void()>> jobs, int maxThreadCount) {
+void threadedWorkFromList(List<std::function<void()>> jobs, int32_t maxThreadCount) {
 	if (jobs.length() > 0) {
 	if (jobs.length() > 0) {
 		threadedWorkFromArray(&jobs[0], jobs.length(), maxThreadCount);
 		threadedWorkFromArray(&jobs[0], jobs.length(), maxThreadCount);
 	}
 	}
 	jobs.clear();
 	jobs.clear();
 }
 }
 
 
-void threadedSplit(int startIndex, int stopIndex, std::function<void(int startIndex, int stopIndex)> task, int minimumJobSize, int jobsPerThread) {
+void threadedSplit(int32_t startIndex, int32_t stopIndex, std::function<void(int32_t startIndex, int32_t stopIndex)> task, int32_t minimumJobSize, int32_t jobsPerThread) {
 	#ifndef DISABLE_MULTI_THREADING
 	#ifndef DISABLE_MULTI_THREADING
-		int totalCount = stopIndex - startIndex;
-		int maxJobs = totalCount / minimumJobSize;
-		int jobCount = getThreadCount() * jobsPerThread;
+		int32_t totalCount = stopIndex - startIndex;
+		int32_t maxJobs = totalCount / minimumJobSize;
+		int32_t jobCount = getThreadCount() * jobsPerThread;
 		if (jobCount > maxJobs) { jobCount = maxJobs; }
 		if (jobCount > maxJobs) { jobCount = maxJobs; }
 		if (jobCount < 1) { jobCount = 1; }
 		if (jobCount < 1) { jobCount = 1; }
 	#else
 	#else
-		int jobCount = 1;
+		int32_t jobCount = 1;
 	#endif
 	#endif
 	if (jobCount == 1) {
 	if (jobCount == 1) {
 		// Too little work for multi-threading
 		// Too little work for multi-threading
@@ -204,14 +204,14 @@ void threadedSplit(int startIndex, int stopIndex, std::function<void(int startIn
 	} else {
 	} else {
 		// Use multiple threads
 		// Use multiple threads
 		DestructibleVirtualStackAllocation<std::function<void()>> jobs(jobCount);
 		DestructibleVirtualStackAllocation<std::function<void()>> jobs(jobCount);
-		int givenRow = startIndex;
-		for (int s = 0; s < jobCount; s++) {
-			int remainingJobs = jobCount - s;
-			int remainingRows = stopIndex - givenRow;
-			int y1 = givenRow; // Inclusive
-			int taskSize = remainingRows / remainingJobs;
+		int32_t givenRow = startIndex;
+		for (int32_t s = 0; s < jobCount; s++) {
+			int32_t remainingJobs = jobCount - s;
+			int32_t remainingRows = stopIndex - givenRow;
+			int32_t y1 = givenRow; // Inclusive
+			int32_t taskSize = remainingRows / remainingJobs;
 			givenRow = givenRow + taskSize;
 			givenRow = givenRow + taskSize;
-			int y2 = givenRow; // Exclusive
+			int32_t y2 = givenRow; // Exclusive
 			jobs[s] = [task, y1, y2]() {
 			jobs[s] = [task, y1, y2]() {
 				task(y1, y2);
 				task(y1, y2);
 			};
 			};
@@ -220,18 +220,18 @@ void threadedSplit(int startIndex, int stopIndex, std::function<void(int startIn
 	}
 	}
 }
 }
 
 
-void threadedSplit_disabled(int startIndex, int stopIndex, std::function<void(int startIndex, int stopIndex)> task) {
+void threadedSplit_disabled(int32_t startIndex, int32_t stopIndex, std::function<void(int32_t startIndex, int32_t stopIndex)> task) {
 	task(startIndex, stopIndex);
 	task(startIndex, stopIndex);
 }
 }
 
 
-void threadedSplit(const IRect& bound, std::function<void(const IRect& bound)> task, int minimumRowsPerJob, int jobsPerThread) {
+void threadedSplit(const IRect& bound, std::function<void(const IRect& bound)> task, int32_t minimumRowsPerJob, int32_t jobsPerThread) {
 	#ifndef DISABLE_MULTI_THREADING
 	#ifndef DISABLE_MULTI_THREADING
-		int maxJobs = bound.height() / minimumRowsPerJob;
-		int jobCount = getThreadCount() * jobsPerThread;
+		int32_t maxJobs = bound.height() / minimumRowsPerJob;
+		int32_t jobCount = getThreadCount() * jobsPerThread;
 		if (jobCount > maxJobs) { jobCount = maxJobs; }
 		if (jobCount > maxJobs) { jobCount = maxJobs; }
 		if (jobCount < 1) { jobCount = 1; }
 		if (jobCount < 1) { jobCount = 1; }
 	#else
 	#else
-		int jobCount = 1;
+		int32_t jobCount = 1;
 	#endif
 	#endif
 	if (jobCount == 1) {
 	if (jobCount == 1) {
 		// Too little work for multi-threading
 		// Too little work for multi-threading
@@ -239,12 +239,12 @@ void threadedSplit(const IRect& bound, std::function<void(const IRect& bound)> t
 	} else {
 	} else {
 		// Use multiple threads
 		// Use multiple threads
 		DestructibleVirtualStackAllocation<std::function<void()>> jobs(jobCount);
 		DestructibleVirtualStackAllocation<std::function<void()>> jobs(jobCount);
-		int givenRow = bound.top();
-		for (int s = 0; s < jobCount; s++) {
-			int remainingJobs = jobCount - s;
-			int remainingRows = bound.bottom() - givenRow;
-			int y1 = givenRow;
-			int taskSize = remainingRows / remainingJobs;
+		int32_t givenRow = bound.top();
+		for (int32_t s = 0; s < jobCount; s++) {
+			int32_t remainingJobs = jobCount - s;
+			int32_t remainingRows = bound.bottom() - givenRow;
+			int32_t y1 = givenRow;
+			int32_t taskSize = remainingRows / remainingJobs;
 			givenRow = givenRow + taskSize;
 			givenRow = givenRow + taskSize;
 			IRect subBound = IRect(bound.left(), y1, bound.width(), taskSize);
 			IRect subBound = IRect(bound.left(), y1, bound.width(), taskSize);
 			jobs[s] = [task, subBound]() {
 			jobs[s] = [task, subBound]() {

+ 8 - 8
Source/DFPSR/base/threading.h

@@ -31,23 +31,23 @@
 namespace dsr {
 namespace dsr {
 
 
 // Get the number of threads available.
 // Get the number of threads available.
-int getThreadCount();
+int32_t getThreadCount();
 
 
 // Calls the same job function with indices 0 to jobIndex - 1.
 // Calls the same job function with indices 0 to jobIndex - 1.
 //   This removes the need for capturing the same data over and over again when each task is identical with a different index.
 //   This removes the need for capturing the same data over and over again when each task is identical with a different index.
-void threadedWorkByIndex(std::function<void(void *context, int jobIndex)> job, void *context, int jobCount, int maxThreadCount = 0);
+void threadedWorkByIndex(std::function<void(void *context, int32_t jobIndex)> job, void *context, int32_t jobCount, int32_t maxThreadCount = 0);
 
 
 // Executes every function in the array of jobs from jobs[0] to jobs[jobCount - 1].
 // Executes every function in the array of jobs from jobs[0] to jobs[jobCount - 1].
 //   The maxThreadCount argument is the maximum number of threads to use when enough threads are available.
 //   The maxThreadCount argument is the maximum number of threads to use when enough threads are available.
 //     Letting maxThreadCount be 0 removes the limit and uses as many threads as possible, limited only by getThreadCount() - 1 and jobCount.
 //     Letting maxThreadCount be 0 removes the limit and uses as many threads as possible, limited only by getThreadCount() - 1 and jobCount.
 //     Letting maxThreadCount be 1 forces single-threaded execution on the calling thread.
 //     Letting maxThreadCount be 1 forces single-threaded execution on the calling thread.
 //   Useful when each job to execute is different.
 //   Useful when each job to execute is different.
-void threadedWorkFromArray(SafePointer<std::function<void()>> jobs, int jobCount, int maxThreadCount = 0);
-void threadedWorkFromArray(std::function<void()>* jobs, int jobCount, int maxThreadCount = 0);
+void threadedWorkFromArray(SafePointer<std::function<void()>> jobs, int32_t jobCount, int32_t maxThreadCount = 0);
+void threadedWorkFromArray(std::function<void()>* jobs, int32_t jobCount, int32_t maxThreadCount = 0);
 
 
 // Executes every function in the list of jobs.
 // Executes every function in the list of jobs.
 //   Also clears the list when done.
 //   Also clears the list when done.
-void threadedWorkFromList(List<std::function<void()>> jobs, int maxThreadCount = 0);
+void threadedWorkFromList(List<std::function<void()>> jobs, int32_t maxThreadCount = 0);
 
 
 // Calling the given function with sub-sets of the interval using multiple threads in parallel.
 // Calling the given function with sub-sets of the interval using multiple threads in parallel.
 //   Useful when you have lots of tiny jobs that can be grouped together into larger jobs.
 //   Useful when you have lots of tiny jobs that can be grouped together into larger jobs.
@@ -63,13 +63,13 @@ void threadedWorkFromList(List<std::function<void()>> jobs, int maxThreadCount =
 //     * Do not use for manipulation of pointers, stack memory from the calling thread or anything where corrupted output may lead to a crash.
 //     * Do not use for manipulation of pointers, stack memory from the calling thread or anything where corrupted output may lead to a crash.
 //       Drawing pixel values is okay, because a race condition would only be some noisy pixels that can be spotted and fixed.
 //       Drawing pixel values is okay, because a race condition would only be some noisy pixels that can be spotted and fixed.
 //       Race conditions cannot be tested nor proven away, so assume that they will happen and do your best to avoid them.
 //       Race conditions cannot be tested nor proven away, so assume that they will happen and do your best to avoid them.
-void threadedSplit(int startIndex, int stopIndex, std::function<void(int startIndex, int stopIndex)> task, int minimumJobSize = 128, int jobsPerThread = 2);
+void threadedSplit(int32_t startIndex, int32_t stopIndex, std::function<void(int32_t startIndex, int32_t stopIndex)> task, int32_t minimumJobSize = 128, int32_t jobsPerThread = 2);
 // Use as a place-holder if you want to disable multi-threading but easily turn it on and off for comparing performance
 // Use as a place-holder if you want to disable multi-threading but easily turn it on and off for comparing performance
-void threadedSplit_disabled(int startIndex, int stopIndex, std::function<void(int startIndex, int stopIndex)> task);
+void threadedSplit_disabled(int32_t startIndex, int32_t stopIndex, std::function<void(int32_t startIndex, int32_t stopIndex)> task);
 // A more convenient version for images looping over a rectangular bound of pixels.
 // A more convenient version for images looping over a rectangular bound of pixels.
 //   The same left and right sides are given to each sub-bound to make memory alignment easy.
 //   The same left and right sides are given to each sub-bound to make memory alignment easy.
 //   The top and bottoms are subdivided so that memory access is simple for cache prediction.
 //   The top and bottoms are subdivided so that memory access is simple for cache prediction.
-void threadedSplit(const IRect& bound, std::function<void(const IRect& bound)> task, int minimumRowsPerJob = 128, int jobsPerThread = 2);
+void threadedSplit(const IRect& bound, std::function<void(const IRect& bound)> task, int32_t minimumRowsPerJob = 128, int32_t jobsPerThread = 2);
 // Use as a place-holder if you want to disable multi-threading but easily turn it on and off for comparing performance
 // Use as a place-holder if you want to disable multi-threading but easily turn it on and off for comparing performance
 void threadedSplit_disabled(const IRect& bound, std::function<void(const IRect& bound)> task);
 void threadedSplit_disabled(const IRect& bound, std::function<void(const IRect& bound)> task);
 
 

+ 1 - 1
Source/DFPSR/base/virtualStack.cpp

@@ -29,7 +29,7 @@
 namespace dsr {
 namespace dsr {
 	// How many bytes that are allocated directly in thread local memory.
 	// How many bytes that are allocated directly in thread local memory.
 	static const uint64_t VIRTUAL_STACK_SIZE = 262144;
 	static const uint64_t VIRTUAL_STACK_SIZE = 262144;
-	static const int MAX_EXTRA_STACKS = 63;
+	static const int32_t MAX_EXTRA_STACKS = 63;
 
 
 	static const uintptr_t stackHeaderPaddedSize = memory_getPaddedSize<AllocationHeader>();
 	static const uintptr_t stackHeaderPaddedSize = memory_getPaddedSize<AllocationHeader>();
 	static const uintptr_t stackHeaderAlignmentAndMask = memory_createAlignmentAndMask((uintptr_t)alignof(AllocationHeader));
 	static const uintptr_t stackHeaderAlignmentAndMask = memory_createAlignmentAndMask((uintptr_t)alignof(AllocationHeader));

+ 4 - 4
Source/DFPSR/implementation/font/Font.cpp

@@ -66,8 +66,8 @@ static IRect getCharacterBound(const ImageU8& image, const IRect& searchRegion)
 	int32_t maxX = searchRegion.left();
 	int32_t maxX = searchRegion.left();
 	int32_t minY = searchRegion.bottom();
 	int32_t minY = searchRegion.bottom();
 	int32_t maxY = searchRegion.top();
 	int32_t maxY = searchRegion.top();
-	for (int y = searchRegion.top(); y < searchRegion.bottom(); y++) {
-		for (int x = searchRegion.left(); x < searchRegion.right(); x++) {
+	for (int32_t y = searchRegion.top(); y < searchRegion.bottom(); y++) {
+		for (int32_t x = searchRegion.left(); x < searchRegion.right(); x++) {
 			if (image_readPixel_border(image, x, y)) {
 			if (image_readPixel_border(image, x, y)) {
 				if (x < minX) minX = x;
 				if (x < minX) minX = x;
 				if (x > maxX) maxX = x;
 				if (x > maxX) maxX = x;
@@ -84,8 +84,8 @@ static IRect getCharacterBound(const ImageU8& image, const IRect& searchRegion)
 void RasterFontImpl::registerLatinOne16x16(const ImageU8& atlas) {
 void RasterFontImpl::registerLatinOne16x16(const ImageU8& atlas) {
 	int32_t charWidth = image_getWidth(atlas) / 16;
 	int32_t charWidth = image_getWidth(atlas) / 16;
 	int32_t charHeight = image_getWidth(atlas) / 16;
 	int32_t charHeight = image_getWidth(atlas) / 16;
-	for (int y = 0; y < 16; y++) {
-		for (int x = 0; x < 16; x++) {
+	for (int32_t y = 0; y < 16; y++) {
+		for (int32_t x = 0; x < 16; x++) {
 			IRect searchRegion = IRect(x * charWidth, y * charHeight, charWidth, charHeight);
 			IRect searchRegion = IRect(x * charWidth, y * charHeight, charWidth, charHeight);
 			IRect croppedRegion = getCharacterBound(atlas, searchRegion);
 			IRect croppedRegion = getCharacterBound(atlas, searchRegion);
 			if (croppedRegion.hasArea()) {
 			if (croppedRegion.hasArea()) {

+ 1 - 1
Source/DFPSR/implementation/gui/BackendWindow.cpp

@@ -49,7 +49,7 @@ bool BackendWindow::executeEvents() {
 		this->requestingResize = false;
 		this->requestingResize = false;
 	}
 	}
 	// Look for events
 	// Look for events
-	for (int e = 0; e < this->eventQueue.length(); e++) {
+	for (int32_t e = 0; e < this->eventQueue.length(); e++) {
 		InputEvent* event = this->eventQueue[e];
 		InputEvent* event = this->eventQueue[e];
 		if (event) {
 		if (event) {
 			executedEvent = true;
 			executedEvent = true;

+ 8 - 8
Source/DFPSR/implementation/gui/BackendWindow.h

@@ -45,9 +45,9 @@ public:
 	// Events
 	// Events
 	List<InputEvent*> eventQueue;
 	List<InputEvent*> eventQueue;
 private:
 private:
-	int requestingResize = false;
-	int requestedWidth = 0;
-	int requestedHeight = 0;
+	int32_t requestingResize = false;
+	int32_t requestedWidth = 0;
+	int32_t requestedHeight = 0;
 public:
 public:
 	inline void receivedMouseEvent(MouseEventType mouseEventType, MouseKeyEnum key, IVector2D position) {
 	inline void receivedMouseEvent(MouseEventType mouseEventType, MouseKeyEnum key, IVector2D position) {
 		this->eventQueue.push(new MouseEvent(mouseEventType, key, position));
 		this->eventQueue.push(new MouseEvent(mouseEventType, key, position));
@@ -65,7 +65,7 @@ public:
 	//   When the implementation receives a resize, call receiveWindowResize with the new dimensions.
 	//   When the implementation receives a resize, call receiveWindowResize with the new dimensions.
 	//     If requestingResize is already true, it will just overwrite the old request.
 	//     If requestingResize is already true, it will just overwrite the old request.
 	//   Next call to executeEvents will then use it to resize the canvas.
 	//   Next call to executeEvents will then use it to resize the canvas.
-	inline void receivedWindowResize(int width, int height) {
+	inline void receivedWindowResize(int32_t width, int32_t height) {
 		this->requestingResize = true;
 		this->requestingResize = true;
 		this->requestedWidth = width;
 		this->requestedWidth = width;
 		this->requestedHeight = height;
 		this->requestedHeight = height;
@@ -75,8 +75,8 @@ public:
 	virtual ~BackendWindow() {}
 	virtual ~BackendWindow() {}
 	virtual void setFullScreen(bool enabled) = 0;
 	virtual void setFullScreen(bool enabled) = 0;
 	virtual bool isFullScreen() = 0;
 	virtual bool isFullScreen() = 0;
-	virtual int getWidth() const = 0;
-	virtual int getHeight() const = 0;
+	virtual int32_t getWidth() const = 0;
+	virtual int32_t getHeight() const = 0;
 public:
 public:
 	// Back-end interface
 	// Back-end interface
 	// Responsible for adding events to eventQueue
 	// Responsible for adding events to eventQueue
@@ -85,14 +85,14 @@ public:
 	// Canvas interface
 	// Canvas interface
 	virtual AlignedImageRgbaU8 getCanvas() = 0;
 	virtual AlignedImageRgbaU8 getCanvas() = 0;
 	virtual void showCanvas() = 0;
 	virtual void showCanvas() = 0;
-	virtual void resizeCanvas(int width, int height) = 0;
+	virtual void resizeCanvas(int32_t width, int32_t height) = 0;
 	virtual String getTitle() { return this->title; }
 	virtual String getTitle() { return this->title; }
 	virtual void setTitle(const String &newTitle) = 0;
 	virtual void setTitle(const String &newTitle) = 0;
 public:
 public:
 	// Cursor interface
 	// Cursor interface
 	bool visibleCursor = true; // Written to by setCursorVisibility on success.
 	bool visibleCursor = true; // Written to by setCursorVisibility on success.
 	virtual bool setCursorVisibility(bool visible) { return false; } // Returns true on success.
 	virtual bool setCursorVisibility(bool visible) { return false; } // Returns true on success.
-	virtual bool setCursorPosition(int x, int y) { return false; } // Returns true on success.
+	virtual bool setCursorPosition(int32_t x, int32_t y) { return false; } // Returns true on success.
 public:
 public:
 	// Clipboard interface
 	// Clipboard interface
 	//   If none is replaced, both default implementations will use an internal variable.
 	//   If none is replaced, both default implementations will use an internal variable.

+ 13 - 13
Source/DFPSR/implementation/gui/DsrWindow.cpp

@@ -74,7 +74,7 @@ DsrWindow::DsrWindow(Handle<BackendWindow> backend)
 		this->sendCloseEvent();
 		this->sendCloseEvent();
 	};
 	};
 	// Receiving notifications about resizing should be done in the main panel
 	// Receiving notifications about resizing should be done in the main panel
-	this->backend->resizeEvent() = [this](int width, int height) {
+	this->backend->resizeEvent() = [this](int32_t width, int32_t height) {
 		BackendWindow *backend = this->backend.getUnsafe();
 		BackendWindow *backend = this->backend.getUnsafe();
 		ImageRgbaU8 canvas = backend->getCanvas();
 		ImageRgbaU8 canvas = backend->getCanvas();
 		this->innerWidth = width;
 		this->innerWidth = width;
@@ -92,7 +92,7 @@ DsrWindow::DsrWindow(Handle<BackendWindow> backend)
 
 
 static void setBackendWindowHandle(Handle<VisualComponent> component, Handle<BackendWindow> windowHandle) {
 static void setBackendWindowHandle(Handle<VisualComponent> component, Handle<BackendWindow> windowHandle) {
 	component->window = windowHandle;
 	component->window = windowHandle;
-	for (int c = 0; c < component->children.length(); c++) {
+	for (int32_t c = 0; c < component->children.length(); c++) {
 		setBackendWindowHandle(component->children[c], windowHandle);
 		setBackendWindowHandle(component->children[c], windowHandle);
 	}
 	}
 }
 }
@@ -114,7 +114,7 @@ Handle<VisualComponent> DsrWindow::findComponentByName(ReadableString name) cons
 	}
 	}
 }
 }
 
 
-Handle<VisualComponent> DsrWindow::findComponentByNameAndIndex(ReadableString name, int index) const {
+Handle<VisualComponent> DsrWindow::findComponentByNameAndIndex(ReadableString name, int32_t index) const {
 	if (string_match(this->mainPanel->getName(), name) && this->mainPanel->getIndex() == index) {
 	if (string_match(this->mainPanel->getName(), name) && this->mainPanel->getIndex() == index) {
 		return this->mainPanel;
 		return this->mainPanel;
 	} else {
 	} else {
@@ -184,26 +184,26 @@ void DsrWindow::sendCloseEvent() {
 	this->callback_windowCloseEvent();
 	this->callback_windowCloseEvent();
 }
 }
 
 
-int DsrWindow::getInnerWidth() {
+int32_t DsrWindow::getInnerWidth() {
 	return this->innerWidth;
 	return this->innerWidth;
 }
 }
 
 
-int DsrWindow::getInnerHeight() {
+int32_t DsrWindow::getInnerHeight() {
 	return this->innerHeight;
 	return this->innerHeight;
 }
 }
 
 
-int DsrWindow::getCanvasWidth() {
+int32_t DsrWindow::getCanvasWidth() {
 	return max(1, this->innerWidth / this->pixelScale);
 	return max(1, this->innerWidth / this->pixelScale);
 }
 }
 
 
-int DsrWindow::getCanvasHeight() {
+int32_t DsrWindow::getCanvasHeight() {
 	return max(1, this->innerHeight / this->pixelScale);
 	return max(1, this->innerHeight / this->pixelScale);
 }
 }
 
 
 AlignedImageF32 DsrWindow::getDepthBuffer() {
 AlignedImageF32 DsrWindow::getDepthBuffer() {
 	this->backend->getCanvas();
 	this->backend->getCanvas();
-	int smallWidth = getCanvasWidth();
-	int smallHeight = getCanvasHeight();
+	int32_t smallWidth = getCanvasWidth();
+	int32_t smallHeight = getCanvasHeight();
 	if (!image_exists(this->depthBuffer)
 	if (!image_exists(this->depthBuffer)
 	  || image_getWidth(this->depthBuffer) != smallWidth
 	  || image_getWidth(this->depthBuffer) != smallWidth
 	  || image_getHeight(this->depthBuffer) != smallHeight) {
 	  || image_getHeight(this->depthBuffer) != smallHeight) {
@@ -216,11 +216,11 @@ void DsrWindow::removeDepthBuffer() {
 	this->depthBuffer = AlignedImageF32();
 	this->depthBuffer = AlignedImageF32();
 }
 }
 
 
-int DsrWindow::getPixelScale() const {
+int32_t DsrWindow::getPixelScale() const {
 	return this->pixelScale;
 	return this->pixelScale;
 }
 }
 
 
-void DsrWindow::setPixelScale(int scale) {
+void DsrWindow::setPixelScale(int32_t scale) {
 	if (this->pixelScale != scale) {
 	if (this->pixelScale != scale) {
 		this->pixelScale = scale;
 		this->pixelScale = scale;
 		// Update layout
 		// Update layout
@@ -256,8 +256,8 @@ AlignedImageRgbaU8 DsrWindow::getCanvas() {
 	auto fullResolutionCanvas = this->backend->getCanvas();
 	auto fullResolutionCanvas = this->backend->getCanvas();
 	if (this->pixelScale > 1) {
 	if (this->pixelScale > 1) {
 		// Get low resolution canvas in deterministic RGBA pack order
 		// Get low resolution canvas in deterministic RGBA pack order
-		int smallWidth = getCanvasWidth();
-		int smallHeight = getCanvasHeight();
+		int32_t smallWidth = getCanvasWidth();
+		int32_t smallHeight = getCanvasHeight();
 		if (!image_exists(this->lowResolutionCanvas)
 		if (!image_exists(this->lowResolutionCanvas)
 		 || image_getWidth(this->lowResolutionCanvas) != smallWidth
 		 || image_getWidth(this->lowResolutionCanvas) != smallWidth
  		 || image_getHeight(this->lowResolutionCanvas) != smallHeight) {
  		 || image_getHeight(this->lowResolutionCanvas) != smallHeight) {

+ 10 - 10
Source/DFPSR/implementation/gui/DsrWindow.h

@@ -50,7 +50,7 @@ private:
 	// The inner window dimensions that are synchronized with the canvas.
 	// The inner window dimensions that are synchronized with the canvas.
 	//   The backend on the contrary may have its size changed before the resize event has been fetched.
 	//   The backend on the contrary may have its size changed before the resize event has been fetched.
 	//   Getting the asynchronous window dimensions directly wouldn't be synchronized with the canvas.
 	//   Getting the asynchronous window dimensions directly wouldn't be synchronized with the canvas.
-	int innerWidth, innerHeight;
+	int32_t innerWidth, innerHeight;
 	// The last mouse position is used to create new mouse-move events when pixelScale changes.
 	// The last mouse position is used to create new mouse-move events when pixelScale changes.
 	IVector2D lastMousePosition;
 	IVector2D lastMousePosition;
 public:
 public:
@@ -68,9 +68,9 @@ public:
 		Handle<T> findComponentByName(ReadableString name) const {
 		Handle<T> findComponentByName(ReadableString name) const {
 			return handle_dynamicCast<T>(this->findComponentByName(name));
 			return handle_dynamicCast<T>(this->findComponentByName(name));
 		}
 		}
-		Handle<VisualComponent> findComponentByNameAndIndex(ReadableString name, int index) const;
+		Handle<VisualComponent> findComponentByNameAndIndex(ReadableString name, int32_t index) const;
 		template <typename T>
 		template <typename T>
-		Handle<T> findComponentByNameAndIndex(ReadableString name, int index) const {
+		Handle<T> findComponentByNameAndIndex(ReadableString name, int32_t index) const {
 			return handle_dynamicCast<T>(this->findComponentByNameAndIndex(name, index));
 			return handle_dynamicCast<T>(this->findComponentByNameAndIndex(name, index));
 		}
 		}
 
 
@@ -107,12 +107,12 @@ public:
 
 
 private:
 private:
 	// Upscaling information
 	// Upscaling information
-		int pixelScale = 1;
+		int32_t pixelScale = 1;
 		AlignedImageRgbaU8 lowResolutionCanvas;
 		AlignedImageRgbaU8 lowResolutionCanvas;
 public:
 public:
 	// Upscaling interface
 	// Upscaling interface
-		int getPixelScale() const;
-		void setPixelScale(int scale);
+		int32_t getPixelScale() const;
+		void setPixelScale(int32_t scale);
 
 
 public:
 public:
 	// Graphics
 	// Graphics
@@ -132,9 +132,9 @@ public:
 		// Show the canvas when an image is ready
 		// Show the canvas when an image is ready
 		void showCanvas();
 		void showCanvas();
 		// Canvas width in the pre-upscale resolution
 		// Canvas width in the pre-upscale resolution
-		int getCanvasWidth();
+		int32_t getCanvasWidth();
 		// Canvas height in the pre-upscale resolution
 		// Canvas height in the pre-upscale resolution
-		int getCanvasHeight();
+		int32_t getCanvasHeight();
 
 
 public:
 public:
 	// Full-screen
 	// Full-screen
@@ -149,9 +149,9 @@ public:
 public:
 public:
 	// Access to backend window
 	// Access to backend window
 		// Full width after upscaling
 		// Full width after upscaling
-		int getInnerWidth();
+		int32_t getInnerWidth();
 		// Full height after upscaling
 		// Full height after upscaling
-		int getInnerHeight();
+		int32_t getInnerHeight();
 		String getTitle();
 		String getTitle();
 		void setTitle(const String &newTitle);
 		void setTitle(const String &newTitle);
 };
 };

+ 1 - 1
Source/DFPSR/implementation/gui/FlexRegion.cpp

@@ -28,7 +28,7 @@ using namespace dsr;
 PERSISTENT_DEFINITION(FlexValue)
 PERSISTENT_DEFINITION(FlexValue)
 
 
 bool FlexValue::assignValue(const ReadableString &text, const ReadableString &fromPath) {
 bool FlexValue::assignValue(const ReadableString &text, const ReadableString &fromPath) {
-	int perCentIndex = string_findFirst(text, U'%');
+	int32_t perCentIndex = string_findFirst(text, U'%');
 	if (perCentIndex > -1) {
 	if (perCentIndex > -1) {
 		// Explicit %
 		// Explicit %
 		ReadableString leftSide = string_before(text, perCentIndex);
 		ReadableString leftSide = string_before(text, perCentIndex);

+ 2 - 2
Source/DFPSR/implementation/gui/FlexRegion.h

@@ -40,7 +40,7 @@ private:
 	int32_t offset = 0; // +- offset
 	int32_t offset = 0; // +- offset
 public:
 public:
 	FlexValue() {}
 	FlexValue() {}
-	FlexValue(int ratio, int offset) : ratio(min(max(0, ratio), 100)), offset(offset) {}
+	FlexValue(int32_t ratio, int32_t offset) : ratio(min(max(0, ratio), 100)), offset(offset) {}
 public:
 public:
 	bool assignValue(const ReadableString &text, const ReadableString &fromPath) override;
 	bool assignValue(const ReadableString &text, const ReadableString &fromPath) override;
 	String& toStreamIndented(String& out, const ReadableString& indentation) const override;
 	String& toStreamIndented(String& out, const ReadableString& indentation) const override;
@@ -84,7 +84,7 @@ public:
 		this->bottom = FlexValue(0, location.bottom());
 		this->bottom = FlexValue(0, location.bottom());
 	}
 	}
 	// Flexible region
 	// Flexible region
-	FlexRegion(int leftRatio, int leftOffset, int topRatio, int topOffset, int rightRatio, int rightOffset, int bottomRatio, int bottomOffset) {
+	FlexRegion(int32_t leftRatio, int32_t leftOffset, int32_t topRatio, int32_t topOffset, int32_t rightRatio, int32_t rightOffset, int32_t bottomRatio, int32_t bottomOffset) {
 		this->left = FlexValue(leftRatio, leftOffset);
 		this->left = FlexValue(leftRatio, leftOffset);
 		this->top = FlexValue(topRatio, topOffset);
 		this->top = FlexValue(topRatio, topOffset);
 		this->right = FlexValue(rightRatio, rightOffset);
 		this->right = FlexValue(rightRatio, rightOffset);

+ 5 - 5
Source/DFPSR/implementation/gui/InputEvent.h

@@ -94,12 +94,12 @@ inline MouseEvent operator-(const MouseEvent &old, const IVector2D &offset) {
 	result.position = result.position - offset;
 	result.position = result.position - offset;
 	return result;
 	return result;
 }
 }
-inline MouseEvent operator*(const MouseEvent &old, int scale) {
+inline MouseEvent operator*(const MouseEvent &old, int32_t scale) {
 	MouseEvent result = old;
 	MouseEvent result = old;
 	result.position = result.position * scale;
 	result.position = result.position * scale;
 	return result;
 	return result;
 }
 }
-inline MouseEvent operator/(const MouseEvent &old, int scale) {
+inline MouseEvent operator/(const MouseEvent &old, int32_t scale) {
 	MouseEvent result = old;
 	MouseEvent result = old;
 	result.position = result.position / scale;
 	result.position = result.position / scale;
 	return result;
 	return result;
@@ -122,15 +122,15 @@ public:
 
 
 // The callback types.
 // The callback types.
 using EmptyCallback = std::function<void()>;
 using EmptyCallback = std::function<void()>;
-using IndexCallback = std::function<void(int index)>;
-using SizeCallback = std::function<void(int width, int height)>;
+using IndexCallback = std::function<void(int32_t index)>;
+using SizeCallback = std::function<void(int32_t width, int32_t height)>;
 using KeyboardCallback = std::function<void(const KeyboardEvent& event)>;
 using KeyboardCallback = std::function<void(const KeyboardEvent& event)>;
 using MouseCallback = std::function<void(const MouseEvent& event)>;
 using MouseCallback = std::function<void(const MouseEvent& event)>;
 
 
 // The default functions to call until a callback has been selected.
 // The default functions to call until a callback has been selected.
 static EmptyCallback emptyCallback = []() {};
 static EmptyCallback emptyCallback = []() {};
 static IndexCallback indexCallback = [](int64_t index) {};
 static IndexCallback indexCallback = [](int64_t index) {};
-static SizeCallback sizeCallback = [](int width, int height) {};
+static SizeCallback sizeCallback = [](int32_t width, int32_t height) {};
 static KeyboardCallback keyboardCallback = [](const KeyboardEvent& event) {};
 static KeyboardCallback keyboardCallback = [](const KeyboardEvent& event) {};
 static MouseCallback mouseCallback = [](const MouseEvent& event) {};
 static MouseCallback mouseCallback = [](const MouseEvent& event) {};
 
 

+ 25 - 25
Source/DFPSR/implementation/gui/VisualComponent.cpp

@@ -33,7 +33,7 @@ VisualComponent::VisualComponent() {}
 VisualComponent::~VisualComponent() {
 VisualComponent::~VisualComponent() {
 	this->callback_destroyEvent();
 	this->callback_destroyEvent();
 	// Let the children know that the parent component no longer exists.
 	// Let the children know that the parent component no longer exists.
-	for (int i = 0; i < this->getChildCount(); i++) {
+	for (int32_t i = 0; i < this->getChildCount(); i++) {
 		this->children[i]->parent = nullptr;
 		this->children[i]->parent = nullptr;
 	}
 	}
 }
 }
@@ -140,14 +140,14 @@ String VisualComponent::getName() const {
 	return this->name.value;
 	return this->name.value;
 }
 }
 
 
-void VisualComponent::setIndex(int newIndex) {
+void VisualComponent::setIndex(int32_t newIndex) {
 	this->index.value = newIndex;
 	this->index.value = newIndex;
 	if (this->parent) {
 	if (this->parent) {
 		this->parent->childChanged = true;
 		this->parent->childChanged = true;
 	}
 	}
 }
 }
 
 
-int VisualComponent::getIndex() const {
+int32_t VisualComponent::getIndex() const {
 	return this->index.value;
 	return this->index.value;
 }
 }
 
 
@@ -171,7 +171,7 @@ void VisualComponent::applyLayout(const IRect& givenSpace) {
 
 
 void VisualComponent::updateLocationEvent(const IRect& oldLocation, const IRect& newLocation) {
 void VisualComponent::updateLocationEvent(const IRect& oldLocation, const IRect& newLocation) {
 	// Place each child component
 	// Place each child component
-	for (int i = 0; i < this->getChildCount(); i++) {
+	for (int32_t i = 0; i < this->getChildCount(); i++) {
 		this->children[i]->applyLayout(IRect(0, 0, newLocation.width(), newLocation.height()));
 		this->children[i]->applyLayout(IRect(0, 0, newLocation.width(), newLocation.height()));
 	}
 	}
 }
 }
@@ -196,7 +196,7 @@ static void drawOverlays(ImageRgbaU8& targetImage, VisualComponent &component, c
 			component.drawOverlay(targetImage, offset - component.location.upperLeft());
 			component.drawOverlay(targetImage, offset - component.location.upperLeft());
 		}
 		}
 		// Draw overlays in each child component on top.
 		// Draw overlays in each child component on top.
-		for (int i = 0; i < component.getChildCount(); i++) {
+		for (int32_t i = 0; i < component.getChildCount(); i++) {
 			drawOverlays(targetImage, component.children[i].getReference(), offset + component.children[i]->location.upperLeft());
 			drawOverlays(targetImage, component.children[i].getReference(), offset + component.children[i]->location.upperLeft());
 		}
 		}
 	}
 	}
@@ -205,7 +205,7 @@ static void drawOverlays(ImageRgbaU8& targetImage, VisualComponent &component, c
 void VisualComponent::flushDeferredActions() {
 void VisualComponent::flushDeferredActions() {
 	this->sendNotifications();
 	this->sendNotifications();
 	if (!this->managesChildren()) {
 	if (!this->managesChildren()) {
-		for (int i = 0; i < this->getChildCount(); i++) {
+		for (int32_t i = 0; i < this->getChildCount(); i++) {
 			this->children[i]->flushDeferredActions();
 			this->children[i]->flushDeferredActions();
 		}
 		}
 	}
 	}
@@ -224,7 +224,7 @@ void VisualComponent::draw(ImageRgbaU8& targetImage, const IVector2D& offset) {
 		this->drawSelf(targetImage, containerBound);
 		this->drawSelf(targetImage, containerBound);
 		// Draw each child component
 		// Draw each child component
 		if (!this->managesChildren()) {
 		if (!this->managesChildren()) {
-			for (int i = 0; i < this->getChildCount(); i++) {
+			for (int32_t i = 0; i < this->getChildCount(); i++) {
 				this->children[i]->drawClipped(targetImage, containerBound.upperLeft(), containerBound);
 				this->children[i]->drawClipped(targetImage, containerBound.upperLeft(), containerBound);
 			}
 			}
 		}
 		}
@@ -289,11 +289,11 @@ bool VisualComponent::addChild(Handle<Persistent> child) {
 	}
 	}
 }
 }
 
 
-int VisualComponent::getChildCount() const {
+int32_t VisualComponent::getChildCount() const {
 	return this->children.length();
 	return this->children.length();
 }
 }
 
 
-Handle<Persistent> VisualComponent::getChild(int index) const {
+Handle<Persistent> VisualComponent::getChild(int32_t index) const {
 	if (index >= 0 && index < this->children.length()) {
 	if (index >= 0 && index < this->children.length()) {
 		return this->children[index];
 		return this->children[index];
 	} else {
 	} else {
@@ -303,7 +303,7 @@ Handle<Persistent> VisualComponent::getChild(int index) const {
 
 
 static void detachFromWindow(Handle<VisualComponent> component) {
 static void detachFromWindow(Handle<VisualComponent> component) {
 	component->window = Handle<BackendWindow>();
 	component->window = Handle<BackendWindow>();
-	for (int c = 0; c < component->children.length(); c++) {
+	for (int32_t c = 0; c < component->children.length(); c++) {
 		detachFromWindow(component->children[c]);
 		detachFromWindow(component->children[c]);
 	}
 	}
 }
 }
@@ -314,7 +314,7 @@ void VisualComponent::detachFromParent() {
 	if (parent != nullptr) {
 	if (parent != nullptr) {
 		parent->childChanged = true;
 		parent->childChanged = true;
 		// Find the component to detach among the child components.
 		// Find the component to detach among the child components.
-		for (int i = 0; i < parent->getChildCount(); i++) {
+		for (int32_t i = 0; i < parent->getChildCount(); i++) {
 			Handle<VisualComponent> current = parent->children[i];
 			Handle<VisualComponent> current = parent->children[i];
 			if (current.getUnsafe() == this) {
 			if (current.getUnsafe() == this) {
 				// Disconnect child from backend window.
 				// Disconnect child from backend window.
@@ -334,7 +334,7 @@ void VisualComponent::detachFromParent() {
 }
 }
 
 
 bool VisualComponent::hasChild(VisualComponent *child) const {
 bool VisualComponent::hasChild(VisualComponent *child) const {
-	for (int i = 0; i < this->getChildCount(); i++) {
+	for (int32_t i = 0; i < this->getChildCount(); i++) {
 		Handle<VisualComponent> current = this->children[i];
 		Handle<VisualComponent> current = this->children[i];
 		if (current.getUnsafe() == child) {
 		if (current.getUnsafe() == child) {
 			return true; // Found the component
 			return true; // Found the component
@@ -352,7 +352,7 @@ bool VisualComponent::hasChild(Handle<VisualComponent> child) const {
 }
 }
 
 
 Handle<VisualComponent> VisualComponent::findChildByName(ReadableString name) const {
 Handle<VisualComponent> VisualComponent::findChildByName(ReadableString name) const {
-	for (int i = 0; i < this->getChildCount(); i++) {
+	for (int32_t i = 0; i < this->getChildCount(); i++) {
 		Handle<VisualComponent> current = this->children[i];
 		Handle<VisualComponent> current = this->children[i];
 		if (string_match(current->getName(), name)) {
 		if (string_match(current->getName(), name)) {
 			return current; // Found the component
 			return current; // Found the component
@@ -366,8 +366,8 @@ Handle<VisualComponent> VisualComponent::findChildByName(ReadableString name) co
 	return Handle<VisualComponent>(); // Could not find the component
 	return Handle<VisualComponent>(); // Could not find the component
 }
 }
 
 
-Handle<VisualComponent> VisualComponent::findChildByNameAndIndex(ReadableString name, int index) const {
-	for (int i = 0; i < this->getChildCount(); i++) {
+Handle<VisualComponent> VisualComponent::findChildByNameAndIndex(ReadableString name, int32_t index) const {
+	for (int32_t i = 0; i < this->getChildCount(); i++) {
 		Handle<VisualComponent> current = this->children[i];
 		Handle<VisualComponent> current = this->children[i];
 		if (string_match(current->getName(), name) && current->getIndex() == index) {
 		if (string_match(current->getName(), name) && current->getIndex() == index) {
 			return current; // Found the component
 			return current; // Found the component
@@ -397,7 +397,7 @@ bool VisualComponent::pointIsInsideOfHover(const IVector2D& pixelPosition) {
 // Non-recursive top-down search
 // Non-recursive top-down search
 Handle<VisualComponent> VisualComponent::getDirectChild(const IVector2D& pixelPosition) {
 Handle<VisualComponent> VisualComponent::getDirectChild(const IVector2D& pixelPosition) {
 	// Iterate child components in reverse drawing order
 	// Iterate child components in reverse drawing order
-	for (int i = this->getChildCount() - 1; i >= 0; i--) {
+	for (int32_t i = this->getChildCount() - 1; i >= 0; i--) {
 		Handle<VisualComponent> currentChild = this->children[i];
 		Handle<VisualComponent> currentChild = this->children[i];
 		// Check if the point is inside the child component
 		// Check if the point is inside the child component
 		if (currentChild->getVisible() && currentChild->pointIsInside(pixelPosition)) {
 		if (currentChild->getVisible() && currentChild->pointIsInside(pixelPosition)) {
@@ -422,7 +422,7 @@ void VisualComponent::updateStateEvent(ComponentState oldState, ComponentState n
 void VisualComponent::updateIndirectStates() {
 void VisualComponent::updateIndirectStates() {
 	// Call recursively for child components while checking what they contain.
 	// Call recursively for child components while checking what they contain.
 	ComponentState childStates = 0;
 	ComponentState childStates = 0;
-	for (int i = this->getChildCount() - 1; i >= 0; i--) {
+	for (int32_t i = this->getChildCount() - 1; i >= 0; i--) {
 		this->children[i]->updateIndirectStates();
 		this->children[i]->updateIndirectStates();
 		childStates |= this->children[i]->currentState;
 		childStates |= this->children[i]->currentState;
 	}
 	}
@@ -434,7 +434,7 @@ void VisualComponent::updateIndirectStates() {
 void VisualComponent::sendNotifications() {
 void VisualComponent::sendNotifications() {
 	// Call recursively for child components while checking what they contain.
 	// Call recursively for child components while checking what they contain.
 	//   Run the loop backwards, so that no components are missed when once is detached.
 	//   Run the loop backwards, so that no components are missed when once is detached.
-	for (int i = this->getChildCount() - 1; i >= 0; i--) {
+	for (int32_t i = this->getChildCount() - 1; i >= 0; i--) {
 		// Use a reference counted pointer to the child, so that it can be removed safely outside of custom events.
 		// Use a reference counted pointer to the child, so that it can be removed safely outside of custom events.
 		Handle<VisualComponent> child = this->children[i];
 		Handle<VisualComponent> child = this->children[i];
 		if (child->detach) {
 		if (child->detach) {
@@ -457,7 +457,7 @@ static VisualComponent *getTopmostOverlay(VisualComponent *component, const IVec
 	// Only visible component may show its overlay or child components.
 	// Only visible component may show its overlay or child components.
 	if (component->getVisible()) {
 	if (component->getVisible()) {
 		// Go through child components in reverse draw order to stop when reaching the one that is visible.
 		// Go through child components in reverse draw order to stop when reaching the one that is visible.
-		for (int i = component->getChildCount() - 1; i >= 0; i--) {
+		for (int32_t i = component->getChildCount() - 1; i >= 0; i--) {
 			VisualComponent *result = getTopmostOverlay(component->children[i].getUnsafe(), point - component->children[i]->location.upperLeft());
 			VisualComponent *result = getTopmostOverlay(component->children[i].getUnsafe(), point - component->children[i]->location.upperLeft());
 			if (result != nullptr) return result;
 			if (result != nullptr) return result;
 		}
 		}
@@ -485,7 +485,7 @@ static IVector2D getTotalOffset(const VisualComponent *child, const VisualCompon
 
 
 // Remove its pointer to its child and the whole trail of focus.
 // Remove its pointer to its child and the whole trail of focus.
 void VisualComponent::defocusChildren() {
 void VisualComponent::defocusChildren() {
-	for (int i = 0; i < this->getChildCount(); i++) {
+	for (int32_t i = 0; i < this->getChildCount(); i++) {
 		this->children[i]->applyStateAndMask(~componentState_focus);
 		this->children[i]->applyStateAndMask(~componentState_focus);
 	}
 	}
 }
 }
@@ -533,7 +533,7 @@ void VisualComponent::hideOverlay() {
 
 
 void VisualComponent::applyStateAndMask(ComponentState keepMask) {
 void VisualComponent::applyStateAndMask(ComponentState keepMask) {
 	this->currentState &= keepMask;
 	this->currentState &= keepMask;
-	for (int i = 0; i < this->getChildCount(); i++) {
+	for (int32_t i = 0; i < this->getChildCount(); i++) {
 		this->children[i]->applyStateAndMask(keepMask);
 		this->children[i]->applyStateAndMask(keepMask);
 	}
 	}
 }
 }
@@ -626,7 +626,7 @@ void VisualComponent::receiveMouseEvent(const MouseEvent& event) {
 }
 }
 
 
 void VisualComponent::sendKeyboardEvent(const KeyboardEvent& event) {
 void VisualComponent::sendKeyboardEvent(const KeyboardEvent& event) {
-	for (int i = 0; i < this->getChildCount(); i++) {
+	for (int32_t i = 0; i < this->getChildCount(); i++) {
 		ComponentState state = this->children[i]->currentState;
 		ComponentState state = this->children[i]->currentState;
 		if (state & componentState_focus) {
 		if (state & componentState_focus) {
 			if (state & componentState_focusDirect) {
 			if (state & componentState_focusDirect) {
@@ -656,7 +656,7 @@ void VisualComponent::receiveKeyboardEvent(const KeyboardEvent& event) {
 void VisualComponent::applyTheme(VisualTheme theme) {
 void VisualComponent::applyTheme(VisualTheme theme) {
 	this->theme = theme;
 	this->theme = theme;
 	this->changedTheme(theme);
 	this->changedTheme(theme);
-	for (int i = 0; i < this->getChildCount(); i++) {
+	for (int32_t i = 0; i < this->getChildCount(); i++) {
 		this->children[i]->applyTheme(theme);
 		this->children[i]->applyTheme(theme);
 	}
 	}
 }
 }
@@ -676,8 +676,8 @@ bool VisualComponent::managesChildren() {
 	return false;
 	return false;
 }
 }
 
 
-MediaResult dsr::component_generateImage(VisualTheme theme, MediaMethod &method, int width, int height, int red, int green, int blue, int pressed, int focused, int hovered) {
-	return method.callUsingKeywords([&theme, &method, width, height, red, green, blue, pressed, focused, hovered](MediaMachine &machine, int methodIndex, int inputIndex, const ReadableString &argumentName) {
+MediaResult dsr::component_generateImage(VisualTheme theme, MediaMethod &method, int32_t width, int32_t height, int32_t red, int32_t green, int32_t blue, int32_t pressed, int32_t focused, int32_t hovered) {
+	return method.callUsingKeywords([&theme, &method, width, height, red, green, blue, pressed, focused, hovered](MediaMachine &machine, int32_t methodIndex, int32_t inputIndex, const ReadableString &argumentName) {
 		if (string_caseInsensitiveMatch(argumentName, U"width")) {
 		if (string_caseInsensitiveMatch(argumentName, U"width")) {
 			machine_setInputByIndex(machine, methodIndex, inputIndex, width);
 			machine_setInputByIndex(machine, methodIndex, inputIndex, width);
 		} else if (string_caseInsensitiveMatch(argumentName, U"height")) {
 		} else if (string_caseInsensitiveMatch(argumentName, U"height")) {

+ 7 - 7
Source/DFPSR/implementation/gui/VisualComponent.h

@@ -36,7 +36,7 @@
 namespace dsr {
 namespace dsr {
 
 
 // A reusable method for calling the media machine that allow providing additional variables as style flags.
 // A reusable method for calling the media machine that allow providing additional variables as style flags.
-MediaResult component_generateImage(VisualTheme theme, MediaMethod &method, int width, int height, int red, int green, int blue, int pressed = 0, int focused = 0, int hovered = 0);
+MediaResult component_generateImage(VisualTheme theme, MediaMethod &method, int32_t width, int32_t height, int32_t red, int32_t green, int32_t blue, int32_t pressed = 0, int32_t focused = 0, int32_t hovered = 0);
 
 
 class VisualComponent : public Persistent {
 class VisualComponent : public Persistent {
 PERSISTENT_DECLARATION(VisualComponent)
 PERSISTENT_DECLARATION(VisualComponent)
@@ -52,7 +52,7 @@ public: // Relations
 	List<Handle<VisualComponent>> children;
 	List<Handle<VisualComponent>> children;
 	// Remember the component used for a drag event.
 	// Remember the component used for a drag event.
 	//   Ensures that mouse down events are followed by mouse up events on the same component.
 	//   Ensures that mouse down events are followed by mouse up events on the same component.
-	int holdCount = 0;
+	int32_t holdCount = 0;
 	// Marked for removal from the parent when set to true.
 	// Marked for removal from the parent when set to true.
 	bool detach = false;
 	bool detach = false;
 	// Applying deferred actions before drawing.
 	// Applying deferred actions before drawing.
@@ -136,8 +136,8 @@ public:
 	bool getVisible() const;
 	bool getVisible() const;
 	void setName(const String& newName);
 	void setName(const String& newName);
 	String getName() const;
 	String getName() const;
-	void setIndex(int index);
-	int getIndex() const;
+	void setIndex(int32_t index);
+	int32_t getIndex() const;
 public: // Internal events that component classes override to know when something has changed.
 public: // Internal events that component classes override to know when something has changed.
 	// Called after the component has been created, moved or resized.
 	// Called after the component has been created, moved or resized.
 	virtual void updateLocationEvent(const IRect& oldLocation, const IRect& newLocation);
 	virtual void updateLocationEvent(const IRect& oldLocation, const IRect& newLocation);
@@ -202,8 +202,8 @@ public:
 	// Called with any persistent type when constructing child components from text
 	// Called with any persistent type when constructing child components from text
 	bool addChild(Handle<Persistent> child) override;
 	bool addChild(Handle<Persistent> child) override;
 	// Called when saving to text
 	// Called when saving to text
-	int getChildCount() const override;
-	Handle<Persistent> getChild(int index) const override;
+	int32_t getChildCount() const override;
+	Handle<Persistent> getChild(int32_t index) const override;
 
 
 	// Returns true iff child is a member of the component
 	// Returns true iff child is a member of the component
 	//   Searches recursively
 	//   Searches recursively
@@ -213,7 +213,7 @@ public:
 	// Find the first child component with the requested name using a case sensitive match.
 	// Find the first child component with the requested name using a case sensitive match.
 	//   Returns: A shared pointer to the child or null if not found.
 	//   Returns: A shared pointer to the child or null if not found.
 	Handle<VisualComponent> findChildByName(ReadableString name) const;
 	Handle<VisualComponent> findChildByName(ReadableString name) const;
-	Handle<VisualComponent> findChildByNameAndIndex(ReadableString name, int index) const;
+	Handle<VisualComponent> findChildByNameAndIndex(ReadableString name, int32_t index) const;
 	// Detach the component from any parent
 	// Detach the component from any parent
 	void detachFromParent();
 	void detachFromParent();
 
 

+ 19 - 19
Source/DFPSR/implementation/gui/VisualTheme.cpp

@@ -244,7 +244,7 @@ struct KeywordEntry {
 	MACRO_NAME(LOCATION strings)
 	MACRO_NAME(LOCATION strings)
 
 
 #define RETURN_TRUE_IF_SETTING_EXISTS(COLLECTION) \
 #define RETURN_TRUE_IF_SETTING_EXISTS(COLLECTION) \
-	for (int i = 0; i < COLLECTION.length(); i++) { \
+	for (int32_t i = 0; i < COLLECTION.length(); i++) { \
 		if (string_caseInsensitiveMatch(COLLECTION[i].key, key)) { \
 		if (string_caseInsensitiveMatch(COLLECTION[i].key, key)) { \
 			return true; \
 			return true; \
 		} \
 		} \
@@ -283,7 +283,7 @@ struct ClassSettings {
 	// Post-condition: Returns true iff the key was found for the expected type.
 	// Post-condition: Returns true iff the key was found for the expected type.
 	// Side-effect: Writes the value of the found key iff found.
 	// Side-effect: Writes the value of the found key iff found.
 	bool getString(String &target, const ReadableString &key) {
 	bool getString(String &target, const ReadableString &key) {
-		for (int i = 0; i < this->strings.length(); i++) {
+		for (int32_t i = 0; i < this->strings.length(); i++) {
 			if (string_caseInsensitiveMatch(this->strings[i].key, key)) {
 			if (string_caseInsensitiveMatch(this->strings[i].key, key)) {
 				target = this->strings[i].value;
 				target = this->strings[i].value;
 				return true;
 				return true;
@@ -294,7 +294,7 @@ struct ClassSettings {
 	// Post-condition: Returns true iff the key was found for the expected type.
 	// Post-condition: Returns true iff the key was found for the expected type.
 	// Side-effect: Writes the value of the found key iff found.
 	// Side-effect: Writes the value of the found key iff found.
 	bool getImage(PersistentImage &target, const ReadableString &key) {
 	bool getImage(PersistentImage &target, const ReadableString &key) {
-		for (int i = 0; i < this->colorImages.length(); i++) {
+		for (int32_t i = 0; i < this->colorImages.length(); i++) {
 			if (string_caseInsensitiveMatch(this->colorImages[i].key, key)) {
 			if (string_caseInsensitiveMatch(this->colorImages[i].key, key)) {
 				target = this->colorImages[i].value;
 				target = this->colorImages[i].value;
 				return true;
 				return true;
@@ -305,7 +305,7 @@ struct ClassSettings {
 	// Post-condition: Returns true iff the key was found for the expected type.
 	// Post-condition: Returns true iff the key was found for the expected type.
 	// Side-effect: Writes the value of the found key iff found.
 	// Side-effect: Writes the value of the found key iff found.
 	bool getScalar(FixedPoint &target, const ReadableString &key) {
 	bool getScalar(FixedPoint &target, const ReadableString &key) {
-		for (int i = 0; i < this->scalars.length(); i++) {
+		for (int32_t i = 0; i < this->scalars.length(); i++) {
 			if (string_caseInsensitiveMatch(this->scalars[i].key, key)) {
 			if (string_caseInsensitiveMatch(this->scalars[i].key, key)) {
 				target = this->scalars[i].value;
 				target = this->scalars[i].value;
 				return true;
 				return true;
@@ -320,14 +320,14 @@ class VisualThemeImpl {
 public:
 public:
 	MediaMachine machine;
 	MediaMachine machine;
 	List<ClassSettings> settings;
 	List<ClassSettings> settings;
-	int getClassIndex(const ReadableString& className) {
-		for (int i = 0; i < this->settings.length(); i++) { if (string_caseInsensitiveMatch(this->settings[i].className, className)) { return i; } }
+	int32_t getClassIndex(const ReadableString& className) {
+		for (int32_t i = 0; i < this->settings.length(); i++) { if (string_caseInsensitiveMatch(this->settings[i].className, className)) { return i; } }
 		return settings.pushConstructGetIndex(className);
 		return settings.pushConstructGetIndex(className);
 	}
 	}
 	VisualThemeImpl(const MediaMachine &machine, const ReadableString &styleSettings, const ReadableString &fromPath) : machine(machine) {
 	VisualThemeImpl(const MediaMachine &machine, const ReadableString &styleSettings, const ReadableString &fromPath) : machine(machine) {
 		this->settings.pushConstruct(U"default");
 		this->settings.pushConstruct(U"default");
 		config_parse_ini(styleSettings, [this, fromPath](const ReadableString& block, const ReadableString& key, const ReadableString& value) {
 		config_parse_ini(styleSettings, [this, fromPath](const ReadableString& block, const ReadableString& key, const ReadableString& value) {
-			int classIndex = (string_length(block) == 0) ? 0 : this->getClassIndex(block);
+			int32_t classIndex = (string_length(block) == 0) ? 0 : this->getClassIndex(block);
 			this->settings[classIndex].setVariable(key, value, fromPath);
 			this->settings[classIndex].setVariable(key, value, fromPath);
 		});
 		});
 	}
 	}
@@ -355,13 +355,13 @@ bool theme_exists(const VisualTheme &theme) {
 	return theme.isNotNull();
 	return theme.isNotNull();
 }
 }
 
 
-int theme_getClassIndex(const VisualTheme &theme, const ReadableString &className) {
+int32_t theme_getClassIndex(const VisualTheme &theme, const ReadableString &className) {
 	if (!theme_exists(theme)) {
 	if (!theme_exists(theme)) {
 		return -1;
 		return -1;
 	} else if (string_length(className) == 0) {
 	} else if (string_length(className) == 0) {
 		return 0;
 		return 0;
 	} else {
 	} else {
-		int classIndex = theme->getClassIndex(className);
+		int32_t classIndex = theme->getClassIndex(className);
 		return (classIndex == -1) ? 0 : classIndex;
 		return (classIndex == -1) ? 0 : classIndex;
 	}
 	}
 }
 }
@@ -378,7 +378,7 @@ OrderedImageRgbaU8 theme_getImage(const VisualTheme &theme, const ReadableString
 	if (!theme.getUnsafe()) {
 	if (!theme.getUnsafe()) {
 		return OrderedImageRgbaU8();
 		return OrderedImageRgbaU8();
 	}
 	}
-	int classIndex = theme->getClassIndex(className);
+	int32_t classIndex = theme->getClassIndex(className);
 	PersistentImage result;
 	PersistentImage result;
 	if ((classIndex != -1 && theme->settings[classIndex].getImage(result, settingName))
 	if ((classIndex != -1 && theme->settings[classIndex].getImage(result, settingName))
 	                     || (theme->settings[0].getImage(result, settingName))) {
 	                     || (theme->settings[0].getImage(result, settingName))) {
@@ -393,7 +393,7 @@ FixedPoint theme_getFixedPoint(const VisualTheme &theme, const ReadableString &c
 	if (!theme.getUnsafe()) {
 	if (!theme.getUnsafe()) {
 		return defaultValue;
 		return defaultValue;
 	}
 	}
-	int classIndex = theme->getClassIndex(className);
+	int32_t classIndex = theme->getClassIndex(className);
 	FixedPoint result;
 	FixedPoint result;
 	if ((classIndex != -1 && theme->settings[classIndex].getScalar(result, settingName))
 	if ((classIndex != -1 && theme->settings[classIndex].getScalar(result, settingName))
 	                     || (theme->settings[0].getScalar(result, settingName))) {
 	                     || (theme->settings[0].getScalar(result, settingName))) {
@@ -404,7 +404,7 @@ FixedPoint theme_getFixedPoint(const VisualTheme &theme, const ReadableString &c
 	}
 	}
 }
 }
 
 
-int theme_getInteger(const VisualTheme &theme, const ReadableString &className, const ReadableString &settingName, const int &defaultValue) {
+int32_t theme_getInteger(const VisualTheme &theme, const ReadableString &className, const ReadableString &settingName, const int32_t &defaultValue) {
 	return fixedPoint_round(theme_getFixedPoint(theme, className, settingName, FixedPoint::fromWhole(defaultValue)));
 	return fixedPoint_round(theme_getFixedPoint(theme, className, settingName, FixedPoint::fromWhole(defaultValue)));
 }
 }
 
 
@@ -412,7 +412,7 @@ ReadableString theme_getString(const VisualTheme &theme, const ReadableString &c
 	if (!theme.getUnsafe()) {
 	if (!theme.getUnsafe()) {
 		return defaultValue;
 		return defaultValue;
 	}
 	}
-	int classIndex = theme->getClassIndex(className);
+	int32_t classIndex = theme->getClassIndex(className);
 	String result;
 	String result;
 	if ((classIndex != -1 && theme->settings[classIndex].getString(result, settingName))
 	if ((classIndex != -1 && theme->settings[classIndex].getString(result, settingName))
 	                     || (theme->settings[0].getString(result, settingName))) {
 	                     || (theme->settings[0].getString(result, settingName))) {
@@ -427,7 +427,7 @@ MediaMethod theme_getScalableImage(const VisualTheme &theme, const ReadableStrin
 	if (!theme.getUnsafe()) {
 	if (!theme.getUnsafe()) {
 		throwError(U"theme_getScalableImage: Can't get scalable image of class ", className, U" from a non-existing theme!\n");
 		throwError(U"theme_getScalableImage: Can't get scalable image of class ", className, U" from a non-existing theme!\n");
 	}
 	}
-	int classIndex = theme->getClassIndex(className);
+	int32_t classIndex = theme->getClassIndex(className);
 	String methodName;
 	String methodName;
 	if ((classIndex != -1 && theme->settings[classIndex].getString(methodName, U"method"))
 	if ((classIndex != -1 && theme->settings[classIndex].getString(methodName, U"method"))
 	                     || (theme->settings[0].getString(methodName, U"method"))) {
 	                     || (theme->settings[0].getString(methodName, U"method"))) {
@@ -439,16 +439,16 @@ MediaMethod theme_getScalableImage(const VisualTheme &theme, const ReadableStrin
 	}
 	}
 }
 }
 
 
-static bool assignMediaMachineArguments(ClassSettings settings, MediaMachine &machine, int methodIndex, int inputIndex, const ReadableString &argumentName) {
+static bool assignMediaMachineArguments(ClassSettings settings, MediaMachine &machine, int32_t methodIndex, int32_t inputIndex, const ReadableString &argumentName) {
 	// Search for argumentName in colorImages.
 	// Search for argumentName in colorImages.
-	for (int i = 0; i < settings.colorImages.length(); i++) {
+	for (int32_t i = 0; i < settings.colorImages.length(); i++) {
 		if (string_caseInsensitiveMatch(settings.colorImages[i].key, argumentName)) {
 		if (string_caseInsensitiveMatch(settings.colorImages[i].key, argumentName)) {
 			machine_setInputByIndex(machine, methodIndex, inputIndex, settings.colorImages[i].value.value);
 			machine_setInputByIndex(machine, methodIndex, inputIndex, settings.colorImages[i].value.value);
 			return true;
 			return true;
 		}
 		}
 	}
 	}
 	// Search for argumentName in scalars.
 	// Search for argumentName in scalars.
-	for (int i = 0; i < settings.scalars.length(); i++) {
+	for (int32_t i = 0; i < settings.scalars.length(); i++) {
 		if (string_caseInsensitiveMatch(settings.scalars[i].key, argumentName)) {
 		if (string_caseInsensitiveMatch(settings.scalars[i].key, argumentName)) {
 			machine_setInputByIndex(machine, methodIndex, inputIndex, settings.scalars[i].value);
 			machine_setInputByIndex(machine, methodIndex, inputIndex, settings.scalars[i].value);
 			return true;
 			return true;
@@ -458,7 +458,7 @@ static bool assignMediaMachineArguments(ClassSettings settings, MediaMachine &ma
 	return false;
 	return false;
 }
 }
 
 
-bool theme_assignMediaMachineArguments(const VisualTheme &theme, int contextIndex, MediaMachine &machine, int methodIndex, int inputIndex, const ReadableString &argumentName) {
+bool theme_assignMediaMachineArguments(const VisualTheme &theme, int32_t contextIndex, MediaMachine &machine, int32_t methodIndex, int32_t inputIndex, const ReadableString &argumentName) {
 	if (!theme.getUnsafe()) { return false; }
 	if (!theme.getUnsafe()) { return false; }
 	// Check in the context first, and then in the default settings.
 	// Check in the context first, and then in the default settings.
 	return (contextIndex > 0 && assignMediaMachineArguments(theme->settings[contextIndex], machine, methodIndex, inputIndex, argumentName))
 	return (contextIndex > 0 && assignMediaMachineArguments(theme->settings[contextIndex], machine, methodIndex, inputIndex, argumentName))
@@ -467,7 +467,7 @@ bool theme_assignMediaMachineArguments(const VisualTheme &theme, int contextInde
 
 
 ComponentState theme_getStateListenerMask(const MediaMethod &scalableImage) {
 ComponentState theme_getStateListenerMask(const MediaMethod &scalableImage) {
 	ComponentState result = 0;
 	ComponentState result = 0;
-	for (int inputIndex = 0; inputIndex < machine_getInputCount(scalableImage.machine, scalableImage.methodIndex); inputIndex++) {
+	for (int32_t inputIndex = 0; inputIndex < machine_getInputCount(scalableImage.machine, scalableImage.methodIndex); inputIndex++) {
 		String upperInputName = string_upperCase(machine_getInputName(scalableImage.machine, scalableImage.methodIndex, inputIndex));
 		String upperInputName = string_upperCase(machine_getInputName(scalableImage.machine, scalableImage.methodIndex, inputIndex));
 		if (string_match(upperInputName, U"FOCUSED")) {
 		if (string_match(upperInputName, U"FOCUSED")) {
 			result |= componentState_focusDirect;
 			result |= componentState_focusDirect;

+ 3 - 3
Source/DFPSR/implementation/gui/VisualTheme.h

@@ -60,7 +60,7 @@ VisualTheme theme_getDefault();
 // Returns true iff theme exists, otherwise false.
 // Returns true iff theme exists, otherwise false.
 bool theme_exists(const VisualTheme &theme);
 bool theme_exists(const VisualTheme &theme);
 // Returns the index of className in theme, 0 if it did not exist in theme or -1 if theme does not exist.
 // Returns the index of className in theme, 0 if it did not exist in theme or -1 if theme does not exist.
-int theme_getClassIndex(const VisualTheme &theme, const ReadableString &className);
+int32_t theme_getClassIndex(const VisualTheme &theme, const ReadableString &className);
 // Returns true iff className exists in theme.
 // Returns true iff className exists in theme.
 bool theme_class_exists(const VisualTheme &theme, const ReadableString &className);
 bool theme_class_exists(const VisualTheme &theme, const ReadableString &className);
 // Returns suggestedClassName if it exists in theme, fallbackClassName otherwise.
 // Returns suggestedClassName if it exists in theme, fallbackClassName otherwise.
@@ -88,7 +88,7 @@ OrderedImageRgbaU8 theme_getImage(const VisualTheme &theme, const ReadableString
 //   Use theme_getClassIndex if you are unsure of why defaultValue was returned, because it will not throw exceptions.
 //   Use theme_getClassIndex if you are unsure of why defaultValue was returned, because it will not throw exceptions.
 FixedPoint theme_getFixedPoint(const VisualTheme &theme, const ReadableString &className, const ReadableString &settingName, const FixedPoint &defaultValue);
 FixedPoint theme_getFixedPoint(const VisualTheme &theme, const ReadableString &className, const ReadableString &settingName, const FixedPoint &defaultValue);
 // Get FixedPoint and truncate to an integer, which should leave 16 bits of useful range.
 // Get FixedPoint and truncate to an integer, which should leave 16 bits of useful range.
-int theme_getInteger(const VisualTheme &theme, const ReadableString &className, const ReadableString &settingName, const int &defaultValue);
+int32_t theme_getInteger(const VisualTheme &theme, const ReadableString &className, const ReadableString &settingName, const int32_t &defaultValue);
 // Get a string from className in theme using settingName, the default value if not found, or throw an exception if theme does not exist.
 // Get a string from className in theme using settingName, the default value if not found, or throw an exception if theme does not exist.
 //   Looks for string assignments to settingName after [className] first, then before the first [] block, and then returns defaultValue if not found at all.
 //   Looks for string assignments to settingName after [className] first, then before the first [] block, and then returns defaultValue if not found at all.
 //   The matches for className and settingName are both case insensitive.
 //   The matches for className and settingName are both case insensitive.
@@ -97,7 +97,7 @@ ReadableString theme_getString(const VisualTheme &theme, const ReadableString &c
 
 
 // Called by VisualComponent to assign input arguments to functions in the media machine that were not given by the component itself.
 // Called by VisualComponent to assign input arguments to functions in the media machine that were not given by the component itself.
 // Post-condition: Returns true if argumentName was identified and assigned as input to inputIndex of methodIndex in machine.
 // Post-condition: Returns true if argumentName was identified and assigned as input to inputIndex of methodIndex in machine.
-bool theme_assignMediaMachineArguments(const VisualTheme &theme, int contextIndex, MediaMachine &machine, int methodIndex, int inputIndex, const ReadableString &argumentName);
+bool theme_assignMediaMachineArguments(const VisualTheme &theme, int32_t contextIndex, MediaMachine &machine, int32_t methodIndex, int32_t inputIndex, const ReadableString &argumentName);
 
 
 // Post-condition:
 // Post-condition:
 //   Returns a bit-mask for the direct states that have corresponding input arguments in the method.
 //   Returns a bit-mask for the direct states that have corresponding input arguments in the method.

+ 6 - 6
Source/DFPSR/implementation/gui/components/Button.cpp

@@ -60,13 +60,13 @@ bool Button::isContainer() const {
 	return false;
 	return false;
 }
 }
 
 
-static OrderedImageRgbaU8 generateButtonImage(Button &button, MediaMethod imageGenerator, int pressed, int width, int height, ColorRgbI32 backColor, ColorRgbI32 foreColor, const ReadableString &text, RasterFont font) {
+static OrderedImageRgbaU8 generateButtonImage(Button &button, MediaMethod imageGenerator, int32_t pressed, int32_t width, int32_t height, ColorRgbI32 backColor, ColorRgbI32 foreColor, const ReadableString &text, RasterFont font) {
 	// Create a scaled image
 	// Create a scaled image
 	OrderedImageRgbaU8 result;
 	OrderedImageRgbaU8 result;
  	component_generateImage(button.getTheme(), imageGenerator, width, height, backColor.red, backColor.green, backColor.blue, pressed)(result);
  	component_generateImage(button.getTheme(), imageGenerator, width, height, backColor.red, backColor.green, backColor.blue, pressed)(result);
 	if (string_length(text) > 0) {
 	if (string_length(text) > 0) {
-		int left = (image_getWidth(result) - font_getLineWidth(font, text)) / 2;
-		int top = (image_getHeight(result) - font_getSize(font)) / 2;
+		int32_t left = (image_getWidth(result) - font_getLineWidth(font, text)) / 2;
+		int32_t top = (image_getHeight(result) - font_getSize(font)) / 2;
 		if (pressed) {
 		if (pressed) {
 			top += 1;
 			top += 1;
 		}
 		}
@@ -76,8 +76,8 @@ static OrderedImageRgbaU8 generateButtonImage(Button &button, MediaMethod imageG
 }
 }
 
 
 void Button::generateGraphics() {
 void Button::generateGraphics() {
-	int width = this->location.width();
-	int height = this->location.height();
+	int32_t width = this->location.width();
+	int32_t height = this->location.height();
 	if (width < 1) { width = 1; }
 	if (width < 1) { width = 1; }
 	if (height < 1) { height = 1; }
 	if (height < 1) { height = 1; }
 	if (!this->hasImages) {
 	if (!this->hasImages) {
@@ -157,6 +157,6 @@ void Button::changedAttribute(const ReadableString &name) {
 
 
 IVector2D Button::getDesiredDimensions() {
 IVector2D Button::getDesiredDimensions() {
 	this->completeAssets();
 	this->completeAssets();
-	int sizeAdder = this->padding.value * 2;
+	int32_t sizeAdder = this->padding.value * 2;
 	return IVector2D(font_getLineWidth(this->font, this->text.value) + sizeAdder, font_getSize(this->font) + sizeAdder);
 	return IVector2D(font_getLineWidth(this->font, this->text.value) + sizeAdder, font_getSize(this->font) + sizeAdder);
 }
 }

+ 1 - 1
Source/DFPSR/implementation/gui/components/Button.h

@@ -54,7 +54,7 @@ private:
 	void generateGraphics();
 	void generateGraphics();
 	// Settings fetched from the theme
 	// Settings fetched from the theme
 	String finalBackgroundClass; // The selected BackgroundClass/Class from layout settings or the component's default theme class "Button".
 	String finalBackgroundClass; // The selected BackgroundClass/Class from layout settings or the component's default theme class "Button".
-	int background_filter = 0; // 0 for solid, 1 for alpha filter.
+	int32_t background_filter = 0; // 0 for solid, 1 for alpha filter.
 	// Generated
 	// Generated
 	bool hasImages = false;
 	bool hasImages = false;
 	OrderedImageRgbaU8 imageUp;
 	OrderedImageRgbaU8 imageUp;

+ 1 - 1
Source/DFPSR/implementation/gui/components/Label.cpp

@@ -80,6 +80,6 @@ void Label::completeAssets() {
 
 
 IVector2D Label::getDesiredDimensions() {
 IVector2D Label::getDesiredDimensions() {
 	this->completeAssets();
 	this->completeAssets();
-	int sizeAdder = this->padding.value * 2;
+	int32_t sizeAdder = this->padding.value * 2;
 	return IVector2D(font_getLineWidth(this->font, this->text.value) + sizeAdder, font_getSize(this->font) + sizeAdder);
 	return IVector2D(font_getLineWidth(this->font, this->text.value) + sizeAdder, font_getSize(this->font) + sizeAdder);
 }
 }

+ 2 - 2
Source/DFPSR/implementation/gui/components/ListBox.cpp

@@ -61,8 +61,8 @@ bool ListBox::isContainer() const {
 	return false;
 	return false;
 }
 }
 
 
-static const int textBorderLeft = 6;
-static const int textBorderTop = 4;
+static const int32_t textBorderLeft = 6;
+static const int32_t textBorderTop = 4;
 
 
 void ListBox::generateGraphics() {
 void ListBox::generateGraphics() {
 	int32_t width = this->location.width();
 	int32_t width = this->location.width();

+ 1 - 1
Source/DFPSR/implementation/gui/components/ListBox.h

@@ -57,7 +57,7 @@ private:
 	void generateGraphics();
 	void generateGraphics();
 	// Settings fetched from the theme
 	// Settings fetched from the theme
 	String finalBackgroundClass; // The selected BackgroundClass/Class from layout settings or the component's default theme class "ListBox".
 	String finalBackgroundClass; // The selected BackgroundClass/Class from layout settings or the component's default theme class "ListBox".
-	int background_filter = 0; // 0 for solid, 1 for alpha filter.
+	int32_t background_filter = 0; // 0 for solid, 1 for alpha filter.
 	// Generated
 	// Generated
 	bool hasImages = false;
 	bool hasImages = false;
 	OrderedImageRgbaU8 image;
 	OrderedImageRgbaU8 image;

+ 28 - 28
Source/DFPSR/implementation/gui/components/Menu.cpp

@@ -79,15 +79,15 @@ bool Menu::hasArrow() {
 	return this->subMenu && this->getChildCount() > 0;
 	return this->subMenu && this->getChildCount() > 0;
 }
 }
 
 
-static OrderedImageRgbaU8 generateHeadImage(Menu &menu, MediaMethod imageGenerator, int pressed, int focused, int hover, int width, int height, ColorRgbI32 backColor, ColorRgbI32 foreColor, const ReadableString &text, RasterFont font) {
+static OrderedImageRgbaU8 generateHeadImage(Menu &menu, MediaMethod imageGenerator, int32_t pressed, int32_t focused, int32_t hover, int32_t width, int32_t height, ColorRgbI32 backColor, ColorRgbI32 foreColor, const ReadableString &text, RasterFont font) {
 	// Create a scaled image
 	// Create a scaled image
 	OrderedImageRgbaU8 result;
 	OrderedImageRgbaU8 result;
  	component_generateImage(menu.getTheme(), imageGenerator, width, height, backColor.red, backColor.green, backColor.blue, pressed, focused, hover)(result);
  	component_generateImage(menu.getTheme(), imageGenerator, width, height, backColor.red, backColor.green, backColor.blue, pressed, focused, hover)(result);
 	if (string_length(text) > 0) {
 	if (string_length(text) > 0) {
-		int backWidth = image_getWidth(result);
-		int backHeight = image_getHeight(result);
-		int left = menu.padding.value;
-		int top = (backHeight - font_getSize(font)) / 2;
+		int32_t backWidth = image_getWidth(result);
+		int32_t backHeight = image_getHeight(result);
+		int32_t left = menu.padding.value;
+		int32_t top = (backHeight - font_getSize(font)) / 2;
 		if (pressed) {
 		if (pressed) {
 			top += 1;
 			top += 1;
 		}
 		}
@@ -95,10 +95,10 @@ static OrderedImageRgbaU8 generateHeadImage(Menu &menu, MediaMethod imageGenerat
 		font_printLine(result, font, text, IVector2D(left, top), ColorRgbaI32(foreColor, 255));
 		font_printLine(result, font, text, IVector2D(left, top), ColorRgbaI32(foreColor, 255));
 		// Draw the arrow
 		// Draw the arrow
 		if (menu.hasArrow()) {
 		if (menu.hasArrow()) {
-			int arrowWidth = image_getWidth(arrowImage);
-			int arrowHeight = image_getHeight(arrowImage);
-			int arrowLeft = backWidth - arrowWidth - 4;
-			int arrowTop = (backHeight - arrowHeight) / 2;
+			int32_t arrowWidth = image_getWidth(arrowImage);
+			int32_t arrowHeight = image_getHeight(arrowImage);
+			int32_t arrowLeft = backWidth - arrowWidth - 4;
+			int32_t arrowTop = (backHeight - arrowHeight) / 2;
 			draw_silhouette(result, arrowImage, ColorRgbaI32(foreColor, 255), arrowLeft, arrowTop);
 			draw_silhouette(result, arrowImage, ColorRgbaI32(foreColor, 255), arrowLeft, arrowTop);
 		}
 		}
 	}
 	}
@@ -106,8 +106,8 @@ static OrderedImageRgbaU8 generateHeadImage(Menu &menu, MediaMethod imageGenerat
 }
 }
 
 
 void Menu::generateGraphics() {
 void Menu::generateGraphics() {
-	int headWidth = this->location.width();
-	int headHeight = this->location.height();
+	int32_t headWidth = this->location.width();
+	int32_t headHeight = this->location.height();
 	if (headWidth < 1) { headWidth = 1; }
 	if (headWidth < 1) { headWidth = 1; }
 	if (headHeight < 1) { headHeight = 1; }
 	if (headHeight < 1) { headHeight = 1; }
 	// headImage is set to an empty handle when something used as input changes.
 	// headImage is set to an empty handle when something used as input changes.
@@ -132,8 +132,8 @@ void Menu::drawSelf(ImageRgbaU8& targetImage, const IRect &relativeLocation) {
 
 
 void Menu::generateBackground() {
 void Menu::generateBackground() {
 	if (!image_exists(this->listBackgroundImage)) {
 	if (!image_exists(this->listBackgroundImage)) {
-		int listWidth = this->overlayLocation.width();
-		int listHeight = this->overlayLocation.height();
+		int32_t listWidth = this->overlayLocation.width();
+		int32_t listHeight = this->overlayLocation.height();
 		if (listWidth < 1) { listWidth = 1; }
 		if (listWidth < 1) { listWidth = 1; }
 		if (listHeight < 1) { listHeight = 1; }
 		if (listHeight < 1) { listHeight = 1; }
 		component_generateImage(this->theme, this->listBackgroundImageMethod, listWidth, listHeight, this->backColor.value.red, this->backColor.value.green, this->backColor.value.blue)(this->listBackgroundImage);
 		component_generateImage(this->theme, this->listBackgroundImageMethod, listWidth, listHeight, this->backColor.value.red, this->backColor.value.green, this->backColor.value.blue)(this->listBackgroundImage);
@@ -145,7 +145,7 @@ void Menu::createOverlay() {
 		this->showOverlay();
 		this->showOverlay();
 		this->makeFocused(); // Focus on the current menu path to make others lose focus.
 		this->makeFocused(); // Focus on the current menu path to make others lose focus.
 		IRect memberBound = this->children[0]->location;
 		IRect memberBound = this->children[0]->location;
-		for (int i = 1; i < this->getChildCount(); i++) {
+		for (int32_t i = 1; i < this->getChildCount(); i++) {
 			memberBound = IRect::merge(memberBound, this->children[i]->location);
 			memberBound = IRect::merge(memberBound, this->children[i]->location);
 		}
 		}
 		// Calculate the new list bound.
 		// Calculate the new list bound.
@@ -169,7 +169,7 @@ void Menu::drawOverlay(ImageRgbaU8& targetImage, const IVector2D &absoluteOffset
 	} else {
 	} else {
 		draw_copy(targetImage, this->listBackgroundImage, overlayOffset.x, overlayOffset.y);
 		draw_copy(targetImage, this->listBackgroundImage, overlayOffset.x, overlayOffset.y);
 	}
 	}
-	for (int i = 0; i < this->getChildCount(); i++) {
+	for (int32_t i = 0; i < this->getChildCount(); i++) {
 		this->children[i]->draw(targetImage, absoluteOffset + this->location.upperLeft());
 		this->children[i]->draw(targetImage, absoluteOffset + this->location.upperLeft());
 	}
 	}
 }
 }
@@ -251,23 +251,23 @@ void Menu::updateStateEvent(ComponentState oldState, ComponentState newState) {
 }
 }
 
 
 void Menu::updateLocationEvent(const IRect& oldLocation, const IRect& newLocation) {	
 void Menu::updateLocationEvent(const IRect& oldLocation, const IRect& newLocation) {	
-	int left = this->padding.value;
-	int top = this->padding.value;
-	int overlap = 3;
+	int32_t left = this->padding.value;
+	int32_t top = this->padding.value;
+	int32_t overlap = 3;
 	if (this->subMenu) {
 	if (this->subMenu) {
 		left += newLocation.width() - overlap;
 		left += newLocation.width() - overlap;
 	} else {
 	} else {
 		top += newLocation.height() - overlap;
 		top += newLocation.height() - overlap;
 	}
 	}
-	int maxWidth = 80; // Minimum usable with.
+	int32_t maxWidth = 80; // Minimum usable with.
 	// Expand list with to fit child components.
 	// Expand list with to fit child components.
-	for (int i = 0; i < this->getChildCount(); i++) {
-		int width = this->children[i]->getDesiredDimensions().x;
+	for (int32_t i = 0; i < this->getChildCount(); i++) {
+		int32_t width = this->children[i]->getDesiredDimensions().x;
 		if (maxWidth < width) maxWidth = width;
 		if (maxWidth < width) maxWidth = width;
 	}
 	}
 	// Stretch out the child components to use the whole width.
 	// Stretch out the child components to use the whole width.
-	for (int i = 0; i < this->getChildCount(); i++) {
-		int height = this->children[i]->getDesiredDimensions().y;
+	for (int32_t i = 0; i < this->getChildCount(); i++) {
+		int32_t height = this->children[i]->getDesiredDimensions().y;
 		this->children[i]->applyLayout(IRect(left, top, maxWidth, height));
 		this->children[i]->applyLayout(IRect(left, top, maxWidth, height));
 		top += height + this->spacing.value;
 		top += height + this->spacing.value;
 	}
 	}
@@ -283,7 +283,7 @@ static void closeEntireMenu(VisualComponent* menu) {
 }
 }
 
 
 void Menu::receiveMouseEvent(const MouseEvent& event) {
 void Menu::receiveMouseEvent(const MouseEvent& event) {
-	int childCount = this->getChildCount();
+	int32_t childCount = this->getChildCount();
 	MouseEvent localEvent = event;
 	MouseEvent localEvent = event;
 	localEvent.position -= this->location.upperLeft();
 	localEvent.position -= this->location.upperLeft();
 	bool inOverlay = this->showingOverlay() && this->pointIsInsideOfOverlay(event.position);
 	bool inOverlay = this->showingOverlay() && this->pointIsInsideOfOverlay(event.position);
@@ -297,7 +297,7 @@ void Menu::receiveMouseEvent(const MouseEvent& event) {
 		}
 		}
 	} else if (inOverlay) {
 	} else if (inOverlay) {
 		// Pass on down and move events to a child component that the cursor is inside of.
 		// Pass on down and move events to a child component that the cursor is inside of.
-		for (int i = childCount - 1; i >= 0; i--) {
+		for (int32_t i = childCount - 1; i >= 0; i--) {
 			if (this->children[i]->pointIsInside(localEvent.position)) {
 			if (this->children[i]->pointIsInside(localEvent.position)) {
 				MouseEvent childEvent = localEvent;
 				MouseEvent childEvent = localEvent;
 				childEvent.position -= this->children[i]->location.upperLeft();
 				childEvent.position -= this->children[i]->location.upperLeft();
@@ -328,7 +328,7 @@ void Menu::receiveMouseEvent(const MouseEvent& event) {
 					if (this->parent != nullptr) {
 					if (this->parent != nullptr) {
 						VisualComponent *toolbar = this->parent;
 						VisualComponent *toolbar = this->parent;
 						if (toolbar->ownsFocus()) {
 						if (toolbar->ownsFocus()) {
-							for (int i = 0; i < toolbar->getChildCount(); i++) {
+							for (int32_t i = 0; i < toolbar->getChildCount(); i++) {
 								if (toolbar->children[i]->showingOverlay()) {
 								if (toolbar->children[i]->showingOverlay()) {
 									toggleExpansion = true;
 									toggleExpansion = true;
 									break;
 									break;
@@ -378,8 +378,8 @@ void Menu::receiveMouseEvent(const MouseEvent& event) {
 
 
 IVector2D Menu::getDesiredDimensions() {
 IVector2D Menu::getDesiredDimensions() {
 	this->completeAssets();
 	this->completeAssets();
-	int widthAdder = this->padding.value * 2;
-	int heightAdder = widthAdder;
+	int32_t widthAdder = this->padding.value * 2;
+	int32_t heightAdder = widthAdder;
 	if (this->hasArrow()) {
 	if (this->hasArrow()) {
 		// Make extra space for the expansion arrowhead when containing a list of members.
 		// Make extra space for the expansion arrowhead when containing a list of members.
 		widthAdder += 24;
 		widthAdder += 24;

+ 2 - 2
Source/DFPSR/implementation/gui/components/Menu.h

@@ -63,8 +63,8 @@ private:
 	// Settings fetched from the theme
 	// Settings fetched from the theme
 	String finalHeadClass; // The selected HeadClass/Class from layout settings or the component's default theme class "MenuTop" or "MenuSub" based on ownership.
 	String finalHeadClass; // The selected HeadClass/Class from layout settings or the component's default theme class "MenuTop" or "MenuSub" based on ownership.
 	String finalListClass; // The selected ListClass from layout settings or the component's default theme class "MenuList".
 	String finalListClass; // The selected ListClass from layout settings or the component's default theme class "MenuList".
-	int menuHead_filter = 0; // 0 for solid, 1 for alpha filter.
-	int menuList_filter = 0; // 0 for solid, 1 for alpha filter.
+	int32_t menuHead_filter = 0; // 0 for solid, 1 for alpha filter.
+	int32_t menuList_filter = 0; // 0 for solid, 1 for alpha filter.
 public:
 public:
 	Menu();
 	Menu();
 public:
 public:

+ 2 - 2
Source/DFPSR/implementation/gui/components/Panel.cpp

@@ -57,8 +57,8 @@ bool Panel::isContainer() const {
 }
 }
 
 
 void Panel::generateGraphics() {
 void Panel::generateGraphics() {
-	int width = this->location.width();
-	int height = this->location.height();
+	int32_t width = this->location.width();
+	int32_t height = this->location.height();
 	if (width < 1) { width = 1; }
 	if (width < 1) { width = 1; }
 	if (height < 1) { height = 1; }
 	if (height < 1) { height = 1; }
 	if (!this->hasImages) {
 	if (!this->hasImages) {

+ 1 - 1
Source/DFPSR/implementation/gui/components/Panel.h

@@ -46,7 +46,7 @@ private:
 	void generateGraphics();
 	void generateGraphics();
 	// Settings fetched from the theme
 	// Settings fetched from the theme
 	String finalBackgroundClass; // The selected BackgroundClass/Class from layout settings or the component's default theme class "Panel".
 	String finalBackgroundClass; // The selected BackgroundClass/Class from layout settings or the component's default theme class "Panel".
-	int background_filter = 0; // 0 for solid, 1 for alpha filter.
+	int32_t background_filter = 0; // 0 for solid, 1 for alpha filter.
 	// Images
 	// Images
 	MediaMethod background;
 	MediaMethod background;
 	OrderedImageRgbaU8 imageBackground; // Alpha is copied to the target and should be 255
 	OrderedImageRgbaU8 imageBackground; // Alpha is copied to the target and should be 255

+ 2 - 2
Source/DFPSR/implementation/gui/components/Picture.cpp

@@ -88,8 +88,8 @@ void Picture::receiveMouseEvent(const MouseEvent& event) {
 }
 }
 
 
 void Picture::generateGraphics() {
 void Picture::generateGraphics() {
-	int width = this->location.width();
-	int height = this->location.height();
+	int32_t width = this->location.width();
+	int32_t height = this->location.height();
 	if (width < 1) { width = 1; }
 	if (width < 1) { width = 1; }
 	if (height < 1) { height = 1; }
 	if (height < 1) { height = 1; }
 	if (!this->hasImages) {
 	if (!this->hasImages) {

+ 1 - 1
Source/DFPSR/implementation/gui/components/TextBox.h

@@ -100,7 +100,7 @@ private:
 	void generateGraphics();
 	void generateGraphics();
 	// Settings fetched from the theme
 	// Settings fetched from the theme
 	String finalBackgroundClass; // The selected BackgroundClass/Class from layout settings or the component's default theme class "TextBox".
 	String finalBackgroundClass; // The selected BackgroundClass/Class from layout settings or the component's default theme class "TextBox".
-	int background_filter = 0; // 0 for solid, 1 for alpha filter.
+	int32_t background_filter = 0; // 0 for solid, 1 for alpha filter.
 	// Generated
 	// Generated
 	bool hasImages = false;
 	bool hasImages = false;
 	bool drawnAsFocused = false;
 	bool drawnAsFocused = false;

+ 14 - 14
Source/DFPSR/implementation/gui/components/Toolbar.cpp

@@ -63,8 +63,8 @@ bool Toolbar::isContainer() const {
 }
 }
 
 
 void Toolbar::generateGraphics() {
 void Toolbar::generateGraphics() {
-	int width = this->location.width();
-	int height = this->location.height();
+	int32_t width = this->location.width();
+	int32_t height = this->location.height();
 	if (width < 1) { width = 1; }
 	if (width < 1) { width = 1; }
 	if (height < 1) { height = 1; }
 	if (height < 1) { height = 1; }
 	if (!this->hasImages) {
 	if (!this->hasImages) {
@@ -125,19 +125,19 @@ void Toolbar::changedAttribute(const ReadableString &name) {
 }
 }
 
 
 void Toolbar::updateLocationEvent(const IRect& oldLocation, const IRect& newLocation) {
 void Toolbar::updateLocationEvent(const IRect& oldLocation, const IRect& newLocation) {
-	int widthStretch = this->region.right.getRatio() - this->region.left.getRatio();
-	int heightStretch = this->region.bottom.getRatio() - this->region.top.getRatio();
+	int32_t widthStretch = this->region.right.getRatio() - this->region.left.getRatio();
+	int32_t heightStretch = this->region.bottom.getRatio() - this->region.top.getRatio();
 	// Place members vertically if the toolbar mostly stretches vertically or if it has uniform stretch and is taller than wide.
 	// Place members vertically if the toolbar mostly stretches vertically or if it has uniform stretch and is taller than wide.
 	bool vertical = (widthStretch < heightStretch) || ((widthStretch == heightStretch) && (newLocation.width() < newLocation.height()));
 	bool vertical = (widthStretch < heightStretch) || ((widthStretch == heightStretch) && (newLocation.width() < newLocation.height()));
 	if (vertical) {
 	if (vertical) {
 		// TODO: Add scroll buttons on the sides if there is not enough space for all child components.
 		// TODO: Add scroll buttons on the sides if there is not enough space for all child components.
 		// Place each child component in order.
 		// Place each child component in order.
 		//   Each child is created within a segmented region, but can choose to add more padding or limit its height for fine adjustments.
 		//   Each child is created within a segmented region, but can choose to add more padding or limit its height for fine adjustments.
-		int left = this->padding.value;
-		int top = this->padding.value;
-		int width = newLocation.width() - (this->padding.value * 2);
-		for (int i = 0; i < this->getChildCount(); i++) {
-			int height = this->children[i]->getDesiredDimensions().y;
+		int32_t left = this->padding.value;
+		int32_t top = this->padding.value;
+		int32_t width = newLocation.width() - (this->padding.value * 2);
+		for (int32_t i = 0; i < this->getChildCount(); i++) {
+			int32_t height = this->children[i]->getDesiredDimensions().y;
 			this->children[i]->applyLayout(IRect(left, top, width, height));
 			this->children[i]->applyLayout(IRect(left, top, width, height));
 			top += height + this->spacing.value;
 			top += height + this->spacing.value;
 		}
 		}
@@ -145,11 +145,11 @@ void Toolbar::updateLocationEvent(const IRect& oldLocation, const IRect& newLoca
 		// TODO: Add scroll buttons on the sides if there is not enough space for all child components.
 		// TODO: Add scroll buttons on the sides if there is not enough space for all child components.
 		// Place each child component in order.
 		// Place each child component in order.
 		//   Each child is created within a segmented region, but can choose to add more padding or limit its height for fine adjustments.
 		//   Each child is created within a segmented region, but can choose to add more padding or limit its height for fine adjustments.
-		int left = this->padding.value;
-		int top = this->padding.value;
-		int height = newLocation.height() - (this->padding.value * 2);
-		for (int i = 0; i < this->getChildCount(); i++) {
-			int width = this->children[i]->getDesiredDimensions().x;
+		int32_t left = this->padding.value;
+		int32_t top = this->padding.value;
+		int32_t height = newLocation.height() - (this->padding.value * 2);
+		for (int32_t i = 0; i < this->getChildCount(); i++) {
+			int32_t width = this->children[i]->getDesiredDimensions().x;
 			this->children[i]->applyLayout(IRect(left, top, width, height));
 			this->children[i]->applyLayout(IRect(left, top, width, height));
 			left += width + this->spacing.value;
 			left += width + this->spacing.value;
 		}
 		}

+ 1 - 1
Source/DFPSR/implementation/gui/components/Toolbar.h

@@ -51,7 +51,7 @@ private:
 	OrderedImageRgbaU8 imageBackground; // Alpha is copied to the target and should be 255
 	OrderedImageRgbaU8 imageBackground; // Alpha is copied to the target and should be 255
 	// Settings fetched from the theme
 	// Settings fetched from the theme
 	String finalBackgroundClass; // The selected BackgroundClass/Class from layout settings or the component's default theme class "Toolbar".
 	String finalBackgroundClass; // The selected BackgroundClass/Class from layout settings or the component's default theme class "Toolbar".
-	int background_filter = 0; // 0 for solid, 1 for alpha filter.
+	int32_t background_filter = 0; // 0 for solid, 1 for alpha filter.
 	// Generated
 	// Generated
 	bool hasImages = false;
 	bool hasImages = false;
 public:
 public:

+ 2 - 2
Source/DFPSR/implementation/gui/components/helpers/ScrollBarImpl.h

@@ -60,8 +60,8 @@ private:
 	bool pressScrollUp = false;
 	bool pressScrollUp = false;
 	bool pressScrollDown = false;
 	bool pressScrollDown = false;
 	bool holdingScrollBar = false;
 	bool holdingScrollBar = false;
-	const int scrollBarThickness = 16;
-	const int scrollButtonLength = 16;
+	const int32_t scrollBarThickness = 16;
+	const int32_t scrollButtonLength = 16;
 	int64_t knobHoldOffset = 0; // The number of pixels right or down from the center that the knob was grabbed at.
 	int64_t knobHoldOffset = 0; // The number of pixels right or down from the center that the knob was grabbed at.
 	// Updated manually.
 	// Updated manually.
 	ScrollRange scrollRange; // Range of valid values.
 	ScrollRange scrollRange; // Range of valid values.

+ 2 - 2
Source/DFPSR/implementation/image/Color.h

@@ -68,7 +68,7 @@ struct ColorRgbI32 {
 	}
 	}
 	// Create a color from a string.
 	// Create a color from a string.
 	explicit ColorRgbI32(const ReadableString &content) : red(0), green(0), blue(0) {
 	explicit ColorRgbI32(const ReadableString &content) : red(0), green(0), blue(0) {
-		int givenChannels = 0;
+		int32_t givenChannels = 0;
 		string_split_callback([this, &givenChannels](ReadableString channelValue) {
 		string_split_callback([this, &givenChannels](ReadableString channelValue) {
 			if (givenChannels == 0) {
 			if (givenChannels == 0) {
 				this->red = string_toInteger(channelValue);
 				this->red = string_toInteger(channelValue);
@@ -127,7 +127,7 @@ struct ColorRgbaI32 {
 	}
 	}
 	// Create a color from a string.
 	// Create a color from a string.
 	explicit ColorRgbaI32(const ReadableString &content) : red(0), green(0), blue(0), alpha(255) {
 	explicit ColorRgbaI32(const ReadableString &content) : red(0), green(0), blue(0), alpha(255) {
-		int givenChannels = 0;
+		int32_t givenChannels = 0;
 		string_split_callback([this, &givenChannels](ReadableString channelValue) {
 		string_split_callback([this, &givenChannels](ReadableString channelValue) {
 			if (givenChannels == 0) {
 			if (givenChannels == 0) {
 				this->red = string_toInteger(channelValue);
 				this->red = string_toInteger(channelValue);

+ 8 - 8
Source/DFPSR/implementation/image/stbImage/stbImageWrapper.cpp

@@ -11,12 +11,12 @@
 
 
 namespace dsr {
 namespace dsr {
 
 
-OrderedImageRgbaU8 image_stb_decode_RgbaU8(SafePointer<const uint8_t> data, int size) {
+OrderedImageRgbaU8 image_stb_decode_RgbaU8(SafePointer<const uint8_t> data, int32_t size) {
 	#ifdef SAFE_POINTER_CHECKS
 	#ifdef SAFE_POINTER_CHECKS
 		// If the safe pointer has debug information, use it to assert that size is within bound.
 		// If the safe pointer has debug information, use it to assert that size is within bound.
 		data.assertInside("image_stb_decode_RgbaU8 (data)", data.getUnsafe(), (size_t)size);
 		data.assertInside("image_stb_decode_RgbaU8 (data)", data.getUnsafe(), (size_t)size);
 	#endif
 	#endif
-	int width, height, bpp;
+	int32_t width, height, bpp;
 	uint8_t *rawPixelData = stbi_load_from_memory(data.getUnsafe(), size, &width, &height, &bpp, 4);
 	uint8_t *rawPixelData = stbi_load_from_memory(data.getUnsafe(), size, &width, &height, &bpp, 4);
 	if (rawPixelData == nullptr) {
 	if (rawPixelData == nullptr) {
 		return OrderedImageRgbaU8(); // Return null
 		return OrderedImageRgbaU8(); // Return null
@@ -24,7 +24,7 @@ OrderedImageRgbaU8 image_stb_decode_RgbaU8(SafePointer<const uint8_t> data, int
 	// Create a padded buffer
 	// Create a padded buffer
 	OrderedImageRgbaU8 result = image_create_RgbaU8(width, height);
 	OrderedImageRgbaU8 result = image_create_RgbaU8(width, height);
 	// Copy the data
 	// Copy the data
-	int rowSize = width * 4;
+	int32_t rowSize = width * 4;
 	int32_t targetStride = image_getStride(result);
 	int32_t targetStride = image_getStride(result);
 	const uint8_t *sourceRow = rawPixelData;
 	const uint8_t *sourceRow = rawPixelData;
 	uint8_t* targetRow = image_dangerous_getData(result);
 	uint8_t* targetRow = image_dangerous_getData(result);
@@ -41,15 +41,15 @@ OrderedImageRgbaU8 image_stb_decode_RgbaU8(SafePointer<const uint8_t> data, int
 }
 }
 
 
 // Pre-condition: Images that STB image don't have stride implementations for must be given unpadded images.
 // Pre-condition: Images that STB image don't have stride implementations for must be given unpadded images.
-Buffer image_stb_encode(const ImageRgbaU8 &image, ImageFileFormat format, int quality) {
-	int width = image_getWidth(image);
-	int height = image_getHeight(image);
+Buffer image_stb_encode(const ImageRgbaU8 &image, ImageFileFormat format, int32_t quality) {
+	int32_t width = image_getWidth(image);
+	int32_t height = image_getHeight(image);
 	List<uint8_t> targetList;
 	List<uint8_t> targetList;
 	// Reserve enough memory for an uncompressed file to reduce the need for reallcation.
 	// Reserve enough memory for an uncompressed file to reduce the need for reallcation.
 	targetList.reserve(width * height * 4 + 2048);
 	targetList.reserve(width * height * 4 + 2048);
-	stbi_write_func* writer = [](void* context, void* data, int size) {
+	stbi_write_func* writer = [](void* context, void* data, int32_t size) {
 		List<uint8_t>* target = (List<uint8_t>*)context;
 		List<uint8_t>* target = (List<uint8_t>*)context;
-		for (int i = 0; i < size; i++) {
+		for (int32_t i = 0; i < size; i++) {
 			target->push(((uint8_t*)data)[i]);
 			target->push(((uint8_t*)data)[i]);
 		}
 		}
 	};
 	};

+ 2 - 2
Source/DFPSR/implementation/image/stbImage/stbImageWrapper.h

@@ -7,12 +7,12 @@
 
 
 namespace dsr {
 namespace dsr {
 
 
-OrderedImageRgbaU8 image_stb_decode_RgbaU8(SafePointer<const uint8_t> data, int size);
+OrderedImageRgbaU8 image_stb_decode_RgbaU8(SafePointer<const uint8_t> data, int32_t size);
 
 
 // Pre-conditions:
 // Pre-conditions:
 // * The image must be packed in RGBA order at runtime, but can't be in the OrderedImageRgbaU8 format because Ordered inherits from Aligned.
 // * The image must be packed in RGBA order at runtime, but can't be in the OrderedImageRgbaU8 format because Ordered inherits from Aligned.
 // * Only the PNG format may use padding in this call.
 // * Only the PNG format may use padding in this call.
-Buffer image_stb_encode(const ImageRgbaU8 &image, ImageFileFormat format, int quality);
+Buffer image_stb_encode(const ImageRgbaU8 &image, ImageFileFormat format, int32_t quality);
 
 
 }
 }
 
 

+ 39 - 39
Source/DFPSR/implementation/machine/VirtualMachine.cpp

@@ -40,12 +40,12 @@ VirtualMachine::VirtualMachine(const ReadableString& code, const Handle<PlanarMe
 	#endif
 	#endif
 	string_split_callback([this](ReadableString currentLine) {
 	string_split_callback([this](ReadableString currentLine) {
 		// If the line has a comment, then skip everything from #
 		// If the line has a comment, then skip everything from #
-		int commentIndex = string_findFirst(currentLine, U'#');
+		int32_t commentIndex = string_findFirst(currentLine, U'#');
 		if (commentIndex > -1) {
 		if (commentIndex > -1) {
 			currentLine = string_before(currentLine, commentIndex);
 			currentLine = string_before(currentLine, commentIndex);
 		}
 		}
 		currentLine = string_removeOuterWhiteSpace(currentLine);
 		currentLine = string_removeOuterWhiteSpace(currentLine);
-		int colonIndex = string_findFirst(currentLine, U':');
+		int32_t colonIndex = string_findFirst(currentLine, U':');
 		if (colonIndex > -1) {
 		if (colonIndex > -1) {
 			ReadableString command = string_removeOuterWhiteSpace(string_before(currentLine, colonIndex));
 			ReadableString command = string_removeOuterWhiteSpace(string_before(currentLine, colonIndex));
 			ReadableString argumentLine = string_after(currentLine, colonIndex);
 			ReadableString argumentLine = string_after(currentLine, colonIndex);
@@ -62,8 +62,8 @@ VirtualMachine::VirtualMachine(const ReadableString& code, const Handle<PlanarMe
 	this->executeMethod(0);
 	this->executeMethod(0);
 }
 }
 
 
-int VirtualMachine::findMethod(const ReadableString& name) {
-	for (int i = 0; i < this->methods.length(); i++) {
+int32_t VirtualMachine::findMethod(const ReadableString& name) {
+	for (int32_t i = 0; i < this->methods.length(); i++) {
 		if (string_caseInsensitiveMatch(this->methods[i].name, name)) {
 		if (string_caseInsensitiveMatch(this->methods[i].name, name)) {
 			return i;
 			return i;
 		}
 		}
@@ -71,7 +71,7 @@ int VirtualMachine::findMethod(const ReadableString& name) {
 	return -1;
 	return -1;
 }
 }
 
 
-Variable* VirtualMachine::getResource(const ReadableString& name, int methodIndex) {
+Variable* VirtualMachine::getResource(const ReadableString& name, int32_t methodIndex) {
 	Variable* result = this->methods[methodIndex].getLocal(name);
 	Variable* result = this->methods[methodIndex].getLocal(name);
 	if (result) {
 	if (result) {
 		// If found, take the local variable
 		// If found, take the local variable
@@ -96,7 +96,7 @@ void VirtualMachine::addMachineWord(MachineOperation operation) {
 
 
 void VirtualMachine::interpretCommand(const ReadableString& operation, const List<VMA>& resolvedArguments) {
 void VirtualMachine::interpretCommand(const ReadableString& operation, const List<VMA>& resolvedArguments) {
 	// Compare the input with overloads
 	// Compare the input with overloads
-	for (int s = 0; s < machineInstructionCount; s++) {
+	for (int32_t s = 0; s < machineInstructionCount; s++) {
 		if (machineInstructions[s].matches(operation, resolvedArguments)) {
 		if (machineInstructions[s].matches(operation, resolvedArguments)) {
 			this->addMachineWord(machineInstructions[s].operation, resolvedArguments);
 			this->addMachineWord(machineInstructions[s].operation, resolvedArguments);
 			return;
 			return;
@@ -104,11 +104,11 @@ void VirtualMachine::interpretCommand(const ReadableString& operation, const Lis
 	}
 	}
 	// TODO: Allow asking the specific machine type what the given types are called.
 	// TODO: Allow asking the specific machine type what the given types are called.
 	String message = string_combine(U"\nError! ", operation, U" does not match any overload for the given arguments:\n");
 	String message = string_combine(U"\nError! ", operation, U" does not match any overload for the given arguments:\n");
-	for (int s = 0; s < machineInstructionCount; s++) {
+	for (int32_t s = 0; s < machineInstructionCount; s++) {
 		const InsSig* signature = &machineInstructions[s];
 		const InsSig* signature = &machineInstructions[s];
 		if (string_caseInsensitiveMatch(signature->name, operation)) {
 		if (string_caseInsensitiveMatch(signature->name, operation)) {
 			string_append(message, "  * ", signature->name, "(");
 			string_append(message, "  * ", signature->name, "(");
-			for (int a = 0; a < signature->arguments.length(); a++) {
+			for (int32_t a = 0; a < signature->arguments.length(); a++) {
 				if (a > 0) {
 				if (a > 0) {
 					string_append(message, ", ");
 					string_append(message, ", ");
 				}
 				}
@@ -122,7 +122,7 @@ void VirtualMachine::interpretCommand(const ReadableString& operation, const Lis
 }
 }
 
 
 // TODO: Inline into declareVariable
 // TODO: Inline into declareVariable
-Variable* VirtualMachine::declareVariable_aux(const VMTypeDef& typeDef, int methodIndex, AccessType access, const ReadableString& name, bool initialize, const ReadableString& defaultValueText) {
+Variable* VirtualMachine::declareVariable_aux(const VMTypeDef& typeDef, int32_t methodIndex, AccessType access, const ReadableString& name, bool initialize, const ReadableString& defaultValueText) {
 	// Make commonly used data more readable
 	// Make commonly used data more readable
 	bool global = methodIndex == 0;
 	bool global = methodIndex == 0;
 	Method* currentMethod = &this->methods[methodIndex];
 	Method* currentMethod = &this->methods[methodIndex];
@@ -152,8 +152,8 @@ Variable* VirtualMachine::declareVariable_aux(const VMTypeDef& typeDef, int meth
 		this->methods[methodIndex].declaredNonInput = true;
 		this->methods[methodIndex].declaredNonInput = true;
 	}
 	}
 	// Declare the variable so that code may find the type and index by name
 	// Declare the variable so that code may find the type and index by name
-	int typeLocalIndex = currentMethod->count[typeDef.dataType] - 1;
-	int globalIndex = typeLocalToGlobalIndex(global, typeLocalIndex);
+	int32_t typeLocalIndex = currentMethod->count[typeDef.dataType] - 1;
+	int32_t globalIndex = typeLocalToGlobalIndex(global, typeLocalIndex);
 	this->methods[methodIndex].locals.pushConstruct(name, access, &typeDef, typeLocalIndex, global);
 	this->methods[methodIndex].locals.pushConstruct(name, access, &typeDef, typeLocalIndex, global);
 	if (initialize && access != AccessType::Input) {
 	if (initialize && access != AccessType::Input) {
 		// Generate instructions for assigning the variable's initial value
 		// Generate instructions for assigning the variable's initial value
@@ -162,7 +162,7 @@ Variable* VirtualMachine::declareVariable_aux(const VMTypeDef& typeDef, int meth
 	return &this->methods[methodIndex].locals.last();
 	return &this->methods[methodIndex].locals.last();
 }
 }
 
 
-Variable* VirtualMachine::declareVariable(int methodIndex, AccessType access, const ReadableString& typeName, const ReadableString& name, bool initialize, const ReadableString& defaultValueText) {
+Variable* VirtualMachine::declareVariable(int32_t methodIndex, AccessType access, const ReadableString& typeName, const ReadableString& name, bool initialize, const ReadableString& defaultValueText) {
 	if (this->getResource(name, methodIndex)) {
 	if (this->getResource(name, methodIndex)) {
 		throwError("A resource named \"", name, "\" already exists! Be aware that resource names are case insensitive.\n");
 		throwError("A resource named \"", name, "\" already exists! Be aware that resource names are case insensitive.\n");
 		return nullptr;
 		return nullptr;
@@ -181,7 +181,7 @@ Variable* VirtualMachine::declareVariable(int methodIndex, AccessType access, co
 	}
 	}
 }
 }
 
 
-VMA VirtualMachine::VMAfromText(int methodIndex, const ReadableString& content) {
+VMA VirtualMachine::VMAfromText(int32_t methodIndex, const ReadableString& content) {
 	DsrChar first = content[0];
 	DsrChar first = content[0];
 	DsrChar second = content[1];
 	DsrChar second = content[1];
 	if (first == U'-' && second >= U'0' && second <= U'9') {
 	if (first == U'-' && second >= U'0' && second <= U'9') {
@@ -189,8 +189,8 @@ VMA VirtualMachine::VMAfromText(int methodIndex, const ReadableString& content)
 	} else if (first >= U'0' && first <= U'9') {
 	} else if (first >= U'0' && first <= U'9') {
 		return VMA(FixedPoint::fromText(content));
 		return VMA(FixedPoint::fromText(content));
 	} else {
 	} else {
-		int leftIndex = string_findFirst(content, U'<');
-		int rightIndex = string_findLast(content, U'>');
+		int32_t leftIndex = string_findFirst(content, U'<');
+		int32_t rightIndex = string_findLast(content, U'>');
 		if (leftIndex > -1 && rightIndex > -1) {
 		if (leftIndex > -1 && rightIndex > -1) {
 			ReadableString name = string_removeOuterWhiteSpace(string_before(content, leftIndex));
 			ReadableString name = string_removeOuterWhiteSpace(string_before(content, leftIndex));
 			ReadableString typeName = string_removeOuterWhiteSpace(string_inclusiveRange(content, leftIndex + 1, rightIndex - 1));
 			ReadableString typeName = string_removeOuterWhiteSpace(string_inclusiveRange(content, leftIndex + 1, rightIndex - 1));
@@ -255,9 +255,9 @@ void VirtualMachine::addCallInstructions(const List<String>& arguments) {
 		throwError(U"Cannot make a call without the name of a method!\n");
 		throwError(U"Cannot make a call without the name of a method!\n");
 	}
 	}
 	// TODO: Allow calling methods that aren't defined yet.
 	// TODO: Allow calling methods that aren't defined yet.
-	int currentMethodIndex = this->methods.length() - 1;
+	int32_t currentMethodIndex = this->methods.length() - 1;
 	ReadableString methodName = string_removeOuterWhiteSpace(arguments[0]);
 	ReadableString methodName = string_removeOuterWhiteSpace(arguments[0]);
-	int calledMethodIndex = findMethod(methodName);
+	int32_t calledMethodIndex = findMethod(methodName);
 	if (calledMethodIndex == -1) {
 	if (calledMethodIndex == -1) {
 		throwError(U"Tried to make an internal call to the method \"", methodName, U"\", which was not previously defined in the virtual machine! Make sure that the name is spelled correctly and the method is defined above the caller.\n");
 		throwError(U"Tried to make an internal call to the method \"", methodName, U"\", which was not previously defined in the virtual machine! Make sure that the name is spelled correctly and the method is defined above the caller.\n");
 	}
 	}
@@ -271,8 +271,8 @@ void VirtualMachine::addCallInstructions(const List<String>& arguments) {
 	List<VMA> outputArguments;
 	List<VMA> outputArguments;
 	inputArguments.push(VMA(FixedPoint::fromMantissa(calledMethodIndex)));
 	inputArguments.push(VMA(FixedPoint::fromMantissa(calledMethodIndex)));
 	outputArguments.push(VMA(FixedPoint::fromMantissa(calledMethodIndex)));
 	outputArguments.push(VMA(FixedPoint::fromMantissa(calledMethodIndex)));
-	int outputCount = 0;
-	for (int a = 1; a < arguments.length(); a++) {
+	int32_t outputCount = 0;
+	for (int32_t a = 1; a < arguments.length(); a++) {
 		ReadableString content = string_removeOuterWhiteSpace(arguments[a]);
 		ReadableString content = string_removeOuterWhiteSpace(arguments[a]);
 		if (string_length(content) > 0) {
 		if (string_length(content) > 0) {
 			if (outputCount < calledMethod->outputCount) {
 			if (outputCount < calledMethod->outputCount) {
@@ -284,7 +284,7 @@ void VirtualMachine::addCallInstructions(const List<String>& arguments) {
 		}
 		}
 	}
 	}
 	// Check types
 	// Check types
-	for (int a = 1; a < outputArguments.length(); a++) {
+	for (int32_t a = 1; a < outputArguments.length(); a++) {
 		// Output
 		// Output
 		Variable* variable = &calledMethod->locals[a - 1 + calledMethod->inputCount];
 		Variable* variable = &calledMethod->locals[a - 1 + calledMethod->inputCount];
 		if (outputArguments[a].argType != ArgumentType::Reference) {
 		if (outputArguments[a].argType != ArgumentType::Reference) {
@@ -293,7 +293,7 @@ void VirtualMachine::addCallInstructions(const List<String>& arguments) {
 			throwError(U"Output argument for \"", variable->name, U"\" in \"", calledMethod->name, U"\" must have the type \"", variable->typeDescription->name, U"\"!\n");
 			throwError(U"Output argument for \"", variable->name, U"\" in \"", calledMethod->name, U"\" must have the type \"", variable->typeDescription->name, U"\"!\n");
 		}
 		}
 	}
 	}
-	for (int a = 1; a < inputArguments.length(); a++) {
+	for (int32_t a = 1; a < inputArguments.length(); a++) {
 		// Input
 		// Input
 		Variable* variable = &calledMethod->locals[a - 1];
 		Variable* variable = &calledMethod->locals[a - 1];
 		if (inputArguments[a].dataType != variable->typeDescription->dataType) {
 		if (inputArguments[a].dataType != variable->typeDescription->dataType) {
@@ -302,9 +302,9 @@ void VirtualMachine::addCallInstructions(const List<String>& arguments) {
 	}
 	}
 	addMachineWord([](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
 	addMachineWord([](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
 		// Get the method to call
 		// Get the method to call
-		int calledMethodIndex = args[0].value.getMantissa();
+		int32_t calledMethodIndex = args[0].value.getMantissa();
 		#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 		#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
-			int oldMethodIndex = memory.current.methodIndex;
+			int32_t oldMethodIndex = memory.current.methodIndex;
 		#endif
 		#endif
 		Method* calledMethod = &machine.methods[calledMethodIndex];
 		Method* calledMethod = &machine.methods[calledMethodIndex];
 		#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 		#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
@@ -313,7 +313,7 @@ void VirtualMachine::addCallInstructions(const List<String>& arguments) {
 		// Calculate new frame pointers
 		// Calculate new frame pointers
 		int32_t newFramePointer[MAX_TYPE_COUNT] = {};
 		int32_t newFramePointer[MAX_TYPE_COUNT] = {};
 		int32_t newStackPointer[MAX_TYPE_COUNT] = {};
 		int32_t newStackPointer[MAX_TYPE_COUNT] = {};
-		for (int t = 0; t < MAX_TYPE_COUNT; t++) {
+		for (int32_t t = 0; t < MAX_TYPE_COUNT; t++) {
 			newFramePointer[t] = memory.current.stackPointer[t];
 			newFramePointer[t] = memory.current.stackPointer[t];
 			newStackPointer[t] = memory.current.stackPointer[t] + machine.methods[calledMethodIndex].count[t];
 			newStackPointer[t] = memory.current.stackPointer[t] + machine.methods[calledMethodIndex].count[t];
 			#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 			#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
@@ -326,33 +326,33 @@ void VirtualMachine::addCallInstructions(const List<String>& arguments) {
 			#endif
 			#endif
 		}
 		}
 		// Assign inputs
 		// Assign inputs
-		for (int a = 1; a < args.length(); a++) {
+		for (int32_t a = 1; a < args.length(); a++) {
 			Variable* target = &calledMethod->locals[a - 1];
 			Variable* target = &calledMethod->locals[a - 1];
 			DataType typeIndex = target->typeDescription->dataType;
 			DataType typeIndex = target->typeDescription->dataType;
-			int targetStackIndex = target->getStackIndex(newFramePointer[typeIndex]);
+			int32_t targetStackIndex = target->getStackIndex(newFramePointer[typeIndex]);
 			memory.store(targetStackIndex, args[a], memory.current.framePointer[typeIndex], typeIndex);
 			memory.store(targetStackIndex, args[a], memory.current.framePointer[typeIndex], typeIndex);
 		}
 		}
 		// Jump into the method
 		// Jump into the method
 		memory.callStack.push(memory.current);
 		memory.callStack.push(memory.current);
 		memory.current.methodIndex = calledMethodIndex;
 		memory.current.methodIndex = calledMethodIndex;
 		memory.current.programCounter = machine.methods[calledMethodIndex].startAddress;
 		memory.current.programCounter = machine.methods[calledMethodIndex].startAddress;
-		for (int t = 0; t < MAX_TYPE_COUNT; t++) {
+		for (int32_t t = 0; t < MAX_TYPE_COUNT; t++) {
 			memory.current.framePointer[t] = newFramePointer[t];
 			memory.current.framePointer[t] = newFramePointer[t];
 			memory.current.stackPointer[t] = newStackPointer[t];
 			memory.current.stackPointer[t] = newStackPointer[t];
 		}
 		}
 	}, inputArguments);
 	}, inputArguments);
 	// Get results from the method
 	// Get results from the method
 	addMachineWord([](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
 	addMachineWord([](VirtualMachine& machine, PlanarMemory& memory, const List<VMA>& args) {
-		int calledMethodIndex = args[0].value.getMantissa();
+		int32_t calledMethodIndex = args[0].value.getMantissa();
 		Method* calledMethod = &machine.methods[calledMethodIndex];
 		Method* calledMethod = &machine.methods[calledMethodIndex];
 		#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 		#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 			printText(U"Writing results after call to \"", calledMethod->name, U"\":\n");
 			printText(U"Writing results after call to \"", calledMethod->name, U"\":\n");
 		#endif
 		#endif
 		// Assign outputs
 		// Assign outputs
-		for (int a = 1; a < args.length(); a++) {
+		for (int32_t a = 1; a < args.length(); a++) {
 			Variable* source = &calledMethod->locals[a - 1 + calledMethod->inputCount];
 			Variable* source = &calledMethod->locals[a - 1 + calledMethod->inputCount];
 			DataType typeIndex = source->typeDescription->dataType;
 			DataType typeIndex = source->typeDescription->dataType;
-			int sourceStackIndex = source->getStackIndex(memory.current.stackPointer[typeIndex]);
+			int32_t sourceStackIndex = source->getStackIndex(memory.current.stackPointer[typeIndex]);
 			memory.load(sourceStackIndex, args[a], memory.current.framePointer[typeIndex], typeIndex);
 			memory.load(sourceStackIndex, args[a], memory.current.framePointer[typeIndex], typeIndex);
 			#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 			#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 				printText(U"  ");
 				printText(U"  ");
@@ -375,7 +375,7 @@ void VirtualMachine::addCallInstructions(const List<String>& arguments) {
 void VirtualMachine::interpretMachineWord(const ReadableString& command, const List<String>& arguments) {
 void VirtualMachine::interpretMachineWord(const ReadableString& command, const List<String>& arguments) {
 	#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 	#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 		printText(U"interpretMachineWord @", this->machineWords.length(), U" ", command, U"(");
 		printText(U"interpretMachineWord @", this->machineWords.length(), U" ", command, U"(");
-		for (int a = 0; a < arguments.length(); a++) {
+		for (int32_t a = 0; a < arguments.length(); a++) {
 			if (a > 0) { printText(U", "); }
 			if (a > 0) { printText(U", "); }
 			printText(getArg(arguments, a));
 			printText(getArg(arguments, a));
 		}
 		}
@@ -389,7 +389,7 @@ void VirtualMachine::interpretMachineWord(const ReadableString& command, const L
 		}
 		}
 		this->methods.pushConstruct(getArg(arguments, 0), this->machineWords.length(), this->machineTypeCount);
 		this->methods.pushConstruct(getArg(arguments, 0), this->machineWords.length(), this->machineTypeCount);
 	} else if (string_caseInsensitiveMatch(command, U"Temp")) {
 	} else if (string_caseInsensitiveMatch(command, U"Temp")) {
-		for (int a = 1; a < arguments.length(); a++) {
+		for (int32_t a = 1; a < arguments.length(); a++) {
 			this->declareVariable(methods.length() - 1, AccessType::Hidden, getArg(arguments, 0), getArg(arguments, a), false, U"");
 			this->declareVariable(methods.length() - 1, AccessType::Hidden, getArg(arguments, 0), getArg(arguments, a), false, U"");
 		}
 		}
 	} else if (string_caseInsensitiveMatch(command, U"Hidden")) {
 	} else if (string_caseInsensitiveMatch(command, U"Hidden")) {
@@ -403,9 +403,9 @@ void VirtualMachine::interpretMachineWord(const ReadableString& command, const L
 	} else if (string_caseInsensitiveMatch(command, U"Call")) {
 	} else if (string_caseInsensitiveMatch(command, U"Call")) {
 		this->addCallInstructions(arguments);
 		this->addCallInstructions(arguments);
 	} else {
 	} else {
-		int methodIndex = this->methods.length() - 1;
+		int32_t methodIndex = this->methods.length() - 1;
 		List<VMA> resolvedArguments;
 		List<VMA> resolvedArguments;
-		for (int a = 0; a < arguments.length(); a++) {
+		for (int32_t a = 0; a < arguments.length(); a++) {
 			ReadableString content = string_removeOuterWhiteSpace(arguments[a]);
 			ReadableString content = string_removeOuterWhiteSpace(arguments[a]);
 			if (string_length(content) > 0) {
 			if (string_length(content) > 0) {
 				resolvedArguments.push(this->VMAfromText(methodIndex, getArg(arguments, a)));
 				resolvedArguments.push(this->VMAfromText(methodIndex, getArg(arguments, a)));
@@ -415,7 +415,7 @@ void VirtualMachine::interpretMachineWord(const ReadableString& command, const L
 	}
 	}
 }
 }
 
 
-void VirtualMachine::executeMethod(int methodIndex) {
+void VirtualMachine::executeMethod(int32_t methodIndex) {
 	Method* rootMethod = &this->methods[methodIndex];
 	Method* rootMethod = &this->methods[methodIndex];
 
 
 	#ifdef VIRTUAL_MACHINE_PROFILE
 	#ifdef VIRTUAL_MACHINE_PROFILE
@@ -429,8 +429,8 @@ void VirtualMachine::executeMethod(int methodIndex) {
 	// Create a new current state
 	// Create a new current state
 	this->memory->current.methodIndex = methodIndex;
 	this->memory->current.methodIndex = methodIndex;
 	this->memory->current.programCounter = rootMethod->startAddress;
 	this->memory->current.programCounter = rootMethod->startAddress;
-	for (int t = 0; t < this->machineTypeCount; t++) {
-		int framePointer = this->methods[0].count[t];
+	for (int32_t t = 0; t < this->machineTypeCount; t++) {
+		int32_t framePointer = this->methods[0].count[t];
 		this->memory->current.framePointer[t] = framePointer;
 		this->memory->current.framePointer[t] = framePointer;
 		this->memory->current.stackPointer[t] = framePointer + this->methods[methodIndex].count[t];
 		this->memory->current.stackPointer[t] = framePointer + this->methods[methodIndex].count[t];
 	}
 	}
@@ -458,7 +458,7 @@ void VirtualMachine::executeMethod(int methodIndex) {
 			const InsSig* signature = getMachineInstructionFromFunction(word->operation);
 			const InsSig* signature = getMachineInstructionFromFunction(word->operation);
 			if (signature) {
 			if (signature) {
 				printText(U"Executing @", pc, U" ", signature->name, U"(");
 				printText(U"Executing @", pc, U" ", signature->name, U"(");
-				for (int a = signature->targetCount; a < word->args.length(); a++) {
+				for (int32_t a = signature->targetCount; a < word->args.length(); a++) {
 					if (a > signature->targetCount) {
 					if (a > signature->targetCount) {
 						printText(U", ");
 						printText(U", ");
 					}
 					}
@@ -470,7 +470,7 @@ void VirtualMachine::executeMethod(int methodIndex) {
 			if (signature) {
 			if (signature) {
 				if (signature->targetCount > 0) {
 				if (signature->targetCount > 0) {
 					printText(U" -> ");
 					printText(U" -> ");
-					for (int a = 0; a < signature->targetCount; a++) {
+					for (int32_t a = 0; a < signature->targetCount; a++) {
 						if (a > 0) {
 						if (a > 0) {
 							printText(U", ");
 							printText(U", ");
 						}
 						}

+ 32 - 32
Source/DFPSR/implementation/machine/VirtualMachine.h

@@ -153,9 +153,9 @@ public:
 	List<CallState> callStack;
 	List<CallState> callStack;
 	virtual ~PlanarMemory() {}
 	virtual ~PlanarMemory() {}
 	// Store in memory
 	// Store in memory
-	virtual void store(int targetStackIndex, const VMA& sourceArg, int sourceFramePointer, DataType type) = 0;
+	virtual void store(int32_t targetStackIndex, const VMA& sourceArg, int32_t sourceFramePointer, DataType type) = 0;
 	// Load from memory
 	// Load from memory
-	virtual void load(int sourceStackIndex, const VMA& targetArg, int targetFramePointer, DataType type) = 0;
+	virtual void load(int32_t sourceStackIndex, const VMA& targetArg, int32_t targetFramePointer, DataType type) = 0;
 };
 };
 
 
 // Lambdas without capture is used to create function pointers without objects
 // Lambdas without capture is used to create function pointers without objects
@@ -174,10 +174,10 @@ struct MachineWord {
 struct InsSig {
 struct InsSig {
 public:
 public:
 	ReadableString name;
 	ReadableString name;
-	int targetCount; // Number of first arguments to present as results
+	int32_t targetCount; // Number of first arguments to present as results
 	List<ArgSig> arguments;
 	List<ArgSig> arguments;
 	MachineOperation operation;
 	MachineOperation operation;
-	InsSig(const ReadableString& name, int targetCount, MachineOperation operation)
+	InsSig(const ReadableString& name, int32_t targetCount, MachineOperation operation)
 	: name(name), targetCount(targetCount), operation(operation) {}
 	: name(name), targetCount(targetCount), operation(operation) {}
 private:
 private:
 	void addArguments() {}
 	void addArguments() {}
@@ -188,7 +188,7 @@ private:
 	}
 	}
 public:
 public:
 	template <typename... ARGS>
 	template <typename... ARGS>
-	static InsSig create(const ReadableString& name, int targetCount, MachineOperation operation, ARGS... args) {
+	static InsSig create(const ReadableString& name, int32_t targetCount, MachineOperation operation, ARGS... args) {
 		InsSig result = InsSig(name, targetCount, operation);
 		InsSig result = InsSig(name, targetCount, operation);
 		result.addArguments(args...);
 		result.addArguments(args...);
 		return result;
 		return result;
@@ -199,7 +199,7 @@ public:
 		} else if (!string_caseInsensitiveMatch(this->name, name)) {
 		} else if (!string_caseInsensitiveMatch(this->name, name)) {
 			return false;
 			return false;
 		} else {
 		} else {
-			for (int i = 0; i < this->arguments.length(); i++) {
+			for (int32_t i = 0; i < this->arguments.length(); i++) {
 				if (!this->arguments[i].matches(resolvedArguments[i].argType, resolvedArguments[i].dataType)) {
 				if (!this->arguments[i].matches(resolvedArguments[i].argType, resolvedArguments[i].dataType)) {
 					return false;
 					return false;
 				}
 				}
@@ -210,9 +210,9 @@ public:
 };
 };
 
 
 // Types
 // Types
-inline void initializeTemplate(VirtualMachine& machine, int globalIndex, const ReadableString& defaultValue) {}
+inline void initializeTemplate(VirtualMachine& machine, int32_t globalIndex, const ReadableString& defaultValue) {}
 using VMT_Initializer = decltype(&initializeTemplate);
 using VMT_Initializer = decltype(&initializeTemplate);
-inline void debugPrintTemplate(PlanarMemory& memory, Variable& variable, int globalIndex, int32_t* framePointer, bool fullContent) {}
+inline void debugPrintTemplate(PlanarMemory& memory, Variable& variable, int32_t globalIndex, int32_t* framePointer, bool fullContent) {}
 using VMT_DebugPrinter = decltype(&debugPrintTemplate);
 using VMT_DebugPrinter = decltype(&debugPrintTemplate);
 struct VMTypeDef {
 struct VMTypeDef {
 	ReadableString name;
 	ReadableString name;
@@ -250,7 +250,7 @@ struct Method {
 		assert(machineTypeCount <= MAX_TYPE_COUNT);
 		assert(machineTypeCount <= MAX_TYPE_COUNT);
 	}
 	}
 	Variable* getLocal(const ReadableString& name) {
 	Variable* getLocal(const ReadableString& name) {
-		for (int i = 0; i < this->locals.length(); i++) {
+		for (int32_t i = 0; i < this->locals.length(); i++) {
 			if (string_caseInsensitiveMatch(this->locals[i].name, name)) {
 			if (string_caseInsensitiveMatch(this->locals[i].name, name)) {
 				return &this->locals[i];
 				return &this->locals[i];
 			}
 			}
@@ -268,7 +268,7 @@ struct VirtualMachine {
 	// Instruction types
 	// Instruction types
 	const InsSig* machineInstructions; int32_t machineInstructionCount;
 	const InsSig* machineInstructions; int32_t machineInstructionCount;
 	const InsSig* getMachineInstructionFromFunction(MachineOperation functionPointer) {
 	const InsSig* getMachineInstructionFromFunction(MachineOperation functionPointer) {
-		for (int s = 0; s < this->machineInstructionCount; s++) {
+		for (int32_t s = 0; s < this->machineInstructionCount; s++) {
 			if (this->machineInstructions[s].operation == functionPointer) {
 			if (this->machineInstructions[s].operation == functionPointer) {
 				return &this->machineInstructions[s];
 				return &this->machineInstructions[s];
 			}
 			}
@@ -280,7 +280,7 @@ struct VirtualMachine {
 	// Types
 	// Types
 	const VMTypeDef* machineTypes; int32_t machineTypeCount;
 	const VMTypeDef* machineTypes; int32_t machineTypeCount;
 	const VMTypeDef* getMachineType(const ReadableString& name) {
 	const VMTypeDef* getMachineType(const ReadableString& name) {
-		for (int s = 0; s < this->machineTypeCount; s++) {
+		for (int32_t s = 0; s < this->machineTypeCount; s++) {
 			if (string_caseInsensitiveMatch(this->machineTypes[s].name, name)) {
 			if (string_caseInsensitiveMatch(this->machineTypes[s].name, name)) {
 				return &this->machineTypes[s];
 				return &this->machineTypes[s];
 			}
 			}
@@ -288,7 +288,7 @@ struct VirtualMachine {
 		return nullptr;
 		return nullptr;
 	}
 	}
 	const VMTypeDef* getMachineType(DataType dataType) {
 	const VMTypeDef* getMachineType(DataType dataType) {
-		for (int s = 0; s < this->machineTypeCount; s++) {
+		for (int32_t s = 0; s < this->machineTypeCount; s++) {
 			if (this->machineTypes[s].dataType == dataType) {
 			if (this->machineTypes[s].dataType == dataType) {
 				return &this->machineTypes[s];
 				return &this->machineTypes[s];
 			}
 			}
@@ -300,8 +300,8 @@ struct VirtualMachine {
 	  const InsSig* machineInstructions, int32_t machineInstructionCount,
 	  const InsSig* machineInstructions, int32_t machineInstructionCount,
 	  const VMTypeDef* machineTypes, int32_t machineTypeCount);
 	  const VMTypeDef* machineTypes, int32_t machineTypeCount);
 
 
-	int findMethod(const ReadableString& name);
-	Variable* getResource(const ReadableString& name, int methodIndex);
+	int32_t findMethod(const ReadableString& name);
+	Variable* getResource(const ReadableString& name, int32_t methodIndex);
 	/*
 	/*
 	Indices
 	Indices
 		Global index: (Identifier) The value stores in the mantissas of machine instructions to refer to things
 		Global index: (Identifier) The value stores in the mantissas of machine instructions to refer to things
@@ -320,10 +320,10 @@ struct VirtualMachine {
 			Can be used to find the name of the variable for debugging
 			Can be used to find the name of the variable for debugging
 			Unlike the type local index, the unified index knows the type
 			Unlike the type local index, the unified index knows the type
 	*/
 	*/
-	static int globalToTypeLocalIndex(int globalIndex) {
+	static int32_t globalToTypeLocalIndex(int32_t globalIndex) {
 		return globalIndex < 0 ? -(globalIndex + 1) : globalIndex;
 		return globalIndex < 0 ? -(globalIndex + 1) : globalIndex;
 	}
 	}
-	static int typeLocalToGlobalIndex(bool isGlobal, int typeLocalIndex) {
+	static int32_t typeLocalToGlobalIndex(bool isGlobal, int32_t typeLocalIndex) {
 		return isGlobal ? -(typeLocalIndex + 1) : typeLocalIndex;
 		return isGlobal ? -(typeLocalIndex + 1) : typeLocalIndex;
 	}
 	}
 
 
@@ -332,25 +332,25 @@ struct VirtualMachine {
 	void addReturnInstruction();
 	void addReturnInstruction();
 	void addCallInstructions(const List<String>& arguments);
 	void addCallInstructions(const List<String>& arguments);
 	void interpretCommand(const ReadableString& operation, const List<VMA>& resolvedArguments);
 	void interpretCommand(const ReadableString& operation, const List<VMA>& resolvedArguments);
-	Variable* declareVariable_aux(const VMTypeDef& typeDef, int methodIndex, AccessType access, const ReadableString& name, bool initialize, const ReadableString& defaultValueText);
-	Variable* declareVariable(int methodIndex, AccessType access, const ReadableString& type, const ReadableString& name, bool initialize, const ReadableString& defaultValueText);
-	VMA VMAfromText(int methodIndex, const ReadableString& content);
+	Variable* declareVariable_aux(const VMTypeDef& typeDef, int32_t methodIndex, AccessType access, const ReadableString& name, bool initialize, const ReadableString& defaultValueText);
+	Variable* declareVariable(int32_t methodIndex, AccessType access, const ReadableString& type, const ReadableString& name, bool initialize, const ReadableString& defaultValueText);
+	VMA VMAfromText(int32_t methodIndex, const ReadableString& content);
 	void interpretMachineWord(const ReadableString& command, const List<String>& arguments);
 	void interpretMachineWord(const ReadableString& command, const List<String>& arguments);
 
 
 	// Run-time debug printing
 	// Run-time debug printing
 	#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
 	#ifdef VIRTUAL_MACHINE_DEBUG_PRINT
-		Variable* getDebugInfo(DataType dataType, int globalIndex, int methodIndex) {
+		Variable* getDebugInfo(DataType dataType, int32_t globalIndex, int32_t methodIndex) {
 			if (globalIndex < 0) { methodIndex = 0; } // Go to the global method if it's a global index
 			if (globalIndex < 0) { methodIndex = 0; } // Go to the global method if it's a global index
 			Method* method = &this->methods[methodIndex];
 			Method* method = &this->methods[methodIndex];
-			int typeLocalIndex = globalToTypeLocalIndex(globalIndex);
-			int unifiedLocalIndex = method->unifiedLocalIndices[dataType][typeLocalIndex];
+			int32_t typeLocalIndex = globalToTypeLocalIndex(globalIndex);
+			int32_t unifiedLocalIndex = method->unifiedLocalIndices[dataType][typeLocalIndex];
 			return &(method->locals[unifiedLocalIndex]);
 			return &(method->locals[unifiedLocalIndex]);
 		}
 		}
-		void debugArgument(const VMA& data, int methodIndex, int32_t* framePointer, bool fullContent) {
+		void debugArgument(const VMA& data, int32_t methodIndex, int32_t* framePointer, bool fullContent) {
 			if (data.argType == ArgumentType::Immediate) {
 			if (data.argType == ArgumentType::Immediate) {
 				printText(data.value);
 				printText(data.value);
 			} else {
 			} else {
-				int globalIndex = data.value.getMantissa();
+				int32_t globalIndex = data.value.getMantissa();
 				Variable* variable = getDebugInfo(data.dataType, globalIndex, methodIndex);
 				Variable* variable = getDebugInfo(data.dataType, globalIndex, methodIndex);
 				const VMTypeDef* typeDefinition = getMachineType(data.dataType);
 				const VMTypeDef* typeDefinition = getMachineType(data.dataType);
 				#ifndef VIRTUAL_MACHINE_DEBUG_FULL_CONTENT
 				#ifndef VIRTUAL_MACHINE_DEBUG_FULL_CONTENT
@@ -368,9 +368,9 @@ struct VirtualMachine {
 				}
 				}
 			}
 			}
 		}
 		}
-		void debugPrintVariables(int methodIndex, int32_t* framePointer, const ReadableString& indentation) {
+		void debugPrintVariables(int32_t methodIndex, int32_t* framePointer, const ReadableString& indentation) {
 			Method* method = &this->methods[methodIndex];
 			Method* method = &this->methods[methodIndex];
-			for (int i = 0; i < method->locals.length(); i++) {
+			for (int32_t i = 0; i < method->locals.length(); i++) {
 				Variable* variable = &method->locals[i];
 				Variable* variable = &method->locals[i];
 				printText(indentation, U"* ", getName(variable->access), U" ");
 				printText(indentation, U"* ", getName(variable->access), U" ");
 				const VMTypeDef* typeDefinition = getMachineType(variable->typeDescription->dataType);
 				const VMTypeDef* typeDefinition = getMachineType(variable->typeDescription->dataType);
@@ -382,30 +382,30 @@ struct VirtualMachine {
 				printText(U"\n");
 				printText(U"\n");
 			}
 			}
 		}
 		}
-		void debugPrintMethod(int methodIndex, int32_t* framePointer, int32_t* stackPointer, const ReadableString& indentation) {
+		void debugPrintMethod(int32_t methodIndex, int32_t* framePointer, int32_t* stackPointer, const ReadableString& indentation) {
 			printText("  ", this->methods[methodIndex].name, ":\n");
 			printText("  ", this->methods[methodIndex].name, ":\n");
-			for (int t = 0; t < this->machineTypeCount; t++) {
+			for (int32_t t = 0; t < this->machineTypeCount; t++) {
 				printText(U"    FramePointer[", t, "] = ", framePointer[t], U" Count[", t, "] = ", this->methods[methodIndex].count[t], U" StackPointer[", t, "] = ", stackPointer[t], U"\n");
 				printText(U"    FramePointer[", t, "] = ", framePointer[t], U" Count[", t, "] = ", this->methods[methodIndex].count[t], U" StackPointer[", t, "] = ", stackPointer[t], U"\n");
 			}
 			}
 			debugPrintVariables(methodIndex, framePointer, indentation);
 			debugPrintVariables(methodIndex, framePointer, indentation);
 			printText(U"\n");
 			printText(U"\n");
 		}
 		}
 		void debugPrintMemory() {
 		void debugPrintMemory() {
-			int methodIndex = this->memory->current.methodIndex;
+			int32_t methodIndex = this->memory->current.methodIndex;
 			printText(U"\nMemory:\n");
 			printText(U"\nMemory:\n");
 			// Global memory is at the bottom of the stack.
 			// Global memory is at the bottom of the stack.
 			int32_t globalFramePointer[MAX_TYPE_COUNT] = {};
 			int32_t globalFramePointer[MAX_TYPE_COUNT] = {};
 			debugPrintMethod(0, globalFramePointer, this->methods[0].count, U"    ");
 			debugPrintMethod(0, globalFramePointer, this->methods[0].count, U"    ");
 			// Stack memory for each calling method.
 			// Stack memory for each calling method.
-			for (int i = 0; i < memory->callStack.length(); i++) {
+			for (int32_t i = 0; i < memory->callStack.length(); i++) {
 				debugPrintMethod(memory->callStack[i].methodIndex, memory->callStack[i].framePointer, memory->callStack[i].stackPointer, U"    ");
 				debugPrintMethod(memory->callStack[i].methodIndex, memory->callStack[i].framePointer, memory->callStack[i].stackPointer, U"    ");
 			}
 			}
 			// Stack memory for the current method, which is not in the call stack because that would be slow to access.
 			// Stack memory for the current method, which is not in the call stack because that would be slow to access.
 			debugPrintMethod(methodIndex, this->memory->current.framePointer, this->memory->current.stackPointer, U"    ");
 			debugPrintMethod(methodIndex, this->memory->current.framePointer, this->memory->current.stackPointer, U"    ");
 		}
 		}
 	#endif
 	#endif
-	void executeMethod(int methodIndex);
-	int32_t getResourceStackIndex(const ReadableString& name, int methodIndex, DataType dataType, AccessType access = AccessType::Any) {
+	void executeMethod(int32_t methodIndex);
+	int32_t getResourceStackIndex(const ReadableString& name, int32_t methodIndex, DataType dataType, AccessType access = AccessType::Any) {
 		Variable* variable = getResource(name, methodIndex);
 		Variable* variable = getResource(name, methodIndex);
 		if (variable) {
 		if (variable) {
 			if (variable->typeDescription->dataType != dataType) {
 			if (variable->typeDescription->dataType != dataType) {

+ 10 - 10
Source/DFPSR/implementation/persistent/ClassFactory.cpp

@@ -39,8 +39,8 @@ Handle<StructureDefinition> Persistent::getStructure() const {
 	return Handle<StructureDefinition>();
 	return Handle<StructureDefinition>();
 }
 }
 
 
-static int findPersistentClass(const String &type) {
-	for (int i = 0; i < persistentClasses.length(); i++) {
+static int32_t findPersistentClass(const String &type) {
+	for (int32_t i = 0; i < persistentClasses.length(); i++) {
 		if (string_match(persistentClasses[i].type, type)) {
 		if (string_match(persistentClasses[i].type, type)) {
 			return i;
 			return i;
 		}
 		}
@@ -53,7 +53,7 @@ String Persistent::getClassName() const {
 }
 }
 
 
 void Persistent::registerPersistentClass() {
 void Persistent::registerPersistentClass() {
-	int existingIndex = findPersistentClass(this->getClassName());
+	int32_t existingIndex = findPersistentClass(this->getClassName());
 	// If a class of the name doesn't already exist
 	// If a class of the name doesn't already exist
 	if (existingIndex == -1) {
 	if (existingIndex == -1) {
 		// Register its constructor using the name
 		// Register its constructor using the name
@@ -65,11 +65,11 @@ bool Persistent::addChild(Handle<Persistent> child) {
 	return false;
 	return false;
 }
 }
 
 
-int Persistent::getChildCount() const {
+int32_t Persistent::getChildCount() const {
 	return 0;
 	return 0;
 }
 }
 
 
-Handle<Persistent> Persistent::getChild(int index) const {
+Handle<Persistent> Persistent::getChild(int32_t index) const {
 	return Handle<Persistent>();
 	return Handle<Persistent>();
 }
 }
 
 
@@ -103,7 +103,7 @@ String& Persistent::toStreamIndented(String& out, const ReadableString& indentat
 	string_append(out, indentation, U"Begin : ", structure->name, U"\n");
 	string_append(out, indentation, U"Begin : ", structure->name, U"\n");
 	String nextIndentation = indentation + U"	";
 	String nextIndentation = indentation + U"	";
 	// Save parameters
 	// Save parameters
-	for (int i = 0; i < structure->length(); i++) {
+	for (int32_t i = 0; i < structure->length(); i++) {
 		String name = structure->attributes[i].name;
 		String name = structure->attributes[i].name;
 		Persistent* value = ((Persistent*)this)->findAttribute(name); // Override const
 		Persistent* value = ((Persistent*)this)->findAttribute(name); // Override const
 		if (value == nullptr) {
 		if (value == nullptr) {
@@ -115,7 +115,7 @@ String& Persistent::toStreamIndented(String& out, const ReadableString& indentat
 		}
 		}
 	}
 	}
 	// Save child objects
 	// Save child objects
-	for (int c = 0; c < this->getChildCount(); c++) {
+	for (int32_t c = 0; c < this->getChildCount(); c++) {
 		this->getChild(c)->toStreamIndented(out, nextIndentation);
 		this->getChild(c)->toStreamIndented(out, nextIndentation);
 	}
 	}
 	string_append(out, indentation, U"End\n");
 	string_append(out, indentation, U"End\n");
@@ -124,7 +124,7 @@ String& Persistent::toStreamIndented(String& out, const ReadableString& indentat
 
 
 Handle<Persistent> dsr::createPersistentClass(const String &type, bool mustExist) {
 Handle<Persistent> dsr::createPersistentClass(const String &type, bool mustExist) {
 	// Look for the component
 	// Look for the component
-	int existingIndex = findPersistentClass(type);
+	int32_t existingIndex = findPersistentClass(type);
 	if (existingIndex > -1) {
 	if (existingIndex > -1) {
 		return persistentClasses[existingIndex].defaultConstructor();
 		return persistentClasses[existingIndex].defaultConstructor();
 	}
 	}
@@ -139,14 +139,14 @@ Handle<Persistent> dsr::createPersistentClassFromText(const ReadableString &text
 	Handle<Persistent> rootObject, newObject;
 	Handle<Persistent> rootObject, newObject;
 	List<Handle<Persistent>> stack;
 	List<Handle<Persistent>> stack;
 	string_split_callback([&rootObject, &newObject, &stack, &fromPath](ReadableString line) {
 	string_split_callback([&rootObject, &newObject, &stack, &fromPath](ReadableString line) {
-		int equalityIndex = string_findFirst(line, '=');
+		int32_t equalityIndex = string_findFirst(line, '=');
 		if (equalityIndex > -1) {
 		if (equalityIndex > -1) {
 			// Assignment
 			// Assignment
 			String key = string_removeOuterWhiteSpace(string_before(line, equalityIndex));
 			String key = string_removeOuterWhiteSpace(string_before(line, equalityIndex));
 			String value = string_removeOuterWhiteSpace(string_after(line, equalityIndex));
 			String value = string_removeOuterWhiteSpace(string_after(line, equalityIndex));
 			stack.last()->setProperty(key, value, fromPath);
 			stack.last()->setProperty(key, value, fromPath);
 		} else {
 		} else {
-			int colonIndex = string_findFirst(line, ':');
+			int32_t colonIndex = string_findFirst(line, ':');
 			if (colonIndex > -1) {
 			if (colonIndex > -1) {
 				// Declaration
 				// Declaration
 				String keyword = string_removeOuterWhiteSpace(string_before(line, colonIndex));
 				String keyword = string_removeOuterWhiteSpace(string_before(line, colonIndex));

+ 3 - 3
Source/DFPSR/implementation/persistent/ClassFactory.h

@@ -85,7 +85,7 @@ public:
 	void declareAttribute(const String &name) {
 	void declareAttribute(const String &name) {
 		this->attributes.push(PersistentAttribute(name));
 		this->attributes.push(PersistentAttribute(name));
 	}
 	}
-	int length() {
+	int32_t length() {
 		return this->attributes.length();
 		return this->attributes.length();
 	}
 	}
 };
 };
@@ -109,8 +109,8 @@ public:
 	//   Return false if the child object was rejected
 	//   Return false if the child object was rejected
 	//   Make sure that connections that would create an infinite loop are rejected
 	//   Make sure that connections that would create an infinite loop are rejected
 	virtual bool addChild(Handle<Persistent> child);
 	virtual bool addChild(Handle<Persistent> child);
-	virtual int getChildCount() const;
-	virtual Handle<Persistent> getChild(int index) const;
+	virtual int32_t getChildCount() const;
+	virtual Handle<Persistent> getChild(int32_t index) const;
 public:
 public:
 	// Override for new compound types
 	// Override for new compound types
 
 

+ 1 - 1
Source/DFPSR/implementation/persistent/atomic/PersistentColor.h

@@ -36,7 +36,7 @@ public:
 public:
 public:
 	PersistentColor() : value(0, 0, 0) {}
 	PersistentColor() : value(0, 0, 0) {}
 	explicit PersistentColor(ColorRgbI32 color) : value(color) {}
 	explicit PersistentColor(ColorRgbI32 color) : value(color) {}
-	explicit PersistentColor(int red, int green, int blue) : value(ColorRgbI32(red, green, blue)) {}
+	explicit PersistentColor(int32_t red, int32_t green, int32_t blue) : value(ColorRgbI32(red, green, blue)) {}
 public:
 public:
 	virtual bool assignValue(const ReadableString &text, const ReadableString &fromPath) override;
 	virtual bool assignValue(const ReadableString &text, const ReadableString &fromPath) override;
 	virtual String& toStreamIndented(String& out, const ReadableString& indentation) const override;
 	virtual String& toStreamIndented(String& out, const ReadableString& indentation) const override;

+ 17 - 17
Source/DFPSR/implementation/persistent/atomic/PersistentImage.cpp

@@ -28,9 +28,9 @@ using namespace dsr;
 
 
 PERSISTENT_DEFINITION(PersistentImage)
 PERSISTENT_DEFINITION(PersistentImage)
 
 
-static uint8_t readHexaDecimal(const ReadableString &text, int &readFrom) {
+static uint8_t readHexaDecimal(const ReadableString &text, int32_t &readFrom) {
 	uint8_t result = 0u;
 	uint8_t result = 0u;
-	for (int i = 0; i < 2; i++) {
+	for (int32_t i = 0; i < 2; i++) {
 		result = result << 4;
 		result = result << 4;
 		DsrChar c = text[readFrom];
 		DsrChar c = text[readFrom];
 		if (U'0' <= c && c <= U'9') {
 		if (U'0' <= c && c <= U'9') {
@@ -51,7 +51,7 @@ bool PersistentImage::assignValue(const ReadableString &text, const ReadableStri
 		this->value = OrderedImageRgbaU8();
 		this->value = OrderedImageRgbaU8();
 	} else {
 	} else {
 		// Create an image from the text
 		// Create an image from the text
-		int colonIndex = string_findFirst(text, U':');
+		int32_t colonIndex = string_findFirst(text, U':');
 		if (colonIndex == -1) {
 		if (colonIndex == -1) {
 			printText("Missing colon when creating PersistentImage from text!\n");
 			printText("Missing colon when creating PersistentImage from text!\n");
 			return false;
 			return false;
@@ -63,25 +63,25 @@ bool PersistentImage::assignValue(const ReadableString &text, const ReadableStri
 			this->value = image_load_RgbaU8(absolutePath);
 			this->value = image_load_RgbaU8(absolutePath);
 		} else {
 		} else {
 			// Read dimensions and a sequence of pixels as hexadecimals
 			// Read dimensions and a sequence of pixels as hexadecimals
-			int xIndex = string_findFirst(text, U'x');
+			int32_t xIndex = string_findFirst(text, U'x');
 			if (xIndex == -1 || xIndex > colonIndex) {
 			if (xIndex == -1 || xIndex > colonIndex) {
 				printText("Missing x when parsing embedded PersistentImage from text!\n");
 				printText("Missing x when parsing embedded PersistentImage from text!\n");
 				return false;
 				return false;
 			}
 			}
-			int width = string_toInteger(string_before(leftSide, xIndex));
-			int height = string_toInteger(string_after(leftSide, xIndex));
+			int32_t width = string_toInteger(string_before(leftSide, xIndex));
+			int32_t height = string_toInteger(string_after(leftSide, xIndex));
 			if (width <= 0 || height <= 0) {
 			if (width <= 0 || height <= 0) {
 				// No pixels found
 				// No pixels found
 				this->value = OrderedImageRgbaU8();
 				this->value = OrderedImageRgbaU8();
 			} else {
 			} else {
 				this->value = image_create_RgbaU8(width, height);
 				this->value = image_create_RgbaU8(width, height);
-				int readIndex = colonIndex + 1;
-				for (int y = 0; y < height; y++) {
-					for (int x = 0; x < width; x++) {
-						int red = readHexaDecimal(text, readIndex);
-						int green = readHexaDecimal(text, readIndex);
-						int blue = readHexaDecimal(text, readIndex);
-						int alpha = readHexaDecimal(text, readIndex);
+				int32_t readIndex = colonIndex + 1;
+				for (int32_t y = 0; y < height; y++) {
+					for (int32_t x = 0; x < width; x++) {
+						int32_t red = readHexaDecimal(text, readIndex);
+						int32_t green = readHexaDecimal(text, readIndex);
+						int32_t blue = readHexaDecimal(text, readIndex);
+						int32_t alpha = readHexaDecimal(text, readIndex);
 						image_writePixel(this->value, x, y, ColorRgbaI32(red, green, blue, alpha));
 						image_writePixel(this->value, x, y, ColorRgbaI32(red, green, blue, alpha));
 					}
 					}
 				}
 				}
@@ -101,11 +101,11 @@ String& PersistentImage::toStreamIndented(String &out, const ReadableString &ind
 	if (string_length(this->path)) {
 	if (string_length(this->path)) {
 		string_append(out, "File:", this->path);
 		string_append(out, "File:", this->path);
 	} else if (image_exists(this->value)) {
 	} else if (image_exists(this->value)) {
-		int width = image_getWidth(this->value);
-		int height = image_getHeight(this->value);
+		int32_t width = image_getWidth(this->value);
+		int32_t height = image_getHeight(this->value);
 		string_append(out, width, U"x", height, U":");
 		string_append(out, width, U"x", height, U":");
-		for (int y = 0; y < height; y++) {
-			for (int x = 0; x < width; x++) {
+		for (int32_t y = 0; y < height; y++) {
+			for (int32_t x = 0; x < width; x++) {
 				ColorRgbaI32 color = image_readPixel_clamp(this->value, x, y);
 				ColorRgbaI32 color = image_readPixel_clamp(this->value, x, y);
 				writeHexaDecimal(out, color.red);
 				writeHexaDecimal(out, color.red);
 				writeHexaDecimal(out, color.green);
 				writeHexaDecimal(out, color.green);

+ 3 - 3
Source/DFPSR/implementation/persistent/atomic/PersistentStringList.cpp

@@ -32,9 +32,9 @@ bool PersistentStringList::assignValue(const ReadableString &text, const Readabl
 	bool quoted = false;
 	bool quoted = false;
 	bool first = true;
 	bool first = true;
 	bool hadComma = false;
 	bool hadComma = false;
-	int start = 0;
+	int32_t start = 0;
 	this->value.clear();
 	this->value.clear();
-	for (int i = 0; i < string_length(text); i++) {
+	for (int32_t i = 0; i < string_length(text); i++) {
 		DsrChar c = text[i];
 		DsrChar c = text[i];
 		if (quoted) {
 		if (quoted) {
 			if (c == U'\\') { // Escape sequence
 			if (c == U'\\') { // Escape sequence
@@ -73,7 +73,7 @@ bool PersistentStringList::assignValue(const ReadableString &text, const Readabl
 
 
 String& PersistentStringList::toStreamIndented(String& out, const ReadableString& indentation) const {
 String& PersistentStringList::toStreamIndented(String& out, const ReadableString& indentation) const {
 	string_append(out, indentation);
 	string_append(out, indentation);
-	for (int i = 0; i < this->value.length(); i++) {
+	for (int32_t i = 0; i < this->value.length(); i++) {
 		if (i > 0) {
 		if (i > 0) {
 			string_append(out, ", ");
 			string_append(out, ", ");
 		}
 		}

+ 15 - 15
Source/DFPSR/implementation/render/Camera.h

@@ -40,15 +40,15 @@ namespace dsr {
 class ViewFrustum {
 class ViewFrustum {
 private:
 private:
 	FPlane3D planes[6];
 	FPlane3D planes[6];
-	int planeCount;
+	int32_t planeCount;
 public:
 public:
 	// Named indices to the different planes defining a view frustum.
 	// Named indices to the different planes defining a view frustum.
-	static const int view_left   = 0;
-	static const int view_right  = 1;
-	static const int view_top    = 2;
-	static const int view_bottom = 3;
-	static const int view_near   = 4;
-	static const int view_far    = 5;
+	static const int32_t view_left   = 0;
+	static const int32_t view_right  = 1;
+	static const int32_t view_top    = 2;
+	static const int32_t view_bottom = 3;
+	static const int32_t view_near   = 4;
+	static const int32_t view_far    = 5;
 	ViewFrustum() : planeCount(0) {}
 	ViewFrustum() : planeCount(0) {}
 	// Orthogonal view frustum in camera space
 	// Orthogonal view frustum in camera space
 	ViewFrustum(float halfWidth, float halfHeight)
 	ViewFrustum(float halfWidth, float halfHeight)
@@ -71,10 +71,10 @@ public:
 		planes[view_near  ] = FPlane3D(FVector3D(0.0f, 0.0f, -1.0f), -nearClip);
 		planes[view_near  ] = FPlane3D(FVector3D(0.0f, 0.0f, -1.0f), -nearClip);
 		planes[view_far   ] = FPlane3D(FVector3D(0.0f, 0.0f,  1.0f),   farClip);
 		planes[view_far   ] = FPlane3D(FVector3D(0.0f, 0.0f,  1.0f),   farClip);
 	}
 	}
-	inline int getPlaneCount() const {
+	inline int32_t getPlaneCount() const {
 		return this->planeCount;
 		return this->planeCount;
 	}
 	}
-	inline FPlane3D getPlane(int sideIndex) const {
+	inline FPlane3D getPlane(int32_t sideIndex) const {
 		assert(sideIndex >= 0 && sideIndex < this->planeCount);
 		assert(sideIndex >= 0 && sideIndex < this->planeCount);
 		return planes[sideIndex];
 		return planes[sideIndex];
 	}
 	}
@@ -83,13 +83,13 @@ public:
 	// Returns 0 if all points are outside of the same plane, so that an object within the convex hull can not be visible.
 	// Returns 0 if all points are outside of the same plane, so that an object within the convex hull can not be visible.
 	// Returns 1 if one or more points are outside of the view frustum but they are not all outside of the same plane, so it may or may not be visible.
 	// Returns 1 if one or more points are outside of the view frustum but they are not all outside of the same plane, so it may or may not be visible.
 	// Returns 2 if all points are inside of the view frustum, so that it is certainly visible, unless hidden by something else.
 	// Returns 2 if all points are inside of the view frustum, so that it is certainly visible, unless hidden by something else.
-	int isConvexHullSeen(SafePointer<const FVector3D> cameraSpacePoints, int32_t pointCount) const {
+	int32_t isConvexHullSeen(SafePointer<const FVector3D> cameraSpacePoints, int32_t pointCount) const {
 		bool anyOutside = false;
 		bool anyOutside = false;
-		for (int s = 0; s < this->getPlaneCount(); s++) {
+		for (int32_t s = 0; s < this->getPlaneCount(); s++) {
 			FPlane3D plane = this->getPlane(s);
 			FPlane3D plane = this->getPlane(s);
 			// Check if any point is inside of the current plane.
 			// Check if any point is inside of the current plane.
 			bool anyInside = false;
 			bool anyInside = false;
-			for (int p = 0; p < pointCount; p++) {
+			for (int32_t p = 0; p < pointCount; p++) {
 				if (plane.inside(cameraSpacePoints[p])) {
 				if (plane.inside(cameraSpacePoints[p])) {
 					anyInside = true;
 					anyInside = true;
 				} else {
 				} else {
@@ -188,17 +188,17 @@ public:
 		return this->cameraToScreen(this->worldToCamera(worldSpace));
 		return this->cameraToScreen(this->worldToCamera(worldSpace));
 	}
 	}
 	// Get the number of planes in the clipping or culling frustum.
 	// Get the number of planes in the clipping or culling frustum.
-	inline int getFrustumPlaneCount(bool clipping = false) const {
+	inline int32_t getFrustumPlaneCount(bool clipping = false) const {
 		return clipping ? this->clipFrustum.getPlaneCount() : this->cullFrustum.getPlaneCount();
 		return clipping ? this->clipFrustum.getPlaneCount() : this->cullFrustum.getPlaneCount();
 	}
 	}
 	// Get a certain plane from the clipping or culling frustum.
 	// Get a certain plane from the clipping or culling frustum.
 	//   The plane is expressed in camera space.
 	//   The plane is expressed in camera space.
-	inline FPlane3D getFrustumPlane(int sideIndex, bool clipping = false) const {
+	inline FPlane3D getFrustumPlane(int32_t sideIndex, bool clipping = false) const {
 		return clipping ? this->clipFrustum.getPlane(sideIndex) : this->cullFrustum.getPlane(sideIndex);
 		return clipping ? this->clipFrustum.getPlane(sideIndex) : this->cullFrustum.getPlane(sideIndex);
 	}
 	}
 	// Returns 0 iff the model inside of the bound can clearly not be visible, 1 if it intersects with the view frustum, or 2 if fully in view.
 	// Returns 0 iff the model inside of the bound can clearly not be visible, 1 if it intersects with the view frustum, or 2 if fully in view.
 	//   by having all corners outside of the same side in the camera's culling frustum.
 	//   by having all corners outside of the same side in the camera's culling frustum.
-	int isBoxSeen(const FVector3D& minModelSpaceBound, const FVector3D& maxModelSpaceBound, const Transform3D &modelToWorld) const {
+	int32_t isBoxSeen(const FVector3D& minModelSpaceBound, const FVector3D& maxModelSpaceBound, const Transform3D &modelToWorld) const {
 		// Allocate memory for the corners.
 		// Allocate memory for the corners.
 		FVector3D cornerBuffer[8];
 		FVector3D cornerBuffer[8];
 		SafePointer<FVector3D> corners = SafePointer<FVector3D>("corners in Camera::isBoxSeen", cornerBuffer, sizeof(cornerBuffer));
 		SafePointer<FVector3D> corners = SafePointer<FVector3D>("corners in Camera::isBoxSeen", cornerBuffer, sizeof(cornerBuffer));

+ 18 - 18
Source/DFPSR/implementation/render/ITriangle2D.cpp

@@ -35,10 +35,10 @@ IRect dsr::getTriangleBound(LVector2D a, LVector2D b, LVector2D c) {
 	int32_t rY2 = (b.y + constants::unitsPerHalfPixel) / constants::unitsPerPixel;
 	int32_t rY2 = (b.y + constants::unitsPerHalfPixel) / constants::unitsPerPixel;
 	int32_t rX3 = (c.x + constants::unitsPerHalfPixel) / constants::unitsPerPixel;
 	int32_t rX3 = (c.x + constants::unitsPerHalfPixel) / constants::unitsPerPixel;
 	int32_t rY3 = (c.y + constants::unitsPerHalfPixel) / constants::unitsPerPixel;
 	int32_t rY3 = (c.y + constants::unitsPerHalfPixel) / constants::unitsPerPixel;
-	int leftBound = min(rX1, rX2, rX3) - 1;
-	int topBound = min(rY1, rY2, rY3) - 1;
-	int rightBound = max(rX1, rX2, rX3) + 1;
-	int bottomBound = max(rY1, rY2, rY3) + 1;
+	int32_t leftBound = min(rX1, rX2, rX3) - 1;
+	int32_t topBound = min(rY1, rY2, rY3) - 1;
+	int32_t rightBound = max(rX1, rX2, rX3) + 1;
+	int32_t bottomBound = max(rY1, rY2, rY3) + 1;
 	return IRect(leftBound, topBound, rightBound - leftBound, bottomBound - topBound);
 	return IRect(leftBound, topBound, rightBound - leftBound, bottomBound - topBound);
 }
 }
 
 
@@ -67,14 +67,14 @@ inline static void cutLeft(int32_t& leftBound, int32_t value) {
 	leftBound = max(leftBound, value);
 	leftBound = max(leftBound, value);
 }
 }
 
 
-IRect ITriangle2D::getAlignedRasterBound(const IRect& clipBound, int alignX, int alignY) const {
+IRect ITriangle2D::getAlignedRasterBound(const IRect& clipBound, int32_t alignX, int32_t alignY) const {
 	IRect unaligned = IRect::cut(this->wholeBound, clipBound);
 	IRect unaligned = IRect::cut(this->wholeBound, clipBound);
-	int alignedTop = roundDown(unaligned.top(), 2);
-	int alignedBottom = roundUp(unaligned.bottom(), 2);
+	int32_t alignedTop = roundDown(unaligned.top(), 2);
+	int32_t alignedBottom = roundUp(unaligned.bottom(), 2);
 	return IRect(unaligned.left(), alignedTop, unaligned.width(), alignedBottom - alignedTop);
 	return IRect(unaligned.left(), alignedTop, unaligned.width(), alignedBottom - alignedTop);
 }
 }
 
 
-int ITriangle2D::getBufferSize(const IRect& clipBound, int alignX, int alignY) const {
+int32_t ITriangle2D::getBufferSize(const IRect& clipBound, int32_t alignX, int32_t alignY) const {
 	if (IRect::overlaps(this->wholeBound, clipBound)) {
 	if (IRect::overlaps(this->wholeBound, clipBound)) {
 		IRect rasterBound = this->getAlignedRasterBound(clipBound, alignX, alignY);
 		IRect rasterBound = this->getAlignedRasterBound(clipBound, alignX, alignY);
 		return rasterBound.bottom() - rasterBound.top();
 		return rasterBound.bottom() - rasterBound.top();
@@ -84,10 +84,10 @@ int ITriangle2D::getBufferSize(const IRect& clipBound, int alignX, int alignY) c
 }
 }
 
 
 static void cutConvexEdge(const LVector2D& startPoint, const LVector2D& endPoint, RowInterval* rows, const IRect& clipBound) {
 static void cutConvexEdge(const LVector2D& startPoint, const LVector2D& endPoint, RowInterval* rows, const IRect& clipBound) {
-	int leftBound = clipBound.left();
-	int topBound = clipBound.top();
-	int rightBound = clipBound.right();
-	int bottomBound = clipBound.bottom();
+	int32_t leftBound = clipBound.left();
+	int32_t topBound = clipBound.top();
+	int32_t rightBound = clipBound.right();
+	int32_t bottomBound = clipBound.bottom();
 
 
 	// Get origin in units
 	// Get origin in units
 	int64_t originX = constants::unitsPerHalfPixel + clipBound.left() * constants::unitsPerPixel;
 	int64_t originX = constants::unitsPerHalfPixel + clipBound.left() * constants::unitsPerPixel;
@@ -168,7 +168,7 @@ void dsr::rasterizeTriangle(const LVector2D& cornerA, const LVector2D& cornerB,
 	}
 	}
 }
 }
 
 
-void ITriangle2D::getShape(int& startRow, RowInterval* rows, const IRect& clipBound, int alignX, int alignY) const {
+void ITriangle2D::getShape(int32_t& startRow, RowInterval* rows, const IRect& clipBound, int32_t alignX, int32_t alignY) const {
 	// TODO: Move alignment to the render core where it belongs so that all alignX and alignY arguments are removed from the triangle
 	// TODO: Move alignment to the render core where it belongs so that all alignX and alignY arguments are removed from the triangle
 	IRect alignedBound = this->getAlignedRasterBound(clipBound, alignX, alignY);
 	IRect alignedBound = this->getAlignedRasterBound(clipBound, alignX, alignY);
 	startRow = alignedBound.top();
 	startRow = alignedBound.top();
@@ -191,8 +191,8 @@ Projection ITriangle2D::getProjection(const FVector3D& subB, const FVector3D& su
 */
 */
 	// Get offsets
 	// Get offsets
 	FVector3D offsetX, offsetY;
 	FVector3D offsetX, offsetY;
-	for (int i = 0; i < 3; i++) {
-		int j = (i + 1) % 3;      // End
+	for (int32_t i = 0; i < 3; i++) {
+		int32_t j = (i + 1) % 3;      // End
 		FVector2D posI = this->position[i].is;
 		FVector2D posI = this->position[i].is;
 		FVector2D posJ = this->position[j].is;
 		FVector2D posJ = this->position[j].is;
 		// Get offsets for each edge
 		// Get offsets for each edge
@@ -202,7 +202,7 @@ Projection ITriangle2D::getProjection(const FVector3D& subB, const FVector3D& su
 	// Get the maximum values along the offsets for normalization
 	// Get the maximum values along the offsets for normalization
 	FVector3D weightMultiplier;
 	FVector3D weightMultiplier;
 	for (int32_t i = 0; i < 3; i++) {
 	for (int32_t i = 0; i < 3; i++) {
-		int o = (i + 2) % 3;
+		int32_t o = (i + 2) % 3;
 		// Take the same kind of dot product from the point that is furthest away from the edge for normalization.
 		// Take the same kind of dot product from the point that is furthest away from the edge for normalization.
 		float otherSideValue = ((this->position[o].is.x - this->position[i].is.x) * offsetX[i])
 		float otherSideValue = ((this->position[o].is.x - this->position[i].is.x) * offsetX[i])
 		                     + ((this->position[o].is.y - this->position[i].is.y) * offsetY[i]);
 		                     + ((this->position[o].is.y - this->position[i].is.y) * offsetY[i]);
@@ -214,14 +214,14 @@ Projection ITriangle2D::getProjection(const FVector3D& subB, const FVector3D& su
 	}
 	}
 	// Get normal from weight multiplier and offset
 	// Get normal from weight multiplier and offset
 	FVector3D normalX, normalY;
 	FVector3D normalX, normalY;
-	for (int i = 0; i < 3; i++) {
+	for (int32_t i = 0; i < 3; i++) {
 		normalX[i] = offsetX[i] * weightMultiplier[i];
 		normalX[i] = offsetX[i] * weightMultiplier[i];
 		normalY[i] = offsetY[i] * weightMultiplier[i];
 		normalY[i] = offsetY[i] * weightMultiplier[i];
 	}
 	}
 	// Sample the weight of each corner at the upper left corner of the target image
 	// Sample the weight of each corner at the upper left corner of the target image
 	FVector3D targetWeight;
 	FVector3D targetWeight;
 	for (int32_t i = 0; i < 3; i++) {
 	for (int32_t i = 0; i < 3; i++) {
-		int o = (i + 2) % 3;
+		int32_t o = (i + 2) % 3;
 		// Take the dot product to get a normalized weight
 		// Take the dot product to get a normalized weight
 		targetWeight[o] = this->position[i].is.x * -normalX[i] + this->position[i].is.y * -normalY[i];
 		targetWeight[o] = this->position[i].is.x * -normalX[i] + this->position[i].is.y * -normalY[i];
 	}
 	}

+ 6 - 6
Source/DFPSR/implementation/render/ITriangle2D.h

@@ -135,12 +135,12 @@ public:
 class RowShape {
 class RowShape {
 public:
 public:
 	// A collection of row intervals telling where pixels should be drawn
 	// A collection of row intervals telling where pixels should be drawn
-	const int startRow;
-	const int rowCount;
+	const int32_t startRow;
+	const int32_t rowCount;
 	const RowInterval *rows;
 	const RowInterval *rows;
 	// Constructors
 	// Constructors
 	RowShape() : startRow(0), rowCount(0), rows(nullptr) {}
 	RowShape() : startRow(0), rowCount(0), rows(nullptr) {}
-	RowShape(int startRow, int rowCount, RowInterval* rows) : startRow(startRow), rowCount(rowCount), rows(rows) {}
+	RowShape(int32_t startRow, int32_t rowCount, RowInterval* rows) : startRow(startRow), rowCount(rowCount), rows(rows) {}
 };
 };
 
 
 // Any extra information will be given to the filling method as this only gives the shape and vertex interpolation data
 // Any extra information will be given to the filling method as this only gives the shape and vertex interpolation data
@@ -156,15 +156,15 @@ public:
 	bool isFrontfacing() const;
 	bool isFrontfacing() const;
 	// Get the region to rasterize where the first and last rows may go outside of the clipBound with empty rows for alignment
 	// Get the region to rasterize where the first and last rows may go outside of the clipBound with empty rows for alignment
 	//   Give a clipBound with top and bottom at even multiples of two if you don't want the result to go outside
 	//   Give a clipBound with top and bottom at even multiples of two if you don't want the result to go outside
-	IRect getAlignedRasterBound(const IRect& clipBound, int alignX, int alignY) const;
-	int getBufferSize(const IRect& clipBound, int alignX, int alignY) const;
+	IRect getAlignedRasterBound(const IRect& clipBound, int32_t alignX, int32_t alignY) const;
+	int32_t getBufferSize(const IRect& clipBound, int32_t alignX, int32_t alignY) const;
 	// Get the row intervals within clipBound into a buffer of a size given by getBufferSize with the same clipBound
 	// Get the row intervals within clipBound into a buffer of a size given by getBufferSize with the same clipBound
 	// Output
 	// Output
 	//   rows: The exclusive row interval for each row from top to bottom
 	//   rows: The exclusive row interval for each row from top to bottom
 	//   startRow: The Y coordinate of the first row
 	//   startRow: The Y coordinate of the first row
 	// Input
 	// Input
 	//   clipBound: The pixel region where the resulting rows may draw.
 	//   clipBound: The pixel region where the resulting rows may draw.
-	void getShape(int& startRow, RowInterval* rows, const IRect& clipBound, int alignX, int alignY) const;
+	void getShape(int32_t& startRow, RowInterval* rows, const IRect& clipBound, int32_t alignX, int32_t alignY) const;
 	// Returns the vertex weight projection for specified sub-vertex weights
 	// Returns the vertex weight projection for specified sub-vertex weights
 	Projection getProjection(const FVector3D& subB, const FVector3D& subC, bool perspective) const;
 	Projection getProjection(const FVector3D& subB, const FVector3D& subC, bool perspective) const;
 	// Returns the vertex weight projection for default sub-vertex weights
 	// Returns the vertex weight projection for default sub-vertex weights

+ 7 - 7
Source/DFPSR/implementation/render/ResourcePool.cpp

@@ -29,8 +29,8 @@
 
 
 using namespace dsr;
 using namespace dsr;
 
 
-int BasicResourcePool::findImageRgba(const ReadableString& name) const {
-	for (int i = 0; i < this->imageRgbaList.length(); i++) {
+int32_t BasicResourcePool::findImageRgba(const ReadableString& name) const {
+	for (int32_t i = 0; i < this->imageRgbaList.length(); i++) {
 		// Warning!
 		// Warning!
 		// This may cover up bugs with case sensitive matching in the Linux file system.
 		// This may cover up bugs with case sensitive matching in the Linux file system.
 		// TODO: Make this case sensitive and enforce it on Windows or allow case insensitive loading on all systems.
 		// TODO: Make this case sensitive and enforce it on Windows or allow case insensitive loading on all systems.
@@ -41,8 +41,8 @@ int BasicResourcePool::findImageRgba(const ReadableString& name) const {
 	return -1;
 	return -1;
 }
 }
 
 
-int BasicResourcePool::findTextureRgba(const ReadableString& name) const {
-	for (int i = 0; i < this->textureRgbaList.length(); i++) {
+int32_t BasicResourcePool::findTextureRgba(const ReadableString& name) const {
+	for (int32_t i = 0; i < this->textureRgbaList.length(); i++) {
 		if (string_caseInsensitiveMatch(name, this->textureRgbaList[i].name)) {
 		if (string_caseInsensitiveMatch(name, this->textureRgbaList[i].name)) {
 			return i;
 			return i;
 		}
 		}
@@ -54,7 +54,7 @@ const ImageRgbaU8 BasicResourcePool::fetchImageRgba(const ReadableString& name)
 	ImageRgbaU8 result;
 	ImageRgbaU8 result;
 	// Using "" will return an empty reference to allow removing textures
 	// Using "" will return an empty reference to allow removing textures
 	if (string_length(name) > 0) {
 	if (string_length(name) > 0) {
-		int existingIndex = this->findImageRgba(name);
+		int32_t existingIndex = this->findImageRgba(name);
 		if (existingIndex > -1) {
 		if (existingIndex > -1) {
 			result = this->imageRgbaList[existingIndex].resource;
 			result = this->imageRgbaList[existingIndex].resource;
 		} else if (string_findFirst(name, U'.') > -1) {
 		} else if (string_findFirst(name, U'.') > -1) {
@@ -87,8 +87,8 @@ const TextureRgbaU8 BasicResourcePool::fetchTextureRgba(const ReadableString& na
 	TextureRgbaU8 result;
 	TextureRgbaU8 result;
 	// Using "" will return an empty reference to allow removing textures
 	// Using "" will return an empty reference to allow removing textures
 	if (string_length(name) > 0) {
 	if (string_length(name) > 0) {
-		int existingTextureIndex = this->findTextureRgba(name);
-		int existingImageIndex = this->findImageRgba(name);
+		int32_t existingTextureIndex = this->findTextureRgba(name);
+		int32_t existingImageIndex = this->findImageRgba(name);
 		if (existingTextureIndex > -1) {
 		if (existingTextureIndex > -1) {
 			result = this->textureRgbaList[existingTextureIndex].resource;
 			result = this->textureRgbaList[existingTextureIndex].resource;
 		} else if (existingImageIndex > -1) {
 		} else if (existingImageIndex > -1) {

+ 2 - 2
Source/DFPSR/implementation/render/ResourcePool.h

@@ -49,8 +49,8 @@ class BasicResourcePool : public ResourcePool {
 private:
 private:
 	List<namedEntry<ImageRgbaU8>> imageRgbaList;
 	List<namedEntry<ImageRgbaU8>> imageRgbaList;
 	List<namedEntry<TextureRgbaU8>> textureRgbaList;
 	List<namedEntry<TextureRgbaU8>> textureRgbaList;
-	int findImageRgba(const ReadableString& name) const;
-	int findTextureRgba(const ReadableString& name) const;
+	int32_t findImageRgba(const ReadableString& name) const;
+	int32_t findTextureRgba(const ReadableString& name) const;
 public:
 public:
 	String path;
 	String path;
 	explicit BasicResourcePool(const ReadableString& path) : path(path) {}
 	explicit BasicResourcePool(const ReadableString& path) : path(path) {}

+ 2 - 2
Source/DFPSR/implementation/render/constants.h

@@ -37,8 +37,8 @@ enum class Filter { Solid, Alpha };
 namespace constants {
 namespace constants {
 
 
 // Used for rasterization of triangles using integer math to prevent gaps
 // Used for rasterization of triangles using integer math to prevent gaps
-static const int unitsPerPixel = 256;
-static const int unitsPerHalfPixel = unitsPerPixel / 2;
+static const int32_t unitsPerPixel = 256;
+static const int32_t unitsPerHalfPixel = unitsPerPixel / 2;
 
 
 }
 }
 
 

+ 47 - 47
Source/DFPSR/implementation/render/model/Model.cpp

@@ -71,7 +71,7 @@ Polygon::Polygon(const Vertex &vertA, const Vertex &vertB, const Vertex &vertC,
 	this->colors[3] = vertD.data.color;
 	this->colors[3] = vertD.data.color;
 }
 }
 
 
-Polygon::Polygon(int indexA, int indexB, int indexC) {
+Polygon::Polygon(int32_t indexA, int32_t indexB, int32_t indexC) {
 	this->pointIndices[0] = indexA;
 	this->pointIndices[0] = indexA;
 	this->pointIndices[1] = indexB;
 	this->pointIndices[1] = indexB;
 	this->pointIndices[2] = indexC;
 	this->pointIndices[2] = indexC;
@@ -86,7 +86,7 @@ Polygon::Polygon(int indexA, int indexB, int indexC) {
 	this->colors[3] = FVector4D(1.0f, 1.0f, 1.0f, 1.0f);
 	this->colors[3] = FVector4D(1.0f, 1.0f, 1.0f, 1.0f);
 }
 }
 
 
-Polygon::Polygon(int indexA, int indexB, int indexC, int indexD) {
+Polygon::Polygon(int32_t indexA, int32_t indexB, int32_t indexC, int32_t indexD) {
 	this->pointIndices[0] = indexA;
 	this->pointIndices[0] = indexA;
 	this->pointIndices[1] = indexB;
 	this->pointIndices[1] = indexB;
 	this->pointIndices[2] = indexC;
 	this->pointIndices[2] = indexC;
@@ -101,7 +101,7 @@ Polygon::Polygon(int indexA, int indexB, int indexC, int indexD) {
 	this->colors[3] = FVector4D(1.0f, 1.0f, 1.0f, 1.0f);
 	this->colors[3] = FVector4D(1.0f, 1.0f, 1.0f, 1.0f);
 }
 }
 
 
-int Polygon::getVertexCount() const {
+int32_t Polygon::getVertexCount() const {
 	if (this->pointIndices[0] < 0) {
 	if (this->pointIndices[0] < 0) {
 		return 0;
 		return 0;
 	} else if (this->pointIndices[1] < 0) {
 	} else if (this->pointIndices[1] < 0) {
@@ -119,10 +119,10 @@ Part::Part(const ReadableString &name) : name(name) {}
 Part::Part(const TextureRgbaU8 &diffuseMap, const TextureRgbaU8 &lightMap, const List<Polygon> &polygonBuffer, const String &name) :
 Part::Part(const TextureRgbaU8 &diffuseMap, const TextureRgbaU8 &lightMap, const List<Polygon> &polygonBuffer, const String &name) :
   diffuseMap(diffuseMap), lightMap(lightMap), polygonBuffer(polygonBuffer), name(name) {}
   diffuseMap(diffuseMap), lightMap(lightMap), polygonBuffer(polygonBuffer), name(name) {}
 Part Part::clone() const { return Part(this->diffuseMap, this->lightMap, this->polygonBuffer, this->name); }
 Part Part::clone() const { return Part(this->diffuseMap, this->lightMap, this->polygonBuffer, this->name); }
-int Part::getPolygonCount() const {
+int32_t Part::getPolygonCount() const {
 	return this->polygonBuffer.length();
 	return this->polygonBuffer.length();
 }
 }
-int Part::getPolygonVertexCount(int polygonIndex) const {
+int32_t Part::getPolygonVertexCount(int32_t polygonIndex) const {
 	CHECK_POLYGON_INDEX(this, polygonIndex, return -1);
 	CHECK_POLYGON_INDEX(this, polygonIndex, return -1);
 	return this->polygonBuffer[polygonIndex].getVertexCount();
 	return this->polygonBuffer[polygonIndex].getVertexCount();
 }
 }
@@ -132,11 +132,11 @@ int Part::getPolygonVertexCount(int polygonIndex) const {
 //         Only decreasing the length of the point buffer, changing a position index or adding new polygons should set it to false
 //         Only decreasing the length of the point buffer, changing a position index or adding new polygons should set it to false
 //         Only running validation before rendering should set it from false to true
 //         Only running validation before rendering should set it from false to true
 //   point indices may not go outside of projected's array range
 //   point indices may not go outside of projected's array range
-static void renderTriangleFromPolygon(CommandQueue *commandQueue, const ImageRgbaU8 &targetImage, const ImageF32 &depthBuffer, const Camera &camera, const Polygon &polygon, int triangleIndex, const ProjectedPoint *projected, Filter filter, const TextureRgbaU8 &diffuse, const TextureRgbaU8 &light) {
+static void renderTriangleFromPolygon(CommandQueue *commandQueue, const ImageRgbaU8 &targetImage, const ImageF32 &depthBuffer, const Camera &camera, const Polygon &polygon, int32_t triangleIndex, const ProjectedPoint *projected, Filter filter, const TextureRgbaU8 &diffuse, const TextureRgbaU8 &light) {
 	// Triangle fan starting from the first vertex of the polygon
 	// Triangle fan starting from the first vertex of the polygon
-	int indexA = 0;
-	int indexB = 1 + triangleIndex;
-	int indexC = 2 + triangleIndex;
+	int32_t indexA = 0;
+	int32_t indexB = 1 + triangleIndex;
+	int32_t indexC = 2 + triangleIndex;
 	ProjectedPoint posA = projected[polygon.pointIndices[indexA]];
 	ProjectedPoint posA = projected[polygon.pointIndices[indexA]];
 	ProjectedPoint posB = projected[polygon.pointIndices[indexB]];
 	ProjectedPoint posB = projected[polygon.pointIndices[indexB]];
 	ProjectedPoint posC = projected[polygon.pointIndices[indexC]];
 	ProjectedPoint posC = projected[polygon.pointIndices[indexC]];
@@ -148,7 +148,7 @@ static void renderTriangleFromPolygon(CommandQueue *commandQueue, const ImageRgb
 }
 }
 
 
 void Part::render(CommandQueue *commandQueue, const ImageRgbaU8 &targetImage, const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera, Filter filter, const ProjectedPoint* projected) const {
 void Part::render(CommandQueue *commandQueue, const ImageRgbaU8 &targetImage, const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera, Filter filter, const ProjectedPoint* projected) const {
-	for (int p = 0; p < this->polygonBuffer.length(); p++) {
+	for (int32_t p = 0; p < this->polygonBuffer.length(); p++) {
 		Polygon polygon = this->polygonBuffer[p];
 		Polygon polygon = this->polygonBuffer[p];
 		if (polygon.pointIndices[3] == -1) {
 		if (polygon.pointIndices[3] == -1) {
 			// Render triangle
 			// Render triangle
@@ -162,7 +162,7 @@ void Part::render(CommandQueue *commandQueue, const ImageRgbaU8 &targetImage, co
 }
 }
 
 
 void Part::renderDepth(const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera, const ProjectedPoint* projected) const {
 void Part::renderDepth(const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera, const ProjectedPoint* projected) const {
-	for (int p = 0; p < this->polygonBuffer.length(); p++) {
+	for (int32_t p = 0; p < this->polygonBuffer.length(); p++) {
 		Polygon polygon = this->polygonBuffer[p];
 		Polygon polygon = this->polygonBuffer[p];
 		if (polygon.pointIndices[3] == -1) {
 		if (polygon.pointIndices[3] == -1) {
 			// Render triangle
 			// Render triangle
@@ -185,12 +185,12 @@ void Part::renderDepth(const ImageF32 &depthBuffer, const Transform3D &modelToWo
 void ModelImpl::render(CommandQueue *commandQueue, const ImageRgbaU8 &targetImage, const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera) const {
 void ModelImpl::render(CommandQueue *commandQueue, const ImageRgbaU8 &targetImage, const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera) const {
 	if (camera.isBoxSeen(this->minBound, this->maxBound, modelToWorldTransform)) {
 	if (camera.isBoxSeen(this->minBound, this->maxBound, modelToWorldTransform)) {
 		// Transform and project all vertices
 		// Transform and project all vertices
-		int positionCount = positionBuffer.length();
+		int32_t positionCount = positionBuffer.length();
 		VirtualStackAllocation<ProjectedPoint> projected(positionCount, "Projected points in ModelImpl::render");
 		VirtualStackAllocation<ProjectedPoint> projected(positionCount, "Projected points in ModelImpl::render");
-		for (int vert = 0; vert < positionCount; vert++) {
+		for (int32_t vert = 0; vert < positionCount; vert++) {
 			projected[vert] = camera.worldToScreen(modelToWorldTransform.transformPoint(positionBuffer[vert]));
 			projected[vert] = camera.worldToScreen(modelToWorldTransform.transformPoint(positionBuffer[vert]));
 		}
 		}
-		for (int partIndex = 0; partIndex < this->partBuffer.length(); partIndex++) {
+		for (int32_t partIndex = 0; partIndex < this->partBuffer.length(); partIndex++) {
 			this->partBuffer[partIndex].render(commandQueue, targetImage, depthBuffer, modelToWorldTransform, camera, this->filter, projected.getUnsafe());
 			this->partBuffer[partIndex].render(commandQueue, targetImage, depthBuffer, modelToWorldTransform, camera, this->filter, projected.getUnsafe());
 		}
 		}
 	}
 	}
@@ -199,12 +199,12 @@ void ModelImpl::render(CommandQueue *commandQueue, const ImageRgbaU8 &targetImag
 void ModelImpl::renderDepth(const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera) const {
 void ModelImpl::renderDepth(const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera) const {
 	if (camera.isBoxSeen(this->minBound, this->maxBound, modelToWorldTransform)) {
 	if (camera.isBoxSeen(this->minBound, this->maxBound, modelToWorldTransform)) {
 		// Transform and project all vertices
 		// Transform and project all vertices
-		int positionCount = positionBuffer.length();
+		int32_t positionCount = positionBuffer.length();
 		VirtualStackAllocation<ProjectedPoint> projected(positionCount, "Projected points in ModelImpl::renderDepth");
 		VirtualStackAllocation<ProjectedPoint> projected(positionCount, "Projected points in ModelImpl::renderDepth");
-		for (int vert = 0; vert < positionCount; vert++) {
+		for (int32_t vert = 0; vert < positionCount; vert++) {
 			projected[vert] = camera.worldToScreen(modelToWorldTransform.transformPoint(positionBuffer[vert]));
 			projected[vert] = camera.worldToScreen(modelToWorldTransform.transformPoint(positionBuffer[vert]));
 		}
 		}
-		for (int partIndex = 0; partIndex < this->partBuffer.length(); partIndex++) {
+		for (int32_t partIndex = 0; partIndex < this->partBuffer.length(); partIndex++) {
 			this->partBuffer[partIndex].renderDepth(depthBuffer, modelToWorldTransform, camera, projected.getUnsafe());
 			this->partBuffer[partIndex].renderDepth(depthBuffer, modelToWorldTransform, camera, projected.getUnsafe());
 		}
 		}
 	}
 	}
@@ -219,63 +219,63 @@ ModelImpl::ModelImpl(const ModelImpl &old) :
   filter(old.filter),
   filter(old.filter),
   positionBuffer(old.positionBuffer),
   positionBuffer(old.positionBuffer),
   partBuffer(old.partBuffer) {}
   partBuffer(old.partBuffer) {}
-int ModelImpl::addEmptyPart(const String& name) {
+int32_t ModelImpl::addEmptyPart(const String& name) {
 	return this->partBuffer.pushConstructGetIndex(name);
 	return this->partBuffer.pushConstructGetIndex(name);
 }
 }
-int ModelImpl::getNumberOfParts() const {
+int32_t ModelImpl::getNumberOfParts() const {
 	return this->partBuffer.length();
 	return this->partBuffer.length();
 }
 }
-void ModelImpl::setPartName(int partIndex, const String &name) {
+void ModelImpl::setPartName(int32_t partIndex, const String &name) {
 	CHECK_PART_INDEX(partIndex, return);
 	CHECK_PART_INDEX(partIndex, return);
 	this->partBuffer[partIndex].name = name;
 	this->partBuffer[partIndex].name = name;
 }
 }
-String ModelImpl::getPartName(int partIndex) const {
+String ModelImpl::getPartName(int32_t partIndex) const {
 	CHECK_PART_INDEX(partIndex, return "");
 	CHECK_PART_INDEX(partIndex, return "");
 	return this->partBuffer[partIndex].name;
 	return this->partBuffer[partIndex].name;
 }
 }
-TextureRgbaU8 ModelImpl::getDiffuseMap(int partIndex) const {
+TextureRgbaU8 ModelImpl::getDiffuseMap(int32_t partIndex) const {
 	CHECK_PART_INDEX(partIndex, return TextureRgbaU8());
 	CHECK_PART_INDEX(partIndex, return TextureRgbaU8());
 	return this->partBuffer[partIndex].diffuseMap;
 	return this->partBuffer[partIndex].diffuseMap;
 }
 }
-void ModelImpl::setDiffuseMap(const TextureRgbaU8 &diffuseMap, int partIndex) {
+void ModelImpl::setDiffuseMap(const TextureRgbaU8 &diffuseMap, int32_t partIndex) {
 	CHECK_PART_INDEX(partIndex, return);
 	CHECK_PART_INDEX(partIndex, return);
 	this->partBuffer[partIndex].diffuseMap = diffuseMap;
 	this->partBuffer[partIndex].diffuseMap = diffuseMap;
 }
 }
-void ModelImpl::setDiffuseMapByName(ResourcePool &pool, const String &filename, int partIndex) {
+void ModelImpl::setDiffuseMapByName(ResourcePool &pool, const String &filename, int32_t partIndex) {
 	CHECK_PART_INDEX(partIndex, return);
 	CHECK_PART_INDEX(partIndex, return);
 	const TextureRgbaU8 texture = pool.fetchTextureRgba(filename, 5);
 	const TextureRgbaU8 texture = pool.fetchTextureRgba(filename, 5);
 	if (texture_exists(texture)) {
 	if (texture_exists(texture)) {
 		this->setDiffuseMap(texture, partIndex);
 		this->setDiffuseMap(texture, partIndex);
 	}
 	}
 }
 }
-TextureRgbaU8 ModelImpl::getLightMap(int partIndex) const {
+TextureRgbaU8 ModelImpl::getLightMap(int32_t partIndex) const {
 	CHECK_PART_INDEX(partIndex, return TextureRgbaU8());
 	CHECK_PART_INDEX(partIndex, return TextureRgbaU8());
 	return this->partBuffer[partIndex].lightMap;
 	return this->partBuffer[partIndex].lightMap;
 }
 }
-void ModelImpl::setLightMap(const TextureRgbaU8 &lightMap, int partIndex) {
+void ModelImpl::setLightMap(const TextureRgbaU8 &lightMap, int32_t partIndex) {
 	CHECK_PART_INDEX(partIndex, return);
 	CHECK_PART_INDEX(partIndex, return);
 	this->partBuffer[partIndex].lightMap = lightMap;
 	this->partBuffer[partIndex].lightMap = lightMap;
 }
 }
-void ModelImpl::setLightMapByName(ResourcePool &pool, const String &filename, int partIndex) {
+void ModelImpl::setLightMapByName(ResourcePool &pool, const String &filename, int32_t partIndex) {
 	CHECK_PART_INDEX(partIndex, return);
 	CHECK_PART_INDEX(partIndex, return);
 	const TextureRgbaU8 texture = pool.fetchTextureRgba(filename, 1); // TODO: Allow configuring the number of mip levels and selecting a sampler somehow.
 	const TextureRgbaU8 texture = pool.fetchTextureRgba(filename, 1); // TODO: Allow configuring the number of mip levels and selecting a sampler somehow.
 	if (texture_exists(texture)) {
 	if (texture_exists(texture)) {
 		this->setLightMap(texture, partIndex);
 		this->setLightMap(texture, partIndex);
 	}
 	}
 }
 }
-int ModelImpl::addPolygon(Polygon polygon, int partIndex) {
+int32_t ModelImpl::addPolygon(Polygon polygon, int32_t partIndex) {
 	CHECK_PART_INDEX(partIndex, return -1);
 	CHECK_PART_INDEX(partIndex, return -1);
 	return this->partBuffer[partIndex].polygonBuffer.pushGetIndex(polygon);
 	return this->partBuffer[partIndex].polygonBuffer.pushGetIndex(polygon);
 }
 }
-int ModelImpl::getNumberOfPolygons(int partIndex) const {
+int32_t ModelImpl::getNumberOfPolygons(int32_t partIndex) const {
 	CHECK_PART_INDEX(partIndex, return -1);
 	CHECK_PART_INDEX(partIndex, return -1);
 	return this->partBuffer[partIndex].getPolygonCount();
 	return this->partBuffer[partIndex].getPolygonCount();
 }
 }
-int ModelImpl::getPolygonVertexCount(int partIndex, int polygonIndex) const {
+int32_t ModelImpl::getPolygonVertexCount(int32_t partIndex, int32_t polygonIndex) const {
 	CHECK_PART_INDEX(partIndex, return -1);
 	CHECK_PART_INDEX(partIndex, return -1);
 	return this->partBuffer[partIndex].getPolygonVertexCount(polygonIndex);
 	return this->partBuffer[partIndex].getPolygonVertexCount(polygonIndex);
 }
 }
-int ModelImpl::getNumberOfPoints() const {
+int32_t ModelImpl::getNumberOfPoints() const {
 	return this->positionBuffer.length();
 	return this->positionBuffer.length();
 }
 }
 void ModelImpl::expandBound(const FVector3D& point) {
 void ModelImpl::expandBound(const FVector3D& point) {
@@ -286,10 +286,10 @@ void ModelImpl::expandBound(const FVector3D& point) {
 	if (this->maxBound.y < point.y) { this->maxBound.y = point.y; }
 	if (this->maxBound.y < point.y) { this->maxBound.y = point.y; }
 	if (this->maxBound.z < point.z) { this->maxBound.z = point.z; }
 	if (this->maxBound.z < point.z) { this->maxBound.z = point.z; }
 }
 }
-int ModelImpl::findPoint(const FVector3D &position, float threshold) const {
+int32_t ModelImpl::findPoint(const FVector3D &position, float threshold) const {
 	float bestDistance = threshold;
 	float bestDistance = threshold;
-	int bestIndex = -1;
-	for (int index = 0; index < this->positionBuffer.length(); index++) {
+	int32_t bestIndex = -1;
+	for (int32_t index = 0; index < this->positionBuffer.length(); index++) {
 		float distance = length(position - this->getPoint(index));
 		float distance = length(position - this->getPoint(index));
 		if (distance < bestDistance) {
 		if (distance < bestDistance) {
 			bestDistance = distance;
 			bestDistance = distance;
@@ -298,21 +298,21 @@ int ModelImpl::findPoint(const FVector3D &position, float threshold) const {
 	}
 	}
 	return bestIndex;
 	return bestIndex;
 }
 }
-FVector3D ModelImpl::getPoint(int pointIndex) const {
+FVector3D ModelImpl::getPoint(int32_t pointIndex) const {
 	CHECK_POINT_INDEX(pointIndex, return FVector3D());
 	CHECK_POINT_INDEX(pointIndex, return FVector3D());
 	return this->positionBuffer[pointIndex];
 	return this->positionBuffer[pointIndex];
 }
 }
-void ModelImpl::setPoint(int pointIndex, const FVector3D& position) {
+void ModelImpl::setPoint(int32_t pointIndex, const FVector3D& position) {
 	CHECK_POINT_INDEX(pointIndex, return);
 	CHECK_POINT_INDEX(pointIndex, return);
 	this->expandBound(position);
 	this->expandBound(position);
 	this->positionBuffer[pointIndex] = position;
 	this->positionBuffer[pointIndex] = position;
 }
 }
-int ModelImpl::addPoint(const FVector3D &position) {
+int32_t ModelImpl::addPoint(const FVector3D &position) {
 	this->expandBound(position);
 	this->expandBound(position);
 	return this->positionBuffer.pushGetIndex(position);
 	return this->positionBuffer.pushGetIndex(position);
 }
 }
-int ModelImpl::addPointIfNeeded(const FVector3D &position, float threshold) {
-	int existingIndex = this->findPoint(position, threshold);
+int32_t ModelImpl::addPointIfNeeded(const FVector3D &position, float threshold) {
+	int32_t existingIndex = this->findPoint(position, threshold);
 	if (existingIndex > -1) {
 	if (existingIndex > -1) {
 		return existingIndex;
 		return existingIndex;
 	} else {
 	} else {
@@ -320,40 +320,40 @@ int ModelImpl::addPointIfNeeded(const FVector3D &position, float threshold) {
 	}
 	}
 }
 }
 
 
-int ModelImpl::getVertexPointIndex(int partIndex, int polygonIndex, int vertexIndex) const {
+int32_t ModelImpl::getVertexPointIndex(int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex) const {
 	CHECK_PART_POLYGON_INDEX(partIndex, polygonIndex, return -1);
 	CHECK_PART_POLYGON_INDEX(partIndex, polygonIndex, return -1);
 	CHECK_VERTEX_INDEX(vertexIndex, return -1);
 	CHECK_VERTEX_INDEX(vertexIndex, return -1);
 	return partBuffer[partIndex].polygonBuffer[polygonIndex].pointIndices[vertexIndex];
 	return partBuffer[partIndex].polygonBuffer[polygonIndex].pointIndices[vertexIndex];
 }
 }
-void ModelImpl::setVertexPointIndex(int partIndex, int polygonIndex, int vertexIndex, int pointIndex) {
+void ModelImpl::setVertexPointIndex(int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex, int32_t pointIndex) {
 	CHECK_PART_POLYGON_INDEX(partIndex, polygonIndex, return);
 	CHECK_PART_POLYGON_INDEX(partIndex, polygonIndex, return);
 	CHECK_VERTEX_INDEX(vertexIndex, return);
 	CHECK_VERTEX_INDEX(vertexIndex, return);
 	partBuffer[partIndex].polygonBuffer[polygonIndex].pointIndices[vertexIndex] = pointIndex;
 	partBuffer[partIndex].polygonBuffer[polygonIndex].pointIndices[vertexIndex] = pointIndex;
 }
 }
-FVector3D ModelImpl::getVertexPosition(int partIndex, int polygonIndex, int vertexIndex) const {
-	int pointIndex = getVertexPointIndex(partIndex, polygonIndex, vertexIndex);
+FVector3D ModelImpl::getVertexPosition(int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex) const {
+	int32_t pointIndex = getVertexPointIndex(partIndex, polygonIndex, vertexIndex);
 	if (pointIndex > -1 && pointIndex < this->getNumberOfPoints()) {
 	if (pointIndex > -1 && pointIndex < this->getNumberOfPoints()) {
 		return this->getPoint(pointIndex);
 		return this->getPoint(pointIndex);
 	} else {
 	} else {
 		return FVector3D();
 		return FVector3D();
 	}
 	}
 }
 }
-FVector4D ModelImpl::getVertexColor(int partIndex, int polygonIndex, int vertexIndex) const {
+FVector4D ModelImpl::getVertexColor(int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex) const {
 	CHECK_PART_POLYGON_INDEX(partIndex, polygonIndex, return FVector4D());
 	CHECK_PART_POLYGON_INDEX(partIndex, polygonIndex, return FVector4D());
 	CHECK_VERTEX_INDEX(vertexIndex, return FVector4D());
 	CHECK_VERTEX_INDEX(vertexIndex, return FVector4D());
 	return partBuffer[partIndex].polygonBuffer[polygonIndex].colors[vertexIndex];
 	return partBuffer[partIndex].polygonBuffer[polygonIndex].colors[vertexIndex];
 }
 }
-void ModelImpl::setVertexColor(int partIndex, int polygonIndex, int vertexIndex, const FVector4D& color) {
+void ModelImpl::setVertexColor(int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex, const FVector4D& color) {
 	CHECK_PART_POLYGON_INDEX(partIndex, polygonIndex, return);
 	CHECK_PART_POLYGON_INDEX(partIndex, polygonIndex, return);
 	CHECK_VERTEX_INDEX(vertexIndex, return);
 	CHECK_VERTEX_INDEX(vertexIndex, return);
 	partBuffer[partIndex].polygonBuffer[polygonIndex].colors[vertexIndex] = color;
 	partBuffer[partIndex].polygonBuffer[polygonIndex].colors[vertexIndex] = color;
 }
 }
-FVector4D ModelImpl::getTexCoord(int partIndex, int polygonIndex, int vertexIndex) const {
+FVector4D ModelImpl::getTexCoord(int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex) const {
 	CHECK_PART_POLYGON_INDEX(partIndex, polygonIndex, return FVector4D());
 	CHECK_PART_POLYGON_INDEX(partIndex, polygonIndex, return FVector4D());
 	CHECK_VERTEX_INDEX(vertexIndex, return FVector4D());
 	CHECK_VERTEX_INDEX(vertexIndex, return FVector4D());
 	return partBuffer[partIndex].polygonBuffer[polygonIndex].texCoords[vertexIndex];
 	return partBuffer[partIndex].polygonBuffer[polygonIndex].texCoords[vertexIndex];
 }
 }
-void ModelImpl::setTexCoord(int partIndex, int polygonIndex, int vertexIndex, const FVector4D& texCoord) {
+void ModelImpl::setTexCoord(int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex, const FVector4D& texCoord) {
 	CHECK_PART_POLYGON_INDEX(partIndex, polygonIndex, return);
 	CHECK_PART_POLYGON_INDEX(partIndex, polygonIndex, return);
 	CHECK_VERTEX_INDEX(vertexIndex, return);
 	CHECK_VERTEX_INDEX(vertexIndex, return);
 	partBuffer[partIndex].polygonBuffer[polygonIndex].texCoords[vertexIndex] = texCoord;
 	partBuffer[partIndex].polygonBuffer[polygonIndex].texCoords[vertexIndex] = texCoord;

+ 32 - 32
Source/DFPSR/implementation/render/model/Model.h

@@ -52,15 +52,15 @@ struct Vertex {
 };
 };
 
 
 struct Polygon {
 struct Polygon {
-	static const int maxCorners = 4;
+	static const int32_t maxCorners = 4;
 	int32_t pointIndices[maxCorners]; // pointIndices[3] equals -1 for triangles
 	int32_t pointIndices[maxCorners]; // pointIndices[3] equals -1 for triangles
 	FVector4D texCoords[maxCorners];
 	FVector4D texCoords[maxCorners];
 	FVector4D colors[maxCorners];
 	FVector4D colors[maxCorners];
 	Polygon(const Vertex &vertA, const Vertex &vertB, const Vertex &vertC);
 	Polygon(const Vertex &vertA, const Vertex &vertB, const Vertex &vertC);
 	Polygon(const Vertex &vertA, const Vertex &vertB, const Vertex &vertC, const Vertex &vertD);
 	Polygon(const Vertex &vertA, const Vertex &vertB, const Vertex &vertC, const Vertex &vertD);
-	Polygon(int indexA, int indexB, int indexC);
-	Polygon(int indexA, int indexB, int indexC, int indexD);
-	int getVertexCount() const;
+	Polygon(int32_t indexA, int32_t indexB, int32_t indexC);
+	Polygon(int32_t indexA, int32_t indexB, int32_t indexC, int32_t indexD);
+	int32_t getVertexCount() const;
 };
 };
 
 
 struct Part {
 struct Part {
@@ -72,8 +72,8 @@ struct Part {
 	Part clone() const;
 	Part clone() const;
 	void render(CommandQueue *commandQueue, const ImageRgbaU8 &targetImage, const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera, Filter filter, const ProjectedPoint* projected) const;
 	void render(CommandQueue *commandQueue, const ImageRgbaU8 &targetImage, const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera, Filter filter, const ProjectedPoint* projected) const;
 	void renderDepth(const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera, const ProjectedPoint* projected) const;
 	void renderDepth(const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera, const ProjectedPoint* projected) const;
-	int getPolygonCount() const;
-	int getPolygonVertexCount(int polygonIndex) const;
+	int32_t getPolygonCount() const;
+	int32_t getPolygonVertexCount(int32_t polygonIndex) const;
 };
 };
 
 
 class ModelImpl {
 class ModelImpl {
@@ -94,39 +94,39 @@ public:
 	//   TODO: Add empty quads and triangles and fill them later using setters
 	//   TODO: Add empty quads and triangles and fill them later using setters
 	//   TODO: Make a texture slot index instead of having getters and setters for each texture slot
 	//   TODO: Make a texture slot index instead of having getters and setters for each texture slot
 	// Part interface
 	// Part interface
-	int addEmptyPart(const String& name);
-	int getNumberOfParts() const;
-	void setPartName(int partIndex, const String &name);
-	String getPartName(int partIndex) const;
+	int32_t addEmptyPart(const String& name);
+	int32_t getNumberOfParts() const;
+	void setPartName(int32_t partIndex, const String &name);
+	String getPartName(int32_t partIndex) const;
 
 
 	// TODO: Make an array of texture slots using a class enum for index
 	// TODO: Make an array of texture slots using a class enum for index
-	TextureRgbaU8 getDiffuseMap(int partIndex) const;
-	void setDiffuseMap(const TextureRgbaU8 &diffuseMap, int partIndex);
-	void setDiffuseMapByName(ResourcePool &pool, const String &filename, int partIndex);
+	TextureRgbaU8 getDiffuseMap(int32_t partIndex) const;
+	void setDiffuseMap(const TextureRgbaU8 &diffuseMap, int32_t partIndex);
+	void setDiffuseMapByName(ResourcePool &pool, const String &filename, int32_t partIndex);
 
 
-	TextureRgbaU8 getLightMap(int partIndex) const;
-	void setLightMap(const TextureRgbaU8 &lightMap, int partIndex);
-	void setLightMapByName(ResourcePool &pool, const String &filename, int partIndex);
+	TextureRgbaU8 getLightMap(int32_t partIndex) const;
+	void setLightMap(const TextureRgbaU8 &lightMap, int32_t partIndex);
+	void setLightMapByName(ResourcePool &pool, const String &filename, int32_t partIndex);
 
 
 	// Polygon interface
 	// Polygon interface
-	int addPolygon(Polygon polygon, int partIndex);
-	int getNumberOfPolygons(int partIndex) const;
-	int getPolygonVertexCount(int partIndex, int polygonIndex) const;
+	int32_t addPolygon(Polygon polygon, int32_t partIndex);
+	int32_t getNumberOfPolygons(int32_t partIndex) const;
+	int32_t getPolygonVertexCount(int32_t partIndex, int32_t polygonIndex) const;
 	// Point interface
 	// Point interface
-	int getNumberOfPoints() const;
-	FVector3D getPoint(int pointIndex) const;
-	void setPoint(int pointIndex, const FVector3D& position);
-	int findPoint(const FVector3D &position, float threshold) const;
-	int addPoint(const FVector3D &position);
-	int addPointIfNeeded(const FVector3D &position, float threshold); // Returns the index of a new point or the first existing within threshold in euclidean 3D distance
+	int32_t getNumberOfPoints() const;
+	FVector3D getPoint(int32_t pointIndex) const;
+	void setPoint(int32_t pointIndex, const FVector3D& position);
+	int32_t findPoint(const FVector3D &position, float threshold) const;
+	int32_t addPoint(const FVector3D &position);
+	int32_t addPointIfNeeded(const FVector3D &position, float threshold); // Returns the index of a new point or the first existing within threshold in euclidean 3D distance
 	// Vertex interface
 	// Vertex interface
-	int getVertexPointIndex(int partIndex, int polygonIndex, int vertexIndex) const;
-	void setVertexPointIndex(int partIndex, int polygonIndex, int vertexIndex, int pointIndex);
-	FVector3D getVertexPosition(int partIndex, int polygonIndex, int vertexIndex) const; // Returning getPoint using the point index shared by other polygons
-	FVector4D getVertexColor(int partIndex, int polygonIndex, int vertexIndex) const;
-	void setVertexColor(int partIndex, int polygonIndex, int vertexIndex, const FVector4D& color);
-	FVector4D getTexCoord(int partIndex, int polygonIndex, int vertexIndex) const;
-	void setTexCoord(int partIndex, int polygonIndex, int vertexIndex, const FVector4D& texCoord);
+	int32_t getVertexPointIndex(int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex) const;
+	void setVertexPointIndex(int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex, int32_t pointIndex);
+	FVector3D getVertexPosition(int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex) const; // Returning getPoint using the point index shared by other polygons
+	FVector4D getVertexColor(int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex) const;
+	void setVertexColor(int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex, const FVector4D& color);
+	FVector4D getTexCoord(int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex) const;
+	void setTexCoord(int32_t partIndex, int32_t polygonIndex, int32_t vertexIndex, const FVector4D& texCoord);
 	// Rendering
 	// Rendering
 	void render(CommandQueue *commandQueue, const ImageRgbaU8 &targetImage, const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera) const;
 	void render(CommandQueue *commandQueue, const ImageRgbaU8 &targetImage, const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera) const;
 	void renderDepth(const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera) const;
 	void renderDepth(const ImageF32 &depthBuffer, const Transform3D &modelToWorldTransform, const Camera &camera) const;

+ 26 - 26
Source/DFPSR/implementation/render/model/format/dmf1.cpp

@@ -41,7 +41,7 @@ struct Triangle_DMF1 {
 struct Part_DMF1 {
 struct Part_DMF1 {
 	String textures[16];
 	String textures[16];
 	String shaderZero;
 	String shaderZero;
-	int minDetailLevel = 0, maxDetailLevel = 2;
+	int32_t minDetailLevel = 0, maxDetailLevel = 2;
 	List<Triangle_DMF1> triangles;
 	List<Triangle_DMF1> triangles;
 	String name;
 	String name;
 	Part_DMF1() {}
 	Part_DMF1() {}
@@ -83,21 +83,21 @@ static const DsrChar space = 32;
 static const DsrChar lineFeed = 10;
 static const DsrChar lineFeed = 10;
 static const DsrChar carriageReturn = 13;
 static const DsrChar carriageReturn = 13;
 
 
-static const int ParserState_WaitForStatement = 0; // NameSpace -> WaitForStatement, Identifier -> WaitForIndexOrProperty
-static const int ParserState_WaitForIndexOrProperty = 1; // index -> WaitForProperty, Property -> WaitForStatement
-static const int ParserState_WaitForProperty = 2; // Property -> WaitForStatement
+static const int32_t ParserState_WaitForStatement = 0; // NameSpace -> WaitForStatement, Identifier -> WaitForIndexOrProperty
+static const int32_t ParserState_WaitForIndexOrProperty = 1; // index -> WaitForProperty, Property -> WaitForStatement
+static const int32_t ParserState_WaitForProperty = 2; // Property -> WaitForStatement
 
 
-static const int ParserSpace_Main = 0;
-static const int ParserSpace_Part = 1;
-static const int ParserSpace_Triangle = 2;
-static const int ParserSpace_Bone = 3;
-static const int ParserSpace_Shape = 4;
-static const int ParserSpace_Point = 5;
-static const int ParserSpace_Unhandled = 6;
+static const int32_t ParserSpace_Main = 0;
+static const int32_t ParserSpace_Part = 1;
+static const int32_t ParserSpace_Triangle = 2;
+static const int32_t ParserSpace_Bone = 3;
+static const int32_t ParserSpace_Shape = 4;
+static const int32_t ParserSpace_Point = 5;
+static const int32_t ParserSpace_Unhandled = 6;
 
 
 struct ParserState {
 struct ParserState {
 	Model_DMF1 *model;
 	Model_DMF1 *model;
-	int parserState, parserSpace, propertyIndex;
+	int32_t parserState, parserSpace, propertyIndex;
 	String lastPropertyName;
 	String lastPropertyName;
 	explicit ParserState(Model_DMF1 *model) :
 	explicit ParserState(Model_DMF1 *model) :
 	  model(model),
 	  model(model),
@@ -107,11 +107,11 @@ struct ParserState {
 };
 };
 
 
 // Precondition: value >= 0.0
 // Precondition: value >= 0.0
-static int roundIndex(double value) {
-	return (int)round(value);
+static int32_t roundIndex(double value) {
+	return (int32_t)round(value);
 }
 }
 
 
-static void setProperty(ParserState &state, const String &propertyName, int index, const ReadableString &content) {
+static void setProperty(ParserState &state, const String &propertyName, int32_t index, const ReadableString &content) {
 	float value = (float)string_toDouble(content);
 	float value = (float)string_toDouble(content);
 	if (state.parserSpace == ParserSpace_Main) {
 	if (state.parserSpace == ParserSpace_Main) {
 		if PROPERTY_MATCH(FilterType) {
 		if PROPERTY_MATCH(FilterType) {
@@ -224,7 +224,7 @@ static void changeNamespace(ParserState &state, const String &newNamespace) {
 
 
 // Start and end are in base zero
 // Start and end are in base zero
 // End is an inclusive index
 // End is an inclusive index
-static void readToken(ParserState &state, const String &fileContent, int start, int end) {
+static void readToken(ParserState &state, const String &fileContent, int32_t start, int32_t end) {
 	if (end >= start) {
 	if (end >= start) {
 		if (fileContent[start] == U'(' && fileContent[end] == U')') {
 		if (fileContent[start] == U'(' && fileContent[end] == U')') {
 			// Property
 			// Property
@@ -277,8 +277,8 @@ static Model_DMF1 loadNative_DMF1(const String &fileContent) {
 		printText("The file does not start with \"DMF1\"!\n");
 		printText("The file does not start with \"DMF1\"!\n");
 		return resultModel;
 		return resultModel;
 	}
 	}
-	int tokenStart = 4; // Everything before this will no longer be used
-	int readIndex = 4;
+	int32_t tokenStart = 4; // Everything before this will no longer be used
+	int32_t readIndex = 4;
 	// Scan the string and send tokens to the state machine
 	// Scan the string and send tokens to the state machine
 	DsrChar firstCharOfToken = U'\0';
 	DsrChar firstCharOfToken = U'\0';
 	for (readIndex = tokenStart; readIndex < string_length(fileContent); readIndex++) {
 	for (readIndex = tokenStart; readIndex < string_length(fileContent); readIndex++) {
@@ -316,13 +316,13 @@ static Model_DMF1 loadNative_DMF1(const String &fileContent) {
 	return resultModel;
 	return resultModel;
 }
 }
 
 
-static Model convertFromDMF1(const Model_DMF1 &nativeModel, ResourcePool &pool, int detailLevel) {
+static Model convertFromDMF1(const Model_DMF1 &nativeModel, ResourcePool &pool, int32_t detailLevel) {
 	Model result = model_create();
 	Model result = model_create();
 	// Convert all parts from the native representation
 	// Convert all parts from the native representation
-	for (int inputPartIndex = 0; inputPartIndex < nativeModel.parts.length(); inputPartIndex++) {
+	for (int32_t inputPartIndex = 0; inputPartIndex < nativeModel.parts.length(); inputPartIndex++) {
 		const Part_DMF1 *inputPart = &(nativeModel.parts[inputPartIndex]);
 		const Part_DMF1 *inputPart = &(nativeModel.parts[inputPartIndex]);
 		if (detailLevel >= inputPart->minDetailLevel && detailLevel <= inputPart->maxDetailLevel) {
 		if (detailLevel >= inputPart->minDetailLevel && detailLevel <= inputPart->maxDetailLevel) {
-			int part = result->addEmptyPart(inputPart->name);
+			int32_t part = result->addEmptyPart(inputPart->name);
 			if (string_caseInsensitiveMatch(inputPart->shaderZero, U"M_Diffuse_0Tex")) {
 			if (string_caseInsensitiveMatch(inputPart->shaderZero, U"M_Diffuse_0Tex")) {
 				// Color
 				// Color
 			} else if (string_caseInsensitiveMatch(inputPart->shaderZero, U"M_Diffuse_1Tex")) {
 			} else if (string_caseInsensitiveMatch(inputPart->shaderZero, U"M_Diffuse_1Tex")) {
@@ -335,12 +335,12 @@ static Model convertFromDMF1(const Model_DMF1 &nativeModel, ResourcePool &pool,
 			} else {
 			} else {
 				printText("The shader ", inputPart->shaderZero, " is not supported. Use M_Diffuse_0Tex, M_Diffuse_1Tex or M_Diffuse_2Tex.\n");
 				printText("The shader ", inputPart->shaderZero, " is not supported. Use M_Diffuse_0Tex, M_Diffuse_1Tex or M_Diffuse_2Tex.\n");
 			}
 			}
-			for (int inputTriangleIndex = 0; inputTriangleIndex < inputPart->triangles.length(); inputTriangleIndex++) {
+			for (int32_t inputTriangleIndex = 0; inputTriangleIndex < inputPart->triangles.length(); inputTriangleIndex++) {
 				const Triangle_DMF1 *inputTriangle = &(inputPart->triangles[inputTriangleIndex]);
 				const Triangle_DMF1 *inputTriangle = &(inputPart->triangles[inputTriangleIndex]);
 				const float threshold = 0.00001f;
 				const float threshold = 0.00001f;
-				int posIndexA = result->addPointIfNeeded(inputTriangle->vertices[0].position, threshold);
-				int posIndexB = result->addPointIfNeeded(inputTriangle->vertices[1].position, threshold);
-				int posIndexC = result->addPointIfNeeded(inputTriangle->vertices[2].position, threshold);
+				int32_t posIndexA = result->addPointIfNeeded(inputTriangle->vertices[0].position, threshold);
+				int32_t posIndexB = result->addPointIfNeeded(inputTriangle->vertices[1].position, threshold);
+				int32_t posIndexC = result->addPointIfNeeded(inputTriangle->vertices[2].position, threshold);
 				VertexData dataA(inputTriangle->vertices[0].texCoord, inputTriangle->vertices[0].color);
 				VertexData dataA(inputTriangle->vertices[0].texCoord, inputTriangle->vertices[0].color);
 				VertexData dataB(inputTriangle->vertices[1].texCoord, inputTriangle->vertices[1].color);
 				VertexData dataB(inputTriangle->vertices[1].texCoord, inputTriangle->vertices[1].color);
 				VertexData dataC(inputTriangle->vertices[2].texCoord, inputTriangle->vertices[2].color);
 				VertexData dataC(inputTriangle->vertices[2].texCoord, inputTriangle->vertices[2].color);
@@ -352,7 +352,7 @@ static Model convertFromDMF1(const Model_DMF1 &nativeModel, ResourcePool &pool,
 	return result;
 	return result;
 }
 }
 
 
-Model dsr::importFromContent_DMF1(const String &fileContent, ResourcePool &pool, int detailLevel) {
+Model dsr::importFromContent_DMF1(const String &fileContent, ResourcePool &pool, int32_t detailLevel) {
 	// Load the raw data
 	// Load the raw data
 	Model_DMF1 nativeModel = loadNative_DMF1(fileContent);
 	Model_DMF1 nativeModel = loadNative_DMF1(fileContent);
 	// Construct a model while loading resources
 	// Construct a model while loading resources

+ 1 - 1
Source/DFPSR/implementation/render/model/format/dmf1.h

@@ -29,7 +29,7 @@
 
 
 namespace dsr {
 namespace dsr {
 
 
-Model importFromContent_DMF1(const String &fileContent, ResourcePool &pool, int detailLevel);
+Model importFromContent_DMF1(const String &fileContent, ResourcePool &pool, int32_t detailLevel);
 
 
 }
 }
 
 

+ 58 - 58
Source/DFPSR/implementation/render/renderCore.cpp

@@ -33,7 +33,7 @@ class SubVertex {
 public:
 public:
 	FVector3D cs; // Camera space position based on the weights
 	FVector3D cs; // Camera space position based on the weights
 	float subB, subC; // Weights for second and third vertices in the parent triangle
 	float subB, subC; // Weights for second and third vertices in the parent triangle
-	int state = 0; // Used by algorithms
+	int32_t state = 0; // Used by algorithms
 	float value = 0.0f; // Used by algorithms
 	float value = 0.0f; // Used by algorithms
 	SubVertex() : subB(0.0f), subC(0.0f) {}
 	SubVertex() : subB(0.0f), subC(0.0f) {}
 	SubVertex(const FVector3D &cs, float subB, float subC) : cs(cs), subB(subB), subC(subC) {}
 	SubVertex(const FVector3D &cs, float subB, float subC) : cs(cs), subB(subB), subC(subC) {}
@@ -57,12 +57,12 @@ static float inverseLerp(float a, float b, float value) {
 	}
 	}
 }
 }
 
 
-static const int maxPoints = 9; // If a triangle starts with 3 points and each of 6 planes in the view frustum can add one point each then the maximum is 9 points
+static const int32_t maxPoints = 9; // If a triangle starts with 3 points and each of 6 planes in the view frustum can add one point each then the maximum is 9 points
 class ClippedTriangle {
 class ClippedTriangle {
 private:
 private:
-	int vertexCount = 0;
+	int32_t vertexCount = 0;
 public:
 public:
-	int getVertexCount() {
+	int32_t getVertexCount() {
 		return this->vertexCount;
 		return this->vertexCount;
 	}
 	}
 	SubVertex vertices[maxPoints] = {};
 	SubVertex vertices[maxPoints] = {};
@@ -72,23 +72,23 @@ public:
 		this->vertices[2] = SubVertex(triangle.position[2].cs, 0.0f, 1.0f);
 		this->vertices[2] = SubVertex(triangle.position[2].cs, 0.0f, 1.0f);
 		this->vertexCount = 3;
 		this->vertexCount = 3;
 	}
 	}
-	void deleteVertex(int removeIndex) {
+	void deleteVertex(int32_t removeIndex) {
 		assert(removeIndex >= 0);
 		assert(removeIndex >= 0);
 		assert(removeIndex < this->vertexCount);
 		assert(removeIndex < this->vertexCount);
 		if (this->vertexCount > 0 && this->vertexCount <= maxPoints) {
 		if (this->vertexCount > 0 && this->vertexCount <= maxPoints) {
-			for (int v = removeIndex; v < this->vertexCount - 1; v++) {
+			for (int32_t v = removeIndex; v < this->vertexCount - 1; v++) {
 				assert(v >= 0 && v + 1 < maxPoints);
 				assert(v >= 0 && v + 1 < maxPoints);
 				this->vertices[v] = this->vertices[v + 1];
 				this->vertices[v] = this->vertices[v + 1];
 			}
 			}
 			this->vertexCount--;
 			this->vertexCount--;
 		}
 		}
 	}
 	}
-	void insertVertex(int newIndex, const SubVertex &newVertex) {
+	void insertVertex(int32_t newIndex, const SubVertex &newVertex) {
 		// Check against buffer overflow in case of bugs from rounding errors
 		// Check against buffer overflow in case of bugs from rounding errors
 		assert(newIndex >= 0);
 		assert(newIndex >= 0);
 		assert(newIndex <= this->vertexCount);
 		assert(newIndex <= this->vertexCount);
 		if (this->vertexCount < maxPoints) {
 		if (this->vertexCount < maxPoints) {
-			for (int v = this->vertexCount - 1; v >= newIndex; v--) {
+			for (int32_t v = this->vertexCount - 1; v >= newIndex; v--) {
 				assert(v >= 0 && v + 1 < maxPoints);
 				assert(v >= 0 && v + 1 < maxPoints);
 				this->vertices[v + 1] = this->vertices[v];
 				this->vertices[v + 1] = this->vertices[v];
 			}
 			}
@@ -101,13 +101,13 @@ public:
 	}
 	}
 	// Cut away parts of the triangle that are on the positive side of the plane
 	// Cut away parts of the triangle that are on the positive side of the plane
 	void clip(const FPlane3D &plane) {
 	void clip(const FPlane3D &plane) {
-		static const int state_use = 0;
-		static const int state_delete = 1;
-		static const int state_modified = 2;
+		static const int32_t state_use = 0;
+		static const int32_t state_delete = 1;
+		static const int32_t state_modified = 2;
 		if (this->vertexCount >= 3 && this->vertexCount < maxPoints) {
 		if (this->vertexCount >= 3 && this->vertexCount < maxPoints) {
-			int outsideCount = 0;
-			int lastOutside = 0;
-			for (int v = 0; v < this->vertexCount; v++) {
+			int32_t outsideCount = 0;
+			int32_t lastOutside = 0;
+			for (int32_t v = 0; v < this->vertexCount; v++) {
 				assert(v >= 0 && v < maxPoints);
 				assert(v >= 0 && v < maxPoints);
 				float distance = plane.signedDistance(this->vertices[v].cs);
 				float distance = plane.signedDistance(this->vertices[v].cs);
 				this->vertices[v].value = distance;
 				this->vertices[v].value = distance;
@@ -124,9 +124,9 @@ public:
 					this->deleteAll();
 					this->deleteAll();
 				} else if (outsideCount == 1) {
 				} else if (outsideCount == 1) {
 					// Split a single vertex into two corners by interpolating with the previous and next corners						
 					// Split a single vertex into two corners by interpolating with the previous and next corners						
-					int currentVertex = lastOutside;
-					int previousVertex = (lastOutside - 1 + this->vertexCount) % this->vertexCount;
-					int nextVertex = (lastOutside + 1) % this->vertexCount;
+					int32_t currentVertex = lastOutside;
+					int32_t previousVertex = (lastOutside - 1 + this->vertexCount) % this->vertexCount;
+					int32_t nextVertex = (lastOutside + 1) % this->vertexCount;
 					float previousToCurrentRatio = inverseLerp(this->vertices[previousVertex].value, this->vertices[currentVertex].value, 0.0f);
 					float previousToCurrentRatio = inverseLerp(this->vertices[previousVertex].value, this->vertices[currentVertex].value, 0.0f);
 					float currentToNextRatio = inverseLerp(this->vertices[currentVertex].value, this->vertices[nextVertex].value, 0.0f);
 					float currentToNextRatio = inverseLerp(this->vertices[currentVertex].value, this->vertices[nextVertex].value, 0.0f);
 					SubVertex cutStart(this->vertices[previousVertex], this->vertices[currentVertex], previousToCurrentRatio);
 					SubVertex cutStart(this->vertices[previousVertex], this->vertices[currentVertex], previousToCurrentRatio);
@@ -135,9 +135,9 @@ public:
 					insertVertex(nextVertex, cutEnd);
 					insertVertex(nextVertex, cutEnd);
 				} else {
 				} else {
 					// Start and end of the cut
 					// Start and end of the cut
-					for (int currentVertex = 0; currentVertex < this->vertexCount; currentVertex++) {
-						int previousVertex = (currentVertex - 1 + this->vertexCount) % this->vertexCount;
-						int nextVertex = (currentVertex + 1) % this->vertexCount;
+					for (int32_t currentVertex = 0; currentVertex < this->vertexCount; currentVertex++) {
+						int32_t previousVertex = (currentVertex - 1 + this->vertexCount) % this->vertexCount;
+						int32_t nextVertex = (currentVertex + 1) % this->vertexCount;
 						if (this->vertices[currentVertex].state == state_delete) {
 						if (this->vertices[currentVertex].state == state_delete) {
 							if (this->vertices[previousVertex].state == state_use) {
 							if (this->vertices[previousVertex].state == state_use) {
 								// Begin the cut
 								// Begin the cut
@@ -155,7 +155,7 @@ public:
 					// Delete every vertex that is marked for removal
 					// Delete every vertex that is marked for removal
 					// Looping backwards will avoid using altered indices while deleting
 					// Looping backwards will avoid using altered indices while deleting
 					if (outsideCount > 2) {
 					if (outsideCount > 2) {
-						for (int v = this->vertexCount - 1; v >= 0; v--) {
+						for (int32_t v = this->vertexCount - 1; v >= 0; v--) {
 							assert(v >= 0 && v < maxPoints);
 							assert(v >= 0 && v < maxPoints);
 							if (this->vertices[v].state == state_delete) {
 							if (this->vertices[v].state == state_delete) {
 								this->deleteVertex(v);
 								this->deleteVertex(v);
@@ -169,26 +169,26 @@ public:
 };
 };
 
 
 Visibility dsr::getTriangleVisibility(const ITriangle2D &triangle, const Camera &camera, bool clipFrustum) {
 Visibility dsr::getTriangleVisibility(const ITriangle2D &triangle, const Camera &camera, bool clipFrustum) {
-	static const int cornerCount = 3;
-	int planeCount = camera.getFrustumPlaneCount(clipFrustum);
+	static const int32_t cornerCount = 3;
+	int32_t planeCount = camera.getFrustumPlaneCount(clipFrustum);
 	VirtualStackAllocation<bool> outside(cornerCount * planeCount, "Corner outside buffer in getTriangleVIsibility");
 	VirtualStackAllocation<bool> outside(cornerCount * planeCount, "Corner outside buffer in getTriangleVIsibility");
 	// Check which corners are outside of the different planes
 	// Check which corners are outside of the different planes
-	int offset = 0;
-	for (int c = 0; c < cornerCount; c++) {
+	int32_t offset = 0;
+	for (int32_t c = 0; c < cornerCount; c++) {
 		FVector3D triangleCorner = triangle.position[c].cs;
 		FVector3D triangleCorner = triangle.position[c].cs;
-		for (int s = 0; s < planeCount; s++) {
+		for (int32_t s = 0; s < planeCount; s++) {
 			outside[offset + s] = !(camera.getFrustumPlane(s, clipFrustum).inside(triangleCorner));
 			outside[offset + s] = !(camera.getFrustumPlane(s, clipFrustum).inside(triangleCorner));
 		}
 		}
 		offset += planeCount;
 		offset += planeCount;
 	}
 	}
 	// Do not render if all corners are outside of the same side
 	// Do not render if all corners are outside of the same side
-	for (int s = 0; s < planeCount; s++) {
+	for (int32_t s = 0; s < planeCount; s++) {
 		if (outside[s] && outside[s + planeCount] && outside[s + 2 * planeCount]) {
 		if (outside[s] && outside[s + planeCount] && outside[s + 2 * planeCount]) {
 			return Visibility::Hidden; // All corners outside of the same plane
 			return Visibility::Hidden; // All corners outside of the same plane
 		}
 		}
 	}
 	}
 	// Partial visibility if any corner is outside of a side
 	// Partial visibility if any corner is outside of a side
-	for (int i = 0; i < planeCount * cornerCount; i++) {
+	for (int32_t i = 0; i < planeCount * cornerCount; i++) {
 		if (outside[i]) {
 		if (outside[i]) {
 			return Visibility::Partial; // Any corner outside of a plane
 			return Visibility::Partial; // Any corner outside of a plane
 		}
 		}
@@ -196,14 +196,14 @@ Visibility dsr::getTriangleVisibility(const ITriangle2D &triangle, const Camera
 	return Visibility::Full;
 	return Visibility::Full;
 }
 }
 
 
-static const int alignX = 2;
-static const int alignY = 2;
+static const int32_t alignX = 2;
+static const int32_t alignY = 2;
 
 
 void dsr::executeTriangleDrawing(const TriangleDrawCommand &command, const IRect &clipBound) {
 void dsr::executeTriangleDrawing(const TriangleDrawCommand &command, const IRect &clipBound) {
 	IRect finalClipBound = IRect::cut(command.clipBound, clipBound);
 	IRect finalClipBound = IRect::cut(command.clipBound, clipBound);
 	int32_t rowCount = command.triangle.getBufferSize(finalClipBound, alignX, alignY);
 	int32_t rowCount = command.triangle.getBufferSize(finalClipBound, alignX, alignY);
 	if (rowCount > 0) {
 	if (rowCount > 0) {
-		int startRow;
+		int32_t startRow;
 		// TODO: Use SafePointer in shape functions.
 		// TODO: Use SafePointer in shape functions.
 		VirtualStackAllocation<RowInterval> rows(rowCount, "Row intervals in executeTriangleDrawing");
 		VirtualStackAllocation<RowInterval> rows(rowCount, "Row intervals in executeTriangleDrawing");
 		command.triangle.getShape(startRow, rows.getUnsafe(), finalClipBound, alignX, alignY);
 		command.triangle.getShape(startRow, rows.getUnsafe(), finalClipBound, alignX, alignY);
@@ -243,15 +243,15 @@ static void drawSubTriangle(CommandQueue *commandQueue, const TriangleDrawData &
 // TODO: Take drawSubTriangle as a lambda to drawClippedTriangle using vertex weights as arguments and vertex data as captured variables
 // TODO: Take drawSubTriangle as a lambda to drawClippedTriangle using vertex weights as arguments and vertex data as captured variables
 static void drawClippedTriangle(CommandQueue *commandQueue, const TriangleDrawData &triangleDrawData, const Camera &camera, const ITriangle2D &triangle, const IRect &clipBound) {
 static void drawClippedTriangle(CommandQueue *commandQueue, const TriangleDrawData &triangleDrawData, const Camera &camera, const ITriangle2D &triangle, const IRect &clipBound) {
 	ClippedTriangle clipped(triangle);
 	ClippedTriangle clipped(triangle);
-	int planeCount = camera.getFrustumPlaneCount(true);
-	for (int s = 0; s < planeCount; s++) {
+	int32_t planeCount = camera.getFrustumPlaneCount(true);
+	for (int32_t s = 0; s < planeCount; s++) {
 		clipped.clip(camera.getFrustumPlane(s, true));
 		clipped.clip(camera.getFrustumPlane(s, true));
 	}
 	}
 	// Draw a convex triangle fan from the clipped triangle
 	// Draw a convex triangle fan from the clipped triangle
-	for (int triangleIndex = 0; triangleIndex < clipped.getVertexCount() - 2; triangleIndex++) {
-		int indexA = 0;
-		int indexB = 1 + triangleIndex;
-		int indexC = 2 + triangleIndex;
+	for (int32_t triangleIndex = 0; triangleIndex < clipped.getVertexCount() - 2; triangleIndex++) {
+		int32_t indexA = 0;
+		int32_t indexB = 1 + triangleIndex;
+		int32_t indexC = 2 + triangleIndex;
 		drawSubTriangle(commandQueue, triangleDrawData, camera, clipBound, clipped.vertices[indexA], clipped.vertices[indexB], clipped.vertices[indexC]);
 		drawSubTriangle(commandQueue, triangleDrawData, camera, clipBound, clipped.vertices[indexA], clipped.vertices[indexB], clipped.vertices[indexC]);
 	}
 	}
 }
 }
@@ -286,12 +286,12 @@ void dsr::renderTriangleFromData(
   Filter filter, const TextureRgbaU8 &diffuse, const TextureRgbaU8 &light,
   Filter filter, const TextureRgbaU8 &diffuse, const TextureRgbaU8 &light,
   const TriangleTexCoords &texCoords, const TriangleColors &colors) {
   const TriangleTexCoords &texCoords, const TriangleColors &colors) {
 	// Get dimensions from both buffers
 	// Get dimensions from both buffers
-	int colorWidth = image_getWidth(targetImage);
-	int colorHeight = image_getHeight(targetImage);
-	int depthWidth = image_getWidth(depthBuffer);
-	int depthHeight = image_getHeight(depthBuffer);
+	int32_t colorWidth = image_getWidth(targetImage);
+	int32_t colorHeight = image_getHeight(targetImage);
+	int32_t depthWidth = image_getWidth(depthBuffer);
+	int32_t depthHeight = image_getHeight(depthBuffer);
 	// Combine dimensions
 	// Combine dimensions
-	int targetWidth, targetHeight;
+	int32_t targetWidth, targetHeight;
 	if (image_exists(targetImage)) {
 	if (image_exists(targetImage)) {
 		targetWidth = colorWidth;
 		targetWidth = colorWidth;
 		targetHeight = colorHeight;
 		targetHeight = colorHeight;
@@ -343,13 +343,13 @@ template<bool AFFINE>
 static void executeTriangleDrawingDepth(const ImageF32 &depthBuffer, const ITriangle2D& triangle, const IRect &clipBound) {
 static void executeTriangleDrawingDepth(const ImageF32 &depthBuffer, const ITriangle2D& triangle, const IRect &clipBound) {
 	int32_t rowCount = triangle.getBufferSize(clipBound, 1, 1);
 	int32_t rowCount = triangle.getBufferSize(clipBound, 1, 1);
 	if (rowCount > 0) {
 	if (rowCount > 0) {
-		int startRow;
+		int32_t startRow;
 		VirtualStackAllocation<RowInterval> rows(rowCount, "Row intervals in executeTriangleDrawingDepth");
 		VirtualStackAllocation<RowInterval> rows(rowCount, "Row intervals in executeTriangleDrawingDepth");
 		triangle.getShape(startRow, rows.getUnsafe(), clipBound, 1, 1);
 		triangle.getShape(startRow, rows.getUnsafe(), clipBound, 1, 1);
 		Projection projection = triangle.getProjection(FVector3D(), FVector3D(), !AFFINE); // TODO: Create a weight using only depth to save time
 		Projection projection = triangle.getProjection(FVector3D(), FVector3D(), !AFFINE); // TODO: Create a weight using only depth to save time
 		RowShape shape = RowShape(startRow, rowCount, rows.getUnsafe());
 		RowShape shape = RowShape(startRow, rowCount, rows.getUnsafe());
 		// Draw the triangle
 		// Draw the triangle
-		const int depthBufferStride = image_getStride(depthBuffer);
+		const int32_t depthBufferStride = image_getStride(depthBuffer);
 		SafePointer<float> depthDataRow = image_getSafePointer<float>(depthBuffer, shape.startRow);
 		SafePointer<float> depthDataRow = image_getSafePointer<float>(depthBuffer, shape.startRow);
 		for (int32_t y = shape.startRow; y < shape.startRow + shape.rowCount; y++) {
 		for (int32_t y = shape.startRow; y < shape.startRow + shape.rowCount; y++) {
 			RowInterval row = shape.rows[y - shape.startRow];
 			RowInterval row = shape.rows[y - shape.startRow];
@@ -426,15 +426,15 @@ void dsr::renderTriangleFromDataDepth(const ImageF32 &depthBuffer, const Camera
 		} else {
 		} else {
 			// Draw a clipped triangle
 			// Draw a clipped triangle
 			ClippedTriangle clipped(triangle); // TODO: Simpler vertex clipping using only positions
 			ClippedTriangle clipped(triangle); // TODO: Simpler vertex clipping using only positions
-			int planeCount = camera.getFrustumPlaneCount(true);
-			for (int s = 0; s < planeCount; s++) {
+			int32_t planeCount = camera.getFrustumPlaneCount(true);
+			for (int32_t s = 0; s < planeCount; s++) {
 				clipped.clip(camera.getFrustumPlane(s, true));
 				clipped.clip(camera.getFrustumPlane(s, true));
 			}
 			}
 			// Draw a convex triangle fan from the clipped triangle
 			// Draw a convex triangle fan from the clipped triangle
-			for (int triangleIndex = 0; triangleIndex < clipped.getVertexCount() - 2; triangleIndex++) {
-				int indexA = 0;
-				int indexB = 1 + triangleIndex;
-				int indexC = 2 + triangleIndex;
+			for (int32_t triangleIndex = 0; triangleIndex < clipped.getVertexCount() - 2; triangleIndex++) {
+				int32_t indexA = 0;
+				int32_t indexB = 1 + triangleIndex;
+				int32_t indexC = 2 + triangleIndex;
 				drawSubTriangleDepth(depthBuffer, camera, clipBound, clipped.vertices[indexA], clipped.vertices[indexB], clipped.vertices[indexC]);
 				drawSubTriangleDepth(depthBuffer, camera, clipBound, clipped.vertices[indexA], clipped.vertices[indexB], clipped.vertices[indexC]);
 			}
 			}
 		}
 		}
@@ -445,10 +445,10 @@ void CommandQueue::add(const TriangleDrawCommand &command) {
 	this->buffer.push(command);
 	this->buffer.push(command);
 }
 }
 
 
-void CommandQueue::execute(const IRect &clipBound, int jobCount) const {
+void CommandQueue::execute(const IRect &clipBound, int32_t jobCount) const {
 	if (jobCount <= 1) {
 	if (jobCount <= 1) {
 		// TODO: Make a setting for sorting triangles using indices within each job
 		// TODO: Make a setting for sorting triangles using indices within each job
-		for (int i = 0; i < this->buffer.length(); i++) {
+		for (int32_t i = 0; i < this->buffer.length(); i++) {
 			if (!this->buffer[i].occluded) {
 			if (!this->buffer[i].occluded) {
 				executeTriangleDrawing(this->buffer[i], clipBound);
 				executeTriangleDrawing(this->buffer[i], clipBound);
 			}
 			}
@@ -456,20 +456,20 @@ void CommandQueue::execute(const IRect &clipBound, int jobCount) const {
 	} else {
 	} else {
 		// Split the target region for multiple threads, with one slice per job.
 		// Split the target region for multiple threads, with one slice per job.
 		VirtualStackAllocation<IRect> regions(jobCount, "Multi-threaded target pixel regions in CommandQueue::execute");
 		VirtualStackAllocation<IRect> regions(jobCount, "Multi-threaded target pixel regions in CommandQueue::execute");
-		int y1 = clipBound.top();
-		for (int j = 0; j < jobCount; j++) {
-			int y2 = clipBound.top() + ((clipBound.bottom() * (j + 1)) / jobCount);
+		int32_t y1 = clipBound.top();
+		for (int32_t j = 0; j < jobCount; j++) {
+			int32_t y2 = clipBound.top() + ((clipBound.bottom() * (j + 1)) / jobCount);
 			// Align to multiples of two lines if it's not at the bottom
 			// Align to multiples of two lines if it's not at the bottom
 			if (j < jobCount - 1) {
 			if (j < jobCount - 1) {
 				y2 = (y2 / 2) * 2;
 				y2 = (y2 / 2) * 2;
 			}
 			}
-			int height = y2 - y1;
+			int32_t height = y2 - y1;
 			regions[j] = IRect(clipBound.left(), y1, clipBound.width(), height);
 			regions[j] = IRect(clipBound.left(), y1, clipBound.width(), height);
 			y1 = y2;
 			y1 = y2;
 		}
 		}
-		std::function<void(void *context, int jobIndex)> job = [&regions](void *context, int jobIndex) {
+		std::function<void(void *context, int32_t jobIndex)> job = [&regions](void *context, int32_t jobIndex) {
 			CommandQueue *commandQueue = (CommandQueue*)context;
 			CommandQueue *commandQueue = (CommandQueue*)context;
-			for (int i = 0; i < commandQueue->buffer.length(); i++) {
+			for (int32_t i = 0; i < commandQueue->buffer.length(); i++) {
 				if (!commandQueue->buffer[i].occluded) {
 				if (!commandQueue->buffer[i].occluded) {
 					executeTriangleDrawing(commandQueue->buffer[i], regions[jobIndex]);
 					executeTriangleDrawing(commandQueue->buffer[i], regions[jobIndex]);
 				}
 				}

+ 1 - 1
Source/DFPSR/implementation/render/renderCore.h

@@ -86,7 +86,7 @@ public:
 	List<TriangleDrawCommand> buffer;
 	List<TriangleDrawCommand> buffer;
 	void add(const TriangleDrawCommand &command);
 	void add(const TriangleDrawCommand &command);
 	// Multi-threading will be disabled if jobCount equals 1.
 	// Multi-threading will be disabled if jobCount equals 1.
-	void execute(const IRect &clipBound, int jobCount = 12) const;
+	void execute(const IRect &clipBound, int32_t jobCount = 12) const;
 	void clear();
 	void clear();
 };
 };
 
 

+ 26 - 26
Source/DFPSR/implementation/render/shader/fillerTemplates.h

@@ -90,9 +90,9 @@ inline void clippedWrite(SafePointer<float> upperLeft, SafePointer<float> lowerL
 }
 }
 
 
 template<bool CLIP_SIDES>
 template<bool CLIP_SIDES>
-inline void clipPixels(int x, const RowInterval &upperRow, const RowInterval &lowerRow, bool &clip0, bool &clip1, bool &clip2, bool &clip3) {
+inline void clipPixels(int32_t x, const RowInterval &upperRow, const RowInterval &lowerRow, bool &clip0, bool &clip1, bool &clip2, bool &clip3) {
 	if (CLIP_SIDES) {
 	if (CLIP_SIDES) {
-		int x2 = x + 1;
+		int32_t x2 = x + 1;
 		clip0 = x >= upperRow.left && x < upperRow.right;
 		clip0 = x >= upperRow.left && x < upperRow.right;
 		clip1 = x2 >= upperRow.left && x2 < upperRow.right;
 		clip1 = x2 >= upperRow.left && x2 < upperRow.right;
 		clip2 = x >= lowerRow.left && x < lowerRow.right;
 		clip2 = x >= lowerRow.left && x < lowerRow.right;
@@ -106,7 +106,7 @@ inline void clipPixels(int x, const RowInterval &upperRow, const RowInterval &lo
 }
 }
 
 
 template<bool CLIP_SIDES, bool DEPTH_READ, bool AFFINE>
 template<bool CLIP_SIDES, bool DEPTH_READ, bool AFFINE>
-inline void getVisibility(int x, const RowInterval &upperRow, const RowInterval &lowerRow, const FVector4D &depth, SafePointer<const float> depthDataUpper, SafePointer<const float> depthDataLower, bool &vis0, bool &vis1, bool &vis2, bool &vis3) {
+inline void getVisibility(int32_t x, const RowInterval &upperRow, const RowInterval &lowerRow, const FVector4D &depth, SafePointer<const float> depthDataUpper, SafePointer<const float> depthDataLower, bool &vis0, bool &vis1, bool &vis2, bool &vis3) {
 	// Clip pixels
 	// Clip pixels
 	bool clip0, clip1, clip2, clip3;
 	bool clip0, clip1, clip2, clip3;
 	clipPixels<CLIP_SIDES>(x, upperRow, lowerRow, clip0, clip1, clip2, clip3);
 	clipPixels<CLIP_SIDES>(x, upperRow, lowerRow, clip0, clip1, clip2, clip3);
@@ -152,7 +152,7 @@ inline void getVisibility(int x, const RowInterval &upperRow, const RowInterval
 }
 }
 
 
 template<bool CLIP_SIDES, bool COLOR_WRITE, bool DEPTH_READ, bool DEPTH_WRITE, Filter FILTER, bool AFFINE>
 template<bool CLIP_SIDES, bool COLOR_WRITE, bool DEPTH_READ, bool DEPTH_WRITE, Filter FILTER, bool AFFINE>
-inline void fillQuadSuper(void *data, PixelShadingCallback pixelShaderFunction, int x, SafePointer<uint32_t> pixelDataUpper, SafePointer<uint32_t> pixelDataLower, SafePointer<float> depthDataUpper, SafePointer<float> depthDataLower, const RowInterval &upperRow, const RowInterval &lowerRow, const PackOrder &targetPackingOrder, const FVector4D &depth, const F32x4x3 &weights) {
+inline void fillQuadSuper(void *data, PixelShadingCallback pixelShaderFunction, int32_t x, SafePointer<uint32_t> pixelDataUpper, SafePointer<uint32_t> pixelDataLower, SafePointer<float> depthDataUpper, SafePointer<float> depthDataLower, const RowInterval &upperRow, const RowInterval &lowerRow, const PackOrder &targetPackingOrder, const FVector4D &depth, const F32x4x3 &weights) {
 	// Get visibility
 	// Get visibility
 	bool vis0, vis1, vis2, vis3;
 	bool vis0, vis1, vis2, vis3;
 	getVisibility<CLIP_SIDES, DEPTH_READ, AFFINE>(x, upperRow, lowerRow, depth, depthDataUpper, depthDataLower, vis0, vis1, vis2, vis3);
 	getVisibility<CLIP_SIDES, DEPTH_READ, AFFINE>(x, upperRow, lowerRow, depth, depthDataUpper, depthDataLower, vis0, vis1, vis2, vis3);
@@ -193,13 +193,13 @@ inline void fillQuadSuper(void *data, PixelShadingCallback pixelShaderFunction,
 // DEPTH_WRITE can be disabled to skip writing to the depth buffer so that it does not occlude following draw calls.
 // DEPTH_WRITE can be disabled to skip writing to the depth buffer so that it does not occlude following draw calls.
 // FILTER can be set to Filter::Alpha to use the output alpha as the opacity.
 // FILTER can be set to Filter::Alpha to use the output alpha as the opacity.
 template<bool CLIP_SIDES, bool COLOR_WRITE, bool DEPTH_READ, bool DEPTH_WRITE, Filter FILTER, bool AFFINE>
 template<bool CLIP_SIDES, bool COLOR_WRITE, bool DEPTH_READ, bool DEPTH_WRITE, Filter FILTER, bool AFFINE>
-inline void fillRowSuper(void *data, PixelShadingCallback pixelShaderFunction, SafePointer<uint32_t> pixelDataUpper, SafePointer<uint32_t> pixelDataLower, SafePointer<float> depthDataUpper, SafePointer<float> depthDataLower, FVector3D pWeightUpper, FVector3D pWeightLower, const FVector3D &pWeightDx, int startX, int endX, const RowInterval &upperRow, const RowInterval &lowerRow, const PackOrder &targetPackingOrder) {
+inline void fillRowSuper(void *data, PixelShadingCallback pixelShaderFunction, SafePointer<uint32_t> pixelDataUpper, SafePointer<uint32_t> pixelDataLower, SafePointer<float> depthDataUpper, SafePointer<float> depthDataLower, FVector3D pWeightUpper, FVector3D pWeightLower, const FVector3D &pWeightDx, int32_t startX, int32_t endX, const RowInterval &upperRow, const RowInterval &lowerRow, const PackOrder &targetPackingOrder) {
 	if (AFFINE) {
 	if (AFFINE) {
 		FVector3D dx2 = pWeightDx * 2.0f;
 		FVector3D dx2 = pWeightDx * 2.0f;
 		F32x4 vLinearDepth(pWeightUpper.x, pWeightUpper.x + pWeightDx.x, pWeightLower.x, pWeightLower.x + pWeightDx.x);
 		F32x4 vLinearDepth(pWeightUpper.x, pWeightUpper.x + pWeightDx.x, pWeightLower.x, pWeightLower.x + pWeightDx.x);
 		F32x4 weightB(pWeightUpper.y, pWeightUpper.y + pWeightDx.y, pWeightLower.y, pWeightLower.y + pWeightDx.y);
 		F32x4 weightB(pWeightUpper.y, pWeightUpper.y + pWeightDx.y, pWeightLower.y, pWeightLower.y + pWeightDx.y);
 		F32x4 weightC(pWeightUpper.z, pWeightUpper.z + pWeightDx.z, pWeightLower.z, pWeightLower.z + pWeightDx.z);
 		F32x4 weightC(pWeightUpper.z, pWeightUpper.z + pWeightDx.z, pWeightLower.z, pWeightLower.z + pWeightDx.z);
-		for (int x = startX; x < endX; x += 2) {
+		for (int32_t x = startX; x < endX; x += 2) {
 			// Get the linear depth
 			// Get the linear depth
 			FVector4D depth = vLinearDepth.get();
 			FVector4D depth = vLinearDepth.get();
 			// Calculate the weight of the first vertex from the other two
 			// Calculate the weight of the first vertex from the other two
@@ -219,7 +219,7 @@ inline void fillRowSuper(void *data, PixelShadingCallback pixelShaderFunction, S
 		F32x4 vRecDepth(pWeightUpper.x, pWeightUpper.x + pWeightDx.x, pWeightLower.x, pWeightLower.x + pWeightDx.x);
 		F32x4 vRecDepth(pWeightUpper.x, pWeightUpper.x + pWeightDx.x, pWeightLower.x, pWeightLower.x + pWeightDx.x);
 		F32x4 vRecU(pWeightUpper.y, pWeightUpper.y + pWeightDx.y, pWeightLower.y, pWeightLower.y + pWeightDx.y);
 		F32x4 vRecU(pWeightUpper.y, pWeightUpper.y + pWeightDx.y, pWeightLower.y, pWeightLower.y + pWeightDx.y);
 		F32x4 vRecV(pWeightUpper.z, pWeightUpper.z + pWeightDx.z, pWeightLower.z, pWeightLower.z + pWeightDx.z);
 		F32x4 vRecV(pWeightUpper.z, pWeightUpper.z + pWeightDx.z, pWeightLower.z, pWeightLower.z + pWeightDx.z);
-		for (int x = startX; x < endX; x += 2) {
+		for (int32_t x = startX; x < endX; x += 2) {
 			// Get the reciprocal depth
 			// Get the reciprocal depth
 			FVector4D depth = vRecDepth.get();
 			FVector4D depth = vRecDepth.get();
 			// After linearly interpolating (1 / W, U / W, V / W) based on the affine weights...
 			// After linearly interpolating (1 / W, U / W, V / W) based on the affine weights...
@@ -246,15 +246,15 @@ inline void fillRowSuper(void *data, PixelShadingCallback pixelShaderFunction, S
 template<bool COLOR_WRITE, bool DEPTH_READ, bool DEPTH_WRITE, Filter FILTER, bool AFFINE>
 template<bool COLOR_WRITE, bool DEPTH_READ, bool DEPTH_WRITE, Filter FILTER, bool AFFINE>
 inline void fillShapeSuper(void *data, PixelShadingCallback pixelShaderFunction, const ImageRgbaU8 &colorBuffer, const ImageF32 &depthBuffer, const ITriangle2D &triangle, const Projection &projection, const RowShape &shape) {
 inline void fillShapeSuper(void *data, PixelShadingCallback pixelShaderFunction, const ImageRgbaU8 &colorBuffer, const ImageF32 &depthBuffer, const ITriangle2D &triangle, const Projection &projection, const RowShape &shape) {
 	// Prepare constants
 	// Prepare constants
-	const int targetStride = image_getStride(colorBuffer);
-	const int depthBufferStride = image_getStride(depthBuffer);
+	const int32_t targetStride = image_getStride(colorBuffer);
+	const int32_t depthBufferStride = image_getStride(depthBuffer);
 	const FVector3D doublePWeightDx = projection.pWeightDx * 2.0f;
 	const FVector3D doublePWeightDx = projection.pWeightDx * 2.0f;
-	const int colorRowSize = image_getWidth(colorBuffer) * sizeof(uint32_t);
-	const int depthRowSize = image_getWidth(depthBuffer) * sizeof(float);
+	const int32_t colorRowSize = image_getWidth(colorBuffer) * sizeof(uint32_t);
+	const int32_t depthRowSize = image_getWidth(depthBuffer) * sizeof(float);
 	const PackOrder& targetPackingOrder = image_exists(colorBuffer) ? image_getPackOrder(colorBuffer) : PackOrder::getPackOrder(PackOrderIndex::RGBA);
 	const PackOrder& targetPackingOrder = image_exists(colorBuffer) ? image_getPackOrder(colorBuffer) : PackOrder::getPackOrder(PackOrderIndex::RGBA);
-	const int colorHeight = image_getHeight(colorBuffer);
-	const int depthHeight = image_getHeight(depthBuffer);
-	const int maxHeight = colorHeight > depthHeight ? colorHeight : depthHeight;
+	const int32_t colorHeight = image_getHeight(colorBuffer);
+	const int32_t depthHeight = image_getHeight(depthBuffer);
+	const int32_t maxHeight = colorHeight > depthHeight ? colorHeight : depthHeight;
 
 
 	// Initialize row pointers for color buffer
 	// Initialize row pointers for color buffer
 	SafePointer<uint32_t> pixelDataUpper, pixelDataLower, pixelDataUpperRow, pixelDataLowerRow;
 	SafePointer<uint32_t> pixelDataUpper, pixelDataLower, pixelDataUpperRow, pixelDataLowerRow;
@@ -271,18 +271,18 @@ inline void fillShapeSuper(void *data, PixelShadingCallback pixelShaderFunction,
 	}
 	}
 
 
 	for (int32_t y1 = shape.startRow; y1 < shape.startRow + shape.rowCount; y1 += 2) {
 	for (int32_t y1 = shape.startRow; y1 < shape.startRow + shape.rowCount; y1 += 2) {
-		int y2 = y1 + 1;
+		int32_t y2 = y1 + 1;
 		RowInterval upperRow = shape.rows[y1 - shape.startRow];
 		RowInterval upperRow = shape.rows[y1 - shape.startRow];
 		RowInterval lowerRow = shape.rows[y2 - shape.startRow];
 		RowInterval lowerRow = shape.rows[y2 - shape.startRow];
-		int outerStart = min(upperRow.left, lowerRow.left);
-		int outerEnd = max(upperRow.right, lowerRow.right);
-		int innerStart = max(upperRow.left, lowerRow.left);
-		int innerEnd = min(upperRow.right, lowerRow.right);
+		int32_t outerStart = min(upperRow.left, lowerRow.left);
+		int32_t outerEnd = max(upperRow.right, lowerRow.right);
+		int32_t innerStart = max(upperRow.left, lowerRow.left);
+		int32_t innerEnd = min(upperRow.right, lowerRow.right);
 		// Round exclusive intervals to multiples of two pixels
 		// Round exclusive intervals to multiples of two pixels
-		int outerBlockStart = roundDownEven(outerStart);
-		int outerBlockEnd = roundUpEven(outerEnd);
-		int innerBlockStart = roundUpEven(innerStart);
-		int innerBlockEnd = roundDownEven(innerEnd);
+		int32_t outerBlockStart = roundDownEven(outerStart);
+		int32_t outerBlockEnd = roundUpEven(outerEnd);
+		int32_t innerBlockStart = roundUpEven(innerStart);
+		int32_t innerBlockEnd = roundDownEven(innerEnd);
 		// Clip last row if outside on odd height
 		// Clip last row if outside on odd height
 		if (y2 >= maxHeight) {
 		if (y2 >= maxHeight) {
 			lowerRow.right = lowerRow.left;
 			lowerRow.right = lowerRow.left;
@@ -305,7 +305,7 @@ inline void fillShapeSuper(void *data, PixelShadingCallback pixelShaderFunction,
 					// Repeat the upper row to avoid reading outside
 					// Repeat the upper row to avoid reading outside
 					pixelDataLower = pixelDataUpperRow.slice("pixelDataLower (from upper)", 0, colorRowSize);
 					pixelDataLower = pixelDataUpperRow.slice("pixelDataLower (from upper)", 0, colorRowSize);
 				}
 				}
-				int startColorOffset = outerBlockStart * sizeof(uint32_t);
+				int32_t startColorOffset = outerBlockStart * sizeof(uint32_t);
 				pixelDataUpper.increaseBytes(startColorOffset);
 				pixelDataUpper.increaseBytes(startColorOffset);
 				pixelDataLower.increaseBytes(startColorOffset);
 				pixelDataLower.increaseBytes(startColorOffset);
 			}
 			}
@@ -355,8 +355,8 @@ inline void fillShapeSuper(void *data, PixelShadingCallback pixelShaderFunction,
 					pWeightUpper = pWeightUpper + doublePWeightDx; pWeightLower = pWeightLower + doublePWeightDx;
 					pWeightUpper = pWeightUpper + doublePWeightDx; pWeightLower = pWeightLower + doublePWeightDx;
 				}
 				}
 				// Full quads
 				// Full quads
-				int width = innerBlockEnd - innerBlockStart;
-				int quadCount = width / 2;
+				int32_t width = innerBlockEnd - innerBlockStart;
+				int32_t quadCount = width / 2;
 				fillRowSuper<false, COLOR_WRITE, DEPTH_READ, DEPTH_WRITE, FILTER, AFFINE>
 				fillRowSuper<false, COLOR_WRITE, DEPTH_READ, DEPTH_WRITE, FILTER, AFFINE>
 				  (data, pixelShaderFunction, pixelDataUpper, pixelDataLower, depthDataUpper, depthDataLower, pWeightUpper, pWeightLower, projection.pWeightDx, innerBlockStart, innerBlockEnd, RowInterval(), RowInterval(), targetPackingOrder);
 				  (data, pixelShaderFunction, pixelDataUpper, pixelDataLower, depthDataUpper, depthDataLower, pWeightUpper, pWeightLower, projection.pWeightDx, innerBlockStart, innerBlockEnd, RowInterval(), RowInterval(), targetPackingOrder);
 				if (COLOR_WRITE) { pixelDataUpper += 2 * quadCount; pixelDataLower += 2 * quadCount; }
 				if (COLOR_WRITE) { pixelDataUpper += 2 * quadCount; pixelDataLower += 2 * quadCount; }

+ 1 - 1
Source/SDK/SoundEngine/Envelope.h

@@ -21,7 +21,7 @@ struct Envelope {
 	// Settings
 	// Settings
 	EnvelopeSettings envelopeSettings;
 	EnvelopeSettings envelopeSettings;
 	// Dynamic
 	// Dynamic
-	int state = 0;
+	int32_t state = 0;
 	double currentVolume = 0.0, currentGoal = 0.0, releaseVolume = 0.0, timeSinceChange = 0.0;
 	double currentVolume = 0.0, currentGoal = 0.0, releaseVolume = 0.0, timeSinceChange = 0.0;
 	bool lastSustained = true;
 	bool lastSustained = true;
 	Envelope(const EnvelopeSettings &envelopeSettings);
 	Envelope(const EnvelopeSettings &envelopeSettings);

+ 17 - 17
Source/SDK/SoundEngine/soundEngine.cpp

@@ -13,9 +13,9 @@
 
 
 namespace dsr {
 namespace dsr {
 
 
-static const int maxChannels = 2;
-static const int outputChannels = 2;
-static const int outputSampleRate = 44100;
+static const int32_t maxChannels = 2;
+static const int32_t outputChannels = 2;
+static const int32_t outputSampleRate = 44100;
 double outputSoundStep = 1.0 / (double)outputSampleRate;
 double outputSoundStep = 1.0 / (double)outputSampleRate;
 
 
 std::future<void> soundFuture;
 std::future<void> soundFuture;
@@ -58,14 +58,14 @@ struct Sound {
 		double ratio = location - truncated;
 		double ratio = location - truncated;
 		return this->sampleLinear(floor, ceiling, ratio, channel);
 		return this->sampleLinear(floor, ceiling, ratio, channel);
 	}
 	}
-	void sampleMinMax(float &minimum, float &maximum, int startSample, int endSample, int channel) {
+	void sampleMinMax(float &minimum, float &maximum, int32_t startSample, int32_t endSample, int32_t channel) {
 		if (startSample < 0) { startSample = 0; }
 		if (startSample < 0) { startSample = 0; }
 		if (endSample >= sound_getSamplesPerChannel(this->buffer)) { endSample = sound_getSamplesPerChannel(this->buffer) - 1; }
 		if (endSample >= sound_getSamplesPerChannel(this->buffer)) { endSample = sound_getSamplesPerChannel(this->buffer) - 1; }
 		if (channel < 0) { channel = 0; }
 		if (channel < 0) { channel = 0; }
 		if (channel >= sound_getChannelCount(this->buffer)) { channel = sound_getChannelCount(this->buffer) - 1; }
 		if (channel >= sound_getChannelCount(this->buffer)) { channel = sound_getChannelCount(this->buffer) - 1; }
-		int bufferIndex = startSample * sound_getChannelCount(this->buffer) + channel;
+		int32_t bufferIndex = startSample * sound_getChannelCount(this->buffer) + channel;
 		SafePointer<float> source = sound_getSafePointer(this->buffer);
 		SafePointer<float> source = sound_getSafePointer(this->buffer);
-		for (int s = startSample; s <= endSample; s++) {
+		for (int32_t s = startSample; s <= endSample; s++) {
 			minMax(minimum, maximum, source[bufferIndex]);
 			minMax(minimum, maximum, source[bufferIndex]);
 			bufferIndex += sound_getChannelCount(this->buffer);
 			bufferIndex += sound_getChannelCount(this->buffer);
 		}
 		}
@@ -73,9 +73,9 @@ struct Sound {
 };
 };
 List<Sound> sounds;
 List<Sound> sounds;
 
 
-int soundEngine_loadSoundFromFile(const ReadableString &filename, bool mustExist) {
+int32_t soundEngine_loadSoundFromFile(const ReadableString &filename, bool mustExist) {
 	// Try to reuse any previously instance of the file before accessing the file system
 	// Try to reuse any previously instance of the file before accessing the file system
-	for (int s = 0; s < sounds.length(); s++) {
+	for (int32_t s = 0; s < sounds.length(); s++) {
 		if (sounds[s].fromFile && string_match(sounds[s].name, filename)) {
 		if (sounds[s].fromFile && string_match(sounds[s].name, filename)) {
 			return s;
 			return s;
 		}
 		}
@@ -83,14 +83,14 @@ int soundEngine_loadSoundFromFile(const ReadableString &filename, bool mustExist
 	return soundEngine_insertSoundBuffer(sound_load(filename, mustExist), filename, true);
 	return soundEngine_insertSoundBuffer(sound_load(filename, mustExist), filename, true);
 }
 }
 
 
-int soundEngine_getSoundBufferCount() {
+int32_t soundEngine_getSoundBufferCount() {
 	return sounds.length();
 	return sounds.length();
 }
 }
 
 
 List<SoundPlayer> fixedPlayers;
 List<SoundPlayer> fixedPlayers;
 int64_t nextPlayerID = 0;
 int64_t nextPlayerID = 0;
-int soundEngine_playSound(int soundIndex, bool repeat, float leftVolume, float rightVolume, const EnvelopeSettings &envelopeSettings) {
-	int result;
+int32_t soundEngine_playSound(int32_t soundIndex, bool repeat, float leftVolume, float rightVolume, const EnvelopeSettings &envelopeSettings) {
+	int32_t result;
 	if (soundIndex < 0 || soundIndex >= sounds.length()) {
 	if (soundIndex < 0 || soundIndex >= sounds.length()) {
 		sendWarning(U"playSound_simple: Sound index ", soundIndex, U" does not exist!\n");
 		sendWarning(U"playSound_simple: Sound index ", soundIndex, U" does not exist!\n");
 		return -1;
 		return -1;
@@ -100,11 +100,11 @@ int soundEngine_playSound(int soundIndex, bool repeat, float leftVolume, float r
 		// Nothing to play.
 		// Nothing to play.
 		return -1;
 		return -1;
 	}
 	}
-	int soundSampleRate = sound_getSampleRate(sound->buffer);
+	int32_t soundSampleRate = sound_getSampleRate(sound->buffer);
 	if (soundSampleRate != outputSampleRate) {
 	if (soundSampleRate != outputSampleRate) {
 		throwError(U"playSound_simple: The sound ", sound->name, U" has ", soundSampleRate, U" samples per second in each channel, but the sound engine samples output at ", outputSampleRate, U" samples per second!\n");
 		throwError(U"playSound_simple: The sound ", sound->name, U" has ", soundSampleRate, U" samples per second in each channel, but the sound engine samples output at ", outputSampleRate, U" samples per second!\n");
 	}
 	}
-	int soundChannel = sound_getChannelCount(sound->buffer);
+	int32_t soundChannel = sound_getChannelCount(sound->buffer);
 	if (soundChannel > maxChannels) {
 	if (soundChannel > maxChannels) {
 		throwError(U"playSound_simple: The sound ", sound->name, U" has ", soundChannel, U" channels, but the sound engine can not play more than ", maxChannels, U"channels!\n");
 		throwError(U"playSound_simple: The sound ", sound->name, U" has ", soundChannel, U" channels, but the sound engine can not play more than ", maxChannels, U"channels!\n");
 	}
 	}
@@ -116,8 +116,8 @@ int soundEngine_playSound(int soundIndex, bool repeat, float leftVolume, float r
 	return result;
 	return result;
 }
 }
 
 
-static int findFixedPlayer(int64_t playerID) {
-	for (int p = 0; p < fixedPlayers.length(); p++) {
+static int32_t findFixedPlayer(int64_t playerID) {
+	for (int32_t p = 0; p < fixedPlayers.length(); p++) {
 		if (fixedPlayers[p].playerID == playerID) {
 		if (fixedPlayers[p].playerID == playerID) {
 			return p;
 			return p;
 		}
 		}
@@ -127,7 +127,7 @@ static int findFixedPlayer(int64_t playerID) {
 void soundEngine_releaseSound(int64_t playerID) {
 void soundEngine_releaseSound(int64_t playerID) {
 	if (playerID != -1) {
 	if (playerID != -1) {
 		soundMutex.lock();
 		soundMutex.lock();
-			int index = findFixedPlayer(playerID);
+			int32_t index = findFixedPlayer(playerID);
 			if (index > -1) {
 			if (index > -1) {
 				fixedPlayers[index].sustained = false;
 				fixedPlayers[index].sustained = false;
 			}
 			}
@@ -137,7 +137,7 @@ void soundEngine_releaseSound(int64_t playerID) {
 void soundEngine_stopSound(int64_t playerID) {
 void soundEngine_stopSound(int64_t playerID) {
 	if (playerID != -1) {
 	if (playerID != -1) {
 		soundMutex.lock();
 		soundMutex.lock();
-			int index = findFixedPlayer(playerID);
+			int32_t index = findFixedPlayer(playerID);
 			if (index > -1) {
 			if (index > -1) {
 				fixedPlayers.remove(index);
 				fixedPlayers.remove(index);
 			}
 			}

+ 1 - 1
Source/SDK/SpriteEngine/DirtyRectangles.h

@@ -36,7 +36,7 @@ public:
 	void makeRegionDirty(IRect newRegion) {
 	void makeRegionDirty(IRect newRegion) {
 		newRegion = IRect::cut(newRegion, getTargetBound());
 		newRegion = IRect::cut(newRegion, getTargetBound());
 		if (newRegion.hasArea()) {
 		if (newRegion.hasArea()) {
-			for (int i = 0; i < this->dirtyRectangles.length(); i++) {
+			for (int32_t i = 0; i < this->dirtyRectangles.length(); i++) {
 				if (IRect::touches(this->dirtyRectangles[i], newRegion)) {
 				if (IRect::touches(this->dirtyRectangles[i], newRegion)) {
 					// Merge with any existing bound
 					// Merge with any existing bound
 					newRegion = IRect::merge(newRegion, this->dirtyRectangles[i]);
 					newRegion = IRect::merge(newRegion, this->dirtyRectangles[i]);

+ 17 - 17
Source/SDK/SpriteEngine/Octree.h

@@ -44,8 +44,8 @@ static const uint32_t Octree_MaskX = 1u;
 static const uint32_t Octree_MaskY = 2u;
 static const uint32_t Octree_MaskY = 2u;
 static const uint32_t Octree_MaskZ = 4u;
 static const uint32_t Octree_MaskZ = 4u;
 
 
-inline int Octree_getBranchIndex(bool pX, bool pY, bool pZ) {
-	return (int)((pX ? Octree_MaskX : 0u) | (pY ? Octree_MaskY : 0u) | (pZ ? Octree_MaskZ : 0u));
+inline int32_t Octree_getBranchIndex(bool pX, bool pY, bool pZ) {
+	return (int32_t)((pX ? Octree_MaskX : 0u) | (pY ? Octree_MaskY : 0u) | (pZ ? Octree_MaskZ : 0u));
 }
 }
 
 
 struct IBox3D {
 struct IBox3D {
@@ -53,7 +53,7 @@ struct IBox3D {
 	IBox3D(const IVector3D& min, const IVector3D& max) : min(min), max(max) {}
 	IBox3D(const IVector3D& min, const IVector3D& max) : min(min), max(max) {}
 };
 };
 
 
-inline IBox3D splitBound(const IBox3D& parent, int branchIndex) {
+inline IBox3D splitBound(const IBox3D& parent, int32_t branchIndex) {
 	assert(branchIndex >= 0 && branchIndex < 8);
 	assert(branchIndex >= 0 && branchIndex < 8);
 	IVector3D size = (parent.max - parent.min) / 2;
 	IVector3D size = (parent.max - parent.min) / 2;
 	assert(size.x > 0 && size.y > 0 && size.z > 0);
 	assert(size.x > 0 && size.y > 0 && size.z > 0);
@@ -89,7 +89,7 @@ public:
 	  maxLeafBound(original.maxLeafBound),
 	  maxLeafBound(original.maxLeafBound),
 	  divided(original.divided),
 	  divided(original.divided),
 	  leaves(original.leaves) {
 	  leaves(original.leaves) {
-		for (int n = 0; n < 8; n++) {
+		for (int32_t n = 0; n < 8; n++) {
 			this->childNodes[n] = original.childNodes[n];
 			this->childNodes[n] = original.childNodes[n];
 		}
 		}
 	}
 	}
@@ -99,7 +99,7 @@ public:
 		this->leaves.push(firstLeaf);
 		this->leaves.push(firstLeaf);
 	}
 	}
 	// Create from first child node
 	// Create from first child node
-	OctreeNode(const OctreeNode<T>& firstBranch, int firstBranchIndex, const IVector3D& minOwnedBound, const IVector3D& maxOwnedBound)
+	OctreeNode(const OctreeNode<T>& firstBranch, int32_t firstBranchIndex, const IVector3D& minOwnedBound, const IVector3D& maxOwnedBound)
 	: minOwnedBound(minOwnedBound), maxOwnedBound(maxOwnedBound), minLeafBound(firstBranch.minLeafBound), maxLeafBound(firstBranch.maxLeafBound), divided(true) {
 	: minOwnedBound(minOwnedBound), maxOwnedBound(maxOwnedBound), minLeafBound(firstBranch.minLeafBound), maxLeafBound(firstBranch.maxLeafBound), divided(true) {
 		this->childNodes[firstBranchIndex] = std::make_shared<OctreeNode<T>>(firstBranch);
 		this->childNodes[firstBranchIndex] = std::make_shared<OctreeNode<T>>(firstBranch);
 	}
 	}
@@ -113,7 +113,7 @@ public:
 		    && origin.x <= this->maxOwnedBound.x && origin.y <= this->maxOwnedBound.y && origin.z <= this->maxOwnedBound.z;
 		    && origin.x <= this->maxOwnedBound.x && origin.y <= this->maxOwnedBound.y && origin.z <= this->maxOwnedBound.z;
 	}
 	}
 	// Get the branch index closest to the origin
 	// Get the branch index closest to the origin
-	int getInnerBranchIndex() {
+	int32_t getInnerBranchIndex() {
 		return Octree_getBranchIndex(
 		return Octree_getBranchIndex(
 		  this->minOwnedBound.x + this->maxOwnedBound.x < 0,
 		  this->minOwnedBound.x + this->maxOwnedBound.x < 0,
 		  this->minOwnedBound.y + this->maxOwnedBound.y < 0,
 		  this->minOwnedBound.y + this->maxOwnedBound.y < 0,
@@ -148,7 +148,7 @@ public:
 			*this = newParent;
 			*this = newParent;
 		}
 		}
 		// Try inserting into any child node
 		// Try inserting into any child node
-		for (int n = 0; n < 8; n++) {
+		for (int32_t n = 0; n < 8; n++) {
 			if (this->childNodes[n].get() != nullptr && this->childNodes[n]->insideOwnedBound(leaf.origin)) {
 			if (this->childNodes[n].get() != nullptr && this->childNodes[n]->insideOwnedBound(leaf.origin)) {
 				this->childNodes[n]->insert(leaf);
 				this->childNodes[n]->insert(leaf);
 				return; // Avoid inserting into multiple nodes
 				return; // Avoid inserting into multiple nodes
@@ -158,7 +158,7 @@ public:
 		if (this->mayBranch(leaf)) {
 		if (this->mayBranch(leaf)) {
 			// Create a new branch for the leaf
 			// Create a new branch for the leaf
 			IVector3D middle = (this->minOwnedBound + this->maxOwnedBound) / 2;
 			IVector3D middle = (this->minOwnedBound + this->maxOwnedBound) / 2;
-			int newBranchIndex = Octree_getBranchIndex(leaf.origin.x >= middle.x, leaf.origin.y >= middle.y, leaf.origin.z >= middle.z);
+			int32_t newBranchIndex = Octree_getBranchIndex(leaf.origin.x >= middle.x, leaf.origin.y >= middle.y, leaf.origin.z >= middle.z);
 			assert(this->childNodes[newBranchIndex].get() == nullptr);
 			assert(this->childNodes[newBranchIndex].get() == nullptr);
 			IBox3D childRegion = splitBound(IBox3D(this->minOwnedBound, this->maxOwnedBound), newBranchIndex);
 			IBox3D childRegion = splitBound(IBox3D(this->minOwnedBound, this->maxOwnedBound), newBranchIndex);
 			this->childNodes[newBranchIndex] = std::make_shared<OctreeNode<T>>(leaf, childRegion.min, childRegion.max);
 			this->childNodes[newBranchIndex] = std::make_shared<OctreeNode<T>>(leaf, childRegion.min, childRegion.max);
@@ -171,7 +171,7 @@ public:
 				this->divided = true;
 				this->divided = true;
 				List<OctreeLeaf<T>> oldLeaves = this->leaves;
 				List<OctreeLeaf<T>> oldLeaves = this->leaves;
 				this->leaves.clear();
 				this->leaves.clear();
-				for (int l = 0; l < oldLeaves.length(); l++) {
+				for (int32_t l = 0; l < oldLeaves.length(); l++) {
 					this->insert(oldLeaves[l]);
 					this->insert(oldLeaves[l]);
 				}
 				}
 			}
 			}
@@ -180,13 +180,13 @@ public:
 	void find(const OcTreeFilter& boundFilter, const OcTreeLeafOperation<T>& leafOperation) {
 	void find(const OcTreeFilter& boundFilter, const OcTreeLeafOperation<T>& leafOperation) {
 		if (boundFilter(this->minLeafBound, this->maxLeafBound)) {
 		if (boundFilter(this->minLeafBound, this->maxLeafBound)) {
 			// Looping backwards over leaves allow erasing without stepping into recently moved elements
 			// Looping backwards over leaves allow erasing without stepping into recently moved elements
-			for (int l = this->leaves.length() - 1; l >= 0; l--) {
+			for (int32_t l = this->leaves.length() - 1; l >= 0; l--) {
 				if (this->leaves[l].find(boundFilter, leafOperation) == LeafAction::Erase) {
 				if (this->leaves[l].find(boundFilter, leafOperation) == LeafAction::Erase) {
 					this->leaves.remove(l);
 					this->leaves.remove(l);
 				}
 				}
 			}
 			}
 			// Search in the other branches recursively
 			// Search in the other branches recursively
-			for (int n = 0; n < 8; n++) {
+			for (int32_t n = 0; n < 8; n++) {
 				if (this->childNodes[n].get() != nullptr) {
 				if (this->childNodes[n].get() != nullptr) {
 					this->childNodes[n]->find(boundFilter, leafOperation);
 					this->childNodes[n]->find(boundFilter, leafOperation);
 				}
 				}
@@ -202,19 +202,19 @@ private:
 	// One start node for each direction to simplify expansion
 	// One start node for each direction to simplify expansion
 	std::shared_ptr<OctreeNode<T>> childNodes[8];
 	std::shared_ptr<OctreeNode<T>> childNodes[8];
 	// Settings
 	// Settings
-	int initialSize; // Should be around the average total world size to create the most balanced trees
+	int32_t initialSize; // Should be around the average total world size to create the most balanced trees
 public:
 public:
-	explicit Octree(int initialSize)
+	explicit Octree(int32_t initialSize)
 	: initialSize(initialSize) {}
 	: initialSize(initialSize) {}
 public:
 public:
 	// Precondition: minBound <= origin <= maxBound
 	// Precondition: minBound <= origin <= maxBound
 	void insert(const T& leaf, const IVector3D& origin, const IVector3D& minBound, const IVector3D& maxBound) {
 	void insert(const T& leaf, const IVector3D& origin, const IVector3D& minBound, const IVector3D& maxBound) {
-		int sideIndex = Octree_getBranchIndex(origin.x >= 0, origin.y >= 0, origin.z >= 0);
+		int32_t sideIndex = Octree_getBranchIndex(origin.x >= 0, origin.y >= 0, origin.z >= 0);
 		if (this->childNodes[sideIndex].get() == nullptr) {
 		if (this->childNodes[sideIndex].get() == nullptr) {
 			// Calculate minimum required size
 			// Calculate minimum required size
-			int requiredSize = std::max(abs(origin.x), std::max(abs(origin.y), abs(origin.z)));
+			int32_t requiredSize = std::max(abs(origin.x), std::max(abs(origin.y), abs(origin.z)));
 			// Calculate final cube size to be stored directly inside of the root
 			// Calculate final cube size to be stored directly inside of the root
-			int size = this->initialSize;
+			int32_t size = this->initialSize;
 			while(size < requiredSize) {
 			while(size < requiredSize) {
 				size *= 2;
 				size *= 2;
 			}
 			}
@@ -235,7 +235,7 @@ public:
 	}
 	}
 	// Find leaves using a custom filter
 	// Find leaves using a custom filter
 	void map(const OcTreeFilter& boundFilter, const OcTreeLeafOperation<T>& leafOperation) {
 	void map(const OcTreeFilter& boundFilter, const OcTreeLeafOperation<T>& leafOperation) {
-		for (int sideIndex = 0; sideIndex < 8; sideIndex++) {
+		for (int32_t sideIndex = 0; sideIndex < 8; sideIndex++) {
 			if (this->childNodes[sideIndex].get() != nullptr) {
 			if (this->childNodes[sideIndex].get() != nullptr) {
 				this->childNodes[sideIndex]->find(boundFilter, leafOperation);
 				this->childNodes[sideIndex]->find(boundFilter, leafOperation);
 			}
 			}

+ 25 - 25
Source/SDK/SpriteEngine/importer.cpp

@@ -6,7 +6,7 @@ namespace dsr {
 struct PlyProperty {
 struct PlyProperty {
 	String name;
 	String name;
 	bool list;
 	bool list;
-	int scale = 1; // 1 for normalized input, 255 for uchar
+	int32_t scale = 1; // 1 for normalized input, 255 for uchar
 	// Single property
 	// Single property
 	PlyProperty(String name, ReadableString typeName) : name(name), list(false) {
 	PlyProperty(String name, ReadableString typeName) : name(name), list(false) {
 		if (string_caseInsensitiveMatch(typeName, U"UCHAR")) {
 		if (string_caseInsensitiveMatch(typeName, U"UCHAR")) {
@@ -29,9 +29,9 @@ struct PlyProperty {
 };
 };
 struct PlyElement {
 struct PlyElement {
 	String name; // Name of the collection
 	String name; // Name of the collection
-	int count; // Size of the collection
+	int32_t count; // Size of the collection
 	List<PlyProperty> properties; // Properties on each line (list properties consume additional tokens)
 	List<PlyProperty> properties; // Properties on each line (list properties consume additional tokens)
-	PlyElement(const String &name, int count) : name(name), count(count) {}
+	PlyElement(const String &name, int32_t count) : name(name), count(count) {}
 };
 };
 enum class PlyDataInput {
 enum class PlyDataInput {
 	Ignore, Vertex, Face
 	Ignore, Vertex, Face
@@ -56,16 +56,16 @@ struct PlyVertex {
 //   This coordinate system is left handed, which makes more sense when working with depth buffers.
 //   This coordinate system is left handed, which makes more sense when working with depth buffers.
 // If exporting from a right-handed editor, setting Y as up and Z as forward might flip the X axis to the left side.
 // If exporting from a right-handed editor, setting Y as up and Z as forward might flip the X axis to the left side.
 //   In that case, flip the X axis when calling this function.
 //   In that case, flip the X axis when calling this function.
-static void loadPlyModel(Model& targetModel, int targetPart, const ReadableString& content, bool flipX, Transform3D axisConversion) {
+static void loadPlyModel(Model& targetModel, int32_t targetPart, const ReadableString& content, bool flipX, Transform3D axisConversion) {
 	//printText("loadPlyModel:\n", content, "\n");
 	//printText("loadPlyModel:\n", content, "\n");
 	// Find the target model
 	// Find the target model
-	int startPointIndex = model_getNumberOfPoints(targetModel);
+	int32_t startPointIndex = model_getNumberOfPoints(targetModel);
 	// Split lines
 	// Split lines
 	List<String> lines = string_split(content, U'\n', true);
 	List<String> lines = string_split(content, U'\n', true);
 	List<PlyElement> elements;
 	List<PlyElement> elements;
 	bool readingContent = false; // True after passing end_header
 	bool readingContent = false; // True after passing end_header
-	int elementIndex = -1; // current member of elements
-	int memberIndex = 0; // current data line within the content of the current element
+	int32_t elementIndex = -1; // current member of elements
+	int32_t memberIndex = 0; // current data line within the content of the current element
 	PlyDataInput inputMode = PlyDataInput::Ignore;
 	PlyDataInput inputMode = PlyDataInput::Ignore;
 	// Temporary geometry
 	// Temporary geometry
 	List<PlyVertex> vertices;
 	List<PlyVertex> vertices;
@@ -79,7 +79,7 @@ static void loadPlyModel(Model& targetModel, int targetPart, const ReadableStrin
 		printText("loadPlyModel: Only supporting the ascii 1.0 format!\n");
 		printText("loadPlyModel: Only supporting the ascii 1.0 format!\n");
 		return;
 		return;
 	}
 	}
-	for (int l = 0; l < lines.length(); l++) {
+	for (int32_t l = 0; l < lines.length(); l++) {
 		// Tokenize the current line
 		// Tokenize the current line
 		List<String> tokens = string_split(lines[l], U' ');
 		List<String> tokens = string_split(lines[l], U' ');
 		if (tokens.length() > 0 && !string_caseInsensitiveMatch(tokens[0], U"COMMENT")) {
 		if (tokens.length() > 0 && !string_caseInsensitiveMatch(tokens[0], U"COMMENT")) {
@@ -91,15 +91,15 @@ static void loadPlyModel(Model& targetModel, int targetPart, const ReadableStrin
 						vertices.push(PlyVertex());
 						vertices.push(PlyVertex());
 					}
 					}
 					PlyElement *currentElement = &(elements[elementIndex]);
 					PlyElement *currentElement = &(elements[elementIndex]);
-					int tokenIndex = 0;
-					for (int propertyIndex = 0; propertyIndex < currentElement->properties.length(); propertyIndex++) {
+					int32_t tokenIndex = 0;
+					for (int32_t propertyIndex = 0; propertyIndex < currentElement->properties.length(); propertyIndex++) {
 						if (tokenIndex >= tokens.length()) {
 						if (tokenIndex >= tokens.length()) {
 							printText("loadPlyModel: Undeclared properties given to ", currentElement->name, " in the data!\n");
 							printText("loadPlyModel: Undeclared properties given to ", currentElement->name, " in the data!\n");
 							break;
 							break;
 						}
 						}
 						PlyProperty *currentProperty = &(currentElement->properties[propertyIndex]);
 						PlyProperty *currentProperty = &(currentElement->properties[propertyIndex]);
 						if (currentProperty->list) {
 						if (currentProperty->list) {
-							int listLength = string_toInteger(tokens[tokenIndex]);
+							int32_t listLength = string_toInteger(tokens[tokenIndex]);
 							tokenIndex++;
 							tokenIndex++;
 							// Detect polygons
 							// Detect polygons
 							if (inputMode == PlyDataInput::Face && string_caseInsensitiveMatch(currentProperty->name, U"VERTEX_INDICES")) {
 							if (inputMode == PlyDataInput::Face && string_caseInsensitiveMatch(currentProperty->name, U"VERTEX_INDICES")) {
@@ -109,16 +109,16 @@ static void loadPlyModel(Model& targetModel, int targetPart, const ReadableStrin
 								bool flipSides = flipX;
 								bool flipSides = flipX;
 								if (listLength == 4) {
 								if (listLength == 4) {
 									// Use a quad to save memory
 									// Use a quad to save memory
-									int indexA = string_toInteger(tokens[tokenIndex]);
-									int indexB = string_toInteger(tokens[tokenIndex + 1]);
-									int indexC = string_toInteger(tokens[tokenIndex + 2]);
-									int indexD = string_toInteger(tokens[tokenIndex + 3]);
+									int32_t indexA = string_toInteger(tokens[tokenIndex]);
+									int32_t indexB = string_toInteger(tokens[tokenIndex + 1]);
+									int32_t indexC = string_toInteger(tokens[tokenIndex + 2]);
+									int32_t indexD = string_toInteger(tokens[tokenIndex + 3]);
 									FVector4D colorA = vertices[indexA].color;
 									FVector4D colorA = vertices[indexA].color;
 									FVector4D colorB = vertices[indexB].color;
 									FVector4D colorB = vertices[indexB].color;
 									FVector4D colorC = vertices[indexC].color;
 									FVector4D colorC = vertices[indexC].color;
 									FVector4D colorD = vertices[indexD].color;
 									FVector4D colorD = vertices[indexD].color;
 									if (flipSides) {
 									if (flipSides) {
-										int polygon = model_addQuad(targetModel, targetPart,
+										int32_t polygon = model_addQuad(targetModel, targetPart,
 										  startPointIndex + indexD,
 										  startPointIndex + indexD,
 										  startPointIndex + indexC,
 										  startPointIndex + indexC,
 										  startPointIndex + indexB,
 										  startPointIndex + indexB,
@@ -129,7 +129,7 @@ static void loadPlyModel(Model& targetModel, int targetPart, const ReadableStrin
 										model_setVertexColor(targetModel, targetPart, polygon, 2, colorB);
 										model_setVertexColor(targetModel, targetPart, polygon, 2, colorB);
 										model_setVertexColor(targetModel, targetPart, polygon, 3, colorA);
 										model_setVertexColor(targetModel, targetPart, polygon, 3, colorA);
 									} else {
 									} else {
-										int polygon = model_addQuad(targetModel, targetPart,
+										int32_t polygon = model_addQuad(targetModel, targetPart,
 										  startPointIndex + indexA,
 										  startPointIndex + indexA,
 										  startPointIndex + indexB,
 										  startPointIndex + indexB,
 										  startPointIndex + indexC,
 										  startPointIndex + indexC,
@@ -142,16 +142,16 @@ static void loadPlyModel(Model& targetModel, int targetPart, const ReadableStrin
 									}
 									}
 								} else {
 								} else {
 									// Polygon generating a triangle fan
 									// Polygon generating a triangle fan
-									int indexA = string_toInteger(tokens[tokenIndex]);
-									int indexB = string_toInteger(tokens[tokenIndex + 1]);
+									int32_t indexA = string_toInteger(tokens[tokenIndex]);
+									int32_t indexB = string_toInteger(tokens[tokenIndex + 1]);
 									FVector4D colorA = vertices[indexA].color;
 									FVector4D colorA = vertices[indexA].color;
 									FVector4D colorB = vertices[indexB].color;
 									FVector4D colorB = vertices[indexB].color;
-									for (int i = 2; i < listLength; i++) {
-										int indexC = string_toInteger(tokens[tokenIndex + i]);
+									for (int32_t i = 2; i < listLength; i++) {
+										int32_t indexC = string_toInteger(tokens[tokenIndex + i]);
 										FVector4D colorC = vertices[indexC].color;
 										FVector4D colorC = vertices[indexC].color;
 										// Create a triangle
 										// Create a triangle
 										if (flipSides) {
 										if (flipSides) {
-											int polygon = model_addTriangle(targetModel, targetPart,
+											int32_t polygon = model_addTriangle(targetModel, targetPart,
 											  startPointIndex + indexC,
 											  startPointIndex + indexC,
 											  startPointIndex + indexB,
 											  startPointIndex + indexB,
 											  startPointIndex + indexA
 											  startPointIndex + indexA
@@ -160,7 +160,7 @@ static void loadPlyModel(Model& targetModel, int targetPart, const ReadableStrin
 											model_setVertexColor(targetModel, targetPart, polygon, 1, colorB);
 											model_setVertexColor(targetModel, targetPart, polygon, 1, colorB);
 											model_setVertexColor(targetModel, targetPart, polygon, 2, colorA);
 											model_setVertexColor(targetModel, targetPart, polygon, 2, colorA);
 										} else {
 										} else {
-											int polygon = model_addTriangle(targetModel, targetPart,
+											int32_t polygon = model_addTriangle(targetModel, targetPart,
 											  startPointIndex + indexA,
 											  startPointIndex + indexA,
 											  startPointIndex + indexB,
 											  startPointIndex + indexB,
 											  startPointIndex + indexC
 											  startPointIndex + indexC
@@ -267,8 +267,8 @@ static void loadPlyModel(Model& targetModel, int targetPart, const ReadableStrin
 	}
 	}
 }
 }
 
 
-void importer_loadModel(Model& targetModel, int part, const ReadableString& filename, bool flipX, Transform3D axisConversion) {
-	int lastDotIndex = string_findLast(filename, U'.');
+void importer_loadModel(Model& targetModel, int32_t part, const ReadableString& filename, bool flipX, Transform3D axisConversion) {
+	int32_t lastDotIndex = string_findLast(filename, U'.');
 	if (lastDotIndex == -1) {
 	if (lastDotIndex == -1) {
 		printText("The model's filename ", filename, " does not have an extension!\n");
 		printText("The model's filename ", filename, " does not have an extension!\n");
 	} else {
 	} else {

+ 1 - 1
Source/SDK/SpriteEngine/importer.h

@@ -10,7 +10,7 @@ namespace dsr {
 Model importer_loadModel(const ReadableString& filename, bool flipX, Transform3D axisConversion);
 Model importer_loadModel(const ReadableString& filename, bool flipX, Transform3D axisConversion);
 
 
 // In-place loading of a new part
 // In-place loading of a new part
-void importer_loadModel(Model& targetModel, int part, const ReadableString& filename, bool flipX, Transform3D axisConversion);
+void importer_loadModel(Model& targetModel, int32_t part, const ReadableString& filename, bool flipX, Transform3D axisConversion);
 
 
 }
 }
 
 

+ 23 - 23
Source/SDK/SpriteEngine/lightAPI.cpp

@@ -32,12 +32,12 @@ void directedLight(const FMatrix3x3& normalToWorldSpace, OrderedImageRgbaU8& lig
 	  lightBuffer, normalBuffer, reverseLightDirection, colorR, colorG, colorB](const IRect& bound) mutable {
 	  lightBuffer, normalBuffer, reverseLightDirection, colorR, colorG, colorB](const IRect& bound) mutable {
 		SafePointer<uint8_t> lightRow = image_getSafePointer_channels(lightBuffer, bound.top());
 		SafePointer<uint8_t> lightRow = image_getSafePointer_channels(lightBuffer, bound.top());
 		SafePointer<uint32_t> normalRow = image_getSafePointer(normalBuffer, bound.top());
 		SafePointer<uint32_t> normalRow = image_getSafePointer(normalBuffer, bound.top());
-		int lightStride = image_getStride(lightBuffer);
-		int normalStride = image_getStride(normalBuffer);
-		for (int y = bound.top(); y < bound.bottom(); y++) {
+		int32_t lightStride = image_getStride(lightBuffer);
+		int32_t normalStride = image_getStride(normalBuffer);
+		for (int32_t y = bound.top(); y < bound.bottom(); y++) {
 			SafePointer<uint8_t> lightPixel = lightRow;
 			SafePointer<uint8_t> lightPixel = lightRow;
 			SafePointer<uint32_t> normalPixel = normalRow;
 			SafePointer<uint32_t> normalPixel = normalRow;
-			for (int x = bound.left(); x < bound.right(); x += laneCountX_32Bit) {
+			for (int32_t x = bound.left(); x < bound.right(); x += laneCountX_32Bit) {
 				// Read surface normals
 				// Read surface normals
 				U32xX normalColor = U32xX::readAligned(normalPixel, "directedLight: reading normal");
 				U32xX normalColor = U32xX::readAligned(normalPixel, "directedLight: reading normal");
 				// TODO: Port SIMD3D to handle arbitrary vector lengths.
 				// TODO: Port SIMD3D to handle arbitrary vector lengths.
@@ -73,12 +73,12 @@ void addDirectedLight(const OrthoView& camera, OrderedImageRgbaU8& lightBuffer,
 	directedLight<true>(camera.normalToWorldSpace, lightBuffer, normalBuffer, lightDirection, lightIntensity, lightColor);
 	directedLight<true>(camera.normalToWorldSpace, lightBuffer, normalBuffer, lightDirection, lightIntensity, lightColor);
 }
 }
 
 
-static IRect calculateBound(const OrthoView& camera, const IVector2D& worldCenter, OrderedImageRgbaU8& lightBuffer, const FVector3D& lightSpacePosition, float lightRadius, int alignmentPixels) {
+static IRect calculateBound(const OrthoView& camera, const IVector2D& worldCenter, OrderedImageRgbaU8& lightBuffer, const FVector3D& lightSpacePosition, float lightRadius, int32_t alignmentPixels) {
 	// Get the light's 2D position in pixels
 	// Get the light's 2D position in pixels
 	FVector3D rotatedPosition = camera.lightSpaceToScreenDepth.transform(lightSpacePosition);
 	FVector3D rotatedPosition = camera.lightSpaceToScreenDepth.transform(lightSpacePosition);
 	IVector2D pixelCenter = IVector2D(rotatedPosition.x, rotatedPosition.y) + worldCenter;
 	IVector2D pixelCenter = IVector2D(rotatedPosition.x, rotatedPosition.y) + worldCenter;
 	// Use the light-space X axis to convert the sphere's radius into pixels
 	// Use the light-space X axis to convert the sphere's radius into pixels
-	int pixelRadius = lightRadius * camera.lightSpaceToScreenDepth.xAxis.x;
+	int32_t pixelRadius = lightRadius * camera.lightSpaceToScreenDepth.xAxis.x;
 	// Check if the location can be seen
 	// Check if the location can be seen
 	IRect imageBound = image_getBound(lightBuffer);
 	IRect imageBound = image_getBound(lightBuffer);
 	if (pixelCenter.x < -pixelRadius
 	if (pixelCenter.x < -pixelRadius
@@ -92,8 +92,8 @@ static IRect calculateBound(const OrthoView& camera, const IVector2D& worldCente
 	IRect result = IRect::cut(imageBound, IRect(pixelCenter.x - pixelRadius, pixelCenter.y - pixelRadius, pixelRadius * 2.0f, pixelRadius * 2.0f));
 	IRect result = IRect::cut(imageBound, IRect(pixelCenter.x - pixelRadius, pixelCenter.y - pixelRadius, pixelRadius * 2.0f, pixelRadius * 2.0f));
 	// Round out to multiples of SIMD vectors
 	// Round out to multiples of SIMD vectors
 	if (result.hasArea() && alignmentPixels > 1) {
 	if (result.hasArea() && alignmentPixels > 1) {
-		int left = roundDown(result.left(), alignmentPixels);
-		int right = roundUp(result.right(), alignmentPixels);
+		int32_t left = roundDown(result.left(), alignmentPixels);
+		int32_t right = roundUp(result.right(), alignmentPixels);
 		result = IRect(left, result.top(), right - left, result.height());
 		result = IRect(left, result.top(), right - left, result.height());
 	}
 	}
 	return result;
 	return result;
@@ -124,8 +124,8 @@ static float getShadowTransparency(SafePointer<float> pixelData, int32_t width,
 	// Project and round to pixels
 	// Project and round to pixels
 	float reciDepth = 1.0f / depth;
 	float reciDepth = 1.0f / depth;
 	float scale = halfWidth * reciDepth;
 	float scale = halfWidth * reciDepth;
-	int32_t sampleX = (int)(halfWidth + (slopeSide * scale));
-	int32_t sampleY = (int)(halfWidth - (slopeUp * scale));
+	int32_t sampleX = (int32_t)(halfWidth + (slopeSide * scale));
+	int32_t sampleY = (int32_t)(halfWidth - (slopeUp * scale));
 	// Clamp to local view coordinates
 	// Clamp to local view coordinates
 	int32_t maxPixel = width - 1;
 	int32_t maxPixel = width - 1;
 	if (sampleX < 0) { sampleX = 0; }
 	if (sampleX < 0) { sampleX = 0; }
@@ -201,9 +201,9 @@ static void addPointLightSuper(const OrthoView& camera, const IVector2D& worldCe
 			// -> (x0, n+1), (x1, n+1), (x2, n+1), (x3, n+1)
 			// -> (x0, n+1), (x1, n+1), (x2, n+1), (x3, n+1)
 			F32xXx3 dy1 = F32xXx3(dy);
 			F32xXx3 dy1 = F32xXx3(dy);
 			// Get strides
 			// Get strides
-			int lightStride = image_getStride(lightBuffer);
-			int normalStride = image_getStride(normalBuffer);
-			int heightStride = image_getStride(heightBuffer);
+			int32_t lightStride = image_getStride(lightBuffer);
+			int32_t normalStride = image_getStride(normalBuffer);
+			int32_t heightStride = image_getStride(heightBuffer);
 			// Get pointers
 			// Get pointers
 			SafePointer<uint8_t> lightRow = image_getSafePointer_channels(lightBuffer, bound.top()) + bound.left() * 4;
 			SafePointer<uint8_t> lightRow = image_getSafePointer_channels(lightBuffer, bound.top()) + bound.left() * 4;
 			SafePointer<uint32_t> normalRow = image_getSafePointer(normalBuffer, bound.top()) + bound.left();
 			SafePointer<uint32_t> normalRow = image_getSafePointer(normalBuffer, bound.top()) + bound.left();
@@ -218,14 +218,14 @@ static void addPointLightSuper(const OrthoView& camera, const IVector2D& worldCe
 				shadowCubeCenter = (float)shadowCubeWidth * 0.5f;
 				shadowCubeCenter = (float)shadowCubeWidth * 0.5f;
 			}
 			}
 			// Loop over the pixels to add light
 			// Loop over the pixels to add light
-			for (int y = bound.top(); y < bound.bottom(); y++) {
+			for (int32_t y = bound.top(); y < bound.bottom(); y++) {
 				// Initiate the leftmost pixels before iterating to the right
 				// Initiate the leftmost pixels before iterating to the right
 				F32xXx3 lightBasePixelxX = lightBaseRowX;
 				F32xXx3 lightBasePixelxX = lightBaseRowX;
 				SafePointer<uint8_t> lightPixel = lightRow;
 				SafePointer<uint8_t> lightPixel = lightRow;
 				SafePointer<uint32_t> normalPixel = normalRow;
 				SafePointer<uint32_t> normalPixel = normalRow;
 				SafePointer<float> heightPixel = heightRow;
 				SafePointer<float> heightPixel = heightRow;
 				// Iterate over 16-bit pixels 8 at a time
 				// Iterate over 16-bit pixels 8 at a time
-				for (int x = bound.left(); x < bound.right(); x += laneCountX_32Bit) {
+				for (int32_t x = bound.left(); x < bound.right(); x += laneCountX_32Bit) {
 					// Read pixel height
 					// Read pixel height
 					F32xX depthOffset = F32xX::readAligned(heightPixel, "addPointLight: reading height");
 					F32xX depthOffset = F32xX::readAligned(heightPixel, "addPointLight: reading height");
 					// Extrude the pixel using positive values towards the camera to represent another height
 					// Extrude the pixel using positive values towards the camera to represent another height
@@ -286,21 +286,21 @@ void addPointLight(const OrthoView& camera, const IVector2D& worldCenter, Ordere
 
 
 void blendLight(AlignedImageRgbaU8& colorBuffer, const OrderedImageRgbaU8& diffuseBuffer, const OrderedImageRgbaU8& lightBuffer) {
 void blendLight(AlignedImageRgbaU8& colorBuffer, const OrderedImageRgbaU8& diffuseBuffer, const OrderedImageRgbaU8& lightBuffer) {
 	PackOrder targetOrder = PackOrder::getPackOrder(image_getPackOrderIndex(colorBuffer));
 	PackOrder targetOrder = PackOrder::getPackOrder(image_getPackOrderIndex(colorBuffer));
-	int width = image_getWidth(colorBuffer);
-	int height = image_getHeight(colorBuffer);
-	threadedSplit(0, height, [colorBuffer, diffuseBuffer, lightBuffer, targetOrder, width](int startIndex, int stopIndex) mutable {
+	int32_t width = image_getWidth(colorBuffer);
+	int32_t height = image_getHeight(colorBuffer);
+	threadedSplit(0, height, [colorBuffer, diffuseBuffer, lightBuffer, targetOrder, width](int32_t startIndex, int32_t stopIndex) mutable {
 		SafePointer<uint32_t> targetRow = image_getSafePointer(colorBuffer, startIndex);
 		SafePointer<uint32_t> targetRow = image_getSafePointer(colorBuffer, startIndex);
 		SafePointer<uint32_t> diffuseRow = image_getSafePointer(diffuseBuffer, startIndex);
 		SafePointer<uint32_t> diffuseRow = image_getSafePointer(diffuseBuffer, startIndex);
 		SafePointer<uint32_t> lightRow = image_getSafePointer(lightBuffer, startIndex);
 		SafePointer<uint32_t> lightRow = image_getSafePointer(lightBuffer, startIndex);
-		int targetStride = image_getStride(colorBuffer);
-		int diffuseStride = image_getStride(diffuseBuffer);
-		int lightStride = image_getStride(lightBuffer);
+		int32_t targetStride = image_getStride(colorBuffer);
+		int32_t diffuseStride = image_getStride(diffuseBuffer);
+		int32_t lightStride = image_getStride(lightBuffer);
 		F32xX scale = F32xX(1.0 / 128.0f);
 		F32xX scale = F32xX(1.0 / 128.0f);
-		for (int y = startIndex; y < stopIndex; y++) {
+		for (int32_t y = startIndex; y < stopIndex; y++) {
 			SafePointer<uint32_t> targetPixel = targetRow;
 			SafePointer<uint32_t> targetPixel = targetRow;
 			SafePointer<uint32_t> diffusePixel = diffuseRow;
 			SafePointer<uint32_t> diffusePixel = diffuseRow;
 			SafePointer<uint32_t> lightPixel = lightRow;
 			SafePointer<uint32_t> lightPixel = lightRow;
-			for (int x = 0; x < width; x += laneCountX_32Bit) {
+			for (int32_t x = 0; x < width; x += laneCountX_32Bit) {
 				U32xX diffuse = U32xX::readAligned(diffusePixel, "blendLight: reading diffuse");
 				U32xX diffuse = U32xX::readAligned(diffusePixel, "blendLight: reading diffuse");
 				U32xX light = U32xX::readAligned(lightPixel, "blendLight: reading light");
 				U32xX light = U32xX::readAligned(lightPixel, "blendLight: reading light");
 				F32xX red = (floatFromU32(packOrder_getRed(diffuse)) * floatFromU32(packOrder_getRed(light))) * scale;
 				F32xX red = (floatFromU32(packOrder_getRed(diffuse)) * floatFromU32(packOrder_getRed(light))) * scale;

+ 10 - 10
Source/SDK/SpriteEngine/orthoAPI.cpp

@@ -3,7 +3,7 @@
 
 
 namespace dsr {
 namespace dsr {
 
 
-OrthoView::OrthoView(int id, const IVector2D roundedXAxis, const IVector2D roundedZAxis, int yPixelsPerTile, const FMatrix3x3 &normalToWorldSpace, Direction worldDirection)
+OrthoView::OrthoView(int32_t id, const IVector2D roundedXAxis, const IVector2D roundedZAxis, int32_t yPixelsPerTile, const FMatrix3x3 &normalToWorldSpace, Direction worldDirection)
 : id(id), worldDirection(worldDirection), normalToWorldSpace(normalToWorldSpace),
 : id(id), worldDirection(worldDirection), normalToWorldSpace(normalToWorldSpace),
   pixelOffsetPerTileX(roundedXAxis), pixelOffsetPerTileZ(roundedZAxis), yPixelsPerTile(yPixelsPerTile) {
   pixelOffsetPerTileX(roundedXAxis), pixelOffsetPerTileZ(roundedZAxis), yPixelsPerTile(yPixelsPerTile) {
 	// Pixel aligned 3D transformation matrix from tile (x, y, z) to screen (x, y, h)
 	// Pixel aligned 3D transformation matrix from tile (x, y, z) to screen (x, y, h)
@@ -57,7 +57,7 @@ IVector3D OrthoView::pixelToMiniPosition(const IVector2D& pixelLocation, const I
 
 
 OrthoSystem::OrthoSystem() : cameraTilt(0), pixelsPerTile(0) {}
 OrthoSystem::OrthoSystem() : cameraTilt(0), pixelsPerTile(0) {}
 
 
-OrthoSystem::OrthoSystem(float cameraTilt, int pixelsPerTile) : cameraTilt(cameraTilt), pixelsPerTile(pixelsPerTile) {
+OrthoSystem::OrthoSystem(float cameraTilt, int32_t pixelsPerTile) : cameraTilt(cameraTilt), pixelsPerTile(pixelsPerTile) {
 	this->update();
 	this->update();
 }
 }
 
 
@@ -80,7 +80,7 @@ OrthoSystem::OrthoSystem(const ReadableString& content) {
 
 
 void OrthoSystem::update() {
 void OrthoSystem::update() {
 	// Calculate y offset rounded to whole tiles to prevent random gaps in grids
 	// Calculate y offset rounded to whole tiles to prevent random gaps in grids
-	int yPixelsPerTile = (float)this->pixelsPerTile / sqrt(this->cameraTilt * this->cameraTilt + 1);
+	int32_t yPixelsPerTile = (float)this->pixelsPerTile / sqrt(this->cameraTilt * this->cameraTilt + 1);
 
 
 	// Define sprite directions
 	// Define sprite directions
 	FVector3D upAxis = FVector3D(0.0f, 1.0f, 0.0f);
 	FVector3D upAxis = FVector3D(0.0f, 1.0f, 0.0f);
@@ -96,7 +96,7 @@ void OrthoSystem::update() {
 	cameraSystems[6] = FMatrix3x3::makeAxisSystem(FVector3D( 0, this->cameraTilt,-1), upAxis);
 	cameraSystems[6] = FMatrix3x3::makeAxisSystem(FVector3D( 0, this->cameraTilt,-1), upAxis);
 	cameraSystems[7] = FMatrix3x3::makeAxisSystem(FVector3D( 1, this->cameraTilt, 0), upAxis);
 	cameraSystems[7] = FMatrix3x3::makeAxisSystem(FVector3D( 1, this->cameraTilt, 0), upAxis);
 
 
-	for (int a = 0; a < maxCameraAngles; a++) {
+	for (int32_t a = 0; a < maxCameraAngles; a++) {
 		// Define the coordinate system for normals
 		// Define the coordinate system for normals
 		FVector3D normalSystemDirection = cameraSystems[a].zAxis;
 		FVector3D normalSystemDirection = cameraSystems[a].zAxis;
 		normalSystemDirection.y = 0.0f;
 		normalSystemDirection.y = 0.0f;
@@ -108,8 +108,8 @@ void OrthoSystem::update() {
 		FVector2D ZAxis = approximateCamera.worldToScreen(FVector3D(0.0f, 0.0f, 1.0f)).is - halfTile;
 		FVector2D ZAxis = approximateCamera.worldToScreen(FVector3D(0.0f, 0.0f, 1.0f)).is - halfTile;
 		this->view[a] = OrthoView(
 		this->view[a] = OrthoView(
 		  a,
 		  a,
-		  IVector2D((int)XAxis.x, (int)XAxis.y),
-		  IVector2D((int)ZAxis.x, (int)ZAxis.y),
+		  IVector2D((int32_t)XAxis.x, (int32_t)XAxis.y),
+		  IVector2D((int32_t)ZAxis.x, (int32_t)ZAxis.y),
 		  yPixelsPerTile,
 		  yPixelsPerTile,
 		  normalToWorldSpace,
 		  normalToWorldSpace,
 		  worldDirections[a]
 		  worldDirections[a]
@@ -117,7 +117,7 @@ void OrthoSystem::update() {
 	}
 	}
 }
 }
 
 
-int ortho_roundToTile(int miniCoordinate) {
+int32_t ortho_roundToTile(int32_t miniCoordinate) {
 	return roundDown(miniCoordinate + (ortho_miniUnitsPerTile / 2), ortho_miniUnitsPerTile);
 	return roundDown(miniCoordinate + (ortho_miniUnitsPerTile / 2), ortho_miniUnitsPerTile);
 }
 }
 
 
@@ -125,7 +125,7 @@ IVector3D ortho_roundToTile(const IVector3D& miniPosition) {
 	return IVector3D(ortho_roundToTile(miniPosition.x), miniPosition.y, ortho_roundToTile(miniPosition.z));
 	return IVector3D(ortho_roundToTile(miniPosition.x), miniPosition.y, ortho_roundToTile(miniPosition.z));
 }
 }
 
 
-float ortho_miniToFloatingTile(int miniCoordinate) {
+float ortho_miniToFloatingTile(int32_t miniCoordinate) {
 	return (float)miniCoordinate * ortho_tilesPerMiniUnit;
 	return (float)miniCoordinate * ortho_tilesPerMiniUnit;
 }
 }
 
 
@@ -137,8 +137,8 @@ FVector3D ortho_miniToFloatingTile(const IVector3D& miniPosition) {
 	);
 	);
 }
 }
 
 
-int ortho_floatingTileToMini(float tileCoordinate) {
-	return (int)round((double)tileCoordinate * (double)ortho_miniUnitsPerTile);
+int32_t ortho_floatingTileToMini(float tileCoordinate) {
+	return (int32_t)round((double)tileCoordinate * (double)ortho_miniUnitsPerTile);
 }
 }
 
 
 IVector3D ortho_floatingTileToMini(const FVector3D& tilePosition) {
 IVector3D ortho_floatingTileToMini(const FVector3D& tilePosition) {

+ 16 - 16
Source/SDK/SpriteEngine/orthoAPI.h

@@ -16,7 +16,7 @@ static const Direction ortho_dir135 = 3;
 static const Direction ortho_dir90 = 2;
 static const Direction ortho_dir90 = 2;
 static const Direction ortho_dir45 = 1;
 static const Direction ortho_dir45 = 1;
 static const Direction ortho_dir0 = 0;
 static const Direction ortho_dir0 = 0;
-inline int correctDirection(Direction direction) {
+inline int32_t correctDirection(Direction direction) {
 	return (int32_t)((uint32_t)((int32_t)direction + (ortho_dir360 * 1024)) % ortho_dir360);
 	return (int32_t)((uint32_t)((int32_t)direction + (ortho_dir360 * 1024)) % ortho_dir360);
 }
 }
 
 
@@ -25,14 +25,14 @@ inline int correctDirection(Direction direction) {
 //     Used for expressing exact tile indices in games so that information can be stored efficiently
 //     Used for expressing exact tile indices in games so that information can be stored efficiently
 //   Mini-Tile = Tile / miniUnitsPerTile
 //   Mini-Tile = Tile / miniUnitsPerTile
 //     Used to express locations in 3D without relying too much on non-deterministic floats
 //     Used to express locations in 3D without relying too much on non-deterministic floats
-static constexpr int ortho_miniUnitsPerTile = 1024;
+static constexpr int32_t ortho_miniUnitsPerTile = 1024;
 static constexpr float ortho_tilesPerMiniUnit = 1.0f / (float)ortho_miniUnitsPerTile;
 static constexpr float ortho_tilesPerMiniUnit = 1.0f / (float)ortho_miniUnitsPerTile;
 
 
-int ortho_roundToTile(int miniCoordinate);
+int32_t ortho_roundToTile(int32_t miniCoordinate);
 IVector3D ortho_roundToTile(const IVector3D& miniPosition);
 IVector3D ortho_roundToTile(const IVector3D& miniPosition);
-float ortho_miniToFloatingTile(int miniCoordinate);
+float ortho_miniToFloatingTile(int32_t miniCoordinate);
 FVector3D ortho_miniToFloatingTile(const IVector3D& miniPosition);
 FVector3D ortho_miniToFloatingTile(const IVector3D& miniPosition);
-int ortho_floatingTileToMini(float tileCoordinate);
+int32_t ortho_floatingTileToMini(float tileCoordinate);
 IVector3D ortho_floatingTileToMini(const FVector3D& tilePosition);
 IVector3D ortho_floatingTileToMini(const FVector3D& tilePosition);
 
 
 // TODO: Make sure that every conversion is derived from a single pixel-rounded world-to-screen transform
 // TODO: Make sure that every conversion is derived from a single pixel-rounded world-to-screen transform
@@ -41,7 +41,7 @@ IVector3D ortho_floatingTileToMini(const FVector3D& tilePosition);
 struct OrthoView {
 struct OrthoView {
 public:
 public:
 	// Unique integer for identifying the view
 	// Unique integer for identifying the view
-	int id = -1;
+	int32_t id = -1;
 
 
 	// Direction for rotating sprites
 	// Direction for rotating sprites
 	Direction worldDirection = ortho_dir0; // How are sprites in the world rotated relative to the camera's point of view
 	Direction worldDirection = ortho_dir0; // How are sprites in the world rotated relative to the camera's point of view
@@ -53,7 +53,7 @@ public:
 	// Pixel aligned space (To ensure that moving one tile has the same number of pixels each time)
 	// Pixel aligned space (To ensure that moving one tile has the same number of pixels each time)
 	IVector2D pixelOffsetPerTileX; // How many pixels does a sprite move per tile in X.
 	IVector2D pixelOffsetPerTileX; // How many pixels does a sprite move per tile in X.
 	IVector2D pixelOffsetPerTileZ; // How many pixels does a sprite move per tile in Z.
 	IVector2D pixelOffsetPerTileZ; // How many pixels does a sprite move per tile in Z.
-	int yPixelsPerTile = 0;
+	int32_t yPixelsPerTile = 0;
 
 
 	// How pixels in the depth buffer maps to world-space coordinates in whole floating tiles.
 	// How pixels in the depth buffer maps to world-space coordinates in whole floating tiles.
 	FMatrix3x3 screenDepthToWorldSpace;
 	FMatrix3x3 screenDepthToWorldSpace;
@@ -69,7 +69,7 @@ public:
 	FMatrix2x2 roundedScreenPixelsToWorldTiles; // TODO: Replace with a screenToTile sub-set
 	FMatrix2x2 roundedScreenPixelsToWorldTiles; // TODO: Replace with a screenToTile sub-set
 public:
 public:
 	OrthoView() {}
 	OrthoView() {}
-	OrthoView(int id, const IVector2D roundedXAxis, const IVector2D roundedZAxis, int yPixelsPerTile, const FMatrix3x3 &normalToWorldSpace, Direction worldDirection);
+	OrthoView(int32_t id, const IVector2D roundedXAxis, const IVector2D roundedZAxis, int32_t yPixelsPerTile, const FMatrix3x3 &normalToWorldSpace, Direction worldDirection);
 public:
 public:
 	IVector2D miniTileOffsetToScreenPixel(const IVector3D& miniTileOffset) const;
 	IVector2D miniTileOffsetToScreenPixel(const IVector3D& miniTileOffset) const;
 	// Position is expressed in world space using mini units
 	// Position is expressed in world space using mini units
@@ -92,11 +92,11 @@ public:
 //     With enough bits in the integers, the result should be steady and not shake around randomly
 //     With enough bits in the integers, the result should be steady and not shake around randomly
 struct OrthoSystem {
 struct OrthoSystem {
 public:
 public:
-	static constexpr int maxCameraAngles = 8;
+	static constexpr int32_t maxCameraAngles = 8;
 	static constexpr float diag = 0.707106781f; // cos(45 degrees) = Sqrt(2) / 2
 	static constexpr float diag = 0.707106781f; // cos(45 degrees) = Sqrt(2) / 2
 	// Persistent settings
 	// Persistent settings
 	float cameraTilt; // Camera coefficient. (-inf is straight down, -1 is diagonal down, 0 is horizontal)
 	float cameraTilt; // Camera coefficient. (-inf is straight down, -1 is diagonal down, 0 is horizontal)
-	int pixelsPerTile; // The sideway length of a tile in pixels when seen from straight ahead.
+	int32_t pixelsPerTile; // The sideway length of a tile in pixels when seen from straight ahead.
 	// Generated views
 	// Generated views
 	OrthoView view[maxCameraAngles];
 	OrthoView view[maxCameraAngles];
 private:
 private:
@@ -105,28 +105,28 @@ private:
 	void update();
 	void update();
 public:
 public:
 	OrthoSystem();
 	OrthoSystem();
-	OrthoSystem(float cameraTilt, int pixelsPerTile);
+	OrthoSystem(float cameraTilt, int32_t pixelsPerTile);
 	explicit OrthoSystem(const ReadableString& content);
 	explicit OrthoSystem(const ReadableString& content);
 public:
 public:
-	IVector2D miniTileOffsetToScreenPixel(const IVector3D& miniTileOffset, int cameraIndex) const {
+	IVector2D miniTileOffsetToScreenPixel(const IVector3D& miniTileOffset, int32_t cameraIndex) const {
 		return this->view[cameraIndex].miniTileOffsetToScreenPixel(miniTileOffset);
 		return this->view[cameraIndex].miniTileOffsetToScreenPixel(miniTileOffset);
 	}
 	}
 	// Position is expressed in world space using mini units
 	// Position is expressed in world space using mini units
-	IVector2D miniTilePositionToScreenPixel(const IVector3D& position, int cameraIndex, const IVector2D& worldCenter) const {
+	IVector2D miniTilePositionToScreenPixel(const IVector3D& position, int32_t cameraIndex, const IVector2D& worldCenter) const {
 		return this->view[cameraIndex].miniTilePositionToScreenPixel(position, worldCenter);
 		return this->view[cameraIndex].miniTilePositionToScreenPixel(position, worldCenter);
 	}
 	}
 public:
 public:
 	// Returns the 3D mini-tile units moved along the ground for the pixel offset
 	// Returns the 3D mini-tile units moved along the ground for the pixel offset
 	//   Only rotation and scaling for pixel offsets
 	//   Only rotation and scaling for pixel offsets
-	FVector3D pixelToTileOffset(const IVector2D& pixelOffset, int cameraIndex) const {
+	FVector3D pixelToTileOffset(const IVector2D& pixelOffset, int32_t cameraIndex) const {
 		return this->view[cameraIndex].pixelToTileOffset(pixelOffset);
 		return this->view[cameraIndex].pixelToTileOffset(pixelOffset);
 	}
 	}
-	IVector3D pixelToMiniOffset(const IVector2D& pixelOffset, int cameraIndex) const {
+	IVector3D pixelToMiniOffset(const IVector2D& pixelOffset, int32_t cameraIndex) const {
 		return this->view[cameraIndex].pixelToMiniOffset(pixelOffset);
 		return this->view[cameraIndex].pixelToMiniOffset(pixelOffset);
 	}
 	}
 	// Returns the 3D mini-tile location for a certain pixel on the screen intersecting with the ground
 	// Returns the 3D mini-tile location for a certain pixel on the screen intersecting with the ground
 	//   Full transform for pixel locations
 	//   Full transform for pixel locations
-	IVector3D pixelToMiniPosition(const IVector2D& pixelLocation, int cameraIndex, const IVector2D& worldCenter) const {
+	IVector3D pixelToMiniPosition(const IVector2D& pixelLocation, int32_t cameraIndex, const IVector2D& worldCenter) const {
 		return this->view[cameraIndex].pixelToMiniPosition(pixelLocation, worldCenter);
 		return this->view[cameraIndex].pixelToMiniPosition(pixelLocation, worldCenter);
 	}
 	}
 };
 };

+ 130 - 130
Source/SDK/SpriteEngine/spriteAPI.cpp

@@ -42,9 +42,9 @@ static IVector3D FVector3DToIVector3D(const FVector3D& v) {
 }
 }
 
 
 struct SpriteConfig {
 struct SpriteConfig {
-	int centerX, centerY; // The sprite's origin in pixels relative to the upper left corner
-	int frameRows; // The atlas has one row for each frame
-	int propertyColumns; // The atlas has one column for each type of information
+	int32_t centerX, centerY; // The sprite's origin in pixels relative to the upper left corner
+	int32_t frameRows; // The atlas has one row for each frame
+	int32_t propertyColumns; // The atlas has one column for each type of information
 	// The 3D model's bound in tile units
 	// The 3D model's bound in tile units
 	//   The height image goes from 0 at minimum Y to 255 at maximum Y
 	//   The height image goes from 0 at minimum Y to 255 at maximum Y
 	FVector3D minBound, maxBound;
 	FVector3D minBound, maxBound;
@@ -52,7 +52,7 @@ struct SpriteConfig {
 	List<FVector3D> points; // 3D points for the triangles to refer to by index
 	List<FVector3D> points; // 3D points for the triangles to refer to by index
 	List<int32_t> triangleIndices; // Triangle indices stored in multiples of three integers
 	List<int32_t> triangleIndices; // Triangle indices stored in multiples of three integers
 	// Construction
 	// Construction
-	SpriteConfig(int centerX, int centerY, int frameRows, int propertyColumns, FVector3D minBound, FVector3D maxBound)
+	SpriteConfig(int32_t centerX, int32_t centerY, int32_t frameRows, int32_t propertyColumns, FVector3D minBound, FVector3D maxBound)
 	: centerX(centerX), centerY(centerY), frameRows(frameRows), propertyColumns(propertyColumns), minBound(minBound), maxBound(maxBound) {}
 	: centerX(centerX), centerY(centerY), frameRows(frameRows), propertyColumns(propertyColumns), minBound(minBound), maxBound(maxBound) {}
 	explicit SpriteConfig(const ReadableString& content) {
 	explicit SpriteConfig(const ReadableString& content) {
 		config_parse_ini(content, [this](const ReadableString& block, const ReadableString& key, const ReadableString& value) {
 		config_parse_ini(content, [this](const ReadableString& block, const ReadableString& key, const ReadableString& value) {
@@ -76,7 +76,7 @@ struct SpriteConfig {
 					} else {
 					} else {
 						this->points.clear();
 						this->points.clear();
 						this->points.reserve(values.length() / 3);
 						this->points.reserve(values.length() / 3);
-						for (int v = 0; v < values.length(); v += 3) {
+						for (int32_t v = 0; v < values.length(); v += 3) {
 							this->points.push(FVector3D(string_toDouble(values[v]), string_toDouble(values[v+1]), string_toDouble(values[v+2])));
 							this->points.push(FVector3D(string_toDouble(values[v]), string_toDouble(values[v+1]), string_toDouble(values[v+2])));
 						}
 						}
 					}
 					}
@@ -87,7 +87,7 @@ struct SpriteConfig {
 					} else {
 					} else {
 						this->triangleIndices.clear();
 						this->triangleIndices.clear();
 						this->triangleIndices.reserve(values.length());
 						this->triangleIndices.reserve(values.length());
-						for (int v = 0; v < values.length(); v++) {
+						for (int32_t v = 0; v < values.length(); v++) {
 							this->triangleIndices.push(string_toInteger(values[v]));
 							this->triangleIndices.push(string_toInteger(values[v]));
 						}
 						}
 					}
 					}
@@ -102,18 +102,18 @@ struct SpriteConfig {
 	// Add model as a persistent shadow caster in the sprite configuration
 	// Add model as a persistent shadow caster in the sprite configuration
 	void appendShadow(const Model& model) {
 	void appendShadow(const Model& model) {
 		points.reserve(this->points.length() + model_getNumberOfPoints(model));
 		points.reserve(this->points.length() + model_getNumberOfPoints(model));
-		for (int p = 0; p < model_getNumberOfPoints(model); p++) {
+		for (int32_t p = 0; p < model_getNumberOfPoints(model); p++) {
 			this->points.push(model_getPoint(model, p));
 			this->points.push(model_getPoint(model, p));
 		}
 		}
-		for (int part = 0; part < model_getNumberOfParts(model); part++) {
-			for (int poly = 0; poly < model_getNumberOfPolygons(model, part); poly++) {
-				int vertexCount = model_getPolygonVertexCount(model, part, poly);
-				int vertA = 0;
-				int indexA = model_getVertexPointIndex(model, part, poly, vertA);
-				for (int vertB = 1; vertB < vertexCount - 1; vertB++) {
-					int vertC = vertB + 1;
-					int indexB = model_getVertexPointIndex(model, part, poly, vertB);
-					int indexC = model_getVertexPointIndex(model, part, poly, vertC);
+		for (int32_t part = 0; part < model_getNumberOfParts(model); part++) {
+			for (int32_t poly = 0; poly < model_getNumberOfPolygons(model, part); poly++) {
+				int32_t vertexCount = model_getPolygonVertexCount(model, part, poly);
+				int32_t vertA = 0;
+				int32_t indexA = model_getVertexPointIndex(model, part, poly, vertA);
+				for (int32_t vertB = 1; vertB < vertexCount - 1; vertB++) {
+					int32_t vertC = vertB + 1;
+					int32_t indexB = model_getVertexPointIndex(model, part, poly, vertB);
+					int32_t indexC = model_getVertexPointIndex(model, part, poly, vertC);
 					triangleIndices.push(indexA); triangleIndices.push(indexB); triangleIndices.push(indexC);
 					triangleIndices.push(indexA); triangleIndices.push(indexB); triangleIndices.push(indexC);
 				}
 				}
 			}
 			}
@@ -133,7 +133,7 @@ struct SpriteConfig {
 		// Low-resolution 3D shape
 		// Low-resolution 3D shape
 		if (this->points.length() > 0) {
 		if (this->points.length() > 0) {
 			string_append(result, U"Points=");
 			string_append(result, U"Points=");
-			for (int p = 0; p < this->points.length(); p++) {
+			for (int32_t p = 0; p < this->points.length(); p++) {
 				if (p > 0) {
 				if (p > 0) {
 					string_append(result, U", ");
 					string_append(result, U", ");
 				}
 				}
@@ -141,7 +141,7 @@ struct SpriteConfig {
 			}
 			}
 			string_append(result, U"\n");
 			string_append(result, U"\n");
 			string_append(result, U"TriangleIndices=");
 			string_append(result, U"TriangleIndices=");
-			for (int i = 0; i < this->triangleIndices.length(); i+=3) {
+			for (int32_t i = 0; i < this->triangleIndices.length(); i+=3) {
 				if (i > 0) {
 				if (i > 0) {
 					string_append(result, U", ");
 					string_append(result, U", ");
 				}
 				}
@@ -156,11 +156,11 @@ struct SpriteConfig {
 static ImageF32 scaleHeightImage(const ImageRgbaU8& heightImage, float minHeight, float maxHeight, const ImageRgbaU8& colorImage) {
 static ImageF32 scaleHeightImage(const ImageRgbaU8& heightImage, float minHeight, float maxHeight, const ImageRgbaU8& colorImage) {
 	float scale = (maxHeight - minHeight) / 255.0f;
 	float scale = (maxHeight - minHeight) / 255.0f;
 	float offset = minHeight;
 	float offset = minHeight;
-	int width = image_getWidth(heightImage);
-	int height = image_getHeight(heightImage);
+	int32_t width = image_getWidth(heightImage);
+	int32_t height = image_getHeight(heightImage);
 	ImageF32 result = image_create_F32(width, height);
 	ImageF32 result = image_create_F32(width, height);
-	for (int y = 0; y < height; y++) {
-		for (int x = 0; x < width; x++) {
+	for (int32_t y = 0; y < height; y++) {
+		for (int32_t x = 0; x < width; x++) {
 			float value = image_readPixel_clamp(heightImage, x, y).red;
 			float value = image_readPixel_clamp(heightImage, x, y).red;
 			if (image_readPixel_clamp(colorImage, x, y).alpha > 127) {
 			if (image_readPixel_clamp(colorImage, x, y).alpha > 127) {
 				image_writePixel(result, x, y, (value * scale) + offset);
 				image_writePixel(result, x, y, (value * scale) + offset);
@@ -208,9 +208,9 @@ public:
 		  ceil(configuration.maxBound.y * ortho_miniUnitsPerTile),
 		  ceil(configuration.maxBound.y * ortho_miniUnitsPerTile),
 		  ceil(configuration.maxBound.z * ortho_miniUnitsPerTile)
 		  ceil(configuration.maxBound.z * ortho_miniUnitsPerTile)
 		);
 		);
-		int width = image_getWidth(loadedAtlas) / configuration.propertyColumns;
-		int height = image_getHeight(loadedAtlas) / configuration.frameRows;
-		for (int a = 0; a < configuration.frameRows; a++) {
+		int32_t width = image_getWidth(loadedAtlas) / configuration.propertyColumns;
+		int32_t height = image_getHeight(loadedAtlas) / configuration.frameRows;
+		for (int32_t a = 0; a < configuration.frameRows; a++) {
 			ImageRgbaU8 colorImage = image_getSubImage(loadedAtlas, IRect(0, a * height, width, height));
 			ImageRgbaU8 colorImage = image_getSubImage(loadedAtlas, IRect(0, a * height, width, height));
 			ImageRgbaU8 heightImage = image_getSubImage(loadedAtlas, IRect(width, a * height, width, height));
 			ImageRgbaU8 heightImage = image_getSubImage(loadedAtlas, IRect(width, a * height, width, height));
 			ImageRgbaU8 normalImage = image_getSubImage(loadedAtlas, IRect(width * 2, a * height, width, height));
 			ImageRgbaU8 normalImage = image_getSubImage(loadedAtlas, IRect(width * 2, a * height, width, height));
@@ -220,19 +220,19 @@ public:
 		// Create a model for rendering shadows
 		// Create a model for rendering shadows
 		if (configuration.points.length() > 0) {
 		if (configuration.points.length() > 0) {
 			this->shadowModel = model_create();
 			this->shadowModel = model_create();
-			for (int p = 0; p < configuration.points.length(); p++) {
+			for (int32_t p = 0; p < configuration.points.length(); p++) {
 				model_addPoint(this->shadowModel, configuration.points[p]);
 				model_addPoint(this->shadowModel, configuration.points[p]);
 			}
 			}
 			model_addEmptyPart(this->shadowModel, U"Shadow");
 			model_addEmptyPart(this->shadowModel, U"Shadow");
-			for (int t = 0; t < configuration.triangleIndices.length(); t+=3) {
+			for (int32_t t = 0; t < configuration.triangleIndices.length(); t+=3) {
 				model_addTriangle(this->shadowModel, 0, configuration.triangleIndices[t], configuration.triangleIndices[t+1], configuration.triangleIndices[t+2]);
 				model_addTriangle(this->shadowModel, 0, configuration.triangleIndices[t], configuration.triangleIndices[t+1], configuration.triangleIndices[t+2]);
 			}
 			}
 		}
 		}
 	}
 	}
 public:
 public:
 	// TODO: Force frame count to a power of two or replace modulo with look-up tables in sprite configurations.
 	// TODO: Force frame count to a power of two or replace modulo with look-up tables in sprite configurations.
-	int getFrameIndex(Direction direction) {
-		const int frameFromDir[8] = {4, 1, 5, 2, 6, 3, 7, 0};
+	int32_t getFrameIndex(Direction direction) {
+		const int32_t frameFromDir[8] = {4, 1, 5, 2, 6, 3, 7, 0};
 		return frameFromDir[correctDirection(direction)] % this->frames.length();
 		return frameFromDir[correctDirection(direction)] % this->frames.length();
 	}
 	}
 };
 };
@@ -285,35 +285,35 @@ public:
 
 
 // Global list of all sprite types ever loaded
 // Global list of all sprite types ever loaded
 List<SpriteType> spriteTypes;
 List<SpriteType> spriteTypes;
-int spriteWorld_loadSpriteTypeFromFile(const String& folderPath, const String& spriteName) {
+int32_t spriteWorld_loadSpriteTypeFromFile(const String& folderPath, const String& spriteName) {
 	return spriteTypes.pushConstructGetIndex(folderPath, spriteName);
 	return spriteTypes.pushConstructGetIndex(folderPath, spriteName);
 }
 }
-int spriteWorld_getSpriteTypeCount() {
+int32_t spriteWorld_getSpriteTypeCount() {
 	return spriteTypes.length();
 	return spriteTypes.length();
 }
 }
-String spriteWorld_getSpriteTypeName(int index) {
+String spriteWorld_getSpriteTypeName(int32_t index) {
 	return spriteTypes[index].name;
 	return spriteTypes[index].name;
 }
 }
 
 
 // Global list of all model types ever loaded
 // Global list of all model types ever loaded
 List<ModelType> modelTypes;
 List<ModelType> modelTypes;
-int spriteWorld_loadModelTypeFromFile(const String& folderPath, const String& visibleModelName, const String& shadowModelName) {
+int32_t spriteWorld_loadModelTypeFromFile(const String& folderPath, const String& visibleModelName, const String& shadowModelName) {
 	return modelTypes.pushConstructGetIndex(folderPath, visibleModelName, shadowModelName);
 	return modelTypes.pushConstructGetIndex(folderPath, visibleModelName, shadowModelName);
 }
 }
-int spriteWorld_getModelTypeCount() {
+int32_t spriteWorld_getModelTypeCount() {
 	return modelTypes.length();
 	return modelTypes.length();
 }
 }
-String spriteWorld_getModelTypeName(int index) {
+String spriteWorld_getModelTypeName(int32_t index) {
 	return modelTypes[index].name;
 	return modelTypes[index].name;
 }
 }
 
 
-static int getSpriteFrameIndex(const SpriteInstance& sprite, OrthoView view) {
+static int32_t getSpriteFrameIndex(const SpriteInstance& sprite, OrthoView view) {
 	return spriteTypes[sprite.typeIndex].getFrameIndex(view.worldDirection + sprite.direction);
 	return spriteTypes[sprite.typeIndex].getFrameIndex(view.worldDirection + sprite.direction);
 }
 }
 
 
 // Returns a 2D bounding box of affected target pixels
 // Returns a 2D bounding box of affected target pixels
 static IRect drawSprite(const SpriteInstance& sprite, const OrthoView& ortho, const IVector2D& worldCenter, ImageF32 targetHeight, ImageRgbaU8 targetColor, ImageRgbaU8 targetNormal) {
 static IRect drawSprite(const SpriteInstance& sprite, const OrthoView& ortho, const IVector2D& worldCenter, ImageF32 targetHeight, ImageRgbaU8 targetColor, ImageRgbaU8 targetNormal) {
-	int frameIndex = getSpriteFrameIndex(sprite, ortho);
+	int32_t frameIndex = getSpriteFrameIndex(sprite, ortho);
 	const SpriteFrame* frame = &spriteTypes[sprite.typeIndex].frames[frameIndex];
 	const SpriteFrame* frame = &spriteTypes[sprite.typeIndex].frames[frameIndex];
 	IVector2D screenSpace = ortho.miniTilePositionToScreenPixel(sprite.location, worldCenter) - frame->centerPoint;
 	IVector2D screenSpace = ortho.miniTilePositionToScreenPixel(sprite.location, worldCenter) - frame->centerPoint;
 	float heightOffset = sprite.location.y * ortho_tilesPerMiniUnit;
 	float heightOffset = sprite.location.y * ortho_tilesPerMiniUnit;
@@ -348,12 +348,12 @@ FMatrix3x3 spriteDirections[8] = {
 };
 };
 
 
 struct CubeMapF32 {
 struct CubeMapF32 {
-	int resolution;           // The width and height of each shadow depth image or 0 if no shadows are casted
+	int32_t resolution;           // The width and height of each shadow depth image or 0 if no shadows are casted
 	AlignedImageF32 cubeMap;  // A vertical sequence of reciprocal depth images for the six sides of the cube
 	AlignedImageF32 cubeMap;  // A vertical sequence of reciprocal depth images for the six sides of the cube
 	ImageF32 cubeMapViews[6]; // Sub-images sharing their allocations with cubeMap as sub-images
 	ImageF32 cubeMapViews[6]; // Sub-images sharing their allocations with cubeMap as sub-images
-	explicit CubeMapF32(int resolution) : resolution(resolution) {
+	explicit CubeMapF32(int32_t resolution) : resolution(resolution) {
 		this->cubeMap = image_create_F32(resolution, resolution * 6);
 		this->cubeMap = image_create_F32(resolution, resolution * 6);
-		for (int s = 0; s < 6; s++) {
+		for (int32_t s = 0; s < 6; s++) {
 			this->cubeMapViews[s] = image_getSubImage(this->cubeMap, IRect(0, s * resolution, resolution, resolution));
 			this->cubeMapViews[s] = image_getSubImage(this->cubeMap, IRect(0, s * resolution, resolution, resolution));
 		}
 		}
 	}
 	}
@@ -379,7 +379,7 @@ public:
 			// Place the model relative to the light source's position, to make rendering in light-space easier
 			// Place the model relative to the light source's position, to make rendering in light-space easier
 			Transform3D modelToWorldTransform = modelInstance.location;
 			Transform3D modelToWorldTransform = modelInstance.location;
 			modelToWorldTransform.position = modelToWorldTransform.position - this->position;
 			modelToWorldTransform.position = modelToWorldTransform.position - this->position;
-			for (int s = 0; s < 6; s++) {
+			for (int32_t s = 0; s < 6; s++) {
 				Camera camera = Camera::createPerspective(Transform3D(FVector3D(), ShadowCubeMapSides[s] * normalToWorld), shadowTarget.resolution, shadowTarget.resolution);
 				Camera camera = Camera::createPerspective(Transform3D(FVector3D(), ShadowCubeMapSides[s] * normalToWorld), shadowTarget.resolution, shadowTarget.resolution);
 				model_renderDepth(model, modelToWorldTransform, shadowTarget.cubeMapViews[s], camera);
 				model_renderDepth(model, modelToWorldTransform, shadowTarget.cubeMapViews[s], camera);
 			}
 			}
@@ -391,7 +391,7 @@ public:
 			if (model_exists(model)) {
 			if (model_exists(model)) {
 				// Place the model relative to the light source's position, to make rendering in light-space easier
 				// Place the model relative to the light source's position, to make rendering in light-space easier
 				Transform3D modelToWorldTransform = Transform3D(ortho_miniToFloatingTile(spriteInstance.location) - this->position, spriteDirections[spriteInstance.direction]);
 				Transform3D modelToWorldTransform = Transform3D(ortho_miniToFloatingTile(spriteInstance.location) - this->position, spriteDirections[spriteInstance.direction]);
-				for (int s = 0; s < 6; s++) {
+				for (int32_t s = 0; s < 6; s++) {
 					Camera camera = Camera::createPerspective(Transform3D(FVector3D(), ShadowCubeMapSides[s] * normalToWorld), shadowTarget.resolution, shadowTarget.resolution);
 					Camera camera = Camera::createPerspective(Transform3D(FVector3D(), ShadowCubeMapSides[s] * normalToWorld), shadowTarget.resolution, shadowTarget.resolution);
 					model_renderDepth(model, modelToWorldTransform, shadowTarget.cubeMapViews[s], camera);
 					model_renderDepth(model, modelToWorldTransform, shadowTarget.cubeMapViews[s], camera);
 				}
 				}
@@ -446,7 +446,7 @@ public:
 	}
 	}
 };
 };
 
 
-IVector3D getBoxCorner(const IVector3D& minBound, const IVector3D& maxBound, int cornerIndex) {
+IVector3D getBoxCorner(const IVector3D& minBound, const IVector3D& maxBound, int32_t cornerIndex) {
 	assert(cornerIndex >= 0 && cornerIndex < 8);
 	assert(cornerIndex >= 0 && cornerIndex < 8);
 	return IVector3D(
 	return IVector3D(
 	  ((uint32_t)cornerIndex & 1u) ? maxBound.x : minBound.x,
 	  ((uint32_t)cornerIndex & 1u) ? maxBound.x : minBound.x,
@@ -457,7 +457,7 @@ IVector3D getBoxCorner(const IVector3D& minBound, const IVector3D& maxBound, int
 
 
 static bool orthoCullingTest(const OrthoView& ortho, const IVector3D& minBound, const IVector3D& maxBound, const IRect& seenRegion) {
 static bool orthoCullingTest(const OrthoView& ortho, const IVector3D& minBound, const IVector3D& maxBound, const IRect& seenRegion) {
 	IVector2D corners[8];
 	IVector2D corners[8];
-	for (int c = 0; c < 8; c++) {
+	for (int32_t c = 0; c < 8; c++) {
 		corners[c] = ortho.miniTileOffsetToScreenPixel(getBoxCorner(minBound, maxBound, c));
 		corners[c] = ortho.miniTileOffsetToScreenPixel(getBoxCorner(minBound, maxBound, c));
 	}
 	}
 	if (corners[0].x < seenRegion.left()
 	if (corners[0].x < seenRegion.left()
@@ -511,10 +511,10 @@ enum class BlockState {
 };
 };
 class BackgroundBlock {
 class BackgroundBlock {
 public:
 public:
-	static const int blockSize = 512;
-	static const int maxDistance = blockSize * 2;
+	static const int32_t blockSize = 512;
+	static const int32_t maxDistance = blockSize * 2;
 	IRect worldRegion;
 	IRect worldRegion;
-	int cameraId = 0;
+	int32_t cameraId = 0;
 	BlockState state = BlockState::Unused;
 	BlockState state = BlockState::Unused;
 	OrderedImageRgbaU8 diffuseBuffer;
 	OrderedImageRgbaU8 diffuseBuffer;
 	OrderedImageRgbaU8 normalBuffer;
 	OrderedImageRgbaU8 normalBuffer;
@@ -553,8 +553,8 @@ public:
 	}
 	}
 	void draw(ImageRgbaU8& diffuseTarget, ImageRgbaU8& normalTarget, ImageF32& heightTarget, const IRect& seenRegion) const {
 	void draw(ImageRgbaU8& diffuseTarget, ImageRgbaU8& normalTarget, ImageF32& heightTarget, const IRect& seenRegion) const {
 		if (this->state != BlockState::Unused) {
 		if (this->state != BlockState::Unused) {
-			int left = this->worldRegion.left() - seenRegion.left();
-			int top = this->worldRegion.top() - seenRegion.top();
+			int32_t left = this->worldRegion.left() - seenRegion.left();
+			int32_t top = this->worldRegion.top() - seenRegion.top();
 			draw_copy(diffuseTarget, this->diffuseBuffer, left, top);
 			draw_copy(diffuseTarget, this->diffuseBuffer, left, top);
 			draw_copy(normalTarget, this->normalBuffer, left, top);
 			draw_copy(normalTarget, this->normalBuffer, left, top);
 			draw_copy(heightTarget, this->heightBuffer, left, top);
 			draw_copy(heightTarget, this->heightBuffer, left, top);
@@ -585,7 +585,7 @@ public:
 	List<PointLight> temporaryPointLights;
 	List<PointLight> temporaryPointLights;
 	List<DirectedLight> temporaryDirectedLights;
 	List<DirectedLight> temporaryDirectedLights;
 	// View
 	// View
-	int cameraIndex = 0;
+	int32_t cameraIndex = 0;
 	IVector3D cameraLocation;
 	IVector3D cameraLocation;
 	// Deferred rendering
 	// Deferred rendering
 	OrderedImageRgbaU8 diffuseBuffer;
 	OrderedImageRgbaU8 diffuseBuffer;
@@ -599,17 +599,17 @@ public:
 	DirtyRectangles dirtyBackground;
 	DirtyRectangles dirtyBackground;
 private:
 private:
 	// Reused buffers
 	// Reused buffers
-	int shadowResolution;
+	int32_t shadowResolution;
 	CubeMapF32 temporaryShadowMap;
 	CubeMapF32 temporaryShadowMap;
 public:
 public:
-	SpriteWorldImpl(const OrthoSystem &ortho, int shadowResolution)
+	SpriteWorldImpl(const OrthoSystem &ortho, int32_t shadowResolution)
 	: ortho(ortho), passiveSprites(ortho_miniUnitsPerTile * 64), passiveModels(ortho_miniUnitsPerTile * 64), shadowResolution(shadowResolution), temporaryShadowMap(shadowResolution) {}
 	: ortho(ortho), passiveSprites(ortho_miniUnitsPerTile * 64), passiveModels(ortho_miniUnitsPerTile * 64), shadowResolution(shadowResolution), temporaryShadowMap(shadowResolution) {}
 public:
 public:
 	// Post-condition: Returns the number of redrawn background blocks. (0 or 1)
 	// Post-condition: Returns the number of redrawn background blocks. (0 or 1)
-	int updateBlockAt(const IRect& blockRegion, const IRect& seenRegion) {
-		int unusedBlockIndex = -1;
+	int32_t updateBlockAt(const IRect& blockRegion, const IRect& seenRegion) {
+		int32_t unusedBlockIndex = -1;
 		// Find an existing block
 		// Find an existing block
-		for (int b = 0; b < this->backgroundBlocks.length(); b++) {
+		for (int32_t b = 0; b < this->backgroundBlocks.length(); b++) {
 			BackgroundBlock* currentBlockPtr = &this->backgroundBlocks[b];
 			BackgroundBlock* currentBlockPtr = &this->backgroundBlocks[b];
 			if (currentBlockPtr->state != BlockState::Unused) {
 			if (currentBlockPtr->state != BlockState::Unused) {
 				// Check direction
 				// Check direction
@@ -653,9 +653,9 @@ public:
 		}
 		}
 		return 1;
 		return 1;
 	}
 	}
-	void invalidateBlockAt(int left, int top) {
+	void invalidateBlockAt(int32_t left, int32_t top) {
 		// Find an existing block
 		// Find an existing block
-		for (int b = 0; b < this->backgroundBlocks.length(); b++) {
+		for (int32_t b = 0; b < this->backgroundBlocks.length(); b++) {
 			BackgroundBlock* currentBlockPtr = &this->backgroundBlocks[b];
 			BackgroundBlock* currentBlockPtr = &this->backgroundBlocks[b];
 			// Assuming that alternative camera angles will be removed when drawing next time
 			// Assuming that alternative camera angles will be removed when drawing next time
 			if (currentBlockPtr->state == BlockState::Ready
 			if (currentBlockPtr->state == BlockState::Ready
@@ -669,8 +669,8 @@ public:
 	// Make sure that each pixel in seenRegion is occupied by an updated background block
 	// Make sure that each pixel in seenRegion is occupied by an updated background block
 	// If maxUpdates is larger than -1, the work is scheduled to do at most maxUpdates per call.
 	// If maxUpdates is larger than -1, the work is scheduled to do at most maxUpdates per call.
 	// Post-condition: Returns the number of redrawn background blocks.
 	// Post-condition: Returns the number of redrawn background blocks.
-	int updateBlocks(const IRect& seenRegion, int maxUpdates = -1) {
-		int updateCount = 0;
+	int32_t updateBlocks(const IRect& seenRegion, int32_t maxUpdates = -1) {
+		int32_t updateCount = 0;
 		// Round inclusive pixel indices down to containing blocks and iterate over them in strides along x and y
 		// Round inclusive pixel indices down to containing blocks and iterate over them in strides along x and y
 		int64_t roundedLeft = roundDown(seenRegion.left(), BackgroundBlock::blockSize);
 		int64_t roundedLeft = roundDown(seenRegion.left(), BackgroundBlock::blockSize);
 		int64_t roundedTop = roundDown(seenRegion.top(), BackgroundBlock::blockSize);
 		int64_t roundedTop = roundDown(seenRegion.top(), BackgroundBlock::blockSize);
@@ -695,14 +695,14 @@ public:
 		assert(image_getWidth(heightTarget) == seenRegion.width() && image_getHeight(heightTarget) == seenRegion.height());
 		assert(image_getWidth(heightTarget) == seenRegion.width() && image_getHeight(heightTarget) == seenRegion.height());
 		this->dirtyBackground.setTargetResolution(seenRegion.width(), seenRegion.height());
 		this->dirtyBackground.setTargetResolution(seenRegion.width(), seenRegion.height());
 		// Draw passive sprites and models to blocks
 		// Draw passive sprites and models to blocks
-		int forcedUpdates = this->updateBlocks(seenRegion);
+		int32_t forcedUpdates = this->updateBlocks(seenRegion);
 		// If no critical updates were made to the background
 		// If no critical updates were made to the background
 		if (forcedUpdates < 1) {
 		if (forcedUpdates < 1) {
 			// Schedule drawing of up to one block from a larger region
 			// Schedule drawing of up to one block from a larger region
 			this->updateBlocks(seenRegion.expanded(128), 1);
 			this->updateBlocks(seenRegion.expanded(128), 1);
 		}
 		}
 		// Draw background blocks to the target images
 		// Draw background blocks to the target images
-		for (int b = 0; b < this->backgroundBlocks.length(); b++) {
+		for (int32_t b = 0; b < this->backgroundBlocks.length(); b++) {
 			#ifdef DIRTY_RECTANGLE_OPTIMIZATION
 			#ifdef DIRTY_RECTANGLE_OPTIMIZATION
 				// Optimized version
 				// Optimized version
 				for (int64_t r = 0; r < this->dirtyBackground.getRectangleCount(); r++) {
 				for (int64_t r = 0; r < this->dirtyBackground.getRectangleCount(); r++) {
@@ -722,11 +722,11 @@ public:
 		// Reset dirty rectangles so that active sprites may record changes
 		// Reset dirty rectangles so that active sprites may record changes
 		this->dirtyBackground.noneDirty();
 		this->dirtyBackground.noneDirty();
 		// Draw active sprites to the targets
 		// Draw active sprites to the targets
-		for (int s = 0; s < this->temporarySprites.length(); s++) {
+		for (int32_t s = 0; s < this->temporarySprites.length(); s++) {
 			IRect drawnRegion = drawSprite(this->temporarySprites[s], this->ortho.view[this->cameraIndex], -seenRegion.upperLeft(), heightTarget, diffuseTarget, normalTarget);
 			IRect drawnRegion = drawSprite(this->temporarySprites[s], this->ortho.view[this->cameraIndex], -seenRegion.upperLeft(), heightTarget, diffuseTarget, normalTarget);
 			this->dirtyBackground.makeRegionDirty(drawnRegion);
 			this->dirtyBackground.makeRegionDirty(drawnRegion);
 		}
 		}
-		for (int s = 0; s < this->temporaryModels.length(); s++) {
+		for (int32_t s = 0; s < this->temporaryModels.length(); s++) {
 			IRect drawnRegion = drawModel(this->temporaryModels[s], this->ortho.view[this->cameraIndex], -seenRegion.upperLeft(), heightTarget, diffuseTarget, normalTarget);
 			IRect drawnRegion = drawModel(this->temporaryModels[s], this->ortho.view[this->cameraIndex], -seenRegion.upperLeft(), heightTarget, diffuseTarget, normalTarget);
 			this->dirtyBackground.makeRegionDirty(drawnRegion);
 			this->dirtyBackground.makeRegionDirty(drawnRegion);
 		}
 		}
@@ -756,8 +756,8 @@ public:
 		IVector2D worldCenter = this->findWorldCenter(colorTarget);
 		IVector2D worldCenter = this->findWorldCenter(colorTarget);
 
 
 		// Resize when the window has resized or the buffers haven't been allocated before
 		// Resize when the window has resized or the buffers haven't been allocated before
-		int width = image_getWidth(colorTarget);
-		int height = image_getHeight(colorTarget);
+		int32_t width = image_getWidth(colorTarget);
+		int32_t height = image_getHeight(colorTarget);
 		if (image_getWidth(this->diffuseBuffer) != width || image_getHeight(this->diffuseBuffer) != height) {
 		if (image_getWidth(this->diffuseBuffer) != width || image_getHeight(this->diffuseBuffer) != height) {
 			this->diffuseBuffer = image_create_RgbaU8(width, height);
 			this->diffuseBuffer = image_create_RgbaU8(width, height);
 			this->normalBuffer = image_create_RgbaU8(width, height);
 			this->normalBuffer = image_create_RgbaU8(width, height);
@@ -774,7 +774,7 @@ public:
 		if (this->temporaryDirectedLights.length() > 0) {
 		if (this->temporaryDirectedLights.length() > 0) {
 			startTime = time_getSeconds();
 			startTime = time_getSeconds();
 				// Overwriting any light from the previous frame
 				// Overwriting any light from the previous frame
-				for (int p = 0; p < this->temporaryDirectedLights.length(); p++) {
+				for (int32_t p = 0; p < this->temporaryDirectedLights.length(); p++) {
 					this->temporaryDirectedLights[p].illuminate(this->ortho.view[this->cameraIndex], worldCenter, this->lightBuffer, this->normalBuffer, p == 0);
 					this->temporaryDirectedLights[p].illuminate(this->ortho.view[this->cameraIndex], worldCenter, this->lightBuffer, this->normalBuffer, p == 0);
 				}
 				}
 			debugText("Sun light: ", (time_getSeconds() - startTime) * 1000.0, " ms\n");
 			debugText("Sun light: ", (time_getSeconds() - startTime) * 1000.0, " ms\n");
@@ -785,7 +785,7 @@ public:
 		}
 		}
 
 
 		// Illuminate using point lights
 		// Illuminate using point lights
-		for (int p = 0; p < this->temporaryPointLights.length(); p++) {
+		for (int32_t p = 0; p < this->temporaryPointLights.length(); p++) {
 			PointLight *currentLight = &this->temporaryPointLights[p];
 			PointLight *currentLight = &this->temporaryPointLights[p];
 			if (currentLight->shadowCasting) {
 			if (currentLight->shadowCasting) {
 				startTime = time_getSeconds();
 				startTime = time_getSeconds();
@@ -794,11 +794,11 @@ public:
 				currentLight->renderPassiveShadows(this->temporaryShadowMap, this->passiveSprites, ortho.view[this->cameraIndex].normalToWorldSpace);
 				currentLight->renderPassiveShadows(this->temporaryShadowMap, this->passiveSprites, ortho.view[this->cameraIndex].normalToWorldSpace);
 				currentLight->renderPassiveShadows(this->temporaryShadowMap, this->passiveModels, ortho.view[this->cameraIndex].normalToWorldSpace);
 				currentLight->renderPassiveShadows(this->temporaryShadowMap, this->passiveModels, ortho.view[this->cameraIndex].normalToWorldSpace);
 				// Shadows from temporary sprites
 				// Shadows from temporary sprites
-				for (int s = 0; s < this->temporarySprites.length(); s++) {
+				for (int32_t s = 0; s < this->temporarySprites.length(); s++) {
 					currentLight->renderSpriteShadow(this->temporaryShadowMap, this->temporarySprites[s], ortho.view[this->cameraIndex].normalToWorldSpace);
 					currentLight->renderSpriteShadow(this->temporaryShadowMap, this->temporarySprites[s], ortho.view[this->cameraIndex].normalToWorldSpace);
 				}
 				}
 				// Shadows from temporary models
 				// Shadows from temporary models
-				for (int s = 0; s < this->temporaryModels.length(); s++) {
+				for (int32_t s = 0; s < this->temporaryModels.length(); s++) {
 					currentLight->renderModelShadow(this->temporaryShadowMap, this->temporaryModels[s], ortho.view[this->cameraIndex].normalToWorldSpace);
 					currentLight->renderModelShadow(this->temporaryShadowMap, this->temporaryModels[s], ortho.view[this->cameraIndex].normalToWorldSpace);
 				}
 				}
 				debugText("Cast point-light shadows: ", (time_getSeconds() - startTime) * 1000.0, " ms\n");
 				debugText("Cast point-light shadows: ", (time_getSeconds() - startTime) * 1000.0, " ms\n");
@@ -815,7 +815,7 @@ public:
 	}
 	}
 };
 };
 
 
-SpriteWorld spriteWorld_create(OrthoSystem ortho, int shadowResolution) {
+SpriteWorld spriteWorld_create(OrthoSystem ortho, int32_t shadowResolution) {
 	return std::make_shared<SpriteWorldImpl>(ortho, shadowResolution);
 	return std::make_shared<SpriteWorldImpl>(ortho, shadowResolution);
 }
 }
 
 
@@ -861,7 +861,7 @@ static void get3DBounds(
 	//   This make searches a lot easier for off-centered sprites and models by belonging to a coordinate independent of the design
 	//   This make searches a lot easier for off-centered sprites and models by belonging to a coordinate independent of the design
 	worldMinBound = FVector3DToIVector3D(transform.position);
 	worldMinBound = FVector3DToIVector3D(transform.position);
 	worldMaxBound = FVector3DToIVector3D(transform.position);
 	worldMaxBound = FVector3DToIVector3D(transform.position);
-	for (int c = 0; c < 8; c++) {
+	for (int32_t c = 0; c < 8; c++) {
 		FVector3D miniSpaceCorner = transformedCorners[c];
 		FVector3D miniSpaceCorner = transformedCorners[c];
 		replaceWithSmaller(worldMinBound.x, (int32_t)floor(miniSpaceCorner.x));
 		replaceWithSmaller(worldMinBound.x, (int32_t)floor(miniSpaceCorner.x));
 		replaceWithSmaller(worldMinBound.y, (int32_t)floor(miniSpaceCorner.y));
 		replaceWithSmaller(worldMinBound.y, (int32_t)floor(miniSpaceCorner.y));
@@ -887,7 +887,7 @@ static void getScreenBounds(SpriteWorld& world, const IVector3D& worldMinBound,
 	FVector3D firstGlobalPixelSpaceCorner = worldToGlobalPixels.transformPoint(corners[0]);
 	FVector3D firstGlobalPixelSpaceCorner = worldToGlobalPixels.transformPoint(corners[0]);
 	globalPixelMinBound = IVector2D((int32_t)floor(firstGlobalPixelSpaceCorner.x), (int32_t)floor(firstGlobalPixelSpaceCorner.y));
 	globalPixelMinBound = IVector2D((int32_t)floor(firstGlobalPixelSpaceCorner.x), (int32_t)floor(firstGlobalPixelSpaceCorner.y));
 	globalPixelMaxBound = IVector2D((int32_t)ceil(firstGlobalPixelSpaceCorner.x), (int32_t)ceil(firstGlobalPixelSpaceCorner.y));
 	globalPixelMaxBound = IVector2D((int32_t)ceil(firstGlobalPixelSpaceCorner.x), (int32_t)ceil(firstGlobalPixelSpaceCorner.y));
-	for (int c = 0; c < 8; c++) {
+	for (int32_t c = 0; c < 8; c++) {
 		FVector3D globalPixelSpaceCorner = worldToGlobalPixels.transformPoint(corners[c]);
 		FVector3D globalPixelSpaceCorner = worldToGlobalPixels.transformPoint(corners[c]);
 		replaceWithSmaller(globalPixelMinBound.x, (int32_t)floor(globalPixelSpaceCorner.x));
 		replaceWithSmaller(globalPixelMinBound.x, (int32_t)floor(globalPixelSpaceCorner.x));
 		replaceWithSmaller(globalPixelMinBound.y, (int32_t)floor(globalPixelSpaceCorner.y));
 		replaceWithSmaller(globalPixelMinBound.y, (int32_t)floor(globalPixelSpaceCorner.y));
@@ -906,7 +906,7 @@ void spriteWorld_addBackgroundSprite(SpriteWorld& world, const SpriteInstance& s
 	// Add the passive sprite to the octree
 	// Add the passive sprite to the octree
 	world->passiveSprites.insert(sprite, sprite.location, worldMinBound, worldMaxBound);
 	world->passiveSprites.insert(sprite, sprite.location, worldMinBound, worldMaxBound);
 	// Find the affected passive region and make it dirty
 	// Find the affected passive region and make it dirty
-	int frameIndex = getSpriteFrameIndex(sprite, world->ortho.view[world->cameraIndex]);
+	int32_t frameIndex = getSpriteFrameIndex(sprite, world->ortho.view[world->cameraIndex]);
 	const SpriteFrame* frame = &spriteTypes[sprite.typeIndex].frames[frameIndex];
 	const SpriteFrame* frame = &spriteTypes[sprite.typeIndex].frames[frameIndex];
 	IVector2D upperLeft = world->ortho.miniTilePositionToScreenPixel(sprite.location, world->cameraIndex, IVector2D()) - frame->centerPoint;
 	IVector2D upperLeft = world->ortho.miniTilePositionToScreenPixel(sprite.location, world->cameraIndex, IVector2D()) - frame->centerPoint;
 	IRect region = IRect(upperLeft.x, upperLeft.y, image_getWidth(frame->colorImage), image_getHeight(frame->colorImage));
 	IRect region = IRect(upperLeft.x, upperLeft.y, image_getWidth(frame->colorImage), image_getHeight(frame->colorImage));
@@ -1012,7 +1012,7 @@ void spriteWorld_draw(SpriteWorld& world, AlignedImageRgbaU8& colorTarget) {
 #define BOX_LINE(INDEX_A, INDEX_B) draw_line(target, corners[INDEX_A].x, corners[INDEX_A].y, corners[INDEX_B].x, corners[INDEX_B].y, color);
 #define BOX_LINE(INDEX_A, INDEX_B) draw_line(target, corners[INDEX_A].x, corners[INDEX_A].y, corners[INDEX_B].x, corners[INDEX_B].y, color);
 void debugDrawBound(SpriteWorld& world, const IVector2D& worldCenter, AlignedImageRgbaU8& target, const ColorRgbaI32& color, const IVector3D& minBound, const IVector3D& maxBound) {
 void debugDrawBound(SpriteWorld& world, const IVector2D& worldCenter, AlignedImageRgbaU8& target, const ColorRgbaI32& color, const IVector3D& minBound, const IVector3D& maxBound) {
 	IVector2D corners[8];
 	IVector2D corners[8];
-	for (int c = 0; c < 8; c++) {
+	for (int32_t c = 0; c < 8; c++) {
 		// TODO: Convert to real screen pixels using the camera offset.
 		// TODO: Convert to real screen pixels using the camera offset.
 		corners[c] = world->ortho.view[world->cameraIndex].miniTilePositionToScreenPixel(getBoxCorner(minBound, maxBound, c), worldCenter);
 		corners[c] = world->ortho.view[world->cameraIndex].miniTilePositionToScreenPixel(getBoxCorner(minBound, maxBound, c), worldCenter);
 	}
 	}
@@ -1094,12 +1094,12 @@ AlignedImageF32 spriteWorld_getHeightBuffer(SpriteWorld& world) {
 	return world->heightBuffer;
 	return world->heightBuffer;
 }
 }
 
 
-int spriteWorld_getCameraDirectionIndex(const SpriteWorld& world) {
+int32_t spriteWorld_getCameraDirectionIndex(const SpriteWorld& world) {
 	MUST_EXIST(world, spriteWorld_getCameraDirectionIndex);
 	MUST_EXIST(world, spriteWorld_getCameraDirectionIndex);
 	return world->cameraIndex;
 	return world->cameraIndex;
 }
 }
 
 
-void spriteWorld_setCameraDirectionIndex(SpriteWorld& world, int index) {
+void spriteWorld_setCameraDirectionIndex(SpriteWorld& world, int32_t index) {
 	MUST_EXIST(world, spriteWorld_setCameraDirectionIndex);
 	MUST_EXIST(world, spriteWorld_setCameraDirectionIndex);
 	if (index != world->cameraIndex) {
 	if (index != world->cameraIndex) {
 		world->cameraIndex = index;
 		world->cameraIndex = index;
@@ -1127,7 +1127,7 @@ static FVector2D FVector3Dto2D(FVector3D v) {
 
 
 // Get the pixel bound from a projected vertex point in floating pixel coordinates
 // Get the pixel bound from a projected vertex point in floating pixel coordinates
 static IRect boundFromVertex(const FVector3D& screenProjection) {
 static IRect boundFromVertex(const FVector3D& screenProjection) {
-	return IRect((int)(screenProjection.x), (int)(screenProjection.y), 1, 1);
+	return IRect((int32_t)(screenProjection.x), (int32_t)(screenProjection.y), 1, 1);
 }
 }
 
 
 // Returns true iff the box might be seen using a pessimistic test
 // Returns true iff the box might be seen using a pessimistic test
@@ -1135,7 +1135,7 @@ static IRect boundingBoxToRectangle(const FVector3D& minBound, const FVector3D&
 	FVector3D points[8];
 	FVector3D points[8];
 	transformCorners(minBound, maxBound, objectToScreenSpace, points);
 	transformCorners(minBound, maxBound, objectToScreenSpace, points);
 	IRect result = boundFromVertex(points[0]);
 	IRect result = boundFromVertex(points[0]);
-	for (int p = 1; p < 8; p++) {
+	for (int32_t p = 1; p < 8; p++) {
 		result = IRect::merge(result, boundFromVertex(points[p]));
 		result = IRect::merge(result, boundFromVertex(points[p]));
 	}
 	}
 	return result;
 	return result;
@@ -1147,10 +1147,10 @@ static IRect getBackCulledTriangleBound(const FVector3D& a, const FVector3D& b,
 		return IRect();
 		return IRect();
 	} else {
 	} else {
 		// Front facing
 		// Front facing
-		int leftBound = (int)std::min(std::min(a.x, b.x), c.x);
-		int topBound = (int)std::min(std::min(a.y, b.y), c.y);
-		int rightBound = (int)(std::max(std::max(a.x, b.x), c.x)) + 1;
-		int bottomBound = (int)(std::max(std::max(a.y, b.y), c.y)) + 1;
+		int32_t leftBound = (int32_t)std::min(std::min(a.x, b.x), c.x);
+		int32_t topBound = (int32_t)std::min(std::min(a.y, b.y), c.y);
+		int32_t rightBound = (int32_t)(std::max(std::max(a.x, b.x), c.x)) + 1;
+		int32_t bottomBound = (int32_t)(std::max(std::max(a.y, b.y), c.y)) + 1;
 		return IRect(leftBound, topBound, rightBound - leftBound, bottomBound - topBound);
 		return IRect(leftBound, topBound, rightBound - leftBound, bottomBound - topBound);
 	}
 	}
 }
 }
@@ -1159,10 +1159,10 @@ static FVector3D normalFromPoints(const FVector3D& A, const FVector3D& B, const
     return normalize(crossProduct(B - A, C - A));
     return normalize(crossProduct(B - A, C - A));
 }
 }
 
 
-static FVector3D getAverageNormal(const Model& model, int part, int poly) {
-	int vertexCount = model_getPolygonVertexCount(model, part, poly);
+static FVector3D getAverageNormal(const Model& model, int32_t part, int32_t poly) {
+	int32_t vertexCount = model_getPolygonVertexCount(model, part, poly);
 	FVector3D normalSum;
 	FVector3D normalSum;
-	for (int t = 0; t < vertexCount - 2; t++) {
+	for (int32_t t = 0; t < vertexCount - 2; t++) {
 		normalSum = normalSum + normalFromPoints(
 		normalSum = normalSum + normalFromPoints(
 		  model_getVertexPosition(model, part, poly, 0),
 		  model_getVertexPosition(model, part, poly, 0),
 		  model_getVertexPosition(model, part, poly, t + 1),
 		  model_getVertexPosition(model, part, poly, t + 1),
@@ -1176,11 +1176,11 @@ DenseModel DenseModel_create(const Model& original) {
 	return std::make_shared<DenseModelImpl>(original);
 	return std::make_shared<DenseModelImpl>(original);
 }
 }
 
 
-static int getTriangleCount(const Model& original) {
-	int triangleCount = 0;
-	for (int part = 0; part < model_getNumberOfParts(original); part++) {
-		for (int poly = 0; poly < model_getNumberOfPolygons(original, part); poly++) {
-			int vertexCount = model_getPolygonVertexCount(original, part, poly);
+static int32_t getTriangleCount(const Model& original) {
+	int32_t triangleCount = 0;
+	for (int32_t part = 0; part < model_getNumberOfParts(original); part++) {
+		for (int32_t poly = 0; poly < model_getNumberOfPolygons(original, part); poly++) {
+			int32_t vertexCount = model_getPolygonVertexCount(original, part, poly);
 			triangleCount += vertexCount - 2;
 			triangleCount += vertexCount - 2;
 		}
 		}
 	}
 	}
@@ -1192,33 +1192,33 @@ DenseModelImpl::DenseModelImpl(const Model& original)
 	// Get the bounding box
 	// Get the bounding box
 	model_getBoundingBox(original, this->minBound, this->maxBound);
 	model_getBoundingBox(original, this->minBound, this->maxBound);
 	// Generate normals
 	// Generate normals
-	int pointCount = model_getNumberOfPoints(original);
+	int32_t pointCount = model_getNumberOfPoints(original);
 	Array<FVector3D> normalPoints(pointCount, FVector3D());
 	Array<FVector3D> normalPoints(pointCount, FVector3D());
 	// Calculate smooth normals in object-space, by adding each polygon's normal to each child vertex
 	// Calculate smooth normals in object-space, by adding each polygon's normal to each child vertex
-	for (int part = 0; part < model_getNumberOfParts(original); part++) {
-		for (int poly = 0; poly < model_getNumberOfPolygons(original, part); poly++) {
+	for (int32_t part = 0; part < model_getNumberOfParts(original); part++) {
+		for (int32_t poly = 0; poly < model_getNumberOfPolygons(original, part); poly++) {
 			FVector3D polygonNormal = getAverageNormal(original, part, poly);
 			FVector3D polygonNormal = getAverageNormal(original, part, poly);
-			for (int vert = 0; vert < model_getPolygonVertexCount(original, part, poly); vert++) {
-				int point = model_getVertexPointIndex(original, part, poly, vert);
+			for (int32_t vert = 0; vert < model_getPolygonVertexCount(original, part, poly); vert++) {
+				int32_t point = model_getVertexPointIndex(original, part, poly, vert);
 				normalPoints[point] = normalPoints[point] + polygonNormal;
 				normalPoints[point] = normalPoints[point] + polygonNormal;
 			}
 			}
 		}
 		}
 	}
 	}
 	// Normalize the result per vertex, to avoid having unbalanced weights when normalizing per pixel
 	// Normalize the result per vertex, to avoid having unbalanced weights when normalizing per pixel
-	for (int point = 0; point < pointCount; point++) {
+	for (int32_t point = 0; point < pointCount; point++) {
 		normalPoints[point] = normalize(normalPoints[point]);
 		normalPoints[point] = normalize(normalPoints[point]);
 	}
 	}
 	// Generate a simpler triangle structure
 	// Generate a simpler triangle structure
-	int triangleIndex = 0;
-	for (int part = 0; part < model_getNumberOfParts(original); part++) {
-		for (int poly = 0; poly < model_getNumberOfPolygons(original, part); poly++) {
-			int vertexCount = model_getPolygonVertexCount(original, part, poly);
-			int vertA = 0;
-			int indexA = model_getVertexPointIndex(original, part, poly, vertA);
-			for (int vertB = 1; vertB < vertexCount - 1; vertB++) {
-				int vertC = vertB + 1;
-				int indexB = model_getVertexPointIndex(original, part, poly, vertB);
-				int indexC = model_getVertexPointIndex(original, part, poly, vertC);
+	int32_t triangleIndex = 0;
+	for (int32_t part = 0; part < model_getNumberOfParts(original); part++) {
+		for (int32_t poly = 0; poly < model_getNumberOfPolygons(original, part); poly++) {
+			int32_t vertexCount = model_getPolygonVertexCount(original, part, poly);
+			int32_t vertA = 0;
+			int32_t indexA = model_getVertexPointIndex(original, part, poly, vertA);
+			for (int32_t vertB = 1; vertB < vertexCount - 1; vertB++) {
+				int32_t vertC = vertB + 1;
+				int32_t indexB = model_getVertexPointIndex(original, part, poly, vertB);
+				int32_t indexC = model_getVertexPointIndex(original, part, poly, vertC);
 				triangles[triangleIndex] =
 				triangles[triangleIndex] =
 				  DenseTriangle(
 				  DenseTriangle(
 					FVector4Dto3D(model_getVertexColor(original, part, poly, vertA)) * 255.0f,
 					FVector4Dto3D(model_getVertexColor(original, part, poly, vertA)) * 255.0f,
@@ -1257,15 +1257,15 @@ static IRect renderDenseModel(const DenseModel& model, OrthoView view, ImageF32
 	// Combine normal transforms
 	// Combine normal transforms
 	FMatrix3x3 modelToNormalSpace = modelToWorldSpace.transform * transpose(view.normalToWorldSpace);
 	FMatrix3x3 modelToNormalSpace = modelToWorldSpace.transform * transpose(view.normalToWorldSpace);
 	// Get image properties
 	// Get image properties
-	int diffuseStride = image_getStride(diffuseTarget);
-	int normalStride = image_getStride(normalTarget);
-	int heightStride = image_getStride(depthBuffer);
+	int32_t diffuseStride = image_getStride(diffuseTarget);
+	int32_t normalStride = image_getStride(normalTarget);
+	int32_t heightStride = image_getStride(depthBuffer);
 	// Call getters in advance to avoid call overhead in the loops
 	// Call getters in advance to avoid call overhead in the loops
 	SafePointer<uint32_t> diffuseData = image_getSafePointer(diffuseTarget);
 	SafePointer<uint32_t> diffuseData = image_getSafePointer(diffuseTarget);
 	SafePointer<uint32_t> normalData = image_getSafePointer(normalTarget);
 	SafePointer<uint32_t> normalData = image_getSafePointer(normalTarget);
 	SafePointer<float> heightData = image_getSafePointer(depthBuffer);
 	SafePointer<float> heightData = image_getSafePointer(depthBuffer);
 	// Render triangles
 	// Render triangles
-	for (int tri = 0; tri < model->triangles.length(); tri++) {
+	for (int32_t tri = 0; tri < model->triangles.length(); tri++) {
 		DenseTriangle triangle =  model->triangles[tri];
 		DenseTriangle triangle =  model->triangles[tri];
 		// Transform positions
 		// Transform positions
 		FVector3D projectedA = objectToScreenSpace.transformPoint(triangle.posA);
 		FVector3D projectedA = objectToScreenSpace.transformPoint(triangle.posA);
@@ -1290,11 +1290,11 @@ static IRect renderDenseModel(const DenseModel& model, OrthoView view, ImageF32
 			FVector3D normalB = modelToNormalSpace.transform(triangle.normalB);
 			FVector3D normalB = modelToNormalSpace.transform(triangle.normalB);
 			FVector3D normalC = modelToNormalSpace.transform(triangle.normalC);
 			FVector3D normalC = modelToNormalSpace.transform(triangle.normalC);
 			// Iterate over the triangle's bounding box
 			// Iterate over the triangle's bounding box
-			for (int y = triangleBound.top(); y < triangleBound.bottom(); y++) {
+			for (int32_t y = triangleBound.top(); y < triangleBound.bottom(); y++) {
 				SafePointer<uint32_t> diffusePixel = diffuseRow + triangleBound.left();
 				SafePointer<uint32_t> diffusePixel = diffuseRow + triangleBound.left();
 				SafePointer<uint32_t> normalPixel = normalRow + triangleBound.left();
 				SafePointer<uint32_t> normalPixel = normalRow + triangleBound.left();
 				SafePointer<float> heightPixel = heightRow + triangleBound.left();
 				SafePointer<float> heightPixel = heightRow + triangleBound.left();
-				for (int x = triangleBound.left(); x < triangleBound.right(); x++) {
+				for (int32_t x = triangleBound.left(); x < triangleBound.right(); x++) {
 					FVector2D weightBC = offsetToWeight.transform(FVector2D(x + 0.5f, y + 0.5f) - cornerA);
 					FVector2D weightBC = offsetToWeight.transform(FVector2D(x + 0.5f, y + 0.5f) - cornerA);
 					FVector3D weight = FVector3D(1.0f - (weightBC.x + weightBC.y), weightBC.x, weightBC.y);
 					FVector3D weight = FVector3D(1.0f - (weightBC.x + weightBC.y), weightBC.x, weightBC.y);
 					// Check if the pixel is inside the triangle
 					// Check if the pixel is inside the triangle
@@ -1327,7 +1327,7 @@ static IRect renderDenseModel(const DenseModel& model, OrthoView view, ImageF32
 	return pessimisticBound;
 	return pessimisticBound;
 }
 }
 
 
-void sprite_generateFromModel(ImageRgbaU8& targetAtlas, String& targetConfigText, const Model& visibleModel, const Model& shadowModel, const OrthoSystem& ortho, const String& targetPath, int cameraAngles) {
+void sprite_generateFromModel(ImageRgbaU8& targetAtlas, String& targetConfigText, const Model& visibleModel, const Model& shadowModel, const OrthoSystem& ortho, const String& targetPath, int32_t cameraAngles) {
 	// Validate input
 	// Validate input
 	if (cameraAngles < 1) {
 	if (cameraAngles < 1) {
 		printText("  Need at least one camera angle to generate a sprite!\n");
 		printText("  Need at least one camera angle to generate a sprite!\n");
@@ -1370,14 +1370,14 @@ void sprite_generateFromModel(ImageRgbaU8& targetAtlas, String& targetConfigText
 		DenseModel denseModel = DenseModel_create(visibleModel);
 		DenseModel denseModel = DenseModel_create(visibleModel);
 		// Render the model to multiple render targets at once
 		// Render the model to multiple render targets at once
 		float heightScale = 255.0f / (maxBound.y - minBound.y);
 		float heightScale = 255.0f / (maxBound.y - minBound.y);
-		for (int a = 0; a < cameraAngles; a++) {
+		for (int32_t a = 0; a < cameraAngles; a++) {
 			image_fill(depthBuffer, -1000000000.0f);
 			image_fill(depthBuffer, -1000000000.0f);
 			image_fill(colorImage[a], ColorRgbaI32(0, 0, 0, 0));
 			image_fill(colorImage[a], ColorRgbaI32(0, 0, 0, 0));
 			FVector2D origin = FVector2D((float)width * 0.5f, (float)height * 0.5f);
 			FVector2D origin = FVector2D((float)width * 0.5f, (float)height * 0.5f);
 			renderDenseModel<true>(denseModel, ortho.view[a], depthBuffer, colorImage[a], normalImage[a], origin, Transform3D());
 			renderDenseModel<true>(denseModel, ortho.view[a], depthBuffer, colorImage[a], normalImage[a], origin, Transform3D());
 			// Convert height into an 8 bit channel for saving
 			// Convert height into an 8 bit channel for saving
-			for (int y = 0; y < height; y++) {
-				for (int x = 0; x < width; x++) {
+			for (int32_t y = 0; y < height; y++) {
+				for (int32_t x = 0; x < width; x++) {
 					int32_t opacityPixel = image_readPixel_clamp(colorImage[a], x, y).alpha;
 					int32_t opacityPixel = image_readPixel_clamp(colorImage[a], x, y).alpha;
 					int32_t heightPixel = (image_readPixel_clamp(depthBuffer, x, y) - minBound.y) * heightScale;
 					int32_t heightPixel = (image_readPixel_clamp(depthBuffer, x, y) - minBound.y) * heightScale;
 					image_writePixel(heightImage[a], x, y, ColorRgbaI32(heightPixel, 0, 0, opacityPixel));
 					image_writePixel(heightImage[a], x, y, ColorRgbaI32(heightPixel, 0, 0, opacityPixel));
@@ -1390,9 +1390,9 @@ void sprite_generateFromModel(ImageRgbaU8& targetAtlas, String& targetConfigText
 		int32_t minY = height;
 		int32_t minY = height;
 		int32_t maxX = 0;
 		int32_t maxX = 0;
 		int32_t maxY = 0;
 		int32_t maxY = 0;
-		for (int a = 0; a < cameraAngles; a++) {
-			for (int y = 0; y < height; y++) {
-				for (int x = 0; x < width; x++) {
+		for (int32_t a = 0; a < cameraAngles; a++) {
+			for (int32_t y = 0; y < height; y++) {
+				for (int32_t x = 0; x < width; x++) {
 					if (image_readPixel_border(colorImage[a], x, y).alpha) {
 					if (image_readPixel_border(colorImage[a], x, y).alpha) {
 						if (x < minX) minX = x;
 						if (x < minX) minX = x;
 						if (x > maxX) maxX = x;
 						if (x > maxX) maxX = x;
@@ -1413,20 +1413,20 @@ void sprite_generateFromModel(ImageRgbaU8& targetAtlas, String& targetConfigText
 			printText("  Cropping failed to find any drawn pixels!\n");
 			printText("  Cropping failed to find any drawn pixels!\n");
 			return;
 			return;
 		}
 		}
-		for (int a = 0; a < cameraAngles; a++) {
+		for (int32_t a = 0; a < cameraAngles; a++) {
 			colorImage[a] = image_getSubImage(colorImage[a], cropRegion);
 			colorImage[a] = image_getSubImage(colorImage[a], cropRegion);
 			heightImage[a] = image_getSubImage(heightImage[a], cropRegion);
 			heightImage[a] = image_getSubImage(heightImage[a], cropRegion);
 			normalImage[a] = image_getSubImage(normalImage[a], cropRegion);
 			normalImage[a] = image_getSubImage(normalImage[a], cropRegion);
 		}
 		}
-		int croppedWidth = cropRegion.width();
-		int croppedHeight = cropRegion.height();
-		int centerX = width / 2 - cropRegion.left();
-		int centerY = height / 2 - cropRegion.top();
+		int32_t croppedWidth = cropRegion.width();
+		int32_t croppedHeight = cropRegion.height();
+		int32_t centerX = width / 2 - cropRegion.left();
+		int32_t centerY = height / 2 - cropRegion.top();
 		printText("  Cropped images of ", croppedWidth, "x", croppedHeight, " pixels with centers at (", centerX, ", ", centerY, ")\n");
 		printText("  Cropped images of ", croppedWidth, "x", croppedHeight, " pixels with centers at (", centerX, ", ", centerY, ")\n");
 
 
 		// Pack everything into an image atlas
 		// Pack everything into an image atlas
 		targetAtlas = image_create_RgbaU8(croppedWidth * 3, croppedHeight * cameraAngles);
 		targetAtlas = image_create_RgbaU8(croppedWidth * 3, croppedHeight * cameraAngles);
-		for (int a = 0; a < cameraAngles; a++) {
+		for (int32_t a = 0; a < cameraAngles; a++) {
 			draw_copy(targetAtlas, colorImage[a], 0, a * croppedHeight);
 			draw_copy(targetAtlas, colorImage[a], 0, a * croppedHeight);
 			draw_copy(targetAtlas, heightImage[a], croppedWidth, a * croppedHeight);
 			draw_copy(targetAtlas, heightImage[a], croppedWidth, a * croppedHeight);
 			draw_copy(targetAtlas, normalImage[a], croppedWidth * 2, a * croppedHeight);
 			draw_copy(targetAtlas, normalImage[a], croppedWidth * 2, a * croppedHeight);
@@ -1442,14 +1442,14 @@ void sprite_generateFromModel(ImageRgbaU8& targetAtlas, String& targetConfigText
 
 
 // Allowing the last decimals to deviate a bit because floating-point operations are rounded differently between computers
 // Allowing the last decimals to deviate a bit because floating-point operations are rounded differently between computers
 static bool approximateTextMatch(const ReadableString &a, const ReadableString &b, double tolerance = 0.00002) {
 static bool approximateTextMatch(const ReadableString &a, const ReadableString &b, double tolerance = 0.00002) {
-	int readerA = 0, readerB = 0;
+	int32_t readerA = 0, readerB = 0;
 	while (readerA < string_length(a) && readerB < string_length(b)) {
 	while (readerA < string_length(a) && readerB < string_length(b)) {
 		DsrChar charA = a[readerA];
 		DsrChar charA = a[readerA];
 		DsrChar charB = b[readerB];
 		DsrChar charB = b[readerB];
 		if (character_isValueCharacter(charA) && character_isValueCharacter(charB)) {
 		if (character_isValueCharacter(charA) && character_isValueCharacter(charB)) {
 			// Scan forward on both sides while consuming content and comparing the actual value
 			// Scan forward on both sides while consuming content and comparing the actual value
-			int startA = readerA;
-			int startB = readerB;
+			int32_t startA = readerA;
+			int32_t startB = readerB;
 			// Only move forward on valid characters
 			// Only move forward on valid characters
 			if (a[readerA] == U'-') { readerA++; }
 			if (a[readerA] == U'-') { readerA++; }
 			if (b[readerB] == U'-') { readerB++; }
 			if (b[readerB] == U'-') { readerB++; }
@@ -1483,7 +1483,7 @@ static bool approximateTextMatch(const ReadableString &a, const ReadableString &
 	}
 	}
 }
 }
 
 
-void sprite_generateFromModel(const Model& visibleModel, const Model& shadowModel, const OrthoSystem& ortho, const String& targetPath, int cameraAngles, bool debug) {
+void sprite_generateFromModel(const Model& visibleModel, const Model& shadowModel, const OrthoSystem& ortho, const String& targetPath, int32_t cameraAngles, bool debug) {
 	// Generate an image and a configuration file from the visible model
 	// Generate an image and a configuration file from the visible model
 	ImageRgbaU8 atlasImage; String configText;
 	ImageRgbaU8 atlasImage; String configText;
 	sprite_generateFromModel(atlasImage, configText, visibleModel, shadowModel, ortho, targetPath, cameraAngles);
 	sprite_generateFromModel(atlasImage, configText, visibleModel, shadowModel, ortho, targetPath, cameraAngles);
@@ -1494,7 +1494,7 @@ void sprite_generateFromModel(const Model& visibleModel, const Model& shadowMode
 		// Try loading any existing image
 		// Try loading any existing image
 		ImageRgbaU8 existingAtlasImage = image_load_RgbaU8(atlasPath, false);
 		ImageRgbaU8 existingAtlasImage = image_load_RgbaU8(atlasPath, false);
 		if (image_exists(existingAtlasImage)) {
 		if (image_exists(existingAtlasImage)) {
-			int difference = image_maxDifference(atlasImage, existingAtlasImage);
+			int32_t difference = image_maxDifference(atlasImage, existingAtlasImage);
 			if (difference <= 2) {
 			if (difference <= 2) {
 				printText("  No significant changes against ", targetPath, ".\n");
 				printText("  No significant changes against ", targetPath, ".\n");
 			} else {
 			} else {

+ 14 - 14
Source/SDK/SpriteEngine/spriteAPI.h

@@ -31,7 +31,7 @@ public:
 	bool shadowCasting;
 	bool shadowCasting;
 	uint64_t userData; // Can be used to store additional information needed for specific games.
 	uint64_t userData; // Can be used to store additional information needed for specific games.
 public:
 public:
-	SpriteInstance(int typeIndex, Direction direction, const IVector3D& location, bool shadowCasting, uint64_t userData = 0)
+	SpriteInstance(int32_t typeIndex, Direction direction, const IVector3D& location, bool shadowCasting, uint64_t userData = 0)
 	: typeIndex(typeIndex), direction(direction), location(location), shadowCasting(shadowCasting), userData(userData) {}
 	: typeIndex(typeIndex), direction(direction), location(location), shadowCasting(shadowCasting), userData(userData) {}
 };
 };
 
 
@@ -43,11 +43,11 @@ DenseModel DenseModel_create(const Model& original);
 //   To be rendered during game-play to allow free rotation.
 //   To be rendered during game-play to allow free rotation.
 struct ModelInstance {
 struct ModelInstance {
 public:
 public:
-	int typeIndex;
+	int32_t typeIndex;
 	Transform3D location; // 3D tile coordinates with translation and 3-axis rotation allowed.
 	Transform3D location; // 3D tile coordinates with translation and 3-axis rotation allowed.
 	uint64_t userData; // Can be used to store additional information needed for specific games.
 	uint64_t userData; // Can be used to store additional information needed for specific games.
 public:
 public:
-	ModelInstance(int typeIndex, const Transform3D& location, uint64_t userData = 0)
+	ModelInstance(int32_t typeIndex, const Transform3D& location, uint64_t userData = 0)
 	: typeIndex(typeIndex), location(location), userData(userData) {}
 	: typeIndex(typeIndex), location(location), userData(userData) {}
 };
 };
 
 
@@ -55,16 +55,16 @@ class SpriteWorldImpl;
 using SpriteWorld = std::shared_ptr<SpriteWorldImpl>;
 using SpriteWorld = std::shared_ptr<SpriteWorldImpl>;
 
 
 // Sprite types
 // Sprite types
-int spriteWorld_loadSpriteTypeFromFile(const String& folderPath, const String& spriteName);
-int spriteWorld_getSpriteTypeCount();
-String spriteWorld_getSpriteTypeName(int index);
+int32_t spriteWorld_loadSpriteTypeFromFile(const String& folderPath, const String& spriteName);
+int32_t spriteWorld_getSpriteTypeCount();
+String spriteWorld_getSpriteTypeName(int32_t index);
 
 
 // Model types
 // Model types
-int spriteWorld_loadModelTypeFromFile(const String& folderPath, const String& visibleModelName, const String& shadowModelName);
-int spriteWorld_getModelTypeCount();
-String spriteWorld_getModelTypeName(int index);
+int32_t spriteWorld_loadModelTypeFromFile(const String& folderPath, const String& visibleModelName, const String& shadowModelName);
+int32_t spriteWorld_getModelTypeCount();
+String spriteWorld_getModelTypeName(int32_t index);
 
 
-SpriteWorld spriteWorld_create(OrthoSystem ortho, int shadowResolution);
+SpriteWorld spriteWorld_create(OrthoSystem ortho, int32_t shadowResolution);
 void spriteWorld_addBackgroundSprite(SpriteWorld& world, const SpriteInstance& sprite);
 void spriteWorld_addBackgroundSprite(SpriteWorld& world, const SpriteInstance& sprite);
 void spriteWorld_addBackgroundModel(SpriteWorld& world, const ModelInstance& instance);
 void spriteWorld_addBackgroundModel(SpriteWorld& world, const ModelInstance& instance);
 void spriteWorld_addTemporarySprite(SpriteWorld& world, const SpriteInstance& sprite);
 void spriteWorld_addTemporarySprite(SpriteWorld& world, const SpriteInstance& sprite);
@@ -125,8 +125,8 @@ void spriteWorld_setCameraLocation(SpriteWorld& world, const IVector3D miniTileL
 // Access the index of the camera's fixed direction.
 // Access the index of the camera's fixed direction.
 //   This is not an index selecting the camera itself, only selecting the viewing angle.
 //   This is not an index selecting the camera itself, only selecting the viewing angle.
 // TODO: Implement bound checks or a system that's easier to understand.
 // TODO: Implement bound checks or a system that's easier to understand.
-int spriteWorld_getCameraDirectionIndex(const SpriteWorld& world);
-void spriteWorld_setCameraDirectionIndex(SpriteWorld& world, int index);
+int32_t spriteWorld_getCameraDirectionIndex(const SpriteWorld& world);
+void spriteWorld_setCameraDirectionIndex(SpriteWorld& world, int32_t index);
 
 
 // Get the current direction's orthogonal axis system.
 // Get the current direction's orthogonal axis system.
 //   This can be used to convert between world and screen coordinates using the camera location.
 //   This can be used to convert between world and screen coordinates using the camera location.
@@ -140,9 +140,9 @@ OrthoSystem& spriteWorld_getOrthoSystem(SpriteWorld& world);
 //   Enabling debug will save another file using a *Debug.png prefix with additional information.
 //   Enabling debug will save another file using a *Debug.png prefix with additional information.
 //     Use it to find flaws in generated shadow shapes that are hard to see in raw data.
 //     Use it to find flaws in generated shadow shapes that are hard to see in raw data.
 // TODO: Hide OrthoSystem or expose it safely.
 // TODO: Hide OrthoSystem or expose it safely.
-void sprite_generateFromModel(const Model& visibleModel, const Model& shadowModel, const OrthoSystem& ortho, const String& targetPath, int cameraAngles, bool debug = false);
+void sprite_generateFromModel(const Model& visibleModel, const Model& shadowModel, const OrthoSystem& ortho, const String& targetPath, int32_t cameraAngles, bool debug = false);
 // A simpler version writing the result to an image and a string instead of saving to files.
 // A simpler version writing the result to an image and a string instead of saving to files.
-void sprite_generateFromModel(ImageRgbaU8& targetAtlas, String& targetConfigText, const Model& visibleModel, const Model& shadowModel, const OrthoSystem& ortho, const String& targetPath, int cameraAngles);
+void sprite_generateFromModel(ImageRgbaU8& targetAtlas, String& targetConfigText, const Model& visibleModel, const Model& shadowModel, const OrthoSystem& ortho, const String& targetPath, int32_t cameraAngles);
 
 
 }
 }
 
 

+ 4 - 4
Source/SDK/camera/main.cpp

@@ -21,7 +21,7 @@ static bool showCursor = false;
 // The window handle
 // The window handle
 static Window window;
 static Window window;
 
 
-static int createRoomPart(Model model, const FVector3D &min, const FVector3D &max) {
+static int32_t createRoomPart(Model model, const FVector3D &min, const FVector3D &max) {
 	// Add positions
 	// Add positions
 	model_addPoint(model, FVector3D(min.x, min.y, min.z)); // 0: Left-down-near
 	model_addPoint(model, FVector3D(min.x, min.y, min.z)); // 0: Left-down-near
 	model_addPoint(model, FVector3D(min.x, min.y, max.z)); // 1: Left-down-far
 	model_addPoint(model, FVector3D(min.x, min.y, max.z)); // 1: Left-down-far
@@ -32,7 +32,7 @@ static int createRoomPart(Model model, const FVector3D &min, const FVector3D &ma
 	model_addPoint(model, FVector3D(max.x, max.y, min.z)); // 6: Right-up-near
 	model_addPoint(model, FVector3D(max.x, max.y, min.z)); // 6: Right-up-near
 	model_addPoint(model, FVector3D(max.x, max.y, max.z)); // 7: Right-up-far
 	model_addPoint(model, FVector3D(max.x, max.y, max.z)); // 7: Right-up-far
 	// Create a part for the polygons
 	// Create a part for the polygons
-	int part = model_addEmptyPart(model, U"cube");
+	int32_t part = model_addEmptyPart(model, U"cube");
 	// Polygons using default texture coordinates on the 4 corners of the texture
 	// Polygons using default texture coordinates on the 4 corners of the texture
 	model_addQuad(model, part, 1, 0, 2, 3); // Left quad
 	model_addQuad(model, part, 1, 0, 2, 3); // Left quad
 	model_addQuad(model, part, 4, 5, 7, 6); // Right quad
 	model_addQuad(model, part, 4, 5, 7, 6); // Right quad
@@ -190,8 +190,8 @@ void dsrMain(List<String> args) {
 		ImageF32 depthBuffer = window_getDepthBuffer(window);
 		ImageF32 depthBuffer = window_getDepthBuffer(window);
 
 
 		// Get target size
 		// Get target size
-		int targetWidth = image_getWidth(colorBuffer);
-		int targetHeight = image_getHeight(colorBuffer);
+		int32_t targetWidth = image_getWidth(colorBuffer);
+		int32_t targetHeight = image_getHeight(colorBuffer);
 
 
 		// Reset the mouse to the center of the canvas when getting too far out.
 		// Reset the mouse to the center of the canvas when getting too far out.
 		cursorOrigin = IVector2D(targetWidth / 2, targetHeight / 2);
 		cursorOrigin = IVector2D(targetWidth / 2, targetHeight / 2);

+ 4 - 4
Source/SDK/cube/main.cpp

@@ -20,7 +20,7 @@ bool debugOccluders = false;
 // The window handle
 // The window handle
 Window window;
 Window window;
 
 
-int createCubePart(Model model, const FVector3D &min, const FVector3D &max) {
+int32_t createCubePart(Model model, const FVector3D &min, const FVector3D &max) {
 	// Add positions
 	// Add positions
 	model_addPoint(model, FVector3D(min.x, min.y, min.z)); // 0: Left-down-near
 	model_addPoint(model, FVector3D(min.x, min.y, min.z)); // 0: Left-down-near
 	model_addPoint(model, FVector3D(min.x, min.y, max.z)); // 1: Left-down-far
 	model_addPoint(model, FVector3D(min.x, min.y, max.z)); // 1: Left-down-far
@@ -31,7 +31,7 @@ int createCubePart(Model model, const FVector3D &min, const FVector3D &max) {
 	model_addPoint(model, FVector3D(max.x, max.y, min.z)); // 6: Right-up-near
 	model_addPoint(model, FVector3D(max.x, max.y, min.z)); // 6: Right-up-near
 	model_addPoint(model, FVector3D(max.x, max.y, max.z)); // 7: Right-up-far
 	model_addPoint(model, FVector3D(max.x, max.y, max.z)); // 7: Right-up-far
 	// Create a part for the polygons
 	// Create a part for the polygons
-	int part = model_addEmptyPart(model, U"cube");
+	int32_t part = model_addEmptyPart(model, U"cube");
 	// Polygons using default texture coordinates on the 4 corners of the texture
 	// Polygons using default texture coordinates on the 4 corners of the texture
 	model_addQuad(model, part, 3, 2, 0, 1); // Left quad
 	model_addQuad(model, part, 3, 2, 0, 1); // Left quad
 	model_addQuad(model, part, 6, 7, 5, 4); // Right quad
 	model_addQuad(model, part, 6, 7, 5, 4); // Right quad
@@ -121,8 +121,8 @@ void dsrMain(List<String> args) {
 		ImageF32 depthBuffer = window_getDepthBuffer(window);
 		ImageF32 depthBuffer = window_getDepthBuffer(window);
 
 
 		// Get target size
 		// Get target size
-		int targetWidth = image_getWidth(colorBuffer);
-		int targetHeight = image_getHeight(colorBuffer);
+		int32_t targetWidth = image_getWidth(colorBuffer);
+		int32_t targetHeight = image_getHeight(colorBuffer);
 
 
 		// Paint the background color
 		// Paint the background color
 		startTime = time_getSeconds();
 		startTime = time_getSeconds();

+ 2 - 2
Source/SDK/fileFinder/main.cpp

@@ -21,14 +21,14 @@ void exploreFolder(const ReadableString& folderPath, const ReadableString& inden
 DSR_MAIN_CALLER(dsrMain)
 DSR_MAIN_CALLER(dsrMain)
 void dsrMain(List<String> args) {
 void dsrMain(List<String> args) {
 	printText("Input arguments:\n");
 	printText("Input arguments:\n");
-	for (int a = 0; a < args.length(); a++) {
+	for (int32_t a = 0; a < args.length(); a++) {
 		printText("  args[", a, "] = ", args[a], "\n");
 		printText("  args[", a, "] = ", args[a], "\n");
 	}
 	}
 	String absolutePath = file_getAbsolutePath(args[0]);
 	String absolutePath = file_getAbsolutePath(args[0]);
 	printText("Absolute path = ", absolutePath, "\n");
 	printText("Absolute path = ", absolutePath, "\n");
 	if (args.length() > 1) {
 	if (args.length() > 1) {
 		// Explore each listed folder from input arguments.
 		// Explore each listed folder from input arguments.
-		for (int a = 1; a < args.length(); a++) {
+		for (int32_t a = 1; a < args.length(); a++) {
 			printText("Exploring ", args[a], "\n");
 			printText("Exploring ", args[a], "\n");
 			exploreFolder(args[a], U"  ");
 			exploreFolder(args[a], U"  ");
 		}
 		}

+ 9 - 9
Source/SDK/guiExample/main.cpp

@@ -3,24 +3,24 @@
 
 
 using namespace dsr;
 using namespace dsr;
 
 
-bool running = true;
+static bool running = true;
 
 
 // GUI handles
 // GUI handles
-Window window;
-Component buttonClear;
-Component buttonAdd;
-Component myListBox;
-Component textElement;
+static Window window;
+static Component buttonClear;
+static Component buttonAdd;
+static Component myListBox;
+static Component textElement;
 
 
 // Custom message handling
 // Custom message handling
-List<String> messages;
+static List<String> messages;
 
 
-void showMessages() {
+static void showMessages() {
 	if (messages.length() > 0) {
 	if (messages.length() > 0) {
 		// Summarizing all messages from the last action, which can also be used to display them in the same pop-up message.
 		// Summarizing all messages from the last action, which can also be used to display them in the same pop-up message.
 		String content;
 		String content;
 		string_append(content, U"Messages:\n");
 		string_append(content, U"Messages:\n");
-		for (int m = 0; m < messages.length(); m++) {
+		for (int32_t m = 0; m < messages.length(); m++) {
 			string_append(content, U"  * ", messages[m]);
 			string_append(content, U"  * ", messages[m]);
 		}
 		}
 		string_append(content, U"\n");
 		string_append(content, U"\n");

+ 2 - 2
Source/SDK/integrationTest/Test.cpp

@@ -37,8 +37,8 @@ void TestContext::finishTest(Grade result) {
 }
 }
 
 
 void TestContext::drawAides(AlignedImageRgbaU8 &canvas) {
 void TestContext::drawAides(AlignedImageRgbaU8 &canvas) {
-	int width = image_getWidth(canvas);
-	int height = image_getHeight(canvas);
+	int32_t width = image_getWidth(canvas);
+	int32_t height = image_getHeight(canvas);
 	draw_rectangle(canvas, IRect(0, this->lastPosition.y - 1, width, 3), ColorRgbaI32(180, 180, 180, 255));
 	draw_rectangle(canvas, IRect(0, this->lastPosition.y - 1, width, 3), ColorRgbaI32(180, 180, 180, 255));
 	draw_rectangle(canvas, IRect(this->lastPosition.x - 1, 0, 3, height), ColorRgbaI32(180, 180, 180, 255));
 	draw_rectangle(canvas, IRect(this->lastPosition.x - 1, 0, 3, height), ColorRgbaI32(180, 180, 180, 255));
 }
 }

+ 2 - 2
Source/SDK/integrationTest/Test.h

@@ -31,8 +31,8 @@ struct TestContext {
 	dsr::List<Test> tests;
 	dsr::List<Test> tests;
 
 
 	// Each test consists of one or more tasks to pass.
 	// Each test consists of one or more tasks to pass.
-	int testIndex = 0; // Each test index refers to a Test in tests to be completed.
-	int taskIndex = 0; // To avoid cluttering the summary with lots of small tests, tests are divided into smaller tasks.
+	int32_t testIndex = 0; // Each test index refers to a Test in tests to be completed.
+	int32_t taskIndex = 0; // To avoid cluttering the summary with lots of small tests, tests are divided into smaller tasks.
 
 
 	// Call when completing a task but not a whole test.
 	// Call when completing a task but not a whole test.
 	void passTask();
 	void passTask();

+ 1 - 1
Source/SDK/integrationTest/main.cpp

@@ -44,7 +44,7 @@ void dsrMain(List<String> args) {
 		[](AlignedImageRgbaU8 &canvas, TestContext &context) {
 		[](AlignedImageRgbaU8 &canvas, TestContext &context) {
 			image_fill(canvas, ColorRgbaI32(255, 255, 255, 255));
 			image_fill(canvas, ColorRgbaI32(255, 255, 255, 255));
 			font_printLine(canvas, font_getDefault(), U"Test summary:", IVector2D(40, 40), ColorRgbaI32(0, 0, 0, 255));
 			font_printLine(canvas, font_getDefault(), U"Test summary:", IVector2D(40, 40), ColorRgbaI32(0, 0, 0, 255));
-			for (int t = 0; t < context.tests.length() - 1; t++) {
+			for (int32_t t = 0; t < context.tests.length() - 1; t++) {
 				font_printLine(canvas, font_getDefault(), string_combine(context.tests[t].result, U" - ", context.tests[t].name), IVector2D(60, t * 20 + 60), ColorRgbaI32(0, 0, 0, 255));
 				font_printLine(canvas, font_getDefault(), string_combine(context.tests[t].result, U" - ", context.tests[t].name), IVector2D(60, t * 20 + 60), ColorRgbaI32(0, 0, 0, 255));
 			}
 			}
 			// TODO: Allow scrolling through the results if it gets too much to fit inside the window.
 			// TODO: Allow scrolling through the results if it gets too much to fit inside the window.

+ 1 - 1
Source/SDK/integrationTest/tests/inputTest.cpp

@@ -8,7 +8,7 @@ using namespace dsr;
 #define TASK_IS(INDEX) context.taskIndex == INDEX
 #define TASK_IS(INDEX) context.taskIndex == INDEX
 #define EVENT_TYPE_IS(TYPE) event.mouseEventType == MouseEventType::TYPE
 #define EVENT_TYPE_IS(TYPE) event.mouseEventType == MouseEventType::TYPE
 
 
-void inputTests_populate(List<Test> &target, int buttonCount, bool relative, bool verticalScroll) {
+void inputTests_populate(List<Test> &target, int32_t buttonCount, bool relative, bool verticalScroll) {
 	if (buttonCount >= 3) {
 	if (buttonCount >= 3) {
 		target.pushConstruct(
 		target.pushConstruct(
 			U"Mouse button test"
 			U"Mouse button test"

+ 1 - 1
Source/SDK/integrationTest/tests/inputTest.h

@@ -19,6 +19,6 @@
 // verticalScroll = true means that there exists a vertical scroll wheel or the two finger gesture to allow scrolling vertically. 
 // verticalScroll = true means that there exists a vertical scroll wheel or the two finger gesture to allow scrolling vertically. 
 // verticalScroll = false is used to skip all tests that require vertical scrolling.
 // verticalScroll = false is used to skip all tests that require vertical scrolling.
 // Horizontal scrolling is currently not supported, because it mostly requires getting a laptop and the tests should be possible to complete with a three button mouse that can easily be moved around between computers.
 // Horizontal scrolling is currently not supported, because it mostly requires getting a laptop and the tests should be possible to complete with a three button mouse that can easily be moved around between computers.
-void inputTests_populate(dsr::List<Test> &target, int buttonCount = 3, bool relative = true, bool verticalScroll = true);
+void inputTests_populate(dsr::List<Test> &target, int32_t buttonCount = 3, bool relative = true, bool verticalScroll = true);
 
 
 #endif
 #endif

+ 14 - 14
Source/SDK/music/main.cpp

@@ -22,12 +22,12 @@ Window window;
 
 
 static const double pi = 3.1415926535897932384626433832795;
 static const double pi = 3.1415926535897932384626433832795;
 static const double cyclesToRadians = pi * 2.0;
 static const double cyclesToRadians = pi * 2.0;
-static const int toneCount = 10;
-Array<int> basicTone = Array<int>(toneCount, -1);
-int testSound;
-Array<int> playing = Array<int>(toneCount, -1);
+static const int32_t toneCount = 10;
+Array<int32_t> basicTone = Array<int32_t>(toneCount, -1);
+int32_t testSound;
+Array<int32_t> playing = Array<int32_t>(toneCount, -1);
 
 
-int createSine(int frequency, const ReadableString &name) {
+int32_t createSine(int32_t frequency, const ReadableString &name) {
 	return soundEngine_insertSoundBuffer(sound_generate_function(44100 / frequency, 1, 44100, [frequency](double time, uint32_t channelIndex) {
 	return soundEngine_insertSoundBuffer(sound_generate_function(44100 / frequency, 1, 44100, [frequency](double time, uint32_t channelIndex) {
 		return sin(time * (cyclesToRadians * double(frequency))) * 0.25f;
 		return sin(time * (cyclesToRadians * double(frequency))) * 0.25f;
 	}), name, false);
 	}), name, false);
@@ -37,7 +37,7 @@ void createTestProject() {
 	// Loaded from file
 	// Loaded from file
 	testSound = soundEngine_loadSoundFromFile(U"Water.wav");
 	testSound = soundEngine_loadSoundFromFile(U"Water.wav");
 	// Pure tones
 	// Pure tones
-	for (int t = 0; t < toneCount; t++) {
+	for (int32_t t = 0; t < toneCount; t++) {
 		playing[t] = -1;
 		playing[t] = -1;
 	}
 	}
 	basicTone[0] = createSine(261, U"C 4"); // C 4
 	basicTone[0] = createSine(261, U"C 4"); // C 4
@@ -56,9 +56,9 @@ static EnvelopeSettings envelope = EnvelopeSettings(0.1, 0.2, 0.8, 0.4, 0.1, -0.
 static double previewPressTime = 1.0;
 static double previewPressTime = 1.0;
 static double previewViewTime = 4.0;
 static double previewViewTime = 4.0;
 
 
-static int selectedBuffer = 0;
+static int32_t selectedBuffer = 0;
 static void limitSelection() {
 static void limitSelection() {
-	int maxIndex = soundEngine_getSoundBufferCount() - 1;
+	int32_t maxIndex = soundEngine_getSoundBufferCount() - 1;
 	if (selectedBuffer < 0) selectedBuffer = 0;
 	if (selectedBuffer < 0) selectedBuffer = 0;
 	if (selectedBuffer > maxIndex) selectedBuffer = maxIndex;
 	if (selectedBuffer > maxIndex) selectedBuffer = maxIndex;
 }
 }
@@ -83,7 +83,7 @@ void dsrMain(List<String> args) {
 			if (key == DsrKey_Escape) {
 			if (key == DsrKey_Escape) {
 				running = false;
 				running = false;
 			} else if (key >= DsrKey_1 && key <= DsrKey_9) {
 			} else if (key >= DsrKey_1 && key <= DsrKey_9) {
-				int toneIndex = key - DsrKey_1;
+				int32_t toneIndex = key - DsrKey_1;
 				// TODO: Stop or reactivate sounds that are still fading out with the same tone to reduce the number of sound players running at the same time.
 				// TODO: Stop or reactivate sounds that are still fading out with the same tone to reduce the number of sound players running at the same time.
 				playing[toneIndex] = soundEngine_playSound(basicTone[toneIndex], true, 1.0f, 1.0f, envelope);
 				playing[toneIndex] = soundEngine_playSound(basicTone[toneIndex], true, 1.0f, 1.0f, envelope);
 			} else if (key == DsrKey_0) {
 			} else if (key == DsrKey_0) {
@@ -109,7 +109,7 @@ void dsrMain(List<String> args) {
 			}
 			}
 		} else if (event.keyboardEventType == KeyboardEventType::KeyUp) {
 		} else if (event.keyboardEventType == KeyboardEventType::KeyUp) {
 			if (key >= DsrKey_1 && key <= DsrKey_9) {
 			if (key >= DsrKey_1 && key <= DsrKey_9) {
-				int toneIndex = key - DsrKey_1;
+				int32_t toneIndex = key - DsrKey_1;
 				soundEngine_releaseSound(playing[toneIndex]);
 				soundEngine_releaseSound(playing[toneIndex]);
 			} else if (key == DsrKey_0) {
 			} else if (key == DsrKey_0) {
 				soundEngine_releaseSound(playing[9]);
 				soundEngine_releaseSound(playing[9]);
@@ -141,13 +141,13 @@ void dsrMain(List<String> args) {
 		// Fill the background
 		// Fill the background
 		AlignedImageRgbaU8 canvas = window_getCanvas(window);
 		AlignedImageRgbaU8 canvas = window_getCanvas(window);
 		image_fill(canvas, ColorRgbaI32(64, 64, 64, 255));
 		image_fill(canvas, ColorRgbaI32(64, 64, 64, 255));
-		int width = image_getWidth(canvas);
+		int32_t width = image_getWidth(canvas);
 		// Draw things
 		// Draw things
-		int height = 50;
-		int top = 0;
+		int32_t height = 50;
+		int32_t top = 0;
 		soundEngine_drawEnvelope(canvas, IRect(0, 0, width, height), envelope, previewPressTime, previewViewTime);
 		soundEngine_drawEnvelope(canvas, IRect(0, 0, width, height), envelope, previewPressTime, previewViewTime);
 		top += height;
 		top += height;
-		for (int s = 0; s < soundEngine_getSoundBufferCount(); s++) {
+		for (int32_t s = 0; s < soundEngine_getSoundBufferCount(); s++) {
 			soundEngine_drawSound(canvas, IRect(0, top, width, height), s, s == selectedBuffer);
 			soundEngine_drawSound(canvas, IRect(0, top, width, height), s, s == selectedBuffer);
 			top += height;
 			top += height;
 		}
 		}

+ 24 - 24
Source/SDK/sandbox/sandbox.cpp

@@ -111,10 +111,10 @@ static bool updateImage = true;
 static IVector2D mousePos;
 static IVector2D mousePos;
 static bool panorate = false;
 static bool panorate = false;
 static bool tileAlign = false;
 static bool tileAlign = false;
-static int debugView = 0;
-static int mouseLights = 1;
+static int32_t debugView = 0;
+static int32_t mouseLights = 1;
 
 
-static int random(const int minimum, const int maximum) {
+static int32_t random(const int32_t minimum, const int32_t maximum) {
 	if (maximum > minimum) {
 	if (maximum > minimum) {
 		return (std::rand() % (maximum + 1 - minimum)) + minimum;
 		return (std::rand() % (maximum + 1 - minimum)) + minimum;
 	} else {
 	} else {
@@ -123,14 +123,14 @@ static int random(const int minimum, const int maximum) {
 }
 }
 
 
 // Variables
 // Variables
-static int brushHeight = 0; // In mini-tile units
+static int32_t brushHeight = 0; // In mini-tile units
 static SpriteInstance spriteBrush(0, ortho_dir0, IVector3D(), true);
 static SpriteInstance spriteBrush(0, ortho_dir0, IVector3D(), true);
 static bool placingModel = false; // True when left mouse button is pressed and the direction is being assigned
 static bool placingModel = false; // True when left mouse button is pressed and the direction is being assigned
 static ModelInstance modelBrush(0, Transform3D());
 static ModelInstance modelBrush(0, Transform3D());
-static const int brushStep = ortho_miniUnitsPerTile / 32;
-static int pressing_left = 0, pressing_right = 0, pressing_up = 0, pressing_down = 0, pressing_delete = 0;
+static const int32_t brushStep = ortho_miniUnitsPerTile / 32;
+static int32_t pressing_left = 0, pressing_right = 0, pressing_up = 0, pressing_down = 0, pressing_delete = 0;
 static IVector2D cameraMovement;
 static IVector2D cameraMovement;
-static const int cameraSpeed = 1;
+static const int32_t cameraSpeed = 1;
 
 
 // World
 // World
 static SpriteWorld world;
 static SpriteWorld world;
@@ -140,15 +140,15 @@ bool castShadows = true;
 // GUI
 // GUI
 static Window window;
 static Window window;
 Component mainPanel, toolPanel, spritePanel, spriteList, modelPanel, modelList;
 Component mainPanel, toolPanel, spritePanel, spriteList, modelPanel, modelList;
-static int overlayMode = 2;
-	static const int OverlayMode_None = 0;
-	static const int OverlayMode_Profiling = 1;
-	static const int OverlayMode_Tools = 2;
-	static const int OverlayModeCount = 3;
-static int tool = 0;
-	static const int Tool_PlaceSprite = 0;
-	static const int Tool_PlaceModel = 1;
-	static const int ToolCount = 2;
+static int32_t overlayMode = 2;
+	static const int32_t OverlayMode_None = 0;
+	static const int32_t OverlayMode_Profiling = 1;
+	static const int32_t OverlayMode_Tools = 2;
+	static const int32_t OverlayModeCount = 3;
+static int32_t tool = 0;
+	static const int32_t Tool_PlaceSprite = 0;
+	static const int32_t Tool_PlaceModel = 1;
+	static const int32_t ToolCount = 2;
 void updateOverlay() {
 void updateOverlay() {
 	component_setProperty_integer(toolPanel, U"Visible", overlayMode == OverlayMode_Tools);
 	component_setProperty_integer(toolPanel, U"Visible", overlayMode == OverlayMode_Tools);
 		component_setProperty_integer(spritePanel, U"Visible", tool == Tool_PlaceSprite);
 		component_setProperty_integer(spritePanel, U"Visible", tool == Tool_PlaceSprite);
@@ -341,14 +341,14 @@ void sandbox_main() {
 	loadModel(U"Mage", U"Character_Mage.ply", U"Character_Mage_Shadow.ply");
 	loadModel(U"Mage", U"Character_Mage.ply", U"Character_Mage_Shadow.ply");
 
 
 	// Create passive sprites
 	// Create passive sprites
-	for (int z = -300; z < 300; z++) {
-		for (int x = -300; x < 300; x++) {
+	for (int32_t z = -300; z < 300; z++) {
+		for (int32_t x = -300; x < 300; x++) {
 			// The bottom floor does not have to throw shadows
 			// The bottom floor does not have to throw shadows
 			spriteWorld_addBackgroundSprite(world, SpriteInstance(random(0, 1), random(0, 3) * ortho_dir90, IVector3D(x * ortho_miniUnitsPerTile, 0, z * ortho_miniUnitsPerTile), false));
 			spriteWorld_addBackgroundSprite(world, SpriteInstance(random(0, 1), random(0, 3) * ortho_dir90, IVector3D(x * ortho_miniUnitsPerTile, 0, z * ortho_miniUnitsPerTile), false));
 		}
 		}
 	}
 	}
-	for (int z = -300; z < 300; z++) {
-		for (int x = -300; x < 300; x++) {
+	for (int32_t z = -300; z < 300; z++) {
+		for (int32_t x = -300; x < 300; x++) {
 			if (random(1, 4) == 1) {
 			if (random(1, 4) == 1) {
 				// Obstacles should cast shadows when possible
 				// Obstacles should cast shadows when possible
 				spriteWorld_addBackgroundSprite(world, SpriteInstance(random(2, 4), random(0, 3) * ortho_dir90, IVector3D(x * ortho_miniUnitsPerTile, 0, z * ortho_miniUnitsPerTile), true));
 				spriteWorld_addBackgroundSprite(world, SpriteInstance(random(2, 4), random(0, 3) * ortho_dir90, IVector3D(x * ortho_miniUnitsPerTile, 0, z * ortho_miniUnitsPerTile), true));
@@ -388,11 +388,11 @@ void sandbox_main() {
 			//   By performing game logic in multiples of msTicks, integer operations
 			//   By performing game logic in multiples of msTicks, integer operations
 			//   can be scaled without comming to a full stop in high frame rates
 			//   can be scaled without comming to a full stop in high frame rates
 			stepRemainder += secondsPerFrame * 1000.0;
 			stepRemainder += secondsPerFrame * 1000.0;
-			int msTicks = (int)stepRemainder;
+			int32_t msTicks = (int32_t)stepRemainder;
 			stepRemainder -= (double)msTicks;
 			stepRemainder -= (double)msTicks;
 
 
 			// Move the camera
 			// Move the camera
-			int cameraSteps = cameraSpeed * msTicks;
+			int32_t cameraSteps = cameraSpeed * msTicks;
 			// TODO: Find a way to move the camera using exact pixel offsets so that the camera's 3D location is only generating the 2D offset when rotating.
 			// TODO: Find a way to move the camera using exact pixel offsets so that the camera's 3D location is only generating the 2D offset when rotating.
 			//       Can the sprite brush be guaranteed to come back to the mouse location after adding and subtracting the same 2D camera offset?
 			//       Can the sprite brush be guaranteed to come back to the mouse location after adding and subtracting the same 2D camera offset?
 			//         A new integer coordinate system along the ground might move half a pixel vertically and a full pixel sideways in the diagonal view.
 			//         A new integer coordinate system along the ground might move half a pixel vertically and a full pixel sideways in the diagonal view.
@@ -474,8 +474,8 @@ void sandbox_main() {
 				draw_copy(colorBuffer, spriteWorld_getNormalBuffer(world));
 				draw_copy(colorBuffer, spriteWorld_getNormalBuffer(world));
 			} else if (debugView == 3) {
 			} else if (debugView == 3) {
 				AlignedImageF32 heightBuffer = spriteWorld_getHeightBuffer(world);
 				AlignedImageF32 heightBuffer = spriteWorld_getHeightBuffer(world);
-				for (int y = 0; y < image_getHeight(colorBuffer); y++) {
-					for (int x = 0; x < image_getWidth(colorBuffer); x++) {
+				for (int32_t y = 0; y < image_getHeight(colorBuffer); y++) {
+					for (int32_t x = 0; x < image_getWidth(colorBuffer); x++) {
 						float height = image_readPixel_clamp(heightBuffer, x, y) * 255.0f;
 						float height = image_readPixel_clamp(heightBuffer, x, y) * 255.0f;
 						if (height < 0.0f) { height = 0.0f; }
 						if (height < 0.0f) { height = 0.0f; }
 						if (height > 255.0f) { height = 255.0f; }
 						if (height > 255.0f) { height = 255.0f; }

+ 60 - 60
Source/SDK/sandbox/tool.cpp

@@ -13,15 +13,15 @@ static FVector4D pixelToVertexColor(const ColorRgbaI32& color) {
 	return FVector4D(color.red * colorScale, color.green * colorScale, color.blue * colorScale, 1.0f);
 	return FVector4D(color.red * colorScale, color.green * colorScale, color.blue * colorScale, 1.0f);
 }
 }
 
 
-static int createTriangle(Model& model, int part, int indexA, int indexB, int indexC, FVector4D colorA, FVector4D colorB, FVector4D colorC, bool flip = false) {
+static int32_t createTriangle(Model& model, int32_t part, int32_t indexA, int32_t indexB, int32_t indexC, FVector4D colorA, FVector4D colorB, FVector4D colorC, bool flip = false) {
 	if (flip) {
 	if (flip) {
-		int poly = model_addTriangle(model, part, indexB, indexA, indexC);
+		int32_t poly = model_addTriangle(model, part, indexB, indexA, indexC);
 		model_setVertexColor(model, part, poly, 0, colorB);
 		model_setVertexColor(model, part, poly, 0, colorB);
 		model_setVertexColor(model, part, poly, 1, colorA);
 		model_setVertexColor(model, part, poly, 1, colorA);
 		model_setVertexColor(model, part, poly, 2, colorC);
 		model_setVertexColor(model, part, poly, 2, colorC);
 		return poly;
 		return poly;
 	} else {
 	} else {
-		int poly = model_addTriangle(model, part, indexA, indexB, indexC);
+		int32_t poly = model_addTriangle(model, part, indexA, indexB, indexC);
 		model_setVertexColor(model, part, poly, 0, colorA);
 		model_setVertexColor(model, part, poly, 0, colorA);
 		model_setVertexColor(model, part, poly, 1, colorB);
 		model_setVertexColor(model, part, poly, 1, colorB);
 		model_setVertexColor(model, part, poly, 2, colorC);
 		model_setVertexColor(model, part, poly, 2, colorC);
@@ -29,22 +29,22 @@ static int createTriangle(Model& model, int part, int indexA, int indexB, int in
 	}
 	}
 }
 }
 
 
-using TransformFunction = std::function<FVector3D(int pixelX, int pixelY, int displacement)>;
+using TransformFunction = std::function<FVector3D(int32_t pixelX, int32_t pixelY, int32_t displacement)>;
 
 
 // Returns the start point index for another side to weld against
 // Returns the start point index for another side to weld against
-int createGridSide(Model& model, int part, const ImageU8& heightMap, const ImageRgbaU8& colorMap,
-  const TransformFunction& transform, bool clipZero, bool mergeSides, bool flipDepth = false, bool flipFaces = false, int otherStartPointIndex = -1) {
-	int startPointIndex = model_getNumberOfPoints(model);
-	int mapWidth = image_getWidth(heightMap);
-	int mapHeight = image_getHeight(heightMap);
-	int flipScale = flipDepth ? -1 : 1;
-	int columns = mergeSides ? mapWidth + 1 : mapWidth;
+int32_t createGridSide(Model& model, int32_t part, const ImageU8& heightMap, const ImageRgbaU8& colorMap,
+  const TransformFunction& transform, bool clipZero, bool mergeSides, bool flipDepth = false, bool flipFaces = false, int32_t otherStartPointIndex = -1) {
+	int32_t startPointIndex = model_getNumberOfPoints(model);
+	int32_t mapWidth = image_getWidth(heightMap);
+	int32_t mapHeight = image_getHeight(heightMap);
+	int32_t flipScale = flipDepth ? -1 : 1;
+	int32_t columns = mergeSides ? mapWidth + 1 : mapWidth;
 	// Create a part for the polygons
 	// Create a part for the polygons
-	for (int z = 0; z < mapHeight; z++) {
-		for (int x = 0; x < columns; x++) {
+	for (int32_t z = 0; z < mapHeight; z++) {
+		for (int32_t x = 0; x < columns; x++) {
 			// Sample the height map and convert to world space
 			// Sample the height map and convert to world space
-			int cx = x % mapWidth;
-			int heightC = image_readPixel_border(heightMap, cx, z);
+			int32_t cx = x % mapWidth;
+			int32_t heightC = image_readPixel_border(heightMap, cx, z);
 			// Add the point to the model
 			// Add the point to the model
 			if (x < mapWidth) {
 			if (x < mapWidth) {
 				// Create a position from the 3D index
 				// Create a position from the 3D index
@@ -55,23 +55,23 @@ int createGridSide(Model& model, int part, const ImageU8& heightMap, const Image
 				//   A-B
 				//   A-B
 				//     |
 				//     |
 				//   D-C
 				//   D-C
-				int px = x - 1;
-				int cz = z;
-				int pz = z - 1;
+				int32_t px = x - 1;
+				int32_t cz = z;
+				int32_t pz = z - 1;
 				// Sample previous heights
 				// Sample previous heights
-				int heightA = image_readPixel_border(heightMap, px, pz);
-				int heightB = image_readPixel_border(heightMap, cx, pz);
-				int heightD = image_readPixel_border(heightMap, px, cz);
+				int32_t heightA = image_readPixel_border(heightMap, px, pz);
+				int32_t heightB = image_readPixel_border(heightMap, cx, pz);
+				int32_t heightD = image_readPixel_border(heightMap, px, cz);
 				// Tell where to weld with another side's points
 				// Tell where to weld with another side's points
 				bool weldA = otherStartPointIndex > -1 && heightA == 0;
 				bool weldA = otherStartPointIndex > -1 && heightA == 0;
 				bool weldB = otherStartPointIndex > -1 && heightB == 0;
 				bool weldB = otherStartPointIndex > -1 && heightB == 0;
 				bool weldC = otherStartPointIndex > -1 && heightC == 0;
 				bool weldC = otherStartPointIndex > -1 && heightC == 0;
 				bool weldD = otherStartPointIndex > -1 && heightD == 0;
 				bool weldD = otherStartPointIndex > -1 && heightD == 0;
 				// Get indices to points
 				// Get indices to points
-				int indexA = (weldA ? otherStartPointIndex : startPointIndex) + px + pz * mapWidth;
-				int indexB = (weldB ? otherStartPointIndex : startPointIndex) + cx + pz * mapWidth;
-				int indexC = (weldC ? otherStartPointIndex : startPointIndex) + cx + cz  * mapWidth;
-				int indexD = (weldD ? otherStartPointIndex : startPointIndex) + px + cz  * mapWidth;
+				int32_t indexA = (weldA ? otherStartPointIndex : startPointIndex) + px + pz * mapWidth;
+				int32_t indexB = (weldB ? otherStartPointIndex : startPointIndex) + cx + pz * mapWidth;
+				int32_t indexC = (weldC ? otherStartPointIndex : startPointIndex) + cx + cz  * mapWidth;
+				int32_t indexD = (weldD ? otherStartPointIndex : startPointIndex) + px + cz  * mapWidth;
 				// Sample colors
 				// Sample colors
 				FVector4D colorA = pixelToVertexColor(image_readPixel_tile(colorMap, px, pz));
 				FVector4D colorA = pixelToVertexColor(image_readPixel_tile(colorMap, px, pz));
 				FVector4D colorB = pixelToVertexColor(image_readPixel_tile(colorMap, cx, pz));
 				FVector4D colorB = pixelToVertexColor(image_readPixel_tile(colorMap, cx, pz));
@@ -92,12 +92,12 @@ int createGridSide(Model& model, int part, const ImageU8& heightMap, const Image
 					if (heightC == 0) { skipFirst = true; }
 					if (heightC == 0) { skipFirst = true; }
 					if (heightA == 0) { skipSecond = true; }
 					if (heightA == 0) { skipSecond = true; }
 				} else {
 				} else {
-					int cA = image_readPixel_tile(heightMap, cx - 2, cz - 2);
-					int cB = image_readPixel_tile(heightMap, cx + 1, cz - 2);
-					int cC = image_readPixel_tile(heightMap, cx + 1, cz + 1);
-					int cD = image_readPixel_tile(heightMap, cx - 2, cz + 1);
-					int diffAC = abs((cA + cC) - (heightA + heightC));
-					int diffBD = abs((cB + cD) - (heightB + heightD));
+					int32_t cA = image_readPixel_tile(heightMap, cx - 2, cz - 2);
+					int32_t cB = image_readPixel_tile(heightMap, cx + 1, cz - 2);
+					int32_t cC = image_readPixel_tile(heightMap, cx + 1, cz + 1);
+					int32_t cD = image_readPixel_tile(heightMap, cx - 2, cz + 1);
+					int32_t diffAC = abs((cA + cC) - (heightA + heightC));
+					int32_t diffBD = abs((cB + cD) - (heightB + heightD));
 					acSplit = diffBD > diffAC;
 					acSplit = diffBD > diffAC;
 				}
 				}
 				if (!clipZero) {
 				if (!clipZero) {
@@ -152,7 +152,7 @@ int createGridSide(Model& model, int part, const ImageU8& heightMap, const Image
 //   Merges normals between mirrored sides to let normals at displacement zero merge with the other side.
 //   Merges normals between mirrored sides to let normals at displacement zero merge with the other side.
 //   mirror must be active for this to have an effect, because there's no mirrored side to weld against otherwise.
 //   mirror must be active for this to have an effect, because there's no mirrored side to weld against otherwise.
 //   clipZero must be active to hide polygons without a normal. (What is the average direction of two opposing planes?)
 //   clipZero must be active to hide polygons without a normal. (What is the average direction of two opposing planes?)
-void createGrid(Model& model, int part, const ImageU8& heightMap, const ImageRgbaU8& colorMap,
+void createGrid(Model& model, int32_t part, const ImageU8& heightMap, const ImageRgbaU8& colorMap,
   const TransformFunction& transform, bool clipZero, bool mergeSides, bool mirror, bool weldNormals) {
   const TransformFunction& transform, bool clipZero, bool mergeSides, bool mirror, bool weldNormals) {
 	if (weldNormals && !mirror) {
 	if (weldNormals && !mirror) {
 		printText("\n  Warning! Cannot weld normals without a mirrored side. The \"weldNormals\" will be ignored because \"mirror\" was not active.\n\n");
 		printText("\n  Warning! Cannot weld normals without a mirrored side. The \"weldNormals\" will be ignored because \"mirror\" was not active.\n\n");
@@ -163,7 +163,7 @@ void createGrid(Model& model, int part, const ImageU8& heightMap, const ImageRgb
 		weldNormals = false;
 		weldNormals = false;
 	}
 	}
 	// Generate primary side
 	// Generate primary side
-	int otherStartPointIndex = createGridSide(model, part, heightMap, colorMap, transform, clipZero, mergeSides);
+	int32_t otherStartPointIndex = createGridSide(model, part, heightMap, colorMap, transform, clipZero, mergeSides);
 	// Generate additional mirrored side
 	// Generate additional mirrored side
 	if (mirror) {
 	if (mirror) {
 		createGridSide(model, part, heightMap, colorMap, transform, clipZero, mergeSides, true, true, weldNormals ? otherStartPointIndex : -1);
 		createGridSide(model, part, heightMap, colorMap, transform, clipZero, mergeSides, true, true, weldNormals ? otherStartPointIndex : -1);
@@ -174,16 +174,16 @@ void createGrid(Model& model, int part, const ImageU8& heightMap, const ImageRgb
 struct PartSettings {
 struct PartSettings {
 	Transform3D location;
 	Transform3D location;
 	float displacement = 1.0f, patchWidth = 1.0f, patchHeight = 1.0f, radius = 0.0f;
 	float displacement = 1.0f, patchWidth = 1.0f, patchHeight = 1.0f, radius = 0.0f;
-	int clipZero = 0; // 1 will cut away displacements from height zero, 0 will try to display all polygons
-	int mirror = 0; // 1 will let height fields generate polygons on both sides to create solid shapes
+	int32_t clipZero = 0; // 1 will cut away displacements from height zero, 0 will try to display all polygons
+	int32_t mirror = 0; // 1 will let height fields generate polygons on both sides to create solid shapes
 	PartSettings() {}
 	PartSettings() {}
 };
 };
 
 
 struct ParserState {
 struct ParserState {
 	String sourcePath;
 	String sourcePath;
-	int angles = 4;
+	int32_t angles = 4;
 	Model model, shadow;
 	Model model, shadow;
-	int part = -1; // Current part index for model (No index used for shadows)
+	int32_t part = -1; // Current part index for model (No index used for shadows)
 	PartSettings partSettings;
 	PartSettings partSettings;
 	explicit ParserState(const String& sourcePath) : sourcePath(sourcePath), model(model_create()), shadow(model_create()) {
 	explicit ParserState(const String& sourcePath) : sourcePath(sourcePath), model(model_create()), shadow(model_create()) {
 		model_addEmptyPart(this->shadow, U"shadow");
 		model_addEmptyPart(this->shadow, U"shadow");
@@ -289,7 +289,7 @@ static void generateField(ParserState& state, Shape shape, const ImageU8& height
 		float heightScale = state.partSettings.patchHeight / -(image_getHeight(heightMap) - 1);
 		float heightScale = state.partSettings.patchHeight / -(image_getHeight(heightMap) - 1);
 		FVector3D localScaling = FVector3D(widthScale, offsetPerUnit, heightScale);
 		FVector3D localScaling = FVector3D(widthScale, offsetPerUnit, heightScale);
 		FVector3D localOrigin = FVector3D(state.partSettings.patchWidth * -0.5f, 0.0f, state.partSettings.patchHeight * 0.5f);
 		FVector3D localOrigin = FVector3D(state.partSettings.patchWidth * -0.5f, 0.0f, state.partSettings.patchHeight * 0.5f);
-		transform = [system, localOrigin, localScaling](int pixelX, int pixelY, int displacement){
+		transform = [system, localOrigin, localScaling](int32_t pixelX, int32_t pixelY, int32_t displacement){
 			return system.transformPoint(localOrigin + (FVector3D(pixelX, displacement, pixelY) * localScaling));
 			return system.transformPoint(localOrigin + (FVector3D(pixelX, displacement, pixelY) * localScaling));
 		};
 		};
 	} else if (shape == Shape::Cylinder) {
 	} else if (shape == Shape::Cylinder) {
@@ -300,9 +300,9 @@ static void generateField(ParserState& state, Shape shape, const ImageU8& height
 		float angleOffset = angleScale * 0.5f; // Start and end half a pixel from the seam
 		float angleOffset = angleScale * 0.5f; // Start and end half a pixel from the seam
 		float heightScale = state.partSettings.patchHeight / -(image_getHeight(heightMap) - 1);
 		float heightScale = state.partSettings.patchHeight / -(image_getHeight(heightMap) - 1);
 		float heightOffset = state.partSettings.patchHeight * 0.5f;
 		float heightOffset = state.partSettings.patchHeight * 0.5f;
-		int lastRow = image_getHeight(heightMap) - 1;
+		int32_t lastRow = image_getHeight(heightMap) - 1;
 		bool fillHoles = !mirror && !clipZero; // Automatically fill the holes to close the shape when not mirroring nor clipping the sides
 		bool fillHoles = !mirror && !clipZero; // Automatically fill the holes to close the shape when not mirroring nor clipping the sides
-		transform = [system, angleOffset, angleScale, heightOffset, heightScale, radius, offsetPerUnit, fillHoles, lastRow](int pixelX, int pixelY, int displacement){
+		transform = [system, angleOffset, angleScale, heightOffset, heightScale, radius, offsetPerUnit, fillHoles, lastRow](int32_t pixelX, int32_t pixelY, int32_t displacement){
 			float angle = ((float)pixelX * angleScale) + angleOffset;
 			float angle = ((float)pixelX * angleScale) + angleOffset;
 			float offset = ((float)displacement * offsetPerUnit) + radius;
 			float offset = ((float)displacement * offsetPerUnit) + radius;
 			float height = ((float)pixelY * heightScale) + heightOffset;
 			float height = ((float)pixelY * heightScale) + heightOffset;
@@ -325,7 +325,7 @@ static void generateField(ParserState& state, Shape shape, const ImageU8& height
 static void generateBasicShape(ParserState& state, Shape shape, const ReadableString& arg1, const ReadableString& arg2, const ReadableString& arg3, bool shadow) {
 static void generateBasicShape(ParserState& state, Shape shape, const ReadableString& arg1, const ReadableString& arg2, const ReadableString& arg3, bool shadow) {
 	Transform3D system = state.partSettings.location;
 	Transform3D system = state.partSettings.location;
 	Model model = shadow ? state.shadow : state.model;
 	Model model = shadow ? state.shadow : state.model;
-	int part = shadow ? 0 : state.part;
+	int32_t part = shadow ? 0 : state.part;
 	// All shapes are centered around the axis system's origin from -0.5 to +0.5 of any given size
 	// All shapes are centered around the axis system's origin from -0.5 to +0.5 of any given size
 	if (shape == Shape::Box) {
 	if (shape == Shape::Box) {
 		// Parse arguments
 		// Parse arguments
@@ -336,7 +336,7 @@ static void generateBasicShape(ParserState& state, Shape shape, const ReadableSt
 		FVector3D upper = FVector3D(width, height, depth) * 0.5f;
 		FVector3D upper = FVector3D(width, height, depth) * 0.5f;
 		FVector3D lower = -upper;
 		FVector3D lower = -upper;
 		// Positions
 		// Positions
-		int first = model_getNumberOfPoints(model);
+		int32_t first = model_getNumberOfPoints(model);
 		model_addPoint(model, system.transformPoint(FVector3D(lower.x, lower.y, lower.z))); // first + 0: Left-down-near
 		model_addPoint(model, system.transformPoint(FVector3D(lower.x, lower.y, lower.z))); // first + 0: Left-down-near
 		model_addPoint(model, system.transformPoint(FVector3D(lower.x, lower.y, upper.z))); // first + 1: Left-down-far
 		model_addPoint(model, system.transformPoint(FVector3D(lower.x, lower.y, upper.z))); // first + 1: Left-down-far
 		model_addPoint(model, system.transformPoint(FVector3D(lower.x, upper.y, lower.z))); // first + 2: Left-up-near
 		model_addPoint(model, system.transformPoint(FVector3D(lower.x, upper.y, lower.z))); // first + 2: Left-up-near
@@ -356,26 +356,26 @@ static void generateBasicShape(ParserState& state, Shape shape, const ReadableSt
 		// Parse arguments
 		// Parse arguments
 		float radius = string_toDouble(arg1);
 		float radius = string_toDouble(arg1);
 		float height = string_toDouble(arg2);
 		float height = string_toDouble(arg2);
-		int sideCount = string_toDouble(arg3);
+		int32_t sideCount = string_toDouble(arg3);
 		// Create a bound
 		// Create a bound
 		float topHeight = height * 0.5f;
 		float topHeight = height * 0.5f;
 		float bottomHeight = height * -0.5f;
 		float bottomHeight = height * -0.5f;
 		// Positions
 		// Positions
 		float angleScale = 6.283185307 / (float)sideCount;
 		float angleScale = 6.283185307 / (float)sideCount;
-		int centerTop = model_addPoint(model, system.transformPoint(FVector3D(0.0f, topHeight, 0.0f)));
-		int firstTopSide = model_getNumberOfPoints(model);
-		for (int p = 0; p < sideCount; p++) {
+		int32_t centerTop = model_addPoint(model, system.transformPoint(FVector3D(0.0f, topHeight, 0.0f)));
+		int32_t firstTopSide = model_getNumberOfPoints(model);
+		for (int32_t p = 0; p < sideCount; p++) {
 			float radians = p * angleScale;
 			float radians = p * angleScale;
 			model_addPoint(model, system.transformPoint(FVector3D(sin(radians) * radius, topHeight, cos(radians) * radius)));
 			model_addPoint(model, system.transformPoint(FVector3D(sin(radians) * radius, topHeight, cos(radians) * radius)));
 		}
 		}
-		int centerBottom = model_addPoint(model, system.transformPoint(FVector3D(0.0f, bottomHeight, 0.0f)));
-		int firstBottomSide = model_getNumberOfPoints(model);
-		for (int p = 0; p < sideCount; p++) {
+		int32_t centerBottom = model_addPoint(model, system.transformPoint(FVector3D(0.0f, bottomHeight, 0.0f)));
+		int32_t firstBottomSide = model_getNumberOfPoints(model);
+		for (int32_t p = 0; p < sideCount; p++) {
 			float radians = p * angleScale;
 			float radians = p * angleScale;
 			model_addPoint(model, system.transformPoint(FVector3D(sin(radians) * radius, bottomHeight, cos(radians) * radius)));	
 			model_addPoint(model, system.transformPoint(FVector3D(sin(radians) * radius, bottomHeight, cos(radians) * radius)));	
 		}
 		}
-		for (int p = 0; p < sideCount; p++) {
-			int q = (p + 1) % sideCount;
+		for (int32_t p = 0; p < sideCount; p++) {
+			int32_t q = (p + 1) % sideCount;
 			// Top fan
 			// Top fan
 			model_addTriangle(model, part, centerTop, firstTopSide + p, firstTopSide + q);
 			model_addTriangle(model, part, centerTop, firstTopSide + p, firstTopSide + q);
 			// Bottom fan
 			// Bottom fan
@@ -413,7 +413,7 @@ static void parse_shape(ParserState& state, List<String>& args, bool shadow) {
 		} else {
 		} else {
 			bool flipX = (shape == Shape::RightHandedModel);
 			bool flipX = (shape == Shape::RightHandedModel);
 			Model targetModel = shadow ? state.shadow : state.model;
 			Model targetModel = shadow ? state.shadow : state.model;
-			int targetPart = shadow ? 0 : state.part;
+			int32_t targetPart = shadow ? 0 : state.part;
 			importer_loadModel(targetModel, targetPart, string_combine(state.sourcePath, args[1]), flipX, state.partSettings.location);
 			importer_loadModel(targetModel, targetPart, string_combine(state.sourcePath, args[1]), flipX, state.partSettings.location);
 		}
 		}
 	} else if (args.length() == 2) {
 	} else if (args.length() == 2) {
@@ -435,20 +435,20 @@ static void parse_shape(ParserState& state, List<String>& args, bool shadow) {
 
 
 static void parse_dsm(ParserState& state, const ReadableString& content) {
 static void parse_dsm(ParserState& state, const ReadableString& content) {
 	List<String> lines = string_split(content, U'\n');
 	List<String> lines = string_split(content, U'\n');
-	for (int l = 0; l < lines.length(); l++) {
+	for (int32_t l = 0; l < lines.length(); l++) {
 		// Get the current line
 		// Get the current line
 		ReadableString line = lines[l];
 		ReadableString line = lines[l];
 		// Skip comments
 		// Skip comments
-		int commentIndex = string_findFirst(line, U';');
+		int32_t commentIndex = string_findFirst(line, U';');
 		if (commentIndex > -1) {
 		if (commentIndex > -1) {
 			line = string_removeOuterWhiteSpace(string_before(line, commentIndex));
 			line = string_removeOuterWhiteSpace(string_before(line, commentIndex));
 		}
 		}
 		if (string_length(line) > 0) {
 		if (string_length(line) > 0) {
 			// Find assignments
 			// Find assignments
-			int assignmentIndex = string_findFirst(line, U'=');
-			int colonIndex = string_findFirst(line, U':');
-			int blockStartIndex = string_findFirst(line, U'<');
-			int blockEndIndex = string_findFirst(line, U'>');
+			int32_t assignmentIndex = string_findFirst(line, U'=');
+			int32_t colonIndex = string_findFirst(line, U':');
+			int32_t blockStartIndex = string_findFirst(line, U'<');
+			int32_t blockEndIndex = string_findFirst(line, U'>');
 			if (assignmentIndex > -1) {
 			if (assignmentIndex > -1) {
 				ReadableString key = string_removeOuterWhiteSpace(string_before(line, assignmentIndex));
 				ReadableString key = string_removeOuterWhiteSpace(string_before(line, assignmentIndex));
 				ReadableString value = string_removeOuterWhiteSpace(string_after(line, assignmentIndex));
 				ReadableString value = string_removeOuterWhiteSpace(string_after(line, assignmentIndex));
@@ -457,7 +457,7 @@ static void parse_dsm(ParserState& state, const ReadableString& content) {
 				ReadableString command = string_removeOuterWhiteSpace(string_before(line, colonIndex));
 				ReadableString command = string_removeOuterWhiteSpace(string_before(line, colonIndex));
 				ReadableString argContent = string_after(line, colonIndex);
 				ReadableString argContent = string_after(line, colonIndex);
 				List<String> args = string_split(argContent, U',');
 				List<String> args = string_split(argContent, U',');
-				for (int a = 0; a < args.length(); a++) {
+				for (int32_t a = 0; a < args.length(); a++) {
 					args[a] = string_removeOuterWhiteSpace(args[a]);
 					args[a] = string_removeOuterWhiteSpace(args[a]);
 				}
 				}
 				if (string_caseInsensitiveMatch(command, U"Visible")) {
 				if (string_caseInsensitiveMatch(command, U"Visible")) {
@@ -499,7 +499,7 @@ void tool_main(const List<String> &args) {
 		String sourcePath = string_combine(args[1], file_separator());
 		String sourcePath = string_combine(args[1], file_separator());
 		String targetPath = string_combine(args[2], file_separator());
 		String targetPath = string_combine(args[2], file_separator());
 		OrthoSystem ortho = OrthoSystem(string_load(args[3]));
 		OrthoSystem ortho = OrthoSystem(string_load(args[3]));
-		for (int a = 4; a < args.length(); a++) {
+		for (int32_t a = 4; a < args.length(); a++) {
 			processScript(sourcePath, targetPath, ortho, args[a]);
 			processScript(sourcePath, targetPath, ortho, args[a]);
 		}
 		}
 	}
 	}

+ 37 - 37
Source/SDK/terrain/main.cpp

@@ -114,19 +114,19 @@ FVector3D worldToGrid(FVector3D worldSpace) {
 	return FVector3D(worldSpace.x, -worldSpace.z, worldSpace.y);
 	return FVector3D(worldSpace.x, -worldSpace.z, worldSpace.y);
 }
 }
 
 
-float getHeight(const ImageU8& heightMap, int u, int v) {
+float getHeight(const ImageU8& heightMap, int32_t u, int32_t v) {
 	return image_readPixel_border(heightMap, u, v) * heightPerUnit;
 	return image_readPixel_border(heightMap, u, v) * heightPerUnit;
 }
 }
 
 
-int createGridPart(Model& targetModel, const ImageU8& heightMap) {
-	int mapWidth = image_getWidth(heightMap);
-	int mapHeight = image_getHeight(heightMap);
+int32_t createGridPart(Model& targetModel, const ImageU8& heightMap) {
+	int32_t mapWidth = image_getWidth(heightMap);
+	int32_t mapHeight = image_getHeight(heightMap);
 	float scaleU = 1.0f / (mapWidth - 1.0f);
 	float scaleU = 1.0f / (mapWidth - 1.0f);
 	float scaleV = 1.0f / (mapHeight - 1.0f);
 	float scaleV = 1.0f / (mapHeight - 1.0f);
 	// Create a part for the polygons
 	// Create a part for the polygons
-	int part = model_addEmptyPart(targetModel, U"grid");
-	for (int z = 0; z < mapHeight; z++) {
-		for (int x = 0; x < mapWidth; x++) {
+	int32_t part = model_addEmptyPart(targetModel, U"grid");
+	for (int32_t z = 0; z < mapHeight; z++) {
+		for (int32_t x = 0; x < mapWidth; x++) {
 			// Sample the height map and convert to world space
 			// Sample the height map and convert to world space
 			float height = getHeight(heightMap, x, z);
 			float height = getHeight(heightMap, x, z);
 			// Create a position from the 3D index
 			// Create a position from the 3D index
@@ -138,12 +138,12 @@ int createGridPart(Model& targetModel, const ImageU8& heightMap) {
 				//   A-B
 				//   A-B
 				//     |
 				//     |
 				//   D-C
 				//   D-C
-				int px = x - 1;
-				int pz = z - 1;
-				int indexA = px + pz * mapWidth;
-				int indexB = x  + pz * mapWidth;
-				int indexC = x  + z  * mapWidth;
-				int indexD = px + z  * mapWidth;
+				int32_t px = x - 1;
+				int32_t pz = z - 1;
+				int32_t indexA = px + pz * mapWidth;
+				int32_t indexB = x  + pz * mapWidth;
+				int32_t indexC = x  + z  * mapWidth;
+				int32_t indexD = px + z  * mapWidth;
 				FVector4D texA = FVector4D(px * scaleU, pz * scaleV, 0.0f, 0.0f);
 				FVector4D texA = FVector4D(px * scaleU, pz * scaleV, 0.0f, 0.0f);
 				FVector4D texB = FVector4D(x  * scaleU, pz * scaleV, 0.0f, 0.0f);
 				FVector4D texB = FVector4D(x  * scaleU, pz * scaleV, 0.0f, 0.0f);
 				FVector4D texC = FVector4D(x  * scaleU, z  * scaleV, 0.0f, 0.0f);
 				FVector4D texC = FVector4D(x  * scaleU, z  * scaleV, 0.0f, 0.0f);
@@ -151,13 +151,13 @@ int createGridPart(Model& targetModel, const ImageU8& heightMap) {
 				// Create a polygon unless it's at the bottom
 				// Create a polygon unless it's at the bottom
 				if (image_readPixel_border(heightMap, x-1, z-1) > 0 || image_readPixel_border(heightMap, x, z-1) > 0 || image_readPixel_border(heightMap, x-1, z) > 0 || image_readPixel_border(heightMap, x, z) > 0) {
 				if (image_readPixel_border(heightMap, x-1, z-1) > 0 || image_readPixel_border(heightMap, x, z-1) > 0 || image_readPixel_border(heightMap, x-1, z) > 0 || image_readPixel_border(heightMap, x, z) > 0) {
 					if ((x + z) % 2 == 0) {
 					if ((x + z) % 2 == 0) {
-						int poly = model_addQuad(targetModel, part, indexA, indexB, indexC, indexD);
+						int32_t poly = model_addQuad(targetModel, part, indexA, indexB, indexC, indexD);
 						model_setTexCoord(targetModel, part, poly, 0, texA);
 						model_setTexCoord(targetModel, part, poly, 0, texA);
 						model_setTexCoord(targetModel, part, poly, 1, texB);
 						model_setTexCoord(targetModel, part, poly, 1, texB);
 						model_setTexCoord(targetModel, part, poly, 2, texC);
 						model_setTexCoord(targetModel, part, poly, 2, texC);
 						model_setTexCoord(targetModel, part, poly, 3, texD);
 						model_setTexCoord(targetModel, part, poly, 3, texD);
 					} else {
 					} else {
-						int poly = model_addQuad(targetModel, part, indexB, indexC, indexD, indexA);
+						int32_t poly = model_addQuad(targetModel, part, indexB, indexC, indexD, indexA);
 						model_setTexCoord(targetModel, part, poly, 0, texB);
 						model_setTexCoord(targetModel, part, poly, 0, texB);
 						model_setTexCoord(targetModel, part, poly, 1, texC);
 						model_setTexCoord(targetModel, part, poly, 1, texC);
 						model_setTexCoord(targetModel, part, poly, 2, texD);
 						model_setTexCoord(targetModel, part, poly, 2, texD);
@@ -172,12 +172,12 @@ int createGridPart(Model& targetModel, const ImageU8& heightMap) {
 
 
 static Model createGrid(const ImageU8& heightMap, const TextureRgbaU8& colorMap) {
 static Model createGrid(const ImageU8& heightMap, const TextureRgbaU8& colorMap) {
 	Model model = model_create();
 	Model model = model_create();
-	int part = createGridPart(model, heightMap);
+	int32_t part = createGridPart(model, heightMap);
 	model_setDiffuseMap(model, part, colorMap);
 	model_setDiffuseMap(model, part, colorMap);
 	return model;
 	return model;
 }
 }
 
 
-static inline int saturateFloat(float value) {
+static inline int32_t saturateFloat(float value) {
 	if (!(value >= 0.0f)) {
 	if (!(value >= 0.0f)) {
 		// NaN or negative
 		// NaN or negative
 		return 0;
 		return 0;
@@ -186,7 +186,7 @@ static inline int saturateFloat(float value) {
 		return 255;
 		return 255;
 	} else {
 	} else {
 		// Round to closest
 		// Round to closest
-		return (int)(value + 0.5f);
+		return (int32_t)(value + 0.5f);
 	}
 	}
 }
 }
 
 
@@ -219,8 +219,8 @@ ColorRgbaI32 sampleColorRampLinear(const ImageRgbaU8& colorRamp, float x) {
 	} else if (x > 255.0f) {
 	} else if (x > 255.0f) {
 		return image_readPixel_clamp(colorRamp, 255, 0);
 		return image_readPixel_clamp(colorRamp, 255, 0);
 	} else {
 	} else {
-		int low = (int)x;
-		int high = low + 1;
+		int32_t low = (int32_t)x;
+		int32_t high = low + 1;
 		float weight = x - low;
 		float weight = x - low;
 		ColorRgbaI32 lowColor = image_readPixel_clamp(colorRamp, low, 0);
 		ColorRgbaI32 lowColor = image_readPixel_clamp(colorRamp, low, 0);
 		ColorRgbaI32 highColor = image_readPixel_clamp(colorRamp, high, 0);
 		ColorRgbaI32 highColor = image_readPixel_clamp(colorRamp, high, 0);
@@ -230,8 +230,8 @@ ColorRgbaI32 sampleColorRampLinear(const ImageRgbaU8& colorRamp, float x) {
 
 
 // Represents the height in a finer pixel density for material effects
 // Represents the height in a finer pixel density for material effects
 void generateBumpMap(ImageF32& targetBumpMap, const ImageU8& heightMap, const ImageU8& bumpPattern) {
 void generateBumpMap(ImageF32& targetBumpMap, const ImageU8& heightMap, const ImageU8& bumpPattern) {
-	for (int y = 0; y < image_getHeight(targetBumpMap); y++) {
-		for (int x = 0; x < image_getWidth(targetBumpMap); x++) {
+	for (int32_t y = 0; y < image_getHeight(targetBumpMap); y++) {
+		for (int32_t x = 0; x < image_getWidth(targetBumpMap); x++) {
 			// TODO: Apply gaussian blur after bilinear interpolation to hide seams.
 			// TODO: Apply gaussian blur after bilinear interpolation to hide seams.
 			float height = (
 			float height = (
 			    sampleFixedBilinear(heightMap, x, y)
 			    sampleFixedBilinear(heightMap, x, y)
@@ -254,7 +254,7 @@ void generateBumpMap(ImageF32& targetBumpMap, const ImageU8& heightMap, const Im
 	}
 	}
 }
 }
 
 
-FVector3D getNormal(const ImageF32& bumpMap, int x, int y) {
+FVector3D getNormal(const ImageF32& bumpMap, int32_t x, int32_t y) {
 	float bumpLeft = image_readPixel_clamp(bumpMap, x - 1, y);
 	float bumpLeft = image_readPixel_clamp(bumpMap, x - 1, y);
 	float bumpRight = image_readPixel_clamp(bumpMap, x + 1, y);
 	float bumpRight = image_readPixel_clamp(bumpMap, x + 1, y);
 	float bumpUp = image_readPixel_clamp(bumpMap, x, y - 1);
 	float bumpUp = image_readPixel_clamp(bumpMap, x, y - 1);
@@ -265,8 +265,8 @@ FVector3D getNormal(const ImageF32& bumpMap, int x, int y) {
 }
 }
 
 
 void generateLightMap(ImageF32& targetLightMap, const ImageF32& bumpMap, const FVector3D& sunDirection, float ambient) {
 void generateLightMap(ImageF32& targetLightMap, const ImageF32& bumpMap, const FVector3D& sunDirection, float ambient) {
-	for (int y = 0; y < image_getHeight(targetLightMap); y++) {
-		for (int x = 0; x < image_getWidth(targetLightMap); x++) {
+	for (int32_t y = 0; y < image_getHeight(targetLightMap); y++) {
+		for (int32_t x = 0; x < image_getWidth(targetLightMap); x++) {
 			FVector3D surfaceNormal = getNormal(bumpMap, x, y);
 			FVector3D surfaceNormal = getNormal(bumpMap, x, y);
 			float angularIntensity = std::max(0.0f, dotProduct(surfaceNormal, -sunDirection));
 			float angularIntensity = std::max(0.0f, dotProduct(surfaceNormal, -sunDirection));
 			image_writePixel(targetLightMap, x, y, angularIntensity + ambient);
 			image_writePixel(targetLightMap, x, y, angularIntensity + ambient);
@@ -275,12 +275,12 @@ void generateLightMap(ImageF32& targetLightMap, const ImageF32& bumpMap, const F
 }
 }
 
 
 void generateDiffuseMap(ImageRgbaU8& targetDiffuseMap, const ImageF32& bumpMap, const ImageRgbaU8& heightColorRamp) {
 void generateDiffuseMap(ImageRgbaU8& targetDiffuseMap, const ImageF32& bumpMap, const ImageRgbaU8& heightColorRamp) {
-	for (int y = 0; y < image_getHeight(targetDiffuseMap); y++) {
-		for (int x = 0; x < image_getWidth(targetDiffuseMap); x++) {
+	for (int32_t y = 0; y < image_getHeight(targetDiffuseMap); y++) {
+		for (int32_t x = 0; x < image_getWidth(targetDiffuseMap); x++) {
 			float height = image_readPixel_clamp(bumpMap, x, y);
 			float height = image_readPixel_clamp(bumpMap, x, y);
 			ColorRgbaI32 rampColor = sampleColorRampLinear(heightColorRamp, height);
 			ColorRgbaI32 rampColor = sampleColorRampLinear(heightColorRamp, height);
-			/*int rx = remTile(x);
-			int ry = remTile(y);
+			/*int32_t rx = remTile(x);
+			int32_t ry = remTile(y);
 			bool gridLine = rx == 0 || ry == 0 || rx == tileColorDensity - 1 || ry == tileColorDensity - 1;
 			bool gridLine = rx == 0 || ry == 0 || rx == tileColorDensity - 1 || ry == tileColorDensity - 1;
 			if (gridLine) {
 			if (gridLine) {
 				rampColor = ColorRgbaI32(
 				rampColor = ColorRgbaI32(
@@ -297,8 +297,8 @@ void generateDiffuseMap(ImageRgbaU8& targetDiffuseMap, const ImageF32& bumpMap,
 
 
 // Full update of the ground
 // Full update of the ground
 void updateColorMap(ImageRgbaU8& targetColorMap, const ImageRgbaU8& diffuseMap, const ImageF32& lightMap) {
 void updateColorMap(ImageRgbaU8& targetColorMap, const ImageRgbaU8& diffuseMap, const ImageF32& lightMap) {
-	for (int y = 0; y < image_getHeight(targetColorMap); y++) {
-		for (int x = 0; x < image_getWidth(targetColorMap); x++) {
+	for (int32_t y = 0; y < image_getHeight(targetColorMap); y++) {
+		for (int32_t x = 0; x < image_getWidth(targetColorMap); x++) {
 			ColorRgbaI32 diffuse = image_readPixel_clamp(diffuseMap, x, y);
 			ColorRgbaI32 diffuse = image_readPixel_clamp(diffuseMap, x, y);
 			float light = image_readPixel_clamp(lightMap, x, y);
 			float light = image_readPixel_clamp(lightMap, x, y);
 			image_writePixel(targetColorMap, x, y, diffuse * light);
 			image_writePixel(targetColorMap, x, y, diffuse * light);
@@ -347,10 +347,10 @@ void dsrMain(List<String> args) {
 	ImageRgbaU8 heightRamp = image_load_RgbaU8(file_combinePaths(mediaFolder, U"RampIsland.png"));
 	ImageRgbaU8 heightRamp = image_load_RgbaU8(file_combinePaths(mediaFolder, U"RampIsland.png"));
 
 
 	// Get dimensions
 	// Get dimensions
-	const int heighMapWidth = image_getWidth(heightMap);
-	const int heighMapHeight = image_getHeight(heightMap);
-	const int colorMapWidth = heighMapWidth * tileColorDensity;
-	const int colorMapHeight = heighMapHeight * tileColorDensity;
+	const int32_t heighMapWidth = image_getWidth(heightMap);
+	const int32_t heighMapHeight = image_getHeight(heightMap);
+	const int32_t colorMapWidth = heighMapWidth * tileColorDensity;
+	const int32_t colorMapHeight = heighMapHeight * tileColorDensity;
 
 
 	// Create a bump map in the same 0..255 range as the height map, but using floats
 	// Create a bump map in the same 0..255 range as the height map, but using floats
 	ImageF32 bumpMap = image_create_F32(colorMapWidth, colorMapHeight);
 	ImageF32 bumpMap = image_create_F32(colorMapWidth, colorMapHeight);
@@ -389,8 +389,8 @@ void dsrMain(List<String> args) {
 		ImageF32 depthBuffer = window_getDepthBuffer(window);
 		ImageF32 depthBuffer = window_getDepthBuffer(window);
 
 
 		// Get target size
 		// Get target size
-		int targetWidth = image_getWidth(colorBuffer);
-		int targetHeight = image_getHeight(colorBuffer);
+		int32_t targetWidth = image_getWidth(colorBuffer);
+		int32_t targetHeight = image_getHeight(colorBuffer);
 
 
 		// Paint the background color
 		// Paint the background color
 		startTime = time_getSeconds();
 		startTime = time_getSeconds();

+ 5 - 5
Source/tools/wizard/main.cpp

@@ -27,7 +27,7 @@ Component clonePanel;
 	Component acceptCloneButton;
 	Component acceptCloneButton;
 
 
 // Media
 // Media
-int boomSound;
+int32_t boomSound;
 
 
 struct Project {
 struct Project {
 	String projectFilePath;
 	String projectFilePath;
@@ -110,7 +110,7 @@ static void findProjects(const ReadableString& folderPath) {
 // Returns true iff the interface needs to be redrawn.
 // Returns true iff the interface needs to be redrawn.
 static bool updateInterface(bool forceUpdate) {
 static bool updateInterface(bool forceUpdate) {
 	bool needToDraw = false;
 	bool needToDraw = false;
-	int projectIndex = component_getProperty_integer(projectList, U"SelectedIndex", true);
+	int32_t projectIndex = component_getProperty_integer(projectList, U"SelectedIndex", true);
 	//Application name from project name?
 	//Application name from project name?
 	if (projectIndex >= 0 && projectIndex < projects.length()) {
 	if (projectIndex >= 0 && projectIndex < projects.length()) {
 		DsrProcessStatus newStatus = process_getStatus(projects[projectIndex].programHandle);
 		DsrProcessStatus newStatus = process_getStatus(projects[projectIndex].programHandle);
@@ -144,7 +144,7 @@ static void selectProject(int64_t projectIndex) {
 }
 }
 
 
 static void populateInterface() {
 static void populateInterface() {
-	for (int p = 0; p < projects.length(); p++) {
+	for (int32_t p = 0; p < projects.length(); p++) {
 		component_call(projectList, U"PushElement", projects[p].title);
 		component_call(projectList, U"PushElement", projects[p].title);
 	}
 	}
 	selectProject(0);
 	selectProject(0);
@@ -227,7 +227,7 @@ void dsrMain(List<String> args) {
 	});
 	});
 	component_setPressedEvent(cloneButton, []() {
 	component_setPressedEvent(cloneButton, []() {
 		// Get the project index.
 		// Get the project index.
-		int projectIndex = component_getProperty_integer(projectList, U"SelectedIndex", true);
+		int32_t projectIndex = component_getProperty_integer(projectList, U"SelectedIndex", true);
 		// Check if the project index is valid.
 		// Check if the project index is valid.
 		if (projectIndex >= 0 && projectIndex < projects.length()) {
 		if (projectIndex >= 0 && projectIndex < projects.length()) {
 			ReadableString projectFilePath = projects[projectIndex].projectFilePath;
 			ReadableString projectFilePath = projects[projectIndex].projectFilePath;
@@ -269,7 +269,7 @@ void dsrMain(List<String> args) {
 	});
 	});
 	component_setPressedEvent(launchButton, []() {
 	component_setPressedEvent(launchButton, []() {
 		soundEngine_playSound(boomSound, false);
 		soundEngine_playSound(boomSound, false);
-		int projectIndex = component_getProperty_integer(projectList, U"SelectedIndex", true);
+		int32_t projectIndex = component_getProperty_integer(projectList, U"SelectedIndex", true);
 		//Application name from project name?
 		//Application name from project name?
 		if (projectIndex >= 0 && projectIndex < projects.length()) {
 		if (projectIndex >= 0 && projectIndex < projects.length()) {
 			if (file_getEntryType(projects[projectIndex].executableFilePath) != EntryType::File) {
 			if (file_getEntryType(projects[projectIndex].executableFilePath) != EntryType::File) {

+ 18 - 18
Source/windowManagers/CocoaWindow.mm

@@ -23,7 +23,7 @@
 
 
 #include "../DFPSR/settings.h"
 #include "../DFPSR/settings.h"
 
 
-static const int bufferCount = 1;
+static const int32_t bufferCount = 1;
 
 
 static bool applicationInitialized = false;
 static bool applicationInitialized = false;
 static NSApplication *application;
 static NSApplication *application;
@@ -43,7 +43,7 @@ private:
 	// 0 for regular left click.
 	// 0 for regular left click.
 	// 1 for control click converted to right mouse button.
 	// 1 for control click converted to right mouse button.
 	// 2 for command click converted to middle mouse button.
 	// 2 for command click converted to middle mouse button.
-	int modifiedClick = 0;
+	int32_t modifiedClick = 0;
 	// Last modifiers to allow converting NSEventTypeFlagsChanged into up and down key press events.
 	// Last modifiers to allow converting NSEventTypeFlagsChanged into up and down key press events.
 	bool pressedControl = false;
 	bool pressedControl = false;
 	bool pressedCommand = false;
 	bool pressedCommand = false;
@@ -58,12 +58,12 @@ private:
 	dsr::Buffer delayedCanvas;
 	dsr::Buffer delayedCanvas;
 	// An Cocoa image wrapped around the canvas pixel data
 	// An Cocoa image wrapped around the canvas pixel data
 	//NSImage *canvasNS[bufferCount] = {};
 	//NSImage *canvasNS[bufferCount] = {};
-	int drawIndex = 0 % bufferCount;
-	int showIndex = 1 % bufferCount;
+	int32_t drawIndex = 0 % bufferCount;
+	int32_t showIndex = 1 % bufferCount;
 
 
 	// Remembers the dimensions of the window from creation and resize events
 	// Remembers the dimensions of the window from creation and resize events
 	//   This allow requesting the size of the window at any time
 	//   This allow requesting the size of the window at any time
-	int windowWidth = 0, windowHeight = 0;
+	int32_t windowWidth = 0, windowHeight = 0;
 
 
 	// Called before the application fetches events from the input queue
 	// Called before the application fetches events from the input queue
 	//   Closing the window, moving the mouse, pressing a key, et cetera
 	//   Closing the window, moving the mouse, pressing a key, et cetera
@@ -73,26 +73,26 @@ private:
 	bool setCursorVisibility(bool visible) override;
 	bool setCursorVisibility(bool visible) override;
 
 
 	// Place the cursor within the window
 	// Place the cursor within the window
-	bool setCursorPosition(int x, int y) override;
+	bool setCursorPosition(int32_t x, int32_t y) override;
 private:
 private:
 	// Helper methods specific to calling XLib
 	// Helper methods specific to calling XLib
 	void updateTitle();
 	void updateTitle();
 private:
 private:
 	// Canvas methods
 	// Canvas methods
 	dsr::AlignedImageRgbaU8 getCanvas() override { return this->canvas[this->drawIndex]; }
 	dsr::AlignedImageRgbaU8 getCanvas() override { return this->canvas[this->drawIndex]; }
-	void resizeCanvas(int width, int height) override;
+	void resizeCanvas(int32_t width, int32_t height) override;
 	// Window methods
 	// Window methods
 	void setTitle(const dsr::String &newTitle) override {
 	void setTitle(const dsr::String &newTitle) override {
 		this->title = newTitle;
 		this->title = newTitle;
 		this->updateTitle();
 		this->updateTitle();
 	}
 	}
-	int windowState = 0; // 0=none, 1=windowed, 2=fullscreen
+	int32_t windowState = 0; // 0=none, 1=windowed, 2=fullscreen
 public:
 public:
 	// Constructors
 	// Constructors
 	CocoaWindow(const CocoaWindow&) = delete; // Non-copyable because of pointer aliasing.
 	CocoaWindow(const CocoaWindow&) = delete; // Non-copyable because of pointer aliasing.
-	CocoaWindow(const dsr::String& title, int width, int height);
-	int getWidth() const override { return this->windowWidth; };
-	int getHeight() const override { return this->windowHeight; };
+	CocoaWindow(const dsr::String& title, int32_t width, int32_t height);
+	int32_t getWidth() const override { return this->windowWidth; };
+	int32_t getHeight() const override { return this->windowHeight; };
 	// Destructor
 	// Destructor
 	~CocoaWindow();
 	~CocoaWindow();
 	// Full-screen
 	// Full-screen
@@ -150,7 +150,7 @@ bool CocoaWindow::setCursorVisibility(bool visible) {
 	return true;
 	return true;
 }
 }
 
 
-bool CocoaWindow::setCursorPosition(int x, int y) {
+bool CocoaWindow::setCursorPosition(int32_t x, int32_t y) {
 	// Get the offset from window pixels to screen pixels.
 	// Get the offset from window pixels to screen pixels.
 	NSWindow *window = [this->view window];
 	NSWindow *window = [this->view window];
 	NSRect viewBounds = [this->view bounds];
 	NSRect viewBounds = [this->view bounds];
@@ -169,7 +169,7 @@ bool CocoaWindow::setCursorPosition(int x, int y) {
 }
 }
 
 
 void CocoaWindow::setFullScreen(bool enabled) {
 void CocoaWindow::setFullScreen(bool enabled) {
-	int newWindowState = enabled ? 2 : 1;
+	int32_t newWindowState = enabled ? 2 : 1;
 	if (newWindowState != this->windowState) {
 	if (newWindowState != this->windowState) {
 		if (enabled) {
 		if (enabled) {
 			// Entering full screen from the start or for an existing window.
 			// Entering full screen from the start or for an existing window.
@@ -192,7 +192,7 @@ void CocoaWindow::updateTitle() {
 	[window setTitle:windowTitle];
 	[window setTitle:windowTitle];
 }
 }
 
 
-CocoaWindow::CocoaWindow(const dsr::String& title, int width, int height) {
+CocoaWindow::CocoaWindow(const dsr::String& title, int32_t width, int32_t height) {
 	if (!applicationInitialized) {
 	if (!applicationInitialized) {
 		application = [NSApplication sharedApplication];
 		application = [NSApplication sharedApplication];
 		[application setActivationPolicy:NSApplicationActivationPolicyRegular];
 		[application setActivationPolicy:NSApplicationActivationPolicyRegular];
@@ -549,8 +549,8 @@ void CocoaWindow::prefetchEvents() {
 
 
 static const dsr::PackOrderIndex MacOSPackOrder = dsr::PackOrderIndex::ABGR;
 static const dsr::PackOrderIndex MacOSPackOrder = dsr::PackOrderIndex::ABGR;
 
 
-void CocoaWindow::resizeCanvas(int width, int height) {
-	for (int b = 0; b < bufferCount; b++) {
+void CocoaWindow::resizeCanvas(int32_t width, int32_t height) {
+	for (int32_t b = 0; b < bufferCount; b++) {
 		if (image_exists(this->canvas[b])) {
 		if (image_exists(this->canvas[b])) {
 			if (image_getWidth(this->canvas[b]) == width && image_getHeight(this->canvas[b]) == height) {
 			if (image_getWidth(this->canvas[b]) == width && image_getHeight(this->canvas[b]) == height) {
 				// The canvas already has the requested resolution.
 				// The canvas already has the requested resolution.
@@ -582,7 +582,7 @@ void CocoaWindow::showCanvas() {
 			this->drawIndex = (this->drawIndex + 1) % bufferCount;
 			this->drawIndex = (this->drawIndex + 1) % bufferCount;
 			this->showIndex = (this->showIndex + 1) % bufferCount;
 			this->showIndex = (this->showIndex + 1) % bufferCount;
 			this->prefetchEvents();
 			this->prefetchEvents();
-			int displayIndex = this->showIndex;
+			int32_t displayIndex = this->showIndex;
 			if (this->view != nullptr) {
 			if (this->view != nullptr) {
 				// Get image dimensions.
 				// Get image dimensions.
 				int32_t width = dsr::image_getWidth(this->canvas[displayIndex]);
 				int32_t width = dsr::image_getWidth(this->canvas[displayIndex]);
@@ -606,6 +606,6 @@ void CocoaWindow::showCanvas() {
 	}
 	}
 }
 }
 
 
-dsr::Handle<dsr::BackendWindow> createBackendWindow(const dsr::String& title, int width, int height) {
+dsr::Handle<dsr::BackendWindow> createBackendWindow(const dsr::String& title, int32_t width, int32_t height) {
 	return dsr::handle_create<CocoaWindow>(title, width, height);
 	return dsr::handle_create<CocoaWindow>(title, width, height);
 }
 }

+ 1 - 1
Source/windowManagers/NoWindow.cpp

@@ -3,7 +3,7 @@
 #include "../DFPSR/implementation/gui/BackendWindow.h"
 #include "../DFPSR/implementation/gui/BackendWindow.h"
 #include "../DFPSR/api/stringAPI.h"
 #include "../DFPSR/api/stringAPI.h"
 
 
-dsr::Handle<dsr::BackendWindow> createBackendWindow(const dsr::String& title, int width, int height) {
+dsr::Handle<dsr::BackendWindow> createBackendWindow(const dsr::String& title, int32_t width, int32_t height) {
 	dsr::sendWarning("Tried to create a DsrWindow without a window manager selected!\n");
 	dsr::sendWarning("Tried to create a DsrWindow without a window manager selected!\n");
 	return dsr::Handle<dsr::BackendWindow>();
 	return dsr::Handle<dsr::BackendWindow>();
 }
 }

+ 27 - 27
Source/windowManagers/Win32Window.cpp

@@ -31,7 +31,7 @@ Link to these dependencies for MS Windows:
 	inline void unlockWindow() {}
 	inline void unlockWindow() {}
 #endif
 #endif
 
 
-static const int bufferCount = 2;
+static const int32_t bufferCount = 2;
 
 
 class Win32Window : public dsr::BackendWindow {
 class Win32Window : public dsr::BackendWindow {
 public:
 public:
@@ -47,8 +47,8 @@ public:
 
 
 	// Double buffering to allow drawing to a canvas while displaying the previous one
 	// Double buffering to allow drawing to a canvas while displaying the previous one
 	dsr::AlignedImageRgbaU8 canvas[bufferCount];
 	dsr::AlignedImageRgbaU8 canvas[bufferCount];
-	int drawIndex = 0 % bufferCount;
-	int showIndex = 1 % bufferCount;
+	int32_t drawIndex = 0 % bufferCount;
+	int32_t showIndex = 1 % bufferCount;
 	bool firstFrame = true;
 	bool firstFrame = true;
 
 
 	#ifndef DISABLE_MULTI_THREADING
 	#ifndef DISABLE_MULTI_THREADING
@@ -58,7 +58,7 @@ public:
 
 
 	// Remembers the dimensions of the window from creation and resize events
 	// Remembers the dimensions of the window from creation and resize events
 	//   This allow requesting the size of the window at any time
 	//   This allow requesting the size of the window at any time
-	int windowWidth = 0, windowHeight = 0;
+	int32_t windowWidth = 0, windowHeight = 0;
 private:
 private:
 	// Called before the application fetches events from the input queue
 	// Called before the application fetches events from the input queue
 	//   Closing the window, moving the mouse, pressing a key, et cetera
 	//   Closing the window, moving the mouse, pressing a key, et cetera
@@ -69,30 +69,30 @@ private:
 	bool setCursorVisibility(bool visible) override;
 	bool setCursorVisibility(bool visible) override;
 
 
 	// Place the cursor within the window
 	// Place the cursor within the window
-	bool setCursorPosition(int x, int y) override;
+	bool setCursorPosition(int32_t x, int32_t y) override;
 private:
 private:
 	// Helper methods specific to calling XLib
 	// Helper methods specific to calling XLib
 	void updateTitle_locked();
 	void updateTitle_locked();
 private:
 private:
 	// Canvas methods
 	// Canvas methods
 	dsr::AlignedImageRgbaU8 getCanvas() override { return this->canvas[this->drawIndex]; }
 	dsr::AlignedImageRgbaU8 getCanvas() override { return this->canvas[this->drawIndex]; }
-	void resizeCanvas(int width, int height) override;
+	void resizeCanvas(int32_t width, int32_t height) override;
 	// Window methods
 	// Window methods
 	void setTitle(const dsr::String &newTitle) override {
 	void setTitle(const dsr::String &newTitle) override {
 		this->title = newTitle;
 		this->title = newTitle;
 		this->updateTitle_locked();
 		this->updateTitle_locked();
 	}
 	}
 	void removeOldWindow_locked();
 	void removeOldWindow_locked();
-	void createWindowed_locked(const dsr::String& title, int width, int height);
+	void createWindowed_locked(const dsr::String& title, int32_t width, int32_t height);
 	void createFullscreen_locked();
 	void createFullscreen_locked();
 	void prepareWindow_locked();
 	void prepareWindow_locked();
-	int windowState = 0; // 0=none, 1=windowed, 2=fullscreen
+	int32_t windowState = 0; // 0=none, 1=windowed, 2=fullscreen
 public:
 public:
 	// Constructors
 	// Constructors
 	Win32Window(const Win32Window&) = delete; // Non-copyable because of pointer aliasing.
 	Win32Window(const Win32Window&) = delete; // Non-copyable because of pointer aliasing.
-	Win32Window(const dsr::String& title, int width, int height);
-	int getWidth() const override { return this->windowWidth; };
-	int getHeight() const override { return this->windowHeight; };
+	Win32Window(const dsr::String& title, int32_t width, int32_t height);
+	int32_t getWidth() const override { return this->windowWidth; };
+	int32_t getHeight() const override { return this->windowHeight; };
 	// Destructor
 	// Destructor
 	~Win32Window();
 	~Win32Window();
 	// Interface
 	// Interface
@@ -169,7 +169,7 @@ void Win32Window::updateTitle_locked() {
 }
 }
 
 
 // The method can be seen as locked, but it overrides a virtual method that is independent of threading.
 // The method can be seen as locked, but it overrides a virtual method that is independent of threading.
-bool Win32Window::setCursorPosition(int x, int y) {
+bool Win32Window::setCursorPosition(int32_t x, int32_t y) {
 	lockWindow();
 	lockWindow();
 		POINT point; point.x = x; point.y = y;
 		POINT point; point.x = x; point.y = y;
 		ClientToScreen(this->hwnd, &point);
 		ClientToScreen(this->hwnd, &point);
@@ -252,7 +252,7 @@ static void registerIfNeeded() {
 	}
 	}
 }
 }
 
 
-void Win32Window::createWindowed_locked(const dsr::String& title, int width, int height) {
+void Win32Window::createWindowed_locked(const dsr::String& title, int32_t width, int32_t height) {
 	// Request to resize the canvas and interface according to the new window
 	// Request to resize the canvas and interface according to the new window
 	this->windowWidth = width;
 	this->windowWidth = width;
 	this->windowHeight = height;
 	this->windowHeight = height;
@@ -287,8 +287,8 @@ void Win32Window::createWindowed_locked(const dsr::String& title, int width, int
 
 
 void Win32Window::createFullscreen_locked() {
 void Win32Window::createFullscreen_locked() {
 	lockWindow();
 	lockWindow();
-		int screenWidth = GetSystemMetrics(SM_CXSCREEN);
-		int screenHeight = GetSystemMetrics(SM_CYSCREEN);
+		int32_t screenWidth = GetSystemMetrics(SM_CXSCREEN);
+		int32_t screenHeight = GetSystemMetrics(SM_CYSCREEN);
 
 
 		// Request to resize the canvas and interface according to the new window
 		// Request to resize the canvas and interface according to the new window
 		this->windowWidth = screenWidth;
 		this->windowWidth = screenWidth;
@@ -319,7 +319,7 @@ void Win32Window::createFullscreen_locked() {
 	this->prepareWindow_locked();
 	this->prepareWindow_locked();
 }
 }
 
 
-Win32Window::Win32Window(const dsr::String& title, int width, int height) {
+Win32Window::Win32Window(const dsr::String& title, int32_t width, int32_t height) {
 	bool fullScreen = false;
 	bool fullScreen = false;
 	if (width < 1 || height < 1) {
 	if (width < 1 || height < 1) {
 		fullScreen = true;
 		fullScreen = true;
@@ -519,7 +519,7 @@ static LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam,
 	}
 	}
 	// Check that we're using the correct window instance (This might not be the case while toggling full-screen)
 	// Check that we're using the correct window instance (This might not be the case while toggling full-screen)
 	// Handle the message
 	// Handle the message
-	int result = 0;
+	int32_t result = 0;
 	switch (message) {
 	switch (message) {
 	case WM_QUIT:
 	case WM_QUIT:
 		PostQuitMessage(wParam);
 		PostQuitMessage(wParam);
@@ -560,7 +560,7 @@ static LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam,
 		break;
 		break;
 	case WM_MOUSEWHEEL:
 	case WM_MOUSEWHEEL:
 		{
 		{
-			int delta = GET_WHEEL_DELTA_WPARAM(wParam);
+			int32_t delta = GET_WHEEL_DELTA_WPARAM(wParam);
 			if (delta > 0) {
 			if (delta > 0) {
 				parent->receivedMouseEvent(dsr::MouseEventType::Scroll, dsr::MouseKeyEnum::ScrollUp, parent->lastMousePos);
 				parent->receivedMouseEvent(dsr::MouseEventType::Scroll, dsr::MouseKeyEnum::ScrollUp, parent->lastMousePos);
 			} else if (delta < 0) {
 			} else if (delta < 0) {
@@ -604,8 +604,8 @@ static LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam,
 	case WM_SIZE:
 	case WM_SIZE:
 		// If there's no size during minimization, don't try to resize the canvas
 		// If there's no size during minimization, don't try to resize the canvas
 		if (wParam != SIZE_MINIMIZED) {
 		if (wParam != SIZE_MINIMIZED) {
-			int width = LOWORD(lParam);
-			int height = HIWORD(lParam);
+			int32_t width = LOWORD(lParam);
+			int32_t height = HIWORD(lParam);
 			parent->windowWidth = width;
 			parent->windowWidth = width;
 			parent->windowHeight = height;
 			parent->windowHeight = height;
 			parent->receivedWindowResize(width, height);
 			parent->receivedWindowResize(width, height);
@@ -637,10 +637,10 @@ void Win32Window::prefetchEvents() {
 }
 }
 
 
 // Locked because it overrides
 // Locked because it overrides
-void Win32Window::resizeCanvas(int width, int height) {
+void Win32Window::resizeCanvas(int32_t width, int32_t height) {
 	// Create a new canvas
 	// Create a new canvas
 	//   Even thou Windows is using RGBA pack order for the window, the bitmap format used for drawing is using BGRA order
 	//   Even thou Windows is using RGBA pack order for the window, the bitmap format used for drawing is using BGRA order
-	for (int bufferIndex = 0; bufferIndex < bufferCount; bufferIndex++) {
+	for (int32_t bufferIndex = 0; bufferIndex < bufferCount; bufferIndex++) {
 		dsr::AlignedImageRgbaU8 previousCanvas = this->canvas[bufferIndex];
 		dsr::AlignedImageRgbaU8 previousCanvas = this->canvas[bufferIndex];
 		this->canvas[bufferIndex] = dsr::image_create_RgbaU8_native(width, height, dsr::PackOrderIndex::BGRA);
 		this->canvas[bufferIndex] = dsr::image_create_RgbaU8_native(width, height, dsr::PackOrderIndex::BGRA);
 		if (image_exists(previousCanvas)) {
 		if (image_exists(previousCanvas)) {
@@ -686,13 +686,13 @@ void Win32Window::redraw(HWND& hwnd, bool lock, bool swap) {
 		this->showIndex = (this->showIndex + 1) % bufferCount;
 		this->showIndex = (this->showIndex + 1) % bufferCount;
 	}
 	}
 	this->prefetchEvents();
 	this->prefetchEvents();
-	int displayIndex = this->showIndex;
+	int32_t displayIndex = this->showIndex;
 	std::function<void()> task = [this, displayIndex, lock]() {
 	std::function<void()> task = [this, displayIndex, lock]() {
 		// Let the source bitmap use a padded width to safely handle the stride
 		// Let the source bitmap use a padded width to safely handle the stride
 		// Windows requires 8-byte alignment, but the image format uses larger alignment.
 		// Windows requires 8-byte alignment, but the image format uses larger alignment.
-		int paddedWidth = dsr::image_getStride(this->canvas[displayIndex]) / 4;
-		//int width = dsr::image_getWidth(this->canvas[displayIndex]);
-		int height = dsr::image_getHeight(this->canvas[displayIndex]);
+		int32_t paddedWidth = dsr::image_getStride(this->canvas[displayIndex]) / 4;
+		//int32_t width = dsr::image_getWidth(this->canvas[displayIndex]);
+		int32_t height = dsr::image_getHeight(this->canvas[displayIndex]);
 		InvalidateRect(this->hwnd, NULL, false);
 		InvalidateRect(this->hwnd, NULL, false);
 		PAINTSTRUCT paintStruct;
 		PAINTSTRUCT paintStruct;
 		HDC targetContext = BeginPaint(this->hwnd, &paintStruct);
 		HDC targetContext = BeginPaint(this->hwnd, &paintStruct);
@@ -733,6 +733,6 @@ void Win32Window::showCanvas() {
 	this->redraw(this->hwnd, true, true);
 	this->redraw(this->hwnd, true, true);
 }
 }
 
 
-dsr::Handle<dsr::BackendWindow> createBackendWindow(const dsr::String& title, int width, int height) {
+dsr::Handle<dsr::BackendWindow> createBackendWindow(const dsr::String& title, int32_t width, int32_t height) {
 	return dsr::handle_create<Win32Window>(title, width, height);
 	return dsr::handle_create<Win32Window>(title, width, height);
 }
 }

+ 31 - 31
Source/windowManagers/X11Window.cpp

@@ -28,7 +28,7 @@
 	inline void unlockWindow() {}
 	inline void unlockWindow() {}
 #endif
 #endif
 
 
-static const int bufferCount = 2;
+static const int32_t bufferCount = 2;
 
 
 class X11Window : public dsr::BackendWindow {
 class X11Window : public dsr::BackendWindow {
 private:
 private:
@@ -48,8 +48,8 @@ private:
 	dsr::AlignedImageRgbaU8 canvas[bufferCount];
 	dsr::AlignedImageRgbaU8 canvas[bufferCount];
 	// An X11 image wrapped around the canvas pixel data
 	// An X11 image wrapped around the canvas pixel data
 	XImage *canvasX[bufferCount] = {};
 	XImage *canvasX[bufferCount] = {};
-	int drawIndex = 0 % bufferCount;
-	int showIndex = 1 % bufferCount;
+	int32_t drawIndex = 0 % bufferCount;
+	int32_t showIndex = 1 % bufferCount;
 	bool firstFrame = true;
 	bool firstFrame = true;
 
 
 	#ifndef DISABLE_MULTI_THREADING
 	#ifndef DISABLE_MULTI_THREADING
@@ -59,7 +59,7 @@ private:
 
 
 	// Remembers the dimensions of the window from creation and resize events
 	// Remembers the dimensions of the window from creation and resize events
 	//   This allow requesting the size of the window at any time
 	//   This allow requesting the size of the window at any time
-	int windowWidth = 0, windowHeight = 0;
+	int32_t windowWidth = 0, windowHeight = 0;
 
 
 	// Called before the application fetches events from the input queue
 	// Called before the application fetches events from the input queue
 	//   Closing the window, moving the mouse, pressing a key, et cetera
 	//   Closing the window, moving the mouse, pressing a key, et cetera
@@ -70,7 +70,7 @@ private:
 	bool setCursorVisibility(bool visible) override;
 	bool setCursorVisibility(bool visible) override;
 
 
 	// Place the cursor within the window
 	// Place the cursor within the window
-	bool setCursorPosition(int x, int y) override;
+	bool setCursorPosition(int32_t x, int32_t y) override;
 
 
 	// Color format
 	// Color format
 	dsr::PackOrderIndex packOrderIndex = dsr::PackOrderIndex::RGBA;
 	dsr::PackOrderIndex packOrderIndex = dsr::PackOrderIndex::RGBA;
@@ -81,24 +81,24 @@ private:
 private:
 private:
 	// Canvas methods
 	// Canvas methods
 	dsr::AlignedImageRgbaU8 getCanvas() override { return this->canvas[this->drawIndex]; }
 	dsr::AlignedImageRgbaU8 getCanvas() override { return this->canvas[this->drawIndex]; }
-	void resizeCanvas(int width, int height) override;
+	void resizeCanvas(int32_t width, int32_t height) override;
 	// Window methods
 	// Window methods
 	void setTitle(const dsr::String &newTitle) override {
 	void setTitle(const dsr::String &newTitle) override {
 		this->title = newTitle;
 		this->title = newTitle;
 		this->updateTitle_locked();
 		this->updateTitle_locked();
 	}
 	}
 	void removeOldWindow_locked();
 	void removeOldWindow_locked();
-	void createGCWindow_locked(const dsr::String& title, int width, int height);
-	void createWindowed_locked(const dsr::String& title, int width, int height);
+	void createGCWindow_locked(const dsr::String& title, int32_t width, int32_t height);
+	void createWindowed_locked(const dsr::String& title, int32_t width, int32_t height);
 	void createFullscreen_locked();
 	void createFullscreen_locked();
 	void prepareWindow_locked();
 	void prepareWindow_locked();
-	int windowState = 0; // 0=none, 1=windowed, 2=fullscreen
+	int32_t windowState = 0; // 0=none, 1=windowed, 2=fullscreen
 public:
 public:
 	// Constructors
 	// Constructors
 	X11Window(const X11Window&) = delete; // Non-copyable because of pointer aliasing.
 	X11Window(const X11Window&) = delete; // Non-copyable because of pointer aliasing.
-	X11Window(const dsr::String& title, int width, int height);
-	int getWidth() const override { return this->windowWidth; };
-	int getHeight() const override { return this->windowHeight; };
+	X11Window(const dsr::String& title, int32_t width, int32_t height);
+	int32_t getWidth() const override { return this->windowWidth; };
+	int32_t getHeight() const override { return this->windowHeight; };
 	// Destructor
 	// Destructor
 	~X11Window();
 	~X11Window();
 	// Full-screen
 	// Full-screen
@@ -153,7 +153,7 @@ void X11Window::saveToClipboard(const dsr::ReadableString &text, double timeoutI
 	this->listContentInClipboard();
 	this->listContentInClipboard();
 }
 }
 
 
-bool X11Window::setCursorPosition(int x, int y) {
+bool X11Window::setCursorPosition(int32_t x, int32_t y) {
 	lockWindow();
 	lockWindow();
 		XWarpPointer(this->display, this->window, this->window, 0, 0, this->windowWidth, this->windowHeight, x, y);
 		XWarpPointer(this->display, this->window, this->window, 0, 0, this->windowWidth, this->windowHeight, x, y);
 	unlockWindow();
 	unlockWindow();
@@ -193,11 +193,11 @@ dsr::PackOrderIndex X11Window::getColorFormat_locked() {
 		visualRequest.screen = 0;
 		visualRequest.screen = 0;
 		visualRequest.depth = 32;
 		visualRequest.depth = 32;
 		visualRequest.c_class = TrueColor;
 		visualRequest.c_class = TrueColor;
-		int visualCount;
+		int32_t visualCount;
 		dsr::PackOrderIndex result = dsr::PackOrderIndex::RGBA;
 		dsr::PackOrderIndex result = dsr::PackOrderIndex::RGBA;
 		XVisualInfo *formatList = XGetVisualInfo(this->display, VisualScreenMask | VisualDepthMask | VisualClassMask, &visualRequest, &visualCount);
 		XVisualInfo *formatList = XGetVisualInfo(this->display, VisualScreenMask | VisualDepthMask | VisualClassMask, &visualRequest, &visualCount);
 		if (formatList != nullptr) {
 		if (formatList != nullptr) {
-			for (int i = 0; i < visualCount; i++) {
+			for (int32_t i = 0; i < visualCount; i++) {
 				if (formatList[i].bits_per_rgb == 8) {
 				if (formatList[i].bits_per_rgb == 8) {
 					const uint32_t red = formatList[i].red_mask;
 					const uint32_t red = formatList[i].red_mask;
 					const uint32_t green = formatList[i].green_mask;
 					const uint32_t green = formatList[i].green_mask;
@@ -225,7 +225,7 @@ dsr::PackOrderIndex X11Window::getColorFormat_locked() {
 			visualRequest.depth = 24;
 			visualRequest.depth = 24;
 			XVisualInfo *formatList = XGetVisualInfo(this->display, VisualScreenMask | VisualDepthMask | VisualClassMask, &visualRequest, &visualCount);
 			XVisualInfo *formatList = XGetVisualInfo(this->display, VisualScreenMask | VisualDepthMask | VisualClassMask, &visualRequest, &visualCount);
 			if (formatList != nullptr) {
 			if (formatList != nullptr) {
-				for (int i = 0; i < visualCount; i++) {
+				for (int32_t i = 0; i < visualCount; i++) {
 					if (formatList[i].bits_per_rgb == 8) {
 					if (formatList[i].bits_per_rgb == 8) {
 						const uint32_t red = formatList[i].red_mask;
 						const uint32_t red = formatList[i].red_mask;
 						const uint32_t green = formatList[i].green_mask;
 						const uint32_t green = formatList[i].green_mask;
@@ -307,13 +307,13 @@ void X11Window::prepareWindow_locked() {
 	this->resizeCanvas(this->windowWidth, this->windowHeight);
 	this->resizeCanvas(this->windowWidth, this->windowHeight);
 }
 }
 
 
-void X11Window::createGCWindow_locked(const dsr::String& title, int width, int height) {
+void X11Window::createGCWindow_locked(const dsr::String& title, int32_t width, int32_t height) {
 	lockWindow();
 	lockWindow();
 		// Request to resize the canvas and interface according to the new window
 		// Request to resize the canvas and interface according to the new window
 		this->windowWidth = width;
 		this->windowWidth = width;
 		this->windowHeight = height;
 		this->windowHeight = height;
 		this->receivedWindowResize(width, height);
 		this->receivedWindowResize(width, height);
-		int screenIndex = DefaultScreen(this->display);
+		int32_t screenIndex = DefaultScreen(this->display);
 		unsigned long black = BlackPixel(this->display, screenIndex);
 		unsigned long black = BlackPixel(this->display, screenIndex);
 		unsigned long white = WhitePixel(this->display, screenIndex);
 		unsigned long white = WhitePixel(this->display, screenIndex);
 		// Create a new window
 		// Create a new window
@@ -331,7 +331,7 @@ void X11Window::createGCWindow_locked(const dsr::String& title, int width, int h
 	unlockWindow();
 	unlockWindow();
 }
 }
 
 
-void X11Window::createWindowed_locked(const dsr::String& title, int width, int height) {
+void X11Window::createWindowed_locked(const dsr::String& title, int32_t width, int32_t height) {
 	// Create the window
 	// Create the window
 	this->createGCWindow_locked(title, width, height);
 	this->createGCWindow_locked(title, width, height);
 	lockWindow();
 	lockWindow();
@@ -388,7 +388,7 @@ void X11Window::createFullscreen_locked() {
 	this->prepareWindow_locked();
 	this->prepareWindow_locked();
 }
 }
 
 
-X11Window::X11Window(const dsr::String& title, int width, int height) {
+X11Window::X11Window(const dsr::String& title, int32_t width, int32_t height) {
 	bool fullScreen = false;
 	bool fullScreen = false;
 	if (width < 1 || height < 1) {
 	if (width < 1 || height < 1) {
 		fullScreen = true;
 		fullScreen = true;
@@ -434,7 +434,7 @@ X11Window::X11Window(const dsr::String& title, int width, int height) {
 }
 }
 
 
 // Convert keycodes from XLib to DSR
 // Convert keycodes from XLib to DSR
-static dsr::MouseKeyEnum getMouseKey(int keyCode) {
+static dsr::MouseKeyEnum getMouseKey(int32_t keyCode) {
 	dsr::MouseKeyEnum result = dsr::MouseKeyEnum::NoKey;
 	dsr::MouseKeyEnum result = dsr::MouseKeyEnum::NoKey;
 	if (keyCode == Button1) {
 	if (keyCode == Button1) {
 		result = dsr::MouseKeyEnum::Left;
 		result = dsr::MouseKeyEnum::Left;
@@ -595,7 +595,7 @@ static dsr::DsrKey getDsrKey(KeySym keyCode) {
 }
 }
 
 
 static dsr::DsrChar getCharacterCode(XEvent& event) {
 static dsr::DsrChar getCharacterCode(XEvent& event) {
-	const int buffersize = 8;
+	const int32_t buffersize = 8;
 	KeySym key; char codePoints[buffersize]; dsr::DsrChar character = '\0';
 	KeySym key; char codePoints[buffersize]; dsr::DsrChar character = '\0';
 	if (XLookupString(&event.xkey, codePoints, buffersize, &key, 0) == 1) {
 	if (XLookupString(&event.xkey, codePoints, buffersize, &key, 0) == 1) {
 		// X11 does not specify any encoding, but BOM_UTF16LE seems to work on Linux.
 		// X11 does not specify any encoding, but BOM_UTF16LE seems to work on Linux.
@@ -718,7 +718,7 @@ void X11Window::prefetchEvents() {
 						this->loadingFromClipboard = false;
 						this->loadingFromClipboard = false;
 					} else {
 					} else {
 						Atom actualType;
 						Atom actualType;
-						int actualFormat;
+						int32_t actualFormat;
 						unsigned long bytesAfter;
 						unsigned long bytesAfter;
 						unsigned char* data;
 						unsigned char* data;
 						unsigned long count;
 						unsigned long count;
@@ -753,7 +753,7 @@ void X11Window::prefetchEvents() {
 	}
 	}
 }
 }
 
 
-static int destroyXImage(XImage *image) {
+static int32_t destroyXImage(XImage *image) {
 	if (image != nullptr) {
 	if (image != nullptr) {
 		if (image->data) {
 		if (image->data) {
 			dsr::heap_decreaseUseCount(image->data);
 			dsr::heap_decreaseUseCount(image->data);
@@ -765,13 +765,13 @@ static int destroyXImage(XImage *image) {
 }
 }
 
 
 // Locked because it overrides
 // Locked because it overrides
-void X11Window::resizeCanvas(int width, int height) {
+void X11Window::resizeCanvas(int32_t width, int32_t height) {
 	lockWindow();
 	lockWindow();
 		if (this->display) {
 		if (this->display) {
-			unsigned int defaultDepth = DefaultDepth(this->display, XDefaultScreen(this->display));
+			unsigned int32_t defaultDepth = DefaultDepth(this->display, XDefaultScreen(this->display));
 			// Get the old canvas
 			// Get the old canvas
 			dsr::AlignedImageRgbaU8 oldCanvas = this->canvas[this->showIndex];
 			dsr::AlignedImageRgbaU8 oldCanvas = this->canvas[this->showIndex];
-			for (int b = 0; b < bufferCount; b++) {
+			for (int32_t b = 0; b < bufferCount; b++) {
 				// Create a new canvas
 				// Create a new canvas
 				this->canvas[b] = dsr::image_create_RgbaU8_native(width, height, this->packOrderIndex);
 				this->canvas[b] = dsr::image_create_RgbaU8_native(width, height, this->packOrderIndex);
 				// Copy from any old canvas
 				// Copy from any old canvas
@@ -831,12 +831,12 @@ void X11Window::showCanvas() {
 		this->drawIndex = (this->drawIndex + 1) % bufferCount;
 		this->drawIndex = (this->drawIndex + 1) % bufferCount;
 		this->showIndex = (this->showIndex + 1) % bufferCount;
 		this->showIndex = (this->showIndex + 1) % bufferCount;
 		this->prefetchEvents();
 		this->prefetchEvents();
-		int displayIndex = this->showIndex;
+		int32_t displayIndex = this->showIndex;
 		lockWindow();
 		lockWindow();
 		std::function<void()> task = [this, displayIndex]() {
 		std::function<void()> task = [this, displayIndex]() {
 				// Clamp canvas dimensions to the target window
 				// Clamp canvas dimensions to the target window
-				int width = std::min(dsr::image_getWidth(this->canvas[displayIndex]), this->windowWidth);
-				int height = std::min(dsr::image_getHeight(this->canvas[displayIndex]), this->windowHeight);
+				int32_t width = std::min(dsr::image_getWidth(this->canvas[displayIndex]), this->windowWidth);
+				int32_t height = std::min(dsr::image_getHeight(this->canvas[displayIndex]), this->windowHeight);
 				// Display the result
 				// Display the result
 				XPutImage(this->display, this->window, this->graphicsContext, this->canvasX[displayIndex], 0, 0, 0, 0, width, height);
 				XPutImage(this->display, this->window, this->graphicsContext, this->canvasX[displayIndex], 0, 0, 0, 0, width, height);
 			unlockWindow();
 			unlockWindow();
@@ -861,7 +861,7 @@ void X11Window::showCanvas() {
 	}
 	}
 }
 }
 
 
-dsr::Handle<dsr::BackendWindow> createBackendWindow(const dsr::String& title, int width, int height) {
+dsr::Handle<dsr::BackendWindow> createBackendWindow(const dsr::String& title, int32_t width, int32_t height) {
 	if (XOpenDisplay(nullptr) != nullptr) {
 	if (XOpenDisplay(nullptr) != nullptr) {
 		return dsr::handle_create<X11Window>(title, width, height);
 		return dsr::handle_create<X11Window>(title, width, height);
 	} else {
 	} else {