save code
This commit is contained in:
@@ -93,6 +93,8 @@ void android_main(struct android_app *pApp) {
|
||||
}
|
||||
} while (!pApp->destroyRequested);
|
||||
//application.cleanup();
|
||||
g_Application->cleanupSecondInit();
|
||||
g_Application->clearnSecondFaceApp();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+31
-1
@@ -75,12 +75,42 @@ void Application::initVulkan()
|
||||
}
|
||||
|
||||
if (!_sceondInited) {
|
||||
vkDestroySurfaceKHR(instance, surface, nullptr);
|
||||
|
||||
createSurface();
|
||||
createSwapChain(); // 创建交换链
|
||||
createImageViews(); // 创建交换链图像视图
|
||||
createRenderPass(); // 创建渲染流程
|
||||
createPipelineLayout(); // 在这里调用
|
||||
createGraphicsPipeline(); // 创建图形管线
|
||||
createFramebuffers(); // 创建帧缓冲区
|
||||
_sceondInited = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Application::cleanupSecondInit()
|
||||
{
|
||||
vkDestroySwapchainKHR(device, swapChain, nullptr);
|
||||
vkDestroySurfaceKHR(instance, surface, nullptr);
|
||||
vkDestroyPipeline(device, graphicsPipeline, nullptr);
|
||||
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
|
||||
vkDestroyRenderPass(device, renderPass, nullptr);
|
||||
for (auto imageView : swapChainImageViews) {
|
||||
vkDestroyImageView(device, imageView, nullptr);
|
||||
}
|
||||
for (auto framebuffer : swapChainFramebuffers)
|
||||
{
|
||||
if (framebuffer != VK_NULL_HANDLE)
|
||||
{
|
||||
vkDestroyFramebuffer(device, framebuffer, nullptr);
|
||||
}
|
||||
}
|
||||
swapChainFramebuffers.clear();
|
||||
|
||||
_sceondInited = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Application::createImageViews() {
|
||||
swapChainImageViews.resize(swapChainImages.size());
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ protected:
|
||||
VkPipeline graphicsPipeline; // 图形管线
|
||||
std::vector<VkFramebuffer> swapChainFramebuffers; // 帧缓冲区
|
||||
VkQueue presentQueue; // 呈现队列
|
||||
bool _sceondInited = true;
|
||||
|
||||
public:
|
||||
VkCommandPool commandPool;
|
||||
@@ -78,8 +79,8 @@ public:
|
||||
int currentFrame = 0;
|
||||
int MAX_FRAMES_IN_FLIGHT = 2;
|
||||
bool _applicationInited = false;
|
||||
void cleanupSecondInit();
|
||||
|
||||
bool _sceondInited = true;
|
||||
|
||||
protected:
|
||||
void loadTexture(std::string path, Texture& tex, bool srgb, VkCommandPool pool);
|
||||
|
||||
+13
-4
@@ -741,7 +741,7 @@ void FaceApp::render(VkCommandBuffer commandBuffer, long long frameTime)
|
||||
#ifdef _WIN32
|
||||
vkCmdDrawIndexed(commandBuffer, obj_indices.size(), 1, 0, 0, 0);
|
||||
#else
|
||||
//if (getCurrentTimeMillis() - last_update_time < 2000)
|
||||
if (getCurrentTimeMillis() - last_update_time < 2000)
|
||||
{
|
||||
vkCmdDrawIndexed(commandBuffer, obj_indices.size(), 1, 0, 0, 0);
|
||||
}
|
||||
@@ -836,6 +836,18 @@ void FaceApp::initVulkan()
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!_secondfaceAppInited)
|
||||
{
|
||||
Start();
|
||||
_playMotion = true;
|
||||
_secondfaceAppInited = true;
|
||||
}
|
||||
}
|
||||
|
||||
void FaceApp::clearnSecondFaceApp()
|
||||
{
|
||||
_secondfaceAppInited = false;
|
||||
}
|
||||
|
||||
void FaceApp::Start()
|
||||
@@ -912,9 +924,6 @@ void FaceApp::uploadVertexData() {
|
||||
|
||||
void FaceApp::update_face_vertex_buffer(float* pos, int pointCount)
|
||||
{
|
||||
if (pointCount == 0x33435342) {
|
||||
return;
|
||||
}
|
||||
if(!isInited())
|
||||
{
|
||||
return;
|
||||
|
||||
+3
-1
@@ -161,8 +161,9 @@ private:
|
||||
VkDescriptorSetLayout m_descriptorSetLayout_bg = VK_NULL_HANDLE;
|
||||
VkDescriptorSet m_descriptor_set_bg = VK_NULL_HANDLE;
|
||||
|
||||
|
||||
bool _secondfaceAppInited = true;
|
||||
public:
|
||||
void clearnSecondFaceApp();
|
||||
void Start();
|
||||
void Stop();
|
||||
void loadMotionThread();
|
||||
@@ -211,6 +212,7 @@ public:
|
||||
|
||||
void ResumeMotion();
|
||||
bool _faceAppInited = false;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+2
-1
@@ -179,7 +179,8 @@ int main() {
|
||||
//threadRun = true;
|
||||
//std::thread t(threadFunction);
|
||||
app.mainLoop();
|
||||
app._sceondInited = false;
|
||||
app.cleanupSecondInit();
|
||||
|
||||
//threadRun = false;
|
||||
//t.join();
|
||||
//try {
|
||||
|
||||
Reference in New Issue
Block a user