xcal
基于 C++23 的现代图形渲染引擎
载入中...
搜索中...
未找到
context.hpp
浏览该文件的文档.
1
11#pragma once
12
13#include <xcal/public.h>
14
16
17namespace xcal::animation {
18class Timeline;
19class AbsAnimation;
20} // namespace xcal::animation
21namespace xcal::camera {
22class AbsCamera;
23}
24namespace xcal::render {
25class Render;
26}
27namespace xcal::mobject {
28class MObject;
29}
30namespace xcal::render::opengl {
31class OpenGLRender;
32}
36
37 protected:
48 std::string name;
49 CameraHandle(camera_t* camera);
50 CameraHandle(camera_t* camera, const std::string& name);
51 };
54 std::string name;
56 : timeline(timeline),
57 name(std::string("timeline:") +
58 std::to_string((size_t)timeline)) {}
59 };
62 std::string name;
64 : animation(animation),
65 name(std::string("animation:") +
66 std::to_string((size_t)animation)) {}
67 };
68
69 private:
70 std::vector<ObjectHandle> object_handles_{};
71 std::vector<CameraHandle> camera_handles_{};
72 std::vector<AnimationHandle> animation_handles_{};
73 std::vector<TimelineHandle> timeline_handles_{};
74 CameraHandle default_camera_handles_{nullptr, "default"};
75 OpenGLRender* renderer_{nullptr};
76 double last_fps_;
77 std::chrono::high_resolution_clock::time_point last_time_point_;
78 std::chrono::high_resolution_clock::time_point last_update_time_point_;
79
80 private:
81 void render_();
82 void update_fps_();
83
84 public:
85 Context(OpenGLRender* renderer);
86 virtual ~Context() = default;
87
88 public:
89 void flush();
90 std::vector<ObjectHandle>& object_handles() { return object_handles_; }
91 std::vector<CameraHandle>& camera_handles() { return camera_handles_; }
92 std::vector<AnimationHandle>& animation_handles() {
93 return animation_handles_;
94 }
95 std::vector<TimelineHandle>& timeline_handles() {
96 return timeline_handles_;
97 }
98 CameraHandle& default_camera_handle() { return default_camera_handles_; }
99 OpenGLRender* renderer() const { return renderer_; }
100 float_t fps() const { return last_fps_; }
101
102 public:
103 virtual void init() = 0;
104 virtual void deinit() = 0;
105 virtual void before_swap_buffers() = 0;
106 virtual void render() = 0;
107
108 public:
109 Context(const Context&) = delete;
110 Context(Context&&) = delete;
111 Context& operator=(const Context&) = delete;
113};
114} // namespace xcal::render::opengl::ui
抽象图形对象基类
相机系统命名空间
图形对象命名空间
CameraHandle & default_camera_handle()
Definition context.hpp:98
std::vector< TimelineHandle > & timeline_handles()
Definition context.hpp:95
OpenGLRender * renderer() const
Definition context.hpp:99
virtual void before_swap_buffers()=0
Context & operator=(const Context &)=delete
Context(const Context &)=delete
std::vector< AnimationHandle > & animation_handles()
Definition context.hpp:92
std::vector< CameraHandle > & camera_handles()
Definition context.hpp:91
Context & operator=(Context &&)=delete
std::vector< ObjectHandle > & object_handles()
Definition context.hpp:90
PerspectiveCamera 测试套件
XCAL_API const char * to_string(xcal::camera::CameraType type)
float float_t
Definition public.h:27
#define XCAL_API
Definition public.h:69
AnimationHandle(animation::AbsAnimation *animation)
Definition context.hpp:63
TimelineHandle(animation::Timeline *timeline)
Definition context.hpp:55