reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

ofBufferObject.h
Go to the documentation of this file.
1#pragma once
2
3#include "ofConstants.h"
4
5template<typename T>
6class ofPixels_;
7
9public:
11
14 void allocate();
15
20 void allocate(GLsizeiptr bytes, GLenum usage);
21 void allocate(GLsizeiptr bytes, const void * data, GLenum usage);
22
23 template<typename T>
24 void allocate(const std::vector<T> & data, GLenum usage){
25 allocate(data.size()*sizeof(T),&data[0],usage);
26 }
27
28 template<typename T>
29 void allocate(const ofPixels_<T> & data, GLenum usage){
30 allocate(data.size()*sizeof(T),data.getData(),usage);
31 }
32
34 bool isAllocated() const;
35
37 void bind(GLenum target) const;
38
40 void unbind(GLenum target) const;
41
42#if !defined(TARGET_OPENGLES) || defined(TARGET_EMSCRIPTEN)
44 void bindBase(GLenum target,GLuint index) const;
45
47 void unbindBase(GLenum target,GLuint index) const;
48
50 void bindRange(GLenum target,GLuint index, GLintptr offset, GLsizeiptr size) const;
51
53 void unbindRange(GLenum target,GLuint index) const;
54#endif
55
57 GLuint getId() const;
58
62 void setData(GLsizeiptr bytes, const void * data, GLenum usage);
63
64
68 void updateData(GLintptr offset, GLsizeiptr bytes, const void * data);
69 void updateData(GLsizeiptr bytes, const void * data);
70
73 template<typename T>
74 void setData(const std::vector<T> & data, GLenum usage){
75 setData(data.size()*sizeof(T),&data[0],usage);
76 }
77
78 template<typename T>
79 void setData(const ofPixels_<T> & data, GLenum usage){
80 setData(data.size()*sizeof(T),data.getPixels(),usage);
81 }
82
85 template<typename T>
86 void updateData(GLintptr offset, const std::vector<T> & data){
87 updateData(offset,data.size()*sizeof(T),&data[0]);
88 }
89
92 template<typename T>
93 void updateData(const std::vector<T> & data){
94 updateData(0,data.size()*sizeof(T),&data[0]);
95 }
96
97#ifndef TARGET_OPENGLES
101 void * map(GLenum access);
102
106 void unmap();
107
110 template<typename T>
111 T * map(GLenum access){
112 return static_cast<T*>(map(access));
113 }
114
118 void * mapRange(GLintptr offset, GLsizeiptr length, GLenum access);
119
121 void unmapRange();
122
125 template<typename T>
126 T * mapRange(GLintptr offset, GLsizeiptr length, GLenum access){
127 return static_cast<T*>(mapRange(offset,length,access));
128 }
129
130 void copyTo(ofBufferObject & dstBuffer) const;
131 void copyTo(ofBufferObject & dstBuffer, int readOffset, int writeOffset, size_t size) const;
132
133 void invalidate();
134#endif
135
136 GLsizeiptr size() const;
137
138private:
139 struct Data{
140 Data();
141 ~Data();
142 GLuint id;
143 GLsizeiptr size;
144 GLenum lastTarget;
145 bool isBound;
146 bool isDSA;
147 };
148 std::shared_ptr<Data> data;
149};
Definition ofBufferObject.h:8
GLuint getId() const
returns the id of the buffer if it's allocated or 0 otherwise
Definition ofBufferObject.cpp:114
void updateData(GLintptr offset, GLsizeiptr bytes, const void *data)
Definition ofBufferObject.cpp:136
void unbindRange(GLenum target, GLuint index) const
binds the given target and index to 0
Definition ofBufferObject.cpp:109
void bindRange(GLenum target, GLuint index, GLintptr offset, GLsizeiptr size) const
glBindBufferRange: https://www.opengl.org/sdk/docs/man4/html/glBindBufferRange.xhtml
Definition ofBufferObject.cpp:101
void bind(GLenum target) const
glBindBuffer: https://www.opengl.org/sdk/docs/man4/html/glBindBuffer.xhtml
Definition ofBufferObject.cpp:70
void allocate(const std::vector< T > &data, GLenum usage)
Definition ofBufferObject.h:24
T * map(GLenum access)
Definition ofBufferObject.h:111
void setData(const ofPixels_< T > &data, GLenum usage)
Definition ofBufferObject.h:79
void allocate()
Definition ofBufferObject.cpp:52
void * map(GLenum access)
Definition ofBufferObject.cpp:158
void setData(const std::vector< T > &data, GLenum usage)
Definition ofBufferObject.h:74
void unbind(GLenum target) const
binds the passed target to buffer 0
Definition ofBufferObject.cpp:78
void bindBase(GLenum target, GLuint index) const
glBindBufferBase: https://www.opengl.org/sdk/docs/man4/html/glBindBufferBase.xhtml
Definition ofBufferObject.cpp:86
void updateData(const std::vector< T > &data)
Definition ofBufferObject.h:93
void invalidate()
Definition ofBufferObject.cpp:265
void setData(GLsizeiptr bytes, const void *data, GLenum usage)
Definition ofBufferObject.cpp:119
ofBufferObject()
Definition ofBufferObject.cpp:47
void updateData(GLintptr offset, const std::vector< T > &data)
Definition ofBufferObject.h:86
GLsizeiptr size() const
Definition ofBufferObject.cpp:271
void * mapRange(GLintptr offset, GLsizeiptr length, GLenum access)
Definition ofBufferObject.cpp:214
void allocate(const ofPixels_< T > &data, GLenum usage)
Definition ofBufferObject.h:29
void unbindBase(GLenum target, GLuint index) const
binds the given target and index to buffer 0
Definition ofBufferObject.cpp:94
void unmap()
Definition ofBufferObject.cpp:192
bool isAllocated() const
true if allocate was called before
Definition ofBufferObject.cpp:66
void copyTo(ofBufferObject &dstBuffer) const
Definition ofBufferObject.cpp:233
T * mapRange(GLintptr offset, GLsizeiptr length, GLenum access)
Definition ofBufferObject.h:126
void unmapRange()
same as unmap, just to make the api more clear
Definition ofBufferObject.cpp:229
A class representing a collection of pixels.
Definition ofPixels.h:170
PixelType * getData()
Retrieves pixel data from the ofPixel object.
Definition ofPixels.cpp:500
size_t size() const
Get the number of values that the ofPixels object contains, so an RGB data 400x400 would be 480,...
Definition ofPixels.cpp:997