Browse Source

Using the application's path to launch the Sandbox example from a different path.

David Piuva 3 năm trước cách đây
mục cha
commit
cb1c9ba27c
2 tập tin đã thay đổi với 10 bổ sung9 xóa
  1. 5 4
      Source/SDK/SpriteEngine/spriteAPI.cpp
  2. 5 5
      Source/SDK/sandbox/sandbox.cpp

+ 5 - 4
Source/SDK/SpriteEngine/spriteAPI.cpp

@@ -6,6 +6,7 @@
 #include "../../DFPSR/render/ITriangle2D.h"
 #include "../../DFPSR/base/endian.h"
 #include "../../DFPSR/math/scalar.h"
+#include "../../DFPSR/api/fileAPI.h"
 
 // Comment out a flag to disable an optimization when debugging
 #define DIRTY_RECTANGLE_OPTIMIZATION
@@ -191,9 +192,9 @@ public:
 	// folderPath should end with a path separator
 	SpriteType(const String& folderPath, const String& name) : name(name) {
 		// Load the image atlas
-		ImageRgbaU8 loadedAtlas = image_load_RgbaU8(string_combine(folderPath, name, U".png"));
+		ImageRgbaU8 loadedAtlas = image_load_RgbaU8(string_combine(file_combinePaths(folderPath, name), U".png"));
 		// Load the settings
-		const SpriteConfig configuration = SpriteConfig(string_load(string_combine(folderPath, name, U".ini")));
+		const SpriteConfig configuration = SpriteConfig(string_load(string_combine(file_combinePaths(folderPath, name), U".ini")));
 		this->minBoundMini = IVector3D(
 		  floor(configuration.minBound.x * ortho_miniUnitsPerTile),
 		  floor(configuration.minBound.y * ortho_miniUnitsPerTile),
@@ -272,8 +273,8 @@ public:
 		} else {
 			name = visibleModelName;
 		}
-		this->visibleModel = DenseModel_create(importer_loadModel(folderPath + visibleModelName, true, Transform3D()));
-		this->shadowModel = importer_loadModel(folderPath + shadowModelName, true, Transform3D());
+		this->visibleModel = DenseModel_create(importer_loadModel(file_combinePaths(folderPath, visibleModelName), true, Transform3D()));
+		this->shadowModel = importer_loadModel(file_combinePaths(folderPath, shadowModelName), true, Transform3D());
 	}
 	ModelType(const DenseModel& visibleModel, const Model& shadowModel)
 	: visibleModel(visibleModel), shadowModel(shadowModel) {}

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

@@ -101,9 +101,9 @@ LATER:
 
 using namespace dsr;
 
-static const String mediaPath = string_combine(U"media", file_separator());
-static const String imagePath = string_combine(mediaPath, U"images", file_separator());
-static const String modelPath = string_combine(mediaPath, U"models", file_separator());
+static const String mediaPath = file_combinePaths(file_getApplicationFolder(), U"media");
+static const String imagePath = file_combinePaths(mediaPath, U"images");
+static const String modelPath = file_combinePaths(mediaPath, U"models");
 
 // Variables
 static bool running = true;
@@ -169,7 +169,7 @@ void loadModel(const ReadableString& name, const ReadableString& visibleName, co
 
 void sandbox_main() {
 	// Create the world
-	world = spriteWorld_create(OrthoSystem(string_load(string_combine(mediaPath, U"Ortho.ini"))), 256);
+	world = spriteWorld_create(OrthoSystem(string_load(file_combinePaths(mediaPath, U"Ortho.ini"))), 256);
 
 	// Create a window
 	String title = U"David Piuva's Software Renderer - Graphics sandbox";
@@ -177,7 +177,7 @@ void sandbox_main() {
 	//window = window_create_fullscreen(title);
 
 	// Load an interface to the window
-	window_loadInterfaceFromFile(window, mediaPath + U"interface.lof");
+	window_loadInterfaceFromFile(window, file_combinePaths(mediaPath, U"interface.lof"));
 
 	// Tell the application to terminate when the window is closed
 	window_setCloseEvent(window, []() {