forked from arrayfire/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhist_graphics.cpp
More file actions
45 lines (36 loc) · 1.2 KB
/
hist_graphics.cpp
File metadata and controls
45 lines (36 loc) · 1.2 KB
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
/*******************************************************
* Copyright (c) 2014, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <err_cpu.hpp>
#include <hist_graphics.hpp>
#include <platform.hpp>
#include <queue.hpp>
namespace cpu {
template<typename T>
void copy_histogram(const Array<T> &data, fg_histogram hist) {
ForgeModule &_ = graphics::forgePlugin();
data.eval();
getQueue().sync();
CheckGL("Begin copy_histogram");
unsigned bytes = 0, buffer = 0;
FG_CHECK(_.fg_get_histogram_vertex_buffer(&buffer, hist));
FG_CHECK(_.fg_get_histogram_vertex_buffer_size(&bytes, hist));
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glBufferSubData(GL_ARRAY_BUFFER, 0, bytes, data.get());
glBindBuffer(GL_ARRAY_BUFFER, 0);
CheckGL("End copy_histogram");
}
#define INSTANTIATE(T) \
template void copy_histogram<T>(const Array<T> &, fg_histogram);
INSTANTIATE(float)
INSTANTIATE(int)
INSTANTIATE(uint)
INSTANTIATE(uchar)
INSTANTIATE(short)
INSTANTIATE(ushort)
} // namespace cpu