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