-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcurve.h
67 lines (56 loc) · 1.96 KB
/
curve.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
// Copyright(c) Leonardo Romor <[email protected]>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://gnu.org/licenses/gpl-2.0.txt>
#ifndef __CURVE_H_
#define __CURVE_H_
#include <vulkan/vulkan.hpp>
#include <sstream>
#include "vulkan-core.h"
#include "entity.h"
struct Point {
float x, y, z;
std::string to_string() const {
std::ostringstream output;
output << "{ ";
output << x << ", ";
output << y << ", ";
output << z << " }";
return output.str();
}
};
Point operator* (const float scalar, const Point& point);
Point operator* (const Point& point, const float scalar);
Point operator+ (const Point& p1, const Point& p2);
class Curve : public space::Entity {
public:
Curve() {}
virtual void Register(
space::core::VkAppContext *context,
vk::UniquePipelineLayout *pipeline_layout,
vk::UniqueRenderPass *render_pass,
vk::SampleCountFlagBits nsamples,
vk::UniquePipelineCache *pipeline_cache) final;
virtual ~Curve() {}
// Draw in the command buffer
virtual void Draw(const vk::UniqueCommandBuffer *command_buffer) final;
// Update the curve to render from 0 up to t.
void Update(const float t);
private:
vk::UniquePipeline pipeline_;
std::vector<Point> points_;
space::core::VkAppContext *vk_ctx_;
std::unique_ptr<space::core::BufferData> vertex_buffer_data_;
std::unique_ptr<space::core::BufferData> index_buffer_data_;
};
#endif // __CURVE_H_