Browse Source

Removed old build files from templates, because the newer system is easier to explain.
Made an SDK explorer as a first feature of the Wizard application, but launching anything is still not implemented and it needs a custom GUI theme.

David Piuva 3 years ago
parent
commit
3e3143d62d

+ 1 - 0
Source/SDK/cube/Description.txt

@@ -0,0 +1 @@
+SDK example of how to get started with 3D rendering. This fixed function rendering is not so fast nor powerful as custom rendering pipelines, but it's useful as a reference while implementing your own rendering techniques for custom geometry formats such as voxels or heightmaps.

BIN
Source/SDK/cube/Preview.gif


+ 1 - 0
Source/SDK/fileFinder/Description.txt

@@ -0,0 +1 @@
+SDK example of how to traverse the filesystem.

BIN
Source/SDK/fileFinder/Preview.gif


+ 1 - 0
Source/SDK/guiExample/Description.txt

@@ -0,0 +1 @@
+SDK example of how to create and interact with visual components in a window. It's just throwing in as many different components as possible without cluttering with any real functionality.

BIN
Source/SDK/guiExample/Preview.jpg


+ 1 - 0
Source/SDK/sandbox/Description.txt

@@ -0,0 +1 @@
+SDK example of how to render isometric graphics using dynamic light. Uses Source/SDK/SpriteEngine as a graphics engine on top of depth buffered draw calls in the DFPSR library.

BIN
Source/SDK/sandbox/Preview.jpg


+ 1 - 0
Source/SDK/terrain/Description.txt

@@ -0,0 +1 @@
+SDK example of how to generate bump mapping and make models look more detailed than their actual polygon count by generating an original height field of a higher resolution, calculating normals and using a limited dot product to get the light without any shadows.

BIN
Source/SDK/terrain/Preview.jpg


+ 28 - 8
Source/templates/Readme.txt

