VTK
vtkPixelBufferObject.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPixelBufferObject.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
29 #ifndef __vtkPixelBufferObject_h
30 #define __vtkPixelBufferObject_h
31 
32 #include "vtkObject.h"
33 #include "vtkWeakPointer.h" // needed for vtkWeakPointer.
34 
35 class vtkRenderWindow;
37 
39 {
40 public:
41 
42  //BTX
43  // Usage values.
44  enum
45  {
46  StreamDraw=0,
55  NumberOfUsages
56  };
57  //ETX
58 
59  static vtkPixelBufferObject* New();
61  void PrintSelf(ostream& os, vtkIndent indent);
62 
64 
68  void SetContext(vtkRenderWindow* context);
69  vtkRenderWindow* GetContext();
71 
73 
84  vtkGetMacro(Usage,int);
85  vtkSetMacro(Usage,int);
87 
89 
95  bool Upload1D(int type, void* data,
96  unsigned int numtuples, int comps, vtkIdType increment)
97  {
98  unsigned int newdims[3];
99  newdims[0] = numtuples;
100  newdims[1] = 1;
101  newdims[2] = 1;
102  vtkIdType newinc[3];
103  newinc[0] = increment;
104  newinc[1] = 0;
105  newinc[2] = 0;
106  return this->Upload3D(type, data, newdims, comps, newinc,0,0);
107  }
109 
111 
116  bool Upload2D(int type, void* data,
117  unsigned int dims[2],
118  int comps,
119  vtkIdType increments[2])
120  {
121  unsigned int newdims[3];
122  newdims[0] = dims[0];
123  newdims[1] = dims[1];
124  newdims[2] = 1;
125  vtkIdType newinc[3];
126  newinc[0] = increments[0];
127  newinc[1] = increments[1];
128  newinc[2] = 0;
129  return this->Upload3D(type, data, newdims, comps, newinc,0,0);
130  }
132 
134 
139  bool Upload3D(int type, void* data,
140  unsigned int dims[3], int comps,
141  vtkIdType increments[3],
142  int components,
143  int *componentList);
145 
147 
150  vtkGetMacro(Type, int);
152 
154 
156  vtkGetMacro(Size, unsigned int);
158 
160 
161  vtkGetMacro(Handle, unsigned int);
163 
165 
168  int type, void* data,
169  unsigned int dim,
170  int numcomps, vtkIdType increment)
171  {
172  unsigned int newdims[3];
173  newdims[0] = dim;
174  newdims[1] = 1;
175  newdims[2] = 1;
176  vtkIdType newincrements[3];
177  newincrements[0] = increment;
178  newincrements[1] = 0;
179  newincrements[2] = 0;
180  return this->Download3D(type, data, newdims, numcomps, newincrements);
181  }
183 
185 
188  int type, void* data,
189  unsigned int dims[2],
190  int numcomps, vtkIdType increments[2])
191  {
192  unsigned int newdims[3];
193  newdims[0] = dims[0];
194  newdims[1] = dims[1];
195  newdims[2] = 1;
196  vtkIdType newincrements[3];
197  newincrements[0] = increments[0];
198  newincrements[1] = increments[1];
199  newincrements[2] = 0;
200  return this->Download3D(type, data, newdims, numcomps, newincrements);
201  }
203 
205 
207  bool Download3D(int type, void* data,
208  unsigned int dims[3],
209  int numcomps, vtkIdType increments[3]);
211 
213 
215  { this->Bind(PACKED_BUFFER); }
217 
219  { this->Bind(UNPACKED_BUFFER); }
220 
222  void UnBind();
223 
224 //BTX
225  // We can't use just PACKED because this is a cygwin macro defined as
226  // __attribute__((packed))
229  UNPACKED_BUFFER
230  };
231 
233  void Bind(BufferType buffer);
234 
236 
237  void Allocate(unsigned int size,
238  int type);
240 
242  void ReleaseMemory();
243 
245  static bool IsSupported(vtkRenderWindow* renWin);
246 
247 //ETX
248 //BTX
249 protected:
252 
255  bool LoadRequiredExtensions(vtkOpenGLExtensionManager* mgr);
256 
258  void CreateBuffer();
259 
261  void DestroyBuffer();
262 
263  int Usage;
264  unsigned int BufferTarget; // GLenum
265  int Type;
266  unsigned int Size;
268  unsigned int Handle;
269 private:
270  vtkPixelBufferObject(const vtkPixelBufferObject&); // Not implemented.
271  void operator=(const vtkPixelBufferObject&); // Not implemented.
272  //ETX
273 };
274 
275 #endif
276 
277