Forge
CPUCopy.hpp
Go to the documentation of this file.
1 /*******************************************************
2  * Copyright (c) 2015-2019, ArrayFire
3  * All rights reserved.
4  *
5  * This file is distributed under 3-clause BSD license.
6  * The complete license agreement can be obtained at:
7  * http://arrayfire.com/licenses/BSD-3-Clause
8  ********************************************************/
9 
10 #ifndef __CPU_DATA_COPY_H__
11 #define __CPU_DATA_COPY_H__
12 
13 namespace fg
14 {
15 
16 template<typename T>
17 void copy(fg::Image& out, const T * dataPtr)
18 {
19  glBindBuffer(GL_PIXEL_UNPACK_BUFFER, out.pbo());
20  glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, out.size(), dataPtr);
21  glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
22 }
23 
24 /*
25  * Below functions takes any renderable forge object that has following member functions
26  * defined
27  *
28  * `unsigned Renderable::vbo() const;`
29  * `unsigned Renderable::size() const;`
30  *
31  * Currently fg::Plot, fg::Histogram objects in Forge library fit the bill
32  */
33 template<class Renderable, typename T>
34 void copy(Renderable& out, const T * dataPtr)
35 {
36  glBindBuffer(GL_ARRAY_BUFFER, out.vbo());
37  glBufferSubData(GL_ARRAY_BUFFER, 0, out.size(), dataPtr);
38  glBindBuffer(GL_ARRAY_BUFFER, 0);
39 }
40 
41 }
42 
43 #endif //__CPU_DATA_COPY_H__
FGAPI unsigned size() const
Get the OpenGL Pixel Buffer Object resource size.
Definition: CPUCopy.hpp:13
void copy(fg::Image &out, const T *dataPtr)
Definition: CPUCopy.hpp:17
FGAPI unsigned pbo() const
Get the OpenGL Pixel Buffer Object identifier.
Definition: image.h:25