@@ -1,8 +1,28 @@
-To get started with your own project:
-* Copy one of these folders into a location with stable relative access to the DFPSR library.
-  You can also place DFPSR in a standard path and refer to it using absolute paths.
-* Change #include "../../DFPSR/includeFramework.h" in main.cpp to find the header from the new location.
-* Change ROOT_PATH=../.. the same way in build.sh or just delete the whole build script if you're not going to use it.
-* Give execution permission using chmod +x build.sh. (if using Linux)
-* Build and run your new application. (./build.sh if using Linux)
-
+To get started with your own project:
+* Copy one of these folders into a location with stable relative access to the DFPSR library.
+	You can also place DFPSR in a standard path, refer to it using absolute paths and always have your code in the same location.
+	On Linux, you can also place a symbolic link right next to your projects and use relative paths using the symbolic link as a folder name.
+* Change #include "../../DFPSR/includeFramework.h" in main.cpp to find the header from the new location.
+* Change path for tools/builder/buildProject.sh in build_linux.sh, and tools/builder/buildProject.bat in build_windows.bat,
+	so that they give your project file to the build system.
+* Change path for DFPSR/DFPSR.DsrHead in main.DsrProj if imported in your project.
+
+Build on Linux:
+* Give execution permission using:
+	chmod +x build_linux.sh
+* Build using:
+	./build_linux.sh
+"./" for the relative path is needed to distinguish the path from global aliases for the first argument, but not needed when given as input to a program.
+
+Build on Windows:
+* Install the MinGW edition of CodeBlocks.
+	Both to get an IDE that can be used for debugging, and because it's the easiest way to install a GNU compiler on MS-Windows.
+* Update CPP_COMPILER_PATH and CPP_COMPILER_FOLDER to reference where your C++ compiler is located.
+	If you installed CodeBlocks in C:\Program, it might work without any changes.
+	CPP_COMPILER_PATH is the absolute path to the specific compiler's binary.
+	CPP_COMPILER_FOLDER is the folder to launch the compiler from.
+	Any dynamic dependency being used by the compiler that is not registered (regsvr32 if it's self registering),
+	will be loaded from the current directory and not the compiler's own folder (since Windows XP).
+	Therefore the build system will temporarily enter the folder specified by CPP_COMPILER_FOLDER as the CompileFrom flag,
+	so that the compiler's dependencies can be loaded from the compiler's own folder where DLL files are usually stored.
+* Double click on buildProject.bat to build and run.

+ 1 - 0
Source/templates/basic3D/Description.txt

@@ -0,0 +1 @@
+A template for quickly getting started with a new project for 3D graphics. If you don't use sound and want to get rid of the dependency, just remove the Sound variable from main.DsrProj and the stub NoSound.cpp will simply refuse service to any sound engine trying to start it.

BIN
Source/templates/basic3D/Preview.gif


+ 0 - 23
Source/templates/basic3D/build.sh

@@ -1,23 +0,0 @@
-#!/bin/bash
-
-# Assuming that you called build.sh from its own folder, you should already be in the project folder.
-PROJECT_FOLDER=.
-# Placing your executable in the project folder allow using the same relative paths in the final release.
-TARGET_FILE=./application
-# The root folder is where DFPSR, SDK and tools are located.
-ROOT_PATH=../..
-# Select where to place temporary files.
-TEMP_DIR=${ROOT_PATH}/../../temporary
-# Select a window manager
-WINDOW_MANAGER=X11
-# Select safe debug mode or fast release mode
-#MODE=-DDEBUG #Debug mode
-MODE=-DNDEBUG #Release mode
-COMPILER_FLAGS="${MODE} -std=c++14 -O2"
-# Select external libraries
-LINKER_FLAGS=""
-
-# Give execution permission
-chmod +x ${ROOT_PATH}/tools/buildAndRun.sh;
-# Compile everything
-${ROOT_PATH}/tools/buildAndRun.sh "${PROJECT_FOLDER}" "${TARGET_FILE}" "${ROOT_PATH}" "${TEMP_DIR}" "${WINDOW_MANAGER}" "${COMPILER_FLAGS}" "${LINKER_FLAGS}";

+ 1 - 0
Source/templates/basicCLI/Description.txt

@@ -0,0 +1 @@
+A template for quickly getting started with a new command line interface project. The project file does not have any stubs Sound nor Graphics, because the DFPSR.DsrHead is not being imported. Therefore nothing else than the essential code is being linked with your program. The ListDependencies flag is activated in your project so that you can check from where an unwanted dependency was included.

BIN
Source/templates/basicCLI/Preview.gif


+ 0 - 23
Source/templates/basicCLI/build.sh

@@ -1,23 +0,0 @@
-#!/bin/bash
-
-# Assuming that you called build.sh from its own folder, you should already be in the project folder.
-PROJECT_FOLDER=.
-# Placing your executable in the project folder allow using the same relative paths in the final release.
-TARGET_FILE=./application
-# The root folder is where DFPSR, SDK and tools are located.
-ROOT_PATH=../..
-# Select where to place temporary files.
-TEMP_DIR=${ROOT_PATH}/../../temporary
-# Select a window manager
-WINDOW_MANAGER=NONE
-# Select safe debug mode or fast release mode
-#MODE=-DDEBUG #Debug mode
-MODE=-DNDEBUG #Release mode
-COMPILER_FLAGS="${MODE} -std=c++14 -O2"
-# Select external libraries
-LINKER_FLAGS=""
-
-# Give execution permission
-chmod +x ${ROOT_PATH}/tools/buildAndRun.sh;
-# Compile everything
-${ROOT_PATH}/tools/buildAndRun.sh "${PROJECT_FOLDER}" "${TARGET_FILE}" "${ROOT_PATH}" "${TEMP_DIR}" "${WINDOW_MANAGER}" "${COMPILER_FLAGS}" "${LINKER_FLAGS}";

+ 1 - 0
Source/templates/basicGUI/Description.txt

@@ -0,0 +1 @@
+A template for quickly getting started with a new graphical user interface project. If you don't use sound and want to get rid of the dependency, just remove the Sound variable from main.DsrProj and the stub NoSound.cpp will simply refuse service to any sound engine trying to start it.

BIN
Source/templates/basicGUI/Preview.gif


+ 0 - 23
Source/templates/basicGUI/build.sh

@@ -1,23 +0,0 @@
-#!/bin/bash
-
-# Assuming that you called build.sh from its own folder, you should already be in the project folder.
-PROJECT_FOLDER=.
-# Placing your executable in the project folder allow using the same relative paths in the final release.
-TARGET_FILE=./application
-# The root folder is where DFPSR, SDK and tools are located.
-ROOT_PATH=../..
-# Select where to place temporary files.
-TEMP_DIR=${ROOT_PATH}/../../temporary
-# Select a window manager
-WINDOW_MANAGER=X11
-# Select safe debug mode or fast release mode
-#MODE=-DDEBUG #Debug mode
-MODE=-DNDEBUG #Release mode
-COMPILER_FLAGS="${MODE} -std=c++14 -O2"
-# Select external libraries
-LINKER_FLAGS=""
-
-# Give execution permission
-chmod +x ${ROOT_PATH}/tools/buildAndRun.sh;
-# Compile everything
-${ROOT_PATH}/tools/buildAndRun.sh "${PROJECT_FOLDER}" "${TARGET_FILE}" "${ROOT_PATH}" "${TEMP_DIR}" "${WINDOW_MANAGER}" "${COMPILER_FLAGS}" "${LINKER_FLAGS}";

+ 66 - 16
Source/tools/wizard/main.cpp

@@ -5,6 +5,8 @@
 //     How can the file library execute other applications and scripts in a portable way when scripts need to select a terminal application to execute them?
 //     How can the file library execute other applications and scripts in a portable way when scripts need to select a terminal application to execute them?
 //     Maybe call the builder as a static library and have it call the compiler directly in a simulated terminal window embedded into the wizard, instead of using unreliable scripts?
 //     Maybe call the builder as a static library and have it call the compiler directly in a simulated terminal window embedded into the wizard, instead of using unreliable scripts?
 // * Let the user browse a file system and select a location for a new or existing project.
 // * Let the user browse a file system and select a location for a new or existing project.
+//     Should a multi-frame tab container be created to allow having multiple frames in the same container?
+//         Can let frames have a caption for when used within a container.
 
 
 #include "../../DFPSR/includeFramework.h"
 #include "../../DFPSR/includeFramework.h"
 #include "sound.h"
 #include "sound.h"
@@ -24,16 +26,16 @@ Begin : Panel
 		Name = "upperPanel"
 		Name = "upperPanel"
 		Bottom = 50
 		Bottom = 50
 		Solid = 1
 		Solid = 1
-		Color = 120,120,100
+		Color = 190,255,190
 	End
 	End
 	Begin : Panel
 	Begin : Panel
 		Name = "lowerPanel"
 		Name = "lowerPanel"
 		Solid = 1
 		Solid = 1
 		Top = 50
 		Top = 50
-		Color = 120,120,100
+		Color = 0,0,0
 		Begin : ListBox
 		Begin : ListBox
 			Name = "projectList"
 			Name = "projectList"
-			Color = 180,180,140
+			Color = 190,255,190
 			Left = 90%-100
 			Left = 90%-100
 			Right = 100%-5
 			Right = 100%-5
 			Top = 5
 			Top = 5
@@ -42,18 +44,26 @@ Begin : Panel
 		Begin : Button
 		Begin : Button
 			Name = "buildButton"
 			Name = "buildButton"
 			Text = "Build and run"
 			Text = "Build and run"
-			Color = 160,150,150
+			Color = 190,255,190
 			Left = 90%-100
 			Left = 90%-100
 			Right = 100%-5
 			Right = 100%-5
 			Top = 100%-45
 			Top = 100%-45
 			Bottom = 100%-5
 			Bottom = 100%-5
 		End
 		End
+		Begin : Picture
+			Name = "previewPicture"
+			Interpolation = 1
+			Left = 5
+			Top = 5
+			Right = 90%-105
+			Bottom = 70%-5
+		End
 		Begin : Label
 		Begin : Label
 			Name = "descriptionLabel"
 			Name = "descriptionLabel"
-			Text = "DFPSR wizard application"
+			Color = 190,255,190
 			Left = 5
 			Left = 5
 			Right = 90%-105
 			Right = 90%-105
-			Top = 5
+			Top = 70%
 			Bottom = 100%-5
 			Bottom = 100%-5
 		End
 		End
 	End
 	End
@@ -64,18 +74,43 @@ End
 Component projectList;
 Component projectList;
 Component buildButton;
 Component buildButton;
 Component descriptionLabel;
 Component descriptionLabel;
+Component previewPicture;
 
 
 // Media
 // Media
 int boomSound;
 int boomSound;
 
 
 struct Project {
 struct Project {
 	String buildScript; // To execute
 	String buildScript; // To execute
-	String projectFolderName; // To display
-	Project(const ReadableString &buildScript, const ReadableString &projectFolderName)
-	: buildScript(buildScript), projectFolderName(projectFolderName) {}
+	String title; // To display
+	String description; // To show when selected
+	OrderedImageRgbaU8 preview;
+	Project(const ReadableString &buildScript);
 };
 };
 List<Project> projects;
 List<Project> projects;
 
 
+Project::Project(const ReadableString &buildScript)
+: buildScript(buildScript) {
+	String projectFolderPath = file_getRelativeParentFolder(buildScript);
+	this->title = file_getPathlessName(projectFolderPath);
+	String descriptionPath = file_combinePaths(projectFolderPath, U"Description.txt");
+	if (file_getEntryType(descriptionPath) == EntryType::File) {
+		this->description = string_load(descriptionPath);
+	} else {
+		this->description = string_combine(U"Project at ", projectFolderPath, U" did not have any Description.txt to display!");
+	}
+	String previewPath = file_combinePaths(projectFolderPath, U"Preview.jpg");
+	if (file_getEntryType(previewPath) == EntryType::File) {
+		this->preview = image_load_RgbaU8(previewPath);
+	} else {
+		previewPath = file_combinePaths(projectFolderPath, U"Preview.gif");
+		if (file_getEntryType(previewPath) == EntryType::File) {
+			this->preview = image_load_RgbaU8(previewPath);
+		} else {
+			this->preview = OrderedImageRgbaU8();
+		}
+	}
+}
+
 static ReadableString findParent(const ReadableString& startPath, const ReadableString& parentName) {
 static ReadableString findParent(const ReadableString& startPath, const ReadableString& parentName) {
 	int64_t pathEndIndex = -1; // Last character of path leading to Source.
 	int64_t pathEndIndex = -1; // Last character of path leading to Source.
 	file_getPathEntries(startPath, [&pathEndIndex, &parentName](ReadableString entry, int64_t firstIndex, int64_t lastIndex) {
 	file_getPathEntries(startPath, [&pathEndIndex, &parentName](ReadableString entry, int64_t firstIndex, int64_t lastIndex) {
@@ -97,25 +132,38 @@ static void findProjects(const ReadableString& folderPath) {
 			findProjects(entryPath);
 			findProjects(entryPath);
 		} else if (entryType == EntryType::File) {
 		} else if (entryType == EntryType::File) {
 			ReadableString extension = string_upperCase(file_getExtension(entryName));
 			ReadableString extension = string_upperCase(file_getExtension(entryName));
+			Project newProject = Project(entryPath);
 			// If we find a project within folderPath...
 			// If we find a project within folderPath...
 			if (string_match(extension, U"DSRPROJ")) {
 			if (string_match(extension, U"DSRPROJ")) {
-				String projectFolderName = file_getPathlessName(file_getRelativeParentFolder(entryPath));
 				// ...and the folder is not namned wizard...
 				// ...and the folder is not namned wizard...
-				if (!string_match(projectFolderName, U"wizard")) {
+				if (!string_match(newProject.title, U"wizard")) {
 					// ...then add it to the list of projects.
 					// ...then add it to the list of projects.
-					projects.pushConstruct(entryPath, projectFolderName);
+					projects.push(newProject);
 				}
 				}
 			}
 			}
 		}
 		}
 	});
 	});
 }
 }
 
 
