switch chinese UI asset path fix complete

allow asset path check more data path
pull/2/head
ink-soul 2023-06-12 11:05:10 +08:00
parent 0ba1c93ff4
commit 5665ff4105
5 changed files with 52 additions and 25 deletions

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.4 FATAL_ERROR)
cmake_policy(VERSION 2.8)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(NAME games_106)
set(NAME PlumageRender)
project(${NAME})

View File

@ -3,6 +3,7 @@
#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
const std::string getAssetPath()
{
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
@ -10,7 +11,28 @@ const std::string getAssetPath()
#elif defined(VK_EXAMPLE_DATA_DIR)
return VK_EXAMPLE_DATA_DIR;
#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

View File

@ -1,4 +1,4 @@
/*
/*
* Vulkan Example - Physical based rendering a glTF 2.0 model with image based lighting
*
* Copyright (C) 2018 by Sascha Willems - www.saschawillems.de
@ -68,7 +68,7 @@ public:
delete[] fontAsset;
#else
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
io.Fonts->GetTexDataAsRGBA32(&fontData, &texWidth, &texHeight);
fontTexture.loadFromBuffer(fontData, texWidth * texHeight * 4 * sizeof(char), VK_FORMAT_R8G8B8A8_UNORM, texWidth, texHeight, vulkanDevice, queue);

View File

@ -1,4 +1,4 @@

#ifndef TINYGLTF_IMPLEMENTATION
@ -222,7 +222,12 @@ PlumageRender::PlumageRender()
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::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);
@ -1680,8 +1685,8 @@ PlumageRender::PlumageRender()
gui->text("%.1d fps (%.2f ms)", lastFPS, (1000.0f / lastFPS));
if (gui->header("model")) {
if (gui->button(gui->string_to_utf8("open gltf model").c_str())) {
if (gui->header(chineseUI.model)) {
if (gui->button(chineseUI.openNewModel)) {
std::string filename = "";
char buffer[MAX_PATH];
OPENFILENAME ofn;
@ -1703,7 +1708,7 @@ PlumageRender::PlumageRender()
updateCBs = true;
}
}
if (gui->combo("Environment", selectedEnvironment, environments)) {
if (gui->combo(chineseUI.environmentMap, selectedEnvironment, environments)) {
vkDeviceWaitIdle(device);
loadEnvironment(environments[selectedEnvironment]);
setupDescriptors();
@ -1711,7 +1716,7 @@ PlumageRender::PlumageRender()
}
}
if (gui->header("Environment")) {
if (gui->header(chineseUI.environment)) {
if (gui->checkbox("Background", &displayBackground)) {
updateShaderParams = true;
}
@ -1730,27 +1735,27 @@ PlumageRender::PlumageRender()
const std::vector<std::string> debugNamesInputs = {
"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);
updateShaderParams = true;
}
const std::vector<std::string> debugNamesEquation = {
"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);
updateShaderParams = true;
}
}
if (models.scene.animations.size() > 0) {
if (gui->header("animation")) {
gui->checkbox("pause", &animate);
if (gui->header(chineseUI.animation)) {
gui->checkbox(chineseUI.pauseAnimation, &animate);
std::vector<std::string> animationNames;
for (auto animation : models.scene.animations) {
animationNames.push_back(animation.name);
}
gui->combo("animation", &animationIndex, animationNames);
gui->combo(chineseUI.animationSeq, &animationIndex, animationNames);
}
}

View File

@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <stdio.h>
#include <stdlib.h>
@ -62,15 +62,15 @@ public:
} shaderData;
struct ChinesesUI
{
const char * model = "u8模型";
const char* openNewModel = "打开gltf模型";
const char* environmentMap = "环境贴图";
const char* environment = "环境光照";
const char* debugInput = "输入";
const char* debugPBREquation = "PBR计算参数";
const char* animation = "动画";
const char* pauseAnimation = "暂停动画";
const char* animationSeq = "动画序列";
const char * model = "模型";
const char* openNewModel = "打开gltf模型";
const char* environmentMap = "环境贴图";
const char* environment = "环境光照";
const char* debugInput = "输入";
const char* debugPBREquation = "PBR计算参数";
const char* animation = "动画";
const char* pauseAnimation = "启用动画";
const char* animationSeq = "动画序列";
}chineseUI;
struct UniformBufferSet {