1 /* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_RENDER_3D_I_ENGINE_H 17 #define OHOS_RENDER_3D_I_ENGINE_H 18 19 #include <cstdint> 20 #include <string> 21 #include <memory> 22 23 #include <EGL/egl.h> 24 #include <GLES/gl.h> 25 26 #include "custom/custom_render_descriptor.h" 27 #include "custom/shader_input_buffer.h" 28 #include "data_type/constants.h" 29 #include "data_type/geometry/cube.h" 30 #include "data_type/geometry/cone.h" 31 #include "data_type/geometry/sphere.h" 32 #include "data_type/gltf_animation.h" 33 #include "data_type/light.h" 34 #include "data_type/position.h" 35 #include "data_type/pointer_event.h" 36 #include "data_type/quaternion.h" 37 #include "data_type/vec3.h" 38 #include "platform_data.h" 39 #include "texture_info.h" 40 41 namespace OHOS::Render3D { 42 class IEngine { 43 public: 44 virtual ~IEngine() = default; 45 virtual void Clone(IEngine* proto) = 0; 46 virtual bool LoadEngineLib() = 0; 47 virtual bool InitEngine(EGLContext eglContext, const PlatformData& data) = 0; 48 virtual void DeInitEngine() = 0; 49 virtual void UnloadEngineLib() = 0; 50 51 virtual void InitializeScene(uint32_t key) = 0; 52 virtual void SetupCameraViewPort(uint32_t width, uint32_t height) = 0; 53 virtual void SetupCameraTransform(const OHOS::Render3D::Position& position, const OHOS::Render3D::Vec3& lookAt, 54 const OHOS::Render3D::Vec3& up, const OHOS::Render3D::Quaternion& rotation) = 0; 55 virtual void SetupCameraViewProjection(float zNear, float zFar, float fovDegrees) = 0; 56 57 virtual void LoadSceneModel(const std::string& modelPath) = 0; 58 virtual void LoadEnvModel(const std::string& modelPath, BackgroundType type) = 0; 59 virtual void UnloadSceneModel() = 0; 60 virtual void UnloadEnvModel() = 0; 61 62 virtual void OnTouchEvent(const PointerEvent& event) = 0; 63 virtual void OnWindowChange(const TextureInfo& textureInfo) = 0; 64 65 virtual void DrawFrame() = 0; 66 67 virtual void UpdateGeometries(const std::vector<std::shared_ptr<Geometry>>& shapes) = 0; 68 virtual void UpdateGLTFAnimations(const std::vector<std::shared_ptr<GLTFAnimation>>& animations) = 0; 69 virtual void UpdateLights(const std::vector<std::shared_ptr<OHOS::Render3D::Light>>& lights) = 0; 70 virtual void UpdateCustomRender(const std::shared_ptr<CustomRenderDescriptor>& customRender) = 0; 71 virtual void UpdateShaderPath(const std::string& shaderPath) = 0; 72 virtual void UpdateImageTexturePaths(const std::vector<std::string>& imageTextures) = 0; 73 virtual void UpdateShaderInputBuffer( 74 const std::shared_ptr<OHOS::Render3D::ShaderInputBuffer>& shaderInputBuffer) = 0; 75 76 virtual bool NeedsRepaint() = 0; 77 78 #if defined(MULTI_ECS_UPDATE_AT_ONCE) && (MULTI_ECS_UPDATE_AT_ONCE == 1) 79 virtual void DeferDraw() = 0 ; 80 virtual void DrawMultiEcs(const std::unordered_map<void*, void*>& ecss) = 0; 81 #endif 82 }; 83 } // namespace OHOS::Render3D 84 #endif // OHOS_RENDER_3D_I_ENGINE_H 85