PICCANTE  0.4
The hottest HDR imaging library!
ssbo.hpp
Go to the documentation of this file.
1 /*
2 
3 PICCANTE
4 The hottest HDR imaging library!
5 http://vcg.isti.cnr.it/piccante
6 
7 Copyright (C) 2014
8 Visual Computing Laboratory - ISTI CNR
9 http://vcg.isti.cnr.it
10 First author: Francesco Banterle
11 
12 This Source Code Form is subject to the terms of the Mozilla Public
13 License, v. 2.0. If a copy of the MPL was not distributed with this
14 file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 
16 */
17 
18 #ifndef PIC_UTIL_GL_SSBO_HPP
19 #define PIC_UTIL_GL_SSBO_HPP
20 
21 #include <iostream>
22 
23 namespace pic {
24 
25 using namespace std;
26 
27 #ifdef OPEN_GL_4_30
28 
31 class Ssbo
32 {
33 protected:
34  GLuint ssbo;
35  total_size;
36 
37 public:
38 
42  Ssbo()
43  {
44  total_size = 0;
45  ssbo = 0;
46  }
47 
48  ~Ssbo()
49  {
50  if(ssbo != 0) {
51  }
52  }
53 
60  void init(unsigned int size_buffer, unsigned int size_of_type, void *data)
61  {
62  total_size = size_buffer * size_of_type;
63  glGenBuffers(1, &ssbo);
64  glBindBuffer(GL_SHADER_STORAGE_BUFFER, posSSbo );
65  glBufferData(GL_SHADER_STORAGE_BUFFER, total_size, data, GL_DYNAMIC_COPY );
66 
67  glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
68  }
69 
74  void update(void *data)
75  {
76  glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo);
77  GLvoid *p = glMapBuffer(GL_SHADER_STORAGE_BUFFER, GL_WRITE_ONLY);
78  memcpy(p, &data, total_size)
79  glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
80  }
81 
82  void bind(unsigned int index)
83  {
84  glBindBufferBase(GL_SHADER_STORAGE_BUFFER, index, ssbo);
85  }
86 
87  void unbind(unsigned int index)
88  {
89  glBindBufferBase(GL_SHADER_STORAGE_BUFFER, index, 0);
90  }
91 
92  /*
93  void *mapBuffer()
94  {
95  glBindBuffer(GL_SHADER_STORAGE_BUFFER, posSSbo );
96  GLint bufMask = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT;
97  return glMapBufferRange( GL_SHADER_STORAGE_BUFFER, 0, total_size, bufMask);
98  }
99 
100  void unmapBuffer()
101  {
102  glUnmapBuffer( GL_SHADER_STORAGE_BUFFER );
103  }
104  */
105 };
106 
107 #endif
108 
109 }// end namespace pic
110 
111 
112 #endif /* PIC_UTIL_GL_SSBO_HPP */
113 
Definition: bilateral_separation.hpp:25