xcal
基于 C++23 的现代图形渲染引擎
载入中...
搜索中...
未找到
examples
axis.cc
浏览该文件的文档.
1
#include <cmath>
2
#include <cstddef>
3
#include <
xcal/mobject/objects/axis.hpp
>
4
#include <
xcal/mobject/objects/path.hpp
>
5
#include <
xcal/render/impl/opengl/opengl_render.hpp
>
6
#include <
xcal/scene/scene.hpp
>
7
#include <
xcmath/mobject/function.hpp
>
8
9
int
main
() {
10
auto
scene = std::make_unique<xcal::scene::Scene>();
11
using namespace
xcal::mobject
;
12
using namespace
xcal::property
;
13
14
Path::data_t
p(10);
15
16
for
(
size_t
i = 0; i < p.size(); ++i) {
17
auto
d =
xcmath::radians
((
float_t
)i * 360.0 / (
float_t
)p.size());
18
p[i] =
xcmath::vec2<float_t>
{(
float_t
)cos(d), (
float_t
)sin(d)} *
19
(
float_t
(i % 2) * 0.5f + 0.5f);
20
}
21
22
// auto path = scene->add<Path>(Path::data_t{p}, false)
23
// ->set_stroke_color({0, 1, 0, 1})
24
// ->set_fill_color({0, 1, 1, 0.1});
25
26
auto
axis =
27
scene->add(
new
Axis3D
{})->x_axis()->set_stroke_color({1, 0, 0, 1});
28
29
auto
render =
xcal::render::opengl::OpenGLRender
{scene.get()};
30
render.
default_camera
()
31
->
set_background_color
(0.2, 0.2, 0.2, 1.0)
32
->
set_position
(-3, 3, 3);
33
34
render.show(1200, 675);
35
return
0;
36
}
xcal::camera::AbsCamera::set_position
AbsCamera * set_position(Args &&... args)
设置相机位置
Definition
abs_camera.hpp:130
xcal::camera::AbsCamera::set_background_color
AbsCamera * set_background_color(Args &&... args)
设置背景颜色
Definition
abs_camera.hpp:168
xcal::mobject::Axis3D
Definition
axis.hpp:39
xcal::mobject::Path::data_t
std::vector< vec > data_t
Definition
path.hpp:16
xcal::render::opengl::OpenGLRender
Definition
opengl_render.hpp:22
xcal::render::opengl::OpenGLRender::default_camera
xcal::camera::AbsCamera * default_camera() const
Definition
opengl_render.hpp:50
xcmath::vec
Vector class template
Definition
vec.hpp:206
main
int main()
Definition
axis.cc:9
function.hpp
Header file for mathematical functions
axis.hpp
path.hpp
xcal::mobject
Definition
abs_mgroup.hpp:14
xcal::property
Definition
Interpolation.hpp:18
xcal::float_t
float float_t
Definition
public.h:27
xcmath::radians
constexpr T radians(T degrees)
Convert degrees to radians
Definition
function.hpp:25
opengl_render.hpp
scene.hpp
生成于 2025年 九月 19日 星期五 21:12:12 , 为 xcal使用
1.9.8