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

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
)

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)

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;
};

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

View File

@ -9,7 +9,7 @@
namespace Prism
{
class Camera
class PRISM_API Camera
{
public:
Camera(const glm::mat4& projectionMatrix);

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())

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);

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()

View File

@ -11,7 +11,7 @@
namespace Prism
{
class Mesh
class PRISM_API Mesh
{
public:
struct Vertex

View File

@ -35,7 +35,6 @@ namespace Prism
private:
static Renderer* s_Instance;
// static inline Renderer* s_Instance = nullptr;
RenderCommandQueue m_CommandQueue;
};

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)
{

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;
};
}