add when minimized do not render, fix some build problem in dll mode

This commit is contained in:
2025-11-26 20:15:29 +08:00
parent 5bbda471bf
commit 7361d59b5b
15 changed files with 58 additions and 46 deletions
+3 -2
View File
@@ -65,8 +65,9 @@ set(STATIC_LIBRARY ${PROJECT_NAME}-static)
add_library(${STATIC_LIBRARY} STATIC ${SRC_SOURCE})
target_compile_definitions(${STATIC_LIBRARY} PRIVATE
PRISM_STATIC
${DEBUG_DEFINITIONS}
INTERFACE
PRISM_STATIC
)
target_include_directories(${STATIC_LIBRARY} PUBLIC
@@ -83,7 +84,7 @@ target_precompile_headers(${STATIC_LIBRARY} PRIVATE
)
set_target_properties(${STATIC_LIBRARY} PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}d
OUTPUT_NAME ${PROJECT_NAME}
ARCHIVE_OUTPUT_NAME ${PROJECT_NAME}d
)
+31 -21
View File
@@ -18,14 +18,14 @@
namespace Prism
{
#ifdef _MSC_VER
#define BIND_EVENT_FN(fn) std::bind(&Application::##fn, this, std::placeholders::_1)
#else
#ifdef _MSC_VER
#define BIND_EVENT_FN(fn) std::bind(&Application::##fn, this, std::placeholders::_1)
#else
#define BIND_EVENT_FN(fn) std::bind(&Application::fn, this, std::placeholders::_1)
#endif
#endif
Application* Application::s_Instance = nullptr;
// Application* Application::s_Instance = nullptr;
Application::Application()
{
@@ -50,13 +50,16 @@ namespace Prism
while (m_Running)
{
for (Layer* layer : m_LayerStack)
layer->OnUpdate();
if (!m_Minimized)
{
for (Layer* layer : m_LayerStack)
layer->OnUpdate();
Application* app = this;
PM_RENDER_1(app, { app->RenderImGui(); });
PM_RENDER_S({ self->RenderImGui(); });
Renderer::Get().WaitAndRender();
Renderer::Get().WaitAndRender();
}
m_Window->OnUpdate();
}
@@ -96,21 +99,21 @@ namespace Prism
std::string Application::OpenFile(const std::string& filter) const
{
OPENFILENAMEA ofn; // common dialog box structure
CHAR szFile[260] = { 0 }; // if using TCHAR macros
OPENFILENAMEA ofn; // common dialog box structure
CHAR szFile[260] = {0}; // if using TCHAR macros
// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = glfwGetWin32Window((GLFWwindow*)m_Window->GetNativeWindow());
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "All\0*.*\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = glfwGetWin32Window((GLFWwindow*)m_Window->GetNativeWindow());
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "All\0*.*\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileNameA(&ofn) == TRUE)
{
@@ -134,6 +137,13 @@ namespace Prism
bool Application::OnWindowResize(const WindowResizeEvent& e)
{
int width = e.GetWidth(), height = e.GetHeight();
if (width == 0 || height == 0)
{
m_Minimized = true;
return false;
}
m_Minimized = false;
PM_RENDER_2(width, height, { glViewport(0, 0, width, height); });
auto& fbs = FrameBufferPool::GetGlobal()->GetAll();
for (auto& fb : fbs)
+3 -1
View File
@@ -44,10 +44,12 @@ namespace Prism
std::unique_ptr<Window> m_Window;
bool m_Running = true;
bool m_Minimized = false;
LayerStack m_LayerStack;
ImGuiLayer* m_ImGuiLayer;
static Application* s_Instance;
static inline Application* s_Instance = nullptr;
};
+2 -2
View File
@@ -11,7 +11,7 @@ extern Prism::Application* Prism::CreateApplication();
int main(int argc, char** argv)
{
#ifndef PRISM_SHARED
#ifdef PRISM_STATIC
Prism::InitializeCore();
#endif
@@ -19,7 +19,7 @@ int main(int argc, char** argv)
app->Run();
delete app;
#ifndef PRISM_SHARED
#ifdef PRISM_STATIC
Prism::ShutdownCore();
#endif
+1 -1
View File
@@ -9,7 +9,7 @@
namespace Prism
{
class Camera
class PRISM_API Camera
{
public:
Camera(const glm::mat4& projectionMatrix);
+1 -1
View File
@@ -8,7 +8,7 @@
namespace Prism
{
FrameBuffer* Prism::FrameBuffer::Create(uint32_t width, uint32_t height, FramebufferFormat format)
FrameBuffer* FrameBuffer::Create(uint32_t width, uint32_t height, FramebufferFormat format)
{
FrameBuffer* result = nullptr;
switch (RendererAPI::Current())
+1 -1
View File
@@ -16,7 +16,7 @@ namespace Prism
RGBA16F = 2
};
class FrameBuffer
class PRISM_API FrameBuffer
{
public:
static FrameBuffer* Create(uint32_t width, uint32_t height, FramebufferFormat format);
+2 -2
View File
@@ -85,7 +85,7 @@ namespace Prism
}
m_VertexBuffer.reset(VertexBuffer::Create());
m_VertexBuffer->SetData(m_Vertices.data(), m_Vertices.size() * sizeof(Vertex));
m_VertexBuffer->SetData(m_Vertices.data(), (uint32_t)(m_Vertices.size() * sizeof(Vertex)));
// Extract indices from model
m_Indices.reserve(mesh->mNumFaces);
@@ -96,7 +96,7 @@ namespace Prism
}
m_IndexBuffer.reset(IndexBuffer::Create());
m_IndexBuffer->SetData(m_Indices.data(), m_Indices.size() * sizeof(Index));
m_IndexBuffer->SetData(m_Indices.data(), (uint32_t)(m_Indices.size() * sizeof(Index)));
}
Mesh::~Mesh()
+1 -1
View File
@@ -11,7 +11,7 @@
namespace Prism
{
class Mesh
class PRISM_API Mesh
{
public:
struct Vertex
-1
View File
@@ -35,7 +35,6 @@ namespace Prism
private:
static Renderer* s_Instance;
// static inline Renderer* s_Instance = nullptr;
RenderCommandQueue m_CommandQueue;
};
+1 -1
View File
@@ -9,7 +9,7 @@
namespace Prism
{
std::vector<Shader*> Shader::s_AllShaders;
// std::vector<Shader*> Shader::s_AllShaders;
Shader* Shader::Create(const std::string& filepath)
{
+1 -1
View File
@@ -105,7 +105,7 @@ namespace Prism
static Shader* Create(const std::string& filepath);
static std::vector<Shader*> s_AllShaders;
static inline std::vector<Shader*> s_AllShaders;
};
}
+1 -1
View File
@@ -8,5 +8,5 @@ file(COPY ${ASSETS} DESTINATION ${CMAKE_BINARY_DIR}/bin)
add_executable(${PROJECT_NAME} ${SRC_SOURCE})
target_link_libraries(${PROJECT_NAME} PRIVATE Prism-static)
target_link_libraries(${PROJECT_NAME} PRIVATE Prism-shared)
#target_compile_definitions(${PROJECT_NAME} PRIVATE ENABLE_DOCKSPACE)
+9 -9
View File
@@ -369,7 +369,7 @@ void DemoLayer::OnImGuiRender()
if (ImGui::CollapsingHeader("Albedo", nullptr, ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 10));
ImGui::Image(m_AlbedoInput.TextureMap ? (void*)m_AlbedoInput.TextureMap->GetRendererID() : (void*)m_CheckerboardTex->GetRendererID(), ImVec2(64, 64));
ImGui::Image((ImTextureRef)(m_AlbedoInput.TextureMap ? m_AlbedoInput.TextureMap->GetRendererID() : m_CheckerboardTex->GetRendererID()), ImVec2(64, 64));
ImGui::PopStyleVar();
if (ImGui::IsItemHovered())
{
@@ -379,7 +379,7 @@ void DemoLayer::OnImGuiRender()
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::TextUnformatted(m_AlbedoInput.TextureMap->GetPath().c_str());
ImGui::PopTextWrapPos();
ImGui::Image((void*)m_AlbedoInput.TextureMap->GetRendererID(), ImVec2(384, 384));
ImGui::Image((ImTextureRef)m_AlbedoInput.TextureMap->GetRendererID(), ImVec2(384, 384));
ImGui::EndTooltip();
}
if (ImGui::IsItemClicked())
@@ -407,7 +407,7 @@ void DemoLayer::OnImGuiRender()
if (ImGui::CollapsingHeader("Normals", nullptr, ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 10));
ImGui::Image(m_NormalInput.TextureMap ? (void*)m_NormalInput.TextureMap->GetRendererID() : (void*)m_CheckerboardTex->GetRendererID(), ImVec2(64, 64));
ImGui::Image((ImTextureRef)(m_NormalInput.TextureMap ? m_NormalInput.TextureMap->GetRendererID() : m_CheckerboardTex->GetRendererID()), ImVec2(64, 64));
ImGui::PopStyleVar();
if (ImGui::IsItemHovered())
{
@@ -417,7 +417,7 @@ void DemoLayer::OnImGuiRender()
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::TextUnformatted(m_NormalInput.TextureMap->GetPath().c_str());
ImGui::PopTextWrapPos();
ImGui::Image((void*)m_NormalInput.TextureMap->GetRendererID(), ImVec2(384, 384));
ImGui::Image((ImTextureRef)m_NormalInput.TextureMap->GetRendererID(), ImVec2(384, 384));
ImGui::EndTooltip();
}
if (ImGui::IsItemClicked())
@@ -436,7 +436,7 @@ void DemoLayer::OnImGuiRender()
if (ImGui::CollapsingHeader("Metalness", nullptr, ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 10));
ImGui::Image(m_MetalnessInput.TextureMap ? (void*)m_MetalnessInput.TextureMap->GetRendererID() : (void*)m_CheckerboardTex->GetRendererID(), ImVec2(64, 64));
ImGui::Image((ImTextureRef)(m_MetalnessInput.TextureMap ? m_MetalnessInput.TextureMap->GetRendererID() : m_CheckerboardTex->GetRendererID()), ImVec2(64, 64));
ImGui::PopStyleVar();
if (ImGui::IsItemHovered())
{
@@ -446,7 +446,7 @@ void DemoLayer::OnImGuiRender()
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::TextUnformatted(m_MetalnessInput.TextureMap->GetPath().c_str());
ImGui::PopTextWrapPos();
ImGui::Image((void*)m_MetalnessInput.TextureMap->GetRendererID(), ImVec2(384, 384));
ImGui::Image((ImTextureRef)m_MetalnessInput.TextureMap->GetRendererID(), ImVec2(384, 384));
ImGui::EndTooltip();
}
if (ImGui::IsItemClicked())
@@ -467,7 +467,7 @@ void DemoLayer::OnImGuiRender()
if (ImGui::CollapsingHeader("Roughness", nullptr, ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 10));
ImGui::Image(m_RoughnessInput.TextureMap ? (void*)m_RoughnessInput.TextureMap->GetRendererID() : (void*)m_CheckerboardTex->GetRendererID(), ImVec2(64, 64));
ImGui::Image((ImTextureRef)(m_RoughnessInput.TextureMap ? m_RoughnessInput.TextureMap->GetRendererID() : m_CheckerboardTex->GetRendererID()), ImVec2(64, 64));
ImGui::PopStyleVar();
if (ImGui::IsItemHovered())
{
@@ -477,7 +477,7 @@ void DemoLayer::OnImGuiRender()
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::TextUnformatted(m_RoughnessInput.TextureMap->GetPath().c_str());
ImGui::PopTextWrapPos();
ImGui::Image((void*)m_RoughnessInput.TextureMap->GetRendererID(), ImVec2(384, 384));
ImGui::Image((ImTextureRef)m_RoughnessInput.TextureMap->GetRendererID(), ImVec2(384, 384));
ImGui::EndTooltip();
}
if (ImGui::IsItemClicked())
@@ -504,7 +504,7 @@ void DemoLayer::OnImGuiRender()
m_Framebuffer->Resize((uint32_t)viewportSize.x, (uint32_t)viewportSize.y);
m_FinalPresentBuffer->Resize((uint32_t)viewportSize.x, (uint32_t)viewportSize.y);
m_Camera.SetProjectionMatrix(glm::perspectiveFov(glm::radians(45.0f), viewportSize.x, viewportSize.y, 0.1f, 10000.0f));
ImGui::Image((void*)m_FinalPresentBuffer->GetColorAttachmentRendererID(), viewportSize, { 0, 1 }, { 1, 0 });
ImGui::Image((ImTextureRef)m_FinalPresentBuffer->GetColorAttachmentRendererID(), viewportSize, { 0, 1 }, { 1, 0 });
// ImGui::Image((void*)m_Framebuffer->GetColorAttachmentRendererID(), viewportSize, { 0, 1 }, { 1, 0 });
ImGui::End();
ImGui::PopStyleVar();
+1 -1
View File
@@ -246,7 +246,7 @@ void TestLayer::OnImGuiRender()
m_FrameBuffer->Resize((uint32_t)viewportSize.x, (uint32_t)viewportSize.y);
m_FinalPresentBuffer->Resize((uint32_t)viewportSize.x, (uint32_t)viewportSize.y);
m_Camera.SetProjectionMatrix(glm::perspectiveFov(glm::radians(45.0f), viewportSize.x, viewportSize.y, 0.1f, 10000.0f));
ImGui::Image((void*)m_FinalPresentBuffer->GetColorAttachmentRendererID(), viewportSize, {0, 1}, {1, 0});
ImGui::Image((ImTextureRef)m_FinalPresentBuffer->GetColorAttachmentRendererID(), viewportSize, {0, 1}, {1, 0});
ImGui::End();
ImGui::PopStyleVar();
}