+static void selectProject(int64_t index) {
+	int oldIndex = component_getProperty_integer(projectList, U"SelectedIndex", true);
+	printText(oldIndex, U" -> ", index,  U"\n");
+	// Don't trigger new events if the selected index is already updated manually.
+	if (index != oldIndex) {
+		printText(U"Assigned ", index,  U"\n");
+		component_setProperty_integer(projectList, U"SelectedIndex", index, false);
+	}
+	printText(U"Assigning description\n");
+	component_setProperty_string(descriptionLabel, U"Text", projects[index].description);
+	component_setProperty_image(previewPicture, U"Image", projects[index].preview, false);
+}
+
 static void populateInterface(const ReadableString& folderPath) {
 static void populateInterface(const ReadableString& folderPath) {
 	findProjects(folderPath);
 	findProjects(folderPath);
 	for (int p = 0; p < projects.length(); p++) {
 	for (int p = 0; p < projects.length(); p++) {
-		component_call(projectList, U"PushElement", projects[p].projectFolderName);
+		component_call(projectList, U"PushElement", projects[p].title);
 	}
 	}
-	component_setProperty_integer(projectList, U"SelectedIndex", 0, false);
+	selectProject(0);
 }
 }
 
 
 DSR_MAIN_CALLER(dsrMain)
 DSR_MAIN_CALLER(dsrMain)
@@ -132,6 +180,7 @@ void dsrMain(List<String> args) {
 	projectList = window_findComponentByName(window, U"projectList");
 	projectList = window_findComponentByName(window, U"projectList");
 	buildButton = window_findComponentByName(window, U"buildButton");
 	buildButton = window_findComponentByName(window, U"buildButton");
 	descriptionLabel = window_findComponentByName(window, U"descriptionLabel");
 	descriptionLabel = window_findComponentByName(window, U"descriptionLabel");
+	previewPicture = window_findComponentByName(window, U"previewPicture");
 
 
 	// Find projects to showcase
 	// Find projects to showcase
 	//   On systems that don't allow getting the application's folder, the program must be started somewhere within the Source folder.
 	//   On systems that don't allow getting the application's folder, the program must be started somewhere within the Source folder.
@@ -150,12 +199,13 @@ void dsrMain(List<String> args) {
 	});
 	});
 	component_setPressedEvent(buildButton, []() {
 	component_setPressedEvent(buildButton, []() {
 		// TODO: Implement building and running of the selected project.
 		// TODO: Implement building and running of the selected project.
+		playSound(boomSound, false, 1.0, 1.0, 0.7);
 		component_setProperty_string(descriptionLabel, U"Text", U"Compiling and running projects from the wizard application is not yet implemented.");
 		component_setProperty_string(descriptionLabel, U"Text", U"Compiling and running projects from the wizard application is not yet implemented.");
 	});
 	});
 	component_setSelectEvent(projectList, [](int64_t index) {
 	component_setSelectEvent(projectList, [](int64_t index) {
-		// TODO: Load description from a text file with a specific name in the project's folder.
+		printText(U"Selecting ", index, U"\n");
 		playSound(boomSound, false, 0.5, 0.5, 0.5);
 		playSound(boomSound, false, 0.5, 0.5, 0.5);
-		component_setProperty_string(descriptionLabel, U"Text", string_combine(U"Project at ", projects[index].buildScript));
+		selectProject(index);
 	});
 	});
 	window_setCloseEvent(window, []() {
 	window_setCloseEvent(window, []() {
 		running = false;
 		running = false;