switch chinese UI asset path fix complete
allow asset path check more data pathpull/2/head
							parent
							
								
									0ba1c93ff4
								
							
						
					
					
						commit
						5665ff4105
					
				|  | @ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.4 FATAL_ERROR) | ||||||
| cmake_policy(VERSION 2.8) | cmake_policy(VERSION 2.8) | ||||||
| set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") | ||||||
| 
 | 
 | ||||||
| set(NAME games_106) | set(NAME PlumageRender) | ||||||
| 
 | 
 | ||||||
| project(${NAME}) | project(${NAME}) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ | ||||||
| 
 | 
 | ||||||
| #if !(defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK)) | #if !(defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK)) | ||||||
| // iOS & macOS: VulkanExampleBase::getAssetPath() implemented externally to allow access to Objective-C components
 | // iOS & macOS: VulkanExampleBase::getAssetPath() implemented externally to allow access to Objective-C components
 | ||||||
|  | 
 | ||||||
| const std::string getAssetPath() | const std::string getAssetPath() | ||||||
| { | { | ||||||
| #if defined(VK_USE_PLATFORM_ANDROID_KHR) | #if defined(VK_USE_PLATFORM_ANDROID_KHR) | ||||||
|  | @ -10,7 +11,28 @@ const std::string getAssetPath() | ||||||
| #elif defined(VK_EXAMPLE_DATA_DIR) | #elif defined(VK_EXAMPLE_DATA_DIR) | ||||||
| 	return VK_EXAMPLE_DATA_DIR; | 	return VK_EXAMPLE_DATA_DIR; | ||||||
| #else | #else | ||||||
| 	return "./../data/"; | 	 | ||||||
|  | 	if (_access("./../data/", 0) != -1) | ||||||
|  | 	{ | ||||||
|  | 		 | ||||||
|  | 		return "./../data/"; | ||||||
|  | 	} | ||||||
|  | 	else if (_access("./data/", 0) != -1) | ||||||
|  | 	{ | ||||||
|  | 		 | ||||||
|  | 		return "./data/"; | ||||||
|  | 	} | ||||||
|  | 	else if (_access("./../../data/", 0) != -1) | ||||||
|  | 	{ | ||||||
|  | 		 | ||||||
|  | 		return "../../data/"; | ||||||
|  | 	} | ||||||
|  | 	else | ||||||
|  | 	{ | ||||||
|  | 		 | ||||||
|  | 		return "./../../../data"; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| /*
 | /*
 | ||||||
| * Vulkan Example - Physical based rendering a glTF 2.0 model with image based lighting | * Vulkan Example - Physical based rendering a glTF 2.0 model with image based lighting | ||||||
| * | * | ||||||
| * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de | * Copyright (C) 2018 by Sascha Willems - www.saschawillems.de | ||||||
|  | @ -68,7 +68,7 @@ public: | ||||||
| 		delete[] fontAsset; | 		delete[] fontAsset; | ||||||
| #else | #else | ||||||
| 		std::string ttfFilePath = getAssetPath() + "/STXINWEI.TTF"; | 		std::string ttfFilePath = getAssetPath() + "/STXINWEI.TTF"; | ||||||
| 		io.Fonts->AddFontFromFileTTF(ttfFilePath.data(), 16.0f); | 		io.Fonts->AddFontFromFileTTF(ttfFilePath.data(), 16.0f,NULL, io.Fonts->GetGlyphRangesChineseSimplifiedCommon()); | ||||||
| #endif | #endif | ||||||
| 		io.Fonts->GetTexDataAsRGBA32(&fontData, &texWidth, &texHeight); | 		io.Fonts->GetTexDataAsRGBA32(&fontData, &texWidth, &texHeight); | ||||||
| 		fontTexture.loadFromBuffer(fontData, texWidth * texHeight * 4 * sizeof(char), VK_FORMAT_R8G8B8A8_UNORM, texWidth, texHeight, vulkanDevice, queue); | 		fontTexture.loadFromBuffer(fontData, texWidth * texHeight * 4 * sizeof(char), VK_FORMAT_R8G8B8A8_UNORM, texWidth, texHeight, vulkanDevice, queue); | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| #ifndef TINYGLTF_IMPLEMENTATION | #ifndef TINYGLTF_IMPLEMENTATION | ||||||
|  | @ -222,7 +222,12 @@ PlumageRender::PlumageRender() | ||||||
| 		if (_access(assetpath.c_str(),0) != 0) { | 		if (_access(assetpath.c_str(),0) != 0) { | ||||||
| 			std::string msg = "Could not locate asset path in \"" + assetpath + "\".\nMake sure binary is run from correct relative directory!"; | 			std::string msg = "Could not locate asset path in \"" + assetpath + "\".\nMake sure binary is run from correct relative directory!"; | ||||||
| 			std::cerr << msg << std::endl; | 			std::cerr << msg << std::endl; | ||||||
| 			exit(-1); | 			system("pause"); | ||||||
|  | 			//exit(-1);
 | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
|  | 			std::string msg = "asset path check " + assetpath; | ||||||
|  | 			std::cout << msg << std::endl; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		readDirectory(assetpath + "environments", "*.ktx", environments, false); | 		readDirectory(assetpath + "environments", "*.ktx", environments, false); | ||||||
|  | @ -1680,8 +1685,8 @@ PlumageRender::PlumageRender() | ||||||
| 		 | 		 | ||||||
| 		gui->text("%.1d fps (%.2f ms)", lastFPS, (1000.0f / lastFPS)); | 		gui->text("%.1d fps (%.2f ms)", lastFPS, (1000.0f / lastFPS)); | ||||||
| 
 | 
 | ||||||
| 		if (gui->header("model")) { | 		if (gui->header(chineseUI.model)) { | ||||||
| 			if (gui->button(gui->string_to_utf8("open gltf model").c_str())) { | 			if (gui->button(chineseUI.openNewModel)) { | ||||||
| 				std::string filename = ""; | 				std::string filename = ""; | ||||||
| 				char buffer[MAX_PATH]; | 				char buffer[MAX_PATH]; | ||||||
| 				OPENFILENAME ofn; | 				OPENFILENAME ofn; | ||||||
|  | @ -1703,7 +1708,7 @@ PlumageRender::PlumageRender() | ||||||
| 					updateCBs = true; | 					updateCBs = true; | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 			if (gui->combo("Environment", selectedEnvironment, environments)) { | 			if (gui->combo(chineseUI.environmentMap, selectedEnvironment, environments)) { | ||||||
| 				vkDeviceWaitIdle(device); | 				vkDeviceWaitIdle(device); | ||||||
| 				loadEnvironment(environments[selectedEnvironment]); | 				loadEnvironment(environments[selectedEnvironment]); | ||||||
| 				setupDescriptors(); | 				setupDescriptors(); | ||||||
|  | @ -1711,7 +1716,7 @@ PlumageRender::PlumageRender() | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if (gui->header("Environment")) { | 		if (gui->header(chineseUI.environment)) { | ||||||
| 			if (gui->checkbox("Background", &displayBackground)) { | 			if (gui->checkbox("Background", &displayBackground)) { | ||||||
| 				updateShaderParams = true; | 				updateShaderParams = true; | ||||||
| 			} | 			} | ||||||
|  | @ -1730,27 +1735,27 @@ PlumageRender::PlumageRender() | ||||||
| 			const std::vector<std::string> debugNamesInputs = { | 			const std::vector<std::string> debugNamesInputs = { | ||||||
| 				"none", "Base color", "Normal", "Occlusion", "Emissive", "Metallic", "Roughness" | 				"none", "Base color", "Normal", "Occlusion", "Emissive", "Metallic", "Roughness" | ||||||
| 			}; | 			}; | ||||||
| 			if (gui->combo("input", &debugViewInputs, debugNamesInputs)) { | 			if (gui->combo(chineseUI.debugInput, &debugViewInputs, debugNamesInputs)) { | ||||||
| 				shaderData.debugViewInputs = static_cast<float>(debugViewInputs); | 				shaderData.debugViewInputs = static_cast<float>(debugViewInputs); | ||||||
| 				updateShaderParams = true; | 				updateShaderParams = true; | ||||||
| 			} | 			} | ||||||
| 			const std::vector<std::string> debugNamesEquation = { | 			const std::vector<std::string> debugNamesEquation = { | ||||||
| 				"none", "Diff (l,n)", "F (l,h)", "G (l,v,h)", "D (h)", "Specular" | 				"none", "Diff (l,n)", "F (l,h)", "G (l,v,h)", "D (h)", "Specular" | ||||||
| 			}; | 			}; | ||||||
| 			if (gui->combo("PBR equation", &debugViewEquation, debugNamesEquation)) { | 			if (gui->combo(chineseUI.debugPBREquation, &debugViewEquation, debugNamesEquation)) { | ||||||
| 				shaderData.debugViewEquation = static_cast<float>(debugViewEquation); | 				shaderData.debugViewEquation = static_cast<float>(debugViewEquation); | ||||||
| 				updateShaderParams = true; | 				updateShaderParams = true; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if (models.scene.animations.size() > 0) { | 		if (models.scene.animations.size() > 0) { | ||||||
| 			if (gui->header("animation")) { | 			if (gui->header(chineseUI.animation)) { | ||||||
| 				gui->checkbox("pause", &animate); | 				gui->checkbox(chineseUI.pauseAnimation, &animate); | ||||||
| 				std::vector<std::string> animationNames; | 				std::vector<std::string> animationNames; | ||||||
| 				for (auto animation : models.scene.animations) { | 				for (auto animation : models.scene.animations) { | ||||||
| 					animationNames.push_back(animation.name); | 					animationNames.push_back(animation.name); | ||||||
| 				} | 				} | ||||||
| 				gui->combo("animation", &animationIndex, animationNames); | 				gui->combo(chineseUI.animationSeq, &animationIndex, animationNames); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| #pragma once | #pragma once | ||||||
| 
 | 
 | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
|  | @ -62,15 +62,15 @@ public: | ||||||
| 	} shaderData; | 	} shaderData; | ||||||
| 	struct ChinesesUI | 	struct ChinesesUI | ||||||
| 	{ | 	{ | ||||||
| 		const char * model = "u8模型"; | 		const char * model = "模型"; | ||||||
| 		const char* openNewModel = "打开gltf模型"; | 		const char* openNewModel = "打开新gltf模型"; | ||||||
| 		const char* environmentMap = "环境贴图"; | 		const char* environmentMap = "环境贴图"; | ||||||
| 		const char* environment = "环境光照"; | 		const char* environment = "环境光照"; | ||||||
| 		const char* debugInput = "输入"; | 		const char* debugInput = "输入"; | ||||||
| 		const char* debugPBREquation = "PBR计算参数"; | 		const char* debugPBREquation = "PBR计算参数"; | ||||||
| 		const char* animation = "动画"; | 		const char* animation = "动画"; | ||||||
| 		const char* pauseAnimation = "暂停动画"; | 		const char* pauseAnimation = "启用动画"; | ||||||
| 		const char* animationSeq = "动画序列"; | 		const char* animationSeq = "动画序列"; | ||||||
| 
 | 
 | ||||||
| 	}chineseUI; | 	}chineseUI; | ||||||
| 	struct UniformBufferSet { | 	struct UniformBufferSet { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue