openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.97k stars 2.55k forks source link

feature: Pixel Buffer Object (PBO) #1913

Open tobiasebsen opened 11 years ago

tobiasebsen commented 11 years ago

Just want to propose the idea of implementing a pixel buffer object in openFrameworks. There are many uses for this - especially if you want to render pixels into vertices - say, using a fragment shader to create points or a mesh.

The PBO could be a new ofPbo class or just adding functionality to the existing ofVbo. The main changes would be:

  1. Creating non-initialized buffers (unlike setVertexData, that only allows buffers with copy-data), e.g. allocateVertexData(...), alloacteTexCoordData(...), etc.
  2. Reading pixels into the buffers (from framebuffers), e.g. readPixels(...);

This is a suggestion open for discussion.

arturoc commented 11 years ago

i have an ofPBO class that i've mostly used for uploading textures asynchronously and in particular for playing back video faster since the upload time in ofTexture seems to be really slow.

it surely needs to be generalized for other uses but here's what i have by now in case it's useful

ofPBO.h: https://gist.github.com/arturoc/5083363 ofPBO.cpp: https://gist.github.com/arturoc/5083388

also @satoruhiga has this addon which also uses pbo's to do the opposite, download an fbo:

https://github.com/satoruhiga/ofxFastFboReader

tobiasebsen commented 11 years ago

cool. thanks.

i also have a pixel-buffer implementation, but my suggestion would be to re-write all three implementations into a general-purpose ofPbo.

arturoc commented 11 years ago

i think that would be a great addition, but not sure if it would be too specific to have in the core, let's see what other people think

yty commented 11 years ago

Hope of early accession to the PBO ... http://dev.c-base.org/libavg/libavg/blobs/master/src/graphics/PBO.h http://dev.c-base.org/libavg/libavg/blobs/master/src/graphics/PBO.cpp

yty commented 10 years ago

0.81... PBO can add it? @arturoc

bilderbuchi commented 10 years ago

No, as 0.8.1 is a bugfix release, and near completion, too.

tobiasebsen commented 10 years ago

hey @yty have a look at my buffer-object addon: https://github.com/tobiasebsen/ofxBufferObject

Ahbee commented 10 years ago

Im confused what does this currently do, that you cant do with ofVbo and ofTextures?

ghost commented 10 years ago

Im confused what does this currently do, that you cant do with ofVbo and ofTextures?

You can share Pixel Buffer Objects between independent processes, according to this. I really need this feature right now :)

Also, you can read Fast Texture Downloads and Readbacks using Pixel Buffer Objects in OpenGL brief