save code
This commit is contained in:
+10
-1
@@ -53,6 +53,8 @@ void Application::createSurface() {
|
|||||||
|
|
||||||
void Application::initVulkan()
|
void Application::initVulkan()
|
||||||
{
|
{
|
||||||
|
if (!_applicationInited)
|
||||||
|
{
|
||||||
initWindow();
|
initWindow();
|
||||||
createInstance(); // 创建 Vulkan 实例
|
createInstance(); // 创建 Vulkan 实例
|
||||||
setupDebugMessenger(); // 在这里调用
|
setupDebugMessenger(); // 在这里调用
|
||||||
@@ -69,7 +71,14 @@ void Application::initVulkan()
|
|||||||
createCommandBuffer(); // 创建命令缓冲区
|
createCommandBuffer(); // 创建命令缓冲区
|
||||||
createSyncObjects(); // 创建同步对象
|
createSyncObjects(); // 创建同步对象
|
||||||
_lastDrawFrameTime = getCurrentTimeMillis();
|
_lastDrawFrameTime = getCurrentTimeMillis();
|
||||||
inited = true;
|
_applicationInited = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_sceondInited) {
|
||||||
|
vkDestroySurfaceKHR(instance, surface, nullptr);
|
||||||
|
createSurface();
|
||||||
|
_sceondInited = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::createImageViews() {
|
void Application::createImageViews() {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
void createSyncObjects();
|
void createSyncObjects();
|
||||||
virtual void drawFrame(long long frameTime);
|
virtual void drawFrame(long long frameTime);
|
||||||
virtual void render(VkCommandBuffer commandBuffer, long long frameTime);
|
virtual void render(VkCommandBuffer commandBuffer, long long frameTime);
|
||||||
virtual bool isInited() { return inited; }
|
virtual bool isInited() { return _applicationInited; }
|
||||||
|
|
||||||
void processWithVulkan(uint8_t* data, int width, int height, int rowStride, size_t dataSize, Texture& texture, bool srgb, VkCommandPool pool, std::string tex_path);
|
void processWithVulkan(uint8_t* data, int width, int height, int rowStride, size_t dataSize, Texture& texture, bool srgb, VkCommandPool pool, std::string tex_path);
|
||||||
|
|
||||||
@@ -77,8 +77,9 @@ public:
|
|||||||
std::vector<VkFence> imagesInFlight; // 跟踪每个图像的使用状态
|
std::vector<VkFence> imagesInFlight; // 跟踪每个图像的使用状态
|
||||||
int currentFrame = 0;
|
int currentFrame = 0;
|
||||||
int MAX_FRAMES_IN_FLIGHT = 2;
|
int MAX_FRAMES_IN_FLIGHT = 2;
|
||||||
bool inited = false;
|
bool _applicationInited = false;
|
||||||
|
|
||||||
|
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);
|
||||||
@@ -99,4 +100,6 @@ protected:
|
|||||||
long long _lastDrawFrameTime;
|
long long _lastDrawFrameTime;
|
||||||
|
|
||||||
std::mutex changeMotionMtx;
|
std::mutex changeMotionMtx;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
+5
-1
@@ -778,6 +778,8 @@ void FaceApp::initVulkan()
|
|||||||
{
|
{
|
||||||
Application::initVulkan();
|
Application::initVulkan();
|
||||||
|
|
||||||
|
if (!_faceAppInited)
|
||||||
|
{
|
||||||
createVmaAllocator();
|
createVmaAllocator();
|
||||||
LoadOBJ("face_picture_3dmax.obj", obj_vertices, obj_indices);
|
LoadOBJ("face_picture_3dmax.obj", obj_vertices, obj_indices);
|
||||||
//m_texs_left.resize(kTextureMax);
|
//m_texs_left.resize(kTextureMax);
|
||||||
@@ -819,6 +821,7 @@ void FaceApp::initVulkan()
|
|||||||
|
|
||||||
//changeMotion(_initArg.motion);
|
//changeMotion(_initArg.motion);
|
||||||
Start();
|
Start();
|
||||||
|
_faceAppInited = true;
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
std::vector<float> floatArray;
|
std::vector<float> floatArray;
|
||||||
@@ -832,6 +835,7 @@ void FaceApp::initVulkan()
|
|||||||
//ReceiveFacePoint(floatArray.data(), floatArray.size() / 3, 480, 480);
|
//ReceiveFacePoint(floatArray.data(), floatArray.size() / 3, 480, 480);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FaceApp::Start()
|
void FaceApp::Start()
|
||||||
@@ -1470,7 +1474,7 @@ string FaceApp::preLoadMotionList(string motion_list_str, Callback callback)
|
|||||||
|
|
||||||
void FaceApp::loadMotionThread()
|
void FaceApp::loadMotionThread()
|
||||||
{
|
{
|
||||||
while (!_running)
|
while (!isInited())
|
||||||
{
|
{
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -71,7 +71,7 @@ public:
|
|||||||
static FaceApp* Get() { return faceIns; }
|
static FaceApp* Get() { return faceIns; }
|
||||||
void update_face_vertex_buffer(float* pos, int pointCount);
|
void update_face_vertex_buffer(float* pos, int pointCount);
|
||||||
|
|
||||||
virtual bool isInited() override { return inited; }
|
virtual bool isInited() override { return _applicationInited && _faceAppInited && _sceondInited; }
|
||||||
virtual void cleanup() override;
|
virtual void cleanup() override;
|
||||||
|
|
||||||
Texture tex_bg = {};
|
Texture tex_bg = {};
|
||||||
@@ -210,6 +210,7 @@ public:
|
|||||||
void StopMotion();
|
void StopMotion();
|
||||||
|
|
||||||
void ResumeMotion();
|
void ResumeMotion();
|
||||||
|
bool _faceAppInited = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+2
-1
@@ -179,6 +179,7 @@ int main() {
|
|||||||
//threadRun = true;
|
//threadRun = true;
|
||||||
//std::thread t(threadFunction);
|
//std::thread t(threadFunction);
|
||||||
app.mainLoop();
|
app.mainLoop();
|
||||||
|
app._sceondInited = false;
|
||||||
//threadRun = false;
|
//threadRun = false;
|
||||||
//t.join();
|
//t.join();
|
||||||
//try {
|
//try {
|
||||||
@@ -194,7 +195,7 @@ int main() {
|
|||||||
s_motions.motions.push_back(motions["11"]);
|
s_motions.motions.push_back(motions["11"]);
|
||||||
j = s_motions;
|
j = s_motions;
|
||||||
s = j.dump();
|
s = j.dump();
|
||||||
|
app.initVulkan();
|
||||||
app.preLoadMotionList(s, CppCallback2);
|
app.preLoadMotionList(s, CppCallback2);
|
||||||
app.mainLoop();
|
app.mainLoop();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user