save code
This commit is contained in:
+15
-1
@@ -60,7 +60,10 @@ void Application::initWindow()
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
||||
|
||||
window = glfwCreateWindow(480, 480, "Vulkan", nullptr, nullptr);
|
||||
// Windows 端仅用于本机调试。改成接近手机的竖屏比例(540x960),
|
||||
// 这样能直观验证「画布居中正方形 + 上下黑边 letterbox」的效果。
|
||||
// Android 端走另一条分支,窗口尺寸由系统 surface 决定。
|
||||
window = glfwCreateWindow(540, 960, "Vulkan", nullptr, nullptr);
|
||||
#else
|
||||
|
||||
#endif
|
||||
@@ -134,6 +137,17 @@ void Application::initVulkan()
|
||||
}
|
||||
}
|
||||
|
||||
// ⚠️ Android 路径不要调这个!这个函数销毁的是「第二阶段 init」期间创建的所有
|
||||
// 资源(含 renderPass / graphicsPipeline / pipelineLayout),但**没有**重置
|
||||
// _applicationInited / _sceondInited,也没有把销毁的句柄置 VK_NULL_HANDLE。
|
||||
//
|
||||
// 之前 main.cpp android_main 退出时调过它,结果用户在主界面切换镜头再进入
|
||||
// MakeupActivity 时 onWindowInit 看到 _applicationInited=1 走 reinit 复用路径
|
||||
// 引用悬空 renderPass,validation layer 检测出 use-after-free 触发 SEGV。
|
||||
//
|
||||
// Android 上的窗口生命周期是 cleanupForWindowLost() + reinitForNewWindow(),
|
||||
// renderPass / pipeline 跨 NativeActivity 实例由 g_Application 单例持有。
|
||||
// 这个函数目前只保留给 vulkan/main.cpp 那个独立 desktop 入口的进程退出路径。
|
||||
void Application::cleanupSecondInit()
|
||||
{
|
||||
vkDestroySwapchainKHR(device, swapChain, nullptr);
|
||||
|
||||
Reference in New Issue
Block a user