Explorar o código

Made a header for the dmf 1.0 model importer, to allow building 3D projects with the new build system.

David Piuva %!s(int64=3) %!d(string=hai) anos
pai
achega
710d676e97

+ 1 - 2
Source/DFPSR/api/modelAPI.h

@@ -30,6 +30,7 @@
 // TODO: How should these be exposed to the caller?
 #include "../render/Camera.h"
 #include "../render/ResourcePool.h"
+#include "../render/model/format/dmf1.h"
 
 namespace dsr {
 	// Normalized texture coordinates:
@@ -382,10 +383,8 @@ namespace dsr {
 	//       Remove any textures that are not used by the shaders.
 	//       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.
-	// See renderer/model/format/dmf1.cpp for the implementation. (It does not exist in api/modelAPI.cpp)
 	Model importFromContent_DMF1(const String &fileContent, ResourcePool &pool, int detailLevel = 2);
 
 }
 
 #endif
-

+ 36 - 0
Source/DFPSR/render/model/format/dmf1.h

@@ -0,0 +1,36 @@
+// zlib open source license
+//
+// Copyright (c) 2017 to 2022 David Forsgren Piuva
+// 
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any damages
+// arising from the use of this software.
+// 
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+// 
+//    1. The origin of this software must not be misrepresented; you must not
+//    claim that you wrote the original software. If you use this software
+//    in a product, an acknowledgment in the product documentation would be
+//    appreciated but is not required.
+// 
+//    2. Altered source versions must be plainly marked as such, and must not be
+//    misrepresented as being the original software.
+// 
+//    3. This notice may not be removed or altered from any source
+//    distribution.
+
+#ifndef DFPSR_RENDER_MODEL_IMPORT_DMF1
+#define DFPSR_RENDER_MODEL_IMPORT_DMF1
+
+#include "../../ResourcePool.h"
+#include "../../../api/stringAPI.h"
+
+namespace dsr {
+
+Model importFromContent_DMF1(const String &fileContent, ResourcePool &pool, int detailLevel);
+
+}
+
+#endif

+ 6 - 0
Source/SDK/cube/build_linux.sh

@@ -0,0 +1,6 @@
+#!/bin/bash
+
+# Launch the build system with main.DsrProj and Linux selected as the platform.
+echo "Running build_linux.sh $@"
+chmod +x ../../tools/builder/buildProject.sh;
+../../tools/builder/buildProject.sh main.DsrProj Linux $@;

+ 7 - 0
Source/SDK/cube/build_windows.bat

@@ -0,0 +1,7 @@
+@echo off
+
+rem Launch the build system with main.DsrProj and Windows selected as the platform.
+
+echo "Running build_windows.bat %@%
+
+../../tools/builder/buildProject.bat main.DsrProj Windows %@%

+ 9 - 0
Source/SDK/cube/main.DsrProj

@@ -0,0 +1,9 @@
+CompilerFlag "-std=c++14"
+Graphics
+Sound
+Crawl "main.cpp"
+Import "../../DFPSR/DFPSR.DsrHead"
+ProgramPath = "application"
+
+# Uncomment to enable debug mode, which is slower
+#Debug

+ 26 - 6
Source/tools/builder/generator.cpp

@@ -32,6 +32,12 @@ static uint64_t checksum(const Buffer& buffer) {
 	return d;
 }
 
+enum class ScriptLanguage {
+	Unknown,
+	Batch,
+	Bash
+};
+
 struct Connection {
 	String path;
 	int64_t lineNumber = -1;
@@ -327,7 +333,6 @@ void generateCompilationScript(const Machine &settings, const ReadableString& pr
 	} else {
 		printText(U"Using ", compilerName, " as the compiler from the current directory.\n");
 	}
-
 	// Convert lists of linker and compiler flags into strings.
 	// TODO: Give a warning if two contradictory flags are used, such as optimization levels and language versions.
 	// TODO: Make sure that no spaces are inside of the flags, because that can mess up detection of pre-existing and contradictory arguments.
@@ -335,14 +340,29 @@ void generateCompilationScript(const Machine &settings, const ReadableString& pr
 	for (int i = 0; i < settings.compilerFlags.length(); i++) {
 		string_append(compilerFlags, " ", settings.compilerFlags[i]);
 	}
+	// TODO: Warn if -DNDEBUG, -DDEBUG, or optimization levels are given directly.
+	//       Using the variables instead is both more flexible by accepting input arguments
+	//       and keeping the same format to better reuse compiled objects.
+	ReadableString debugMode = getFlag(settings, U"Debug", U"0");
+	if (string_match(debugMode, U"0")) {
+		printText(U"Building with release mode.\n");
+		string_append(compilerFlags, " -DNDEBUG");
+	} else {
+		printText(U"Building with debug mode.\n");
+		string_append(compilerFlags, " -DDEBUG");
+	}
+	ReadableString optimizationLevel = getFlag(settings, U"Optimization", U"2");
+		printText(U"Building with optimization level ", optimizationLevel, U".\n");
+	string_append(compilerFlags, " -O", optimizationLevel);
+
 	String linkerFlags;
 	for (int i = 0; i < settings.linkerFlags.length(); i++) {
 		string_append(linkerFlags, " -l", settings.linkerFlags[i]);
 	}
 
 	// Interpret ProgramPath relative to the project path.
-	ReadableString binaryPath = getFlag(settings, U"ProgramPath", language == ScriptLanguage::Batch ? U"program.exe" : U"program");
-	binaryPath = file_getTheoreticalAbsolutePath(binaryPath, projectPath);
+	ReadableString programPath = getFlag(settings, U"ProgramPath", language == ScriptLanguage::Batch ? U"program.exe" : U"program");
+	programPath = file_getTheoreticalAbsolutePath(programPath, projectPath);
 
 	String output;
 	if (language == ScriptLanguage::Batch) {
@@ -407,7 +427,7 @@ void generateCompilationScript(const Machine &settings, const ReadableString& pr
 			string_append(allObjects, U" ", sourceObjects[i].objectPath);
 		}
 		script_printMessage(output, language, string_combine(U"Linking with ", linkerFlags, U"."));
-		string_append(output, compilerName, allObjects, linkerFlags, U" -o ", binaryPath, U"\n");
+		string_append(output, compilerName, allObjects, linkerFlags, U" -o ", programPath, U"\n");
 		if (changePath) {
 			// Get back to the previous folder.
 			if (language == ScriptLanguage::Batch) {
@@ -417,8 +437,8 @@ void generateCompilationScript(const Machine &settings, const ReadableString& pr
 			}
 		}
 		script_printMessage(output, language, U"Done compiling.");
-		script_printMessage(output, language, string_combine(U"Starting ", binaryPath));
-		script_executeLocalBinary(output, language, binaryPath);
+		script_printMessage(output, language, string_combine(U"Starting ", programPath));
+		script_executeLocalBinary(output, language, programPath);
 		script_printMessage(output, language, U"The program terminated.");
 		if (language == ScriptLanguage::Batch) {
 			// Windows might close the window before you have time to read the results or error messages of a CLI application, so pause at the end.

+ 9 - 5
Source/tools/builder/generator.h

@@ -16,11 +16,15 @@ void resolveDependencies();
 void printDependencies();
 
 // Generate
-enum class ScriptLanguage {
-	Unknown,
-	Batch,
-	Bash
-};
+/*
+Setting variables:
+	* ScriptPath, a path to the script to be generated and saved. The extension of the filename decides which type of code to generate.
+	* Compiler, a path or global alias to the compiler.
+	* CompileFrom, from which path should the compiler be executed? Leave empty to use the current directory.
+	* Debug, 0 for release, anything else (usually 1) for debug.
+	* Optimization, a natural integer specifying the amount of optimization to apply.
+	* ProgramPath, a path to the application to create.
+*/
 void generateCompilationScript(const Machine &settings, const ReadableString& projectPath);
 
 #endif

+ 3 - 0
Source/tools/wizard/main.DsrProj

@@ -19,6 +19,9 @@ Crawl "main.cpp"
 # Enable if you want to see which includes and connected names are used to find source code.
 #ListDependencies
 
+# Enable to compile a debug version
+# Debug
+
 # Extensionless path to the generated binary for this project.
 # Will automatically be named on each operating system.
 ProgramPath = "wizard"