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