reconstruct UI complete
parent
03dda388c2
commit
8e27b83b22
48
base/ui.hpp
48
base/ui.hpp
|
@ -241,24 +241,7 @@ public:
|
||||||
vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
|
vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
|
||||||
vkDestroyDescriptorPool(device, descriptorPool, nullptr);
|
vkDestroyDescriptorPool(device, descriptorPool, nullptr);
|
||||||
}
|
}
|
||||||
std::string string_to_utf8(const std::string& str)
|
|
||||||
{
|
|
||||||
int nwLen = MultiByteToWideChar(CP_ACP, 0, str.c_str(), -1, NULL, 0);
|
|
||||||
wchar_t* pwBuf = new wchar_t[nwLen + 1];
|
|
||||||
memset(pwBuf, 0, nwLen * 2 + 2);
|
|
||||||
MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.length(), pwBuf, nwLen);
|
|
||||||
|
|
||||||
int nLen = WideCharToMultiByte(CP_UTF8, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
|
|
||||||
char* pBuf = new char[nLen + 1];
|
|
||||||
memset(pBuf, 0, nLen + 1);
|
|
||||||
WideCharToMultiByte(CP_UTF8, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL);
|
|
||||||
|
|
||||||
std::string ret = pBuf;
|
|
||||||
delete[]pwBuf;
|
|
||||||
delete[]pBuf;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
void draw(VkCommandBuffer cmdBuffer) {
|
void draw(VkCommandBuffer cmdBuffer) {
|
||||||
vkCmdBindPipeline(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
vkCmdBindPipeline(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
||||||
vkCmdBindDescriptorSets(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSet, 0, nullptr);
|
vkCmdBindDescriptorSets(cmdBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSet, 0, nullptr);
|
||||||
|
@ -334,19 +317,38 @@ public:
|
||||||
bool button(const char *caption) {
|
bool button(const char *caption) {
|
||||||
return ImGui::Button(caption);
|
return ImGui::Button(caption);
|
||||||
}
|
}
|
||||||
|
bool beginChild(const char* caption, ImVec2 size, bool border)
|
||||||
|
{
|
||||||
|
return ImGui::BeginChild(caption, size, border);
|
||||||
|
}
|
||||||
|
|
||||||
bool beginMenu(const char* caption) {
|
void endChild()
|
||||||
|
{
|
||||||
|
return ImGui::EndChild();
|
||||||
|
}
|
||||||
|
|
||||||
|
// menu GUI
|
||||||
|
bool beginMainMenuBar() {
|
||||||
|
return ImGui::BeginMainMenuBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool beginMenu(const char* caption)
|
||||||
|
{
|
||||||
return ImGui::BeginMenu(caption);
|
return ImGui::BeginMenu(caption);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool menuItem(const char* caption,const char* shortcut)
|
bool menuItem(const char* caption)
|
||||||
{
|
{
|
||||||
return ImGui::MenuItem(caption, shortcut);
|
return ImGui::MenuItem(caption);
|
||||||
|
}
|
||||||
|
void endMenu()
|
||||||
|
{
|
||||||
|
return ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool beginMenuBar()
|
|
||||||
{
|
void endMainMenuBar() {
|
||||||
return ImGui::BeginMenuBar();
|
return ImGui::EndMainMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
void text(const char *formatstr, ...) {
|
void text(const char *formatstr, ...) {
|
||||||
|
|
|
@ -1675,18 +1675,23 @@ PlumageRender::PlumageRender()
|
||||||
bool updateShaderParams = false;
|
bool updateShaderParams = false;
|
||||||
bool updateCBs = false;
|
bool updateCBs = false;
|
||||||
float scale = 1.0f;
|
float scale = 1.0f;
|
||||||
|
bool boolTitleWindowShow = false;
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
ImGui::SetNextWindowPos(ImVec2(10, 10));
|
ImGui::SetNextWindowPos(ImVec2(10000, 10000));
|
||||||
ImGui::SetNextWindowSize(ImVec2(200 * scale, (models.scene.animations.size() > 0 ? 440 : 360) * scale), ImGuiSetCond_Always);
|
//ImGui::SetNextWindowSize(ImVec2(200 * scale, (models.scene.animations.size() > 0 ? 440 : 360) * scale), ImGuiSetCond_Always);
|
||||||
ImGui::Begin("Plumage Render", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
|
ImGui::Begin("", nullptr, ImGuiWindowFlags_NoFocusOnAppearing|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
|
|
||||||
ImGui::PushItemWidth(100.0f * scale);
|
ImGui::PushItemWidth(100.0f * scale);
|
||||||
|
|
||||||
|
|
||||||
gui->text("%.1d fps (%.2f ms)", lastFPS, (1000.0f / lastFPS));
|
|
||||||
// TO DO : language switch
|
|
||||||
if (gui->header(chineseUI.model)) {
|
if(gui->beginMainMenuBar()) {
|
||||||
if (gui->button(chineseUI.openNewModel)) {
|
if (gui->beginMenu("file"))
|
||||||
|
{
|
||||||
|
if (gui->menuItem("open"))
|
||||||
|
{
|
||||||
std::wstring filename = L"";
|
std::wstring filename = L"";
|
||||||
wchar_t buffer[MAX_PATH];
|
wchar_t buffer[MAX_PATH];
|
||||||
OPENFILENAMEW ofn;
|
OPENFILENAMEW ofn;
|
||||||
|
@ -1712,15 +1717,18 @@ PlumageRender::PlumageRender()
|
||||||
updateCBs = true;
|
updateCBs = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
gui->endMenu();
|
||||||
|
}
|
||||||
|
if (gui->beginMenu("environment"))
|
||||||
|
{
|
||||||
|
if (gui->beginMenu("config"))
|
||||||
|
{
|
||||||
if (gui->combo(chineseUI.environmentMap, selectedEnvironment, environments)) {
|
if (gui->combo(chineseUI.environmentMap, selectedEnvironment, environments)) {
|
||||||
vkDeviceWaitIdle(device);
|
vkDeviceWaitIdle(device);
|
||||||
loadEnvironment(environments[selectedEnvironment]);
|
loadEnvironment(environments[selectedEnvironment]);
|
||||||
setupDescriptors();
|
setupDescriptors();
|
||||||
updateCBs = true;
|
updateCBs = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (gui->header(chineseUI.environment)) {
|
|
||||||
if (gui->checkbox("Background", &displayBackground)) {
|
if (gui->checkbox("Background", &displayBackground)) {
|
||||||
updateShaderParams = true;
|
updateShaderParams = true;
|
||||||
}
|
}
|
||||||
|
@ -1733,9 +1741,14 @@ PlumageRender::PlumageRender()
|
||||||
if (gui->slider("IBL", &shaderData.scaleIBLAmbient, 0.0f, 1.0f)) {
|
if (gui->slider("IBL", &shaderData.scaleIBLAmbient, 0.0f, 1.0f)) {
|
||||||
updateShaderParams = true;
|
updateShaderParams = true;
|
||||||
}
|
}
|
||||||
|
gui->endMenu();
|
||||||
}
|
}
|
||||||
|
gui->endMenu();
|
||||||
if (gui->header("Debug ")) {
|
}
|
||||||
|
if (gui->beginMenu("debug"))
|
||||||
|
{
|
||||||
|
if (gui->beginMenu("input"))
|
||||||
|
{
|
||||||
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"
|
||||||
};
|
};
|
||||||
|
@ -1743,6 +1756,10 @@ PlumageRender::PlumageRender()
|
||||||
shaderData.debugViewInputs = static_cast<float>(debugViewInputs);
|
shaderData.debugViewInputs = static_cast<float>(debugViewInputs);
|
||||||
updateShaderParams = true;
|
updateShaderParams = true;
|
||||||
}
|
}
|
||||||
|
gui->endMenu();
|
||||||
|
}
|
||||||
|
if (gui->beginMenu("PBR"))
|
||||||
|
{
|
||||||
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"
|
||||||
};
|
};
|
||||||
|
@ -1750,18 +1767,43 @@ PlumageRender::PlumageRender()
|
||||||
shaderData.debugViewEquation = static_cast<float>(debugViewEquation);
|
shaderData.debugViewEquation = static_cast<float>(debugViewEquation);
|
||||||
updateShaderParams = true;
|
updateShaderParams = true;
|
||||||
}
|
}
|
||||||
|
gui->endMenu();
|
||||||
}
|
}
|
||||||
|
if (gui->beginMenu("frame rate"))
|
||||||
if (models.scene.animations.size() > 0) {
|
{
|
||||||
if (gui->header(chineseUI.animation)) {
|
gui->text("%.1d fps (%.2f ms)", lastFPS, (1000.0f / lastFPS));
|
||||||
|
gui->endMenu();
|
||||||
|
}
|
||||||
|
gui->endMenu();
|
||||||
|
}
|
||||||
|
if (gui->beginMenu("animation"))
|
||||||
|
{
|
||||||
|
if (models.scene.animations.size() > 0)
|
||||||
|
{
|
||||||
|
if (gui->beginMenu("activation"))
|
||||||
|
{
|
||||||
gui->checkbox(chineseUI.pauseAnimation, &animate);
|
gui->checkbox(chineseUI.pauseAnimation, &animate);
|
||||||
|
gui->endMenu();
|
||||||
|
}
|
||||||
|
if (gui->beginMenu("anmation sequence"))
|
||||||
|
{
|
||||||
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(chineseUI.animationSeq, &animationIndex, animationNames);
|
gui->combo(chineseUI.animationSeq, &animationIndex, animationNames);
|
||||||
|
gui->endMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gui->text("no animation in loaded model");
|
||||||
|
}
|
||||||
|
gui->endMenu();
|
||||||
|
}
|
||||||
|
gui->endMainMenuBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ImGui::PopItemWidth();
|
ImGui::PopItemWidth();
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
Loading…
Reference in New Issue