#ifndef NATIVE_RENDER_THREAD_H #define NATIVE_RENDER_THREAD_H #include #include #include #include #include #include #include "EGLCore.h" #include "NativeRender.h" namespace NativeOpenCAX { class NativeRenderThread { public: NativeRenderThread(); ~NativeRenderThread(); bool start(OHNativeWindow* window); void stop(); void loadModel(const std::string& filePath); void setCameraRotationMode(bool state); void setRotation(float xAngle, float yAngle); void setTranslation(float x, float y); void resetView(); void setClearColor(float r, float g, float b, float a); void resizeWindow(int width, int height); void swicthView(std::string strView); using Callback = std::function; void registerRenderCompleteCallback(Callback callback); private: void renderLoop(); std::thread renderThread_; std::atomic isRunning_; OHNativeWindow* nativeWindow_; EGLCore* eglCore_; NativeRender renderer_; std::mutex commandMutex_; std::condition_variable commandCondition_; enum CommandType { CMD_LOAD_MODEL, CMD_SET_ROTATION, CMD_SET_TRANSLATION, CMD_RESET_VIEW, CMD_SET_CLEAR_COLOR, CMD_RESIZE, //视图枚举 CMD_VIEW_FRONT, CMD_VIEW_TOP, CMD_VIEW_LEFT_SIDE, CMD_VIEW_RIGHT_SIDE, CMD_VIEW_BOTTOM, CMD_VIEW_REAR, CMD_VIEW_ISO, CMD_VIEW_DIM, CMD_EXIT }; struct RenderCommand { CommandType type; std::string param1; // For file path float param2, param3, param4, param5; bool param6; RenderCommand() : type(CMD_EXIT), param1(""), param2(0.0f), param3(0.0f), param4(0.0f), param5(0.0f) {} RenderCommand(CommandType t) : type(t), param1(""), param2(0), param3(0), param4(0), param5(0),param6(true) {} }; std::queue commandQueue_; std::mutex callbackMutex_; Callback renderCompleteCallback_; int windowWidth_; int windowHeight_; }; } // namespace NaitveRenderThread #endif //NATIVE_RENDER_THREAD_H