History

Introducing the COntext and the Backend object and the specialized GLBackend for the real OpenGL backend to the graphics api

Sam Gateau committed 12 years ago

Commit 88eaeae1 parent 6101c3b7 files · +39 −819Browse files

Showing the changes to interface/src/gpu/Resource.cpp (1 of 7 files). Show all

Unified · Split

interface/src/gpu/Resource.cpp+0−36
@@ -182,39 +182,3 @@ Buffer::Size Buffer::append(Size size, const Byte* data) { · 181 unmodified lines
182 return editSysmem().append( size, data);182 return editSysmem().append( size, data);
183}183}
184 184
185namespace gpu {
186namespace backend {
187
188BufferObject::~BufferObject() {
189 if (_buffer!=0) {
190 glDeleteBuffers(1, &_buffer);
191 }
192}
193
194void syncGPUObject(const Buffer& buffer) {
195 BufferObject* object = buffer.getGPUObject();
196
197 if (object && (object->_stamp == buffer.getSysmem().getStamp())) {
198 return;
199 }
200
201 // need to have a gpu object?
202 if (!object) {
203 object = new BufferObject();
204 glGenBuffers(1, &object->_buffer);
205 buffer.setGPUObject(object);
206 }
207
208 // Now let's update the content of the bo with the sysmem version
209 // TODO: in the future, be smarter about when to actually upload the glBO version based on the data that did change
210 //if () {
211 glBindBuffer(GL_ARRAY_BUFFER, object->_buffer);
212 glBufferData(GL_ARRAY_BUFFER, buffer.getSysmem().getSize(), buffer.getSysmem().readData(), GL_DYNAMIC_DRAW);
213 glBindBuffer(GL_ARRAY_BUFFER, 0);
214 object->_stamp = buffer.getSysmem().getStamp();
215 object->_size = buffer.getSysmem().getSize();
216 //}
217}
218
219};
220};