-
Notifications
You must be signed in to change notification settings - Fork 37
/
gpu_buffer_rt.h
66 lines (48 loc) · 1.62 KB
/
gpu_buffer_rt.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
// This file is distributed under the MIT license.
// See the LICENSE file for details.
#pragma once
#ifndef VSNRAY_COMMON_GPU_BUFFER_RT_H
#define VSNRAY_COMMON_GPU_BUFFER_RT_H 1
#include <visionaray/math/forward.h>
#include <visionaray/math/vector.h>
#include <visionaray/pixel_traits.h>
#include <visionaray/render_target.h>
namespace visionaray
{
// TODO: have a *single* buffered render target template
// from either std::vector or cuda::device_vector???
template <
pixel_format ColorFormat,
pixel_format DepthFormat,
pixel_format AccumFormat = PF_UNSPECIFIED
>
class gpu_buffer_rt : public render_target
{
public:
using color_type = typename pixel_traits<ColorFormat>::type;
using depth_type = typename pixel_traits<DepthFormat>::type;
using accum_type = typename pixel_traits<AccumFormat>::type;
using ref_type = render_target_ref<ColorFormat, DepthFormat, AccumFormat>;
public:
color_type* color();
depth_type* depth();
accum_type* accum();
color_type const* color() const;
depth_type const* depth() const;
accum_type const* accum() const;
ref_type ref();
void clear_color_buffer(vec4 const& color = vec4(0.0f));
void clear_depth_buffer(float depth = 1.0f);
void clear_accum_buffer(vec4 const& color = vec4(0.0f));
void begin_frame();
void end_frame();
void resize(int w, int h);
void display_color_buffer() const;
private:
color_type* color_buffer_ = nullptr;
depth_type* depth_buffer_ = nullptr;
accum_type* accum_buffer_ = nullptr;
};
} // visionaray
#include "gpu_buffer_rt.inl"
#endif // VSNRAY_COMMON_GPU_BUFFER_RT_H