本文整理汇总了C++中ofFbo::bind方法的典型用法代码示例。如果您正苦于以下问题:C++ ofFbo::bind方法的具体用法?C++ ofFbo::bind怎么用?C++ ofFbo::bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofFbo
的用法示例。
在下文中一共展示了ofFbo::bind方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateTexture
void updateTexture(ofFbo & videoFrame){
if(!fbo.isAllocated()){
fbo.allocate(videoFrame.getWidth(),videoFrame.getHeight(),videoFrame.getTextureReference().texData.glInternalFormat);
}
videoFrame.bind();
glReadBuffer(GL_COLOR_ATTACHMENT0);
glBindTexture(fbo.getTextureReference().texData.textureTarget, (GLuint)fbo.getTextureReference().texData.textureID);
glCopyTexImage2D(fbo.getTextureReference().texData.textureTarget,0,fbo.getTextureReference().texData.glInternalFormat,0,0,fbo.getWidth(),fbo.getHeight(),0);
videoFrame.unbind();
glReadBuffer(GL_BACK);
}
示例2: draw
//----------
void Scene::draw(ofFbo & fbo) {
fbo.bind();
ofPushMatrix();
//ofScale(1.0f, -1.0f);
//ofTranslate(0.0f, -ofGetHeight());
this->draw();
ofPopMatrix();
fbo.unbind();
}
示例3: readToFloatPixels
bool ofxFastFboReader::readToFloatPixels(ofFbo &fbo, ofFloatPixelsRef pix, ofImageType type)
{
genPBOs();
int channels;
int glType;
if (type == OF_IMAGE_COLOR)
{
channels = 3;
glType = GL_RGB;
}
else if (type == OF_IMAGE_COLOR_ALPHA)
{
channels = 4;
glType = GL_RGBA;
}
else if (type == OF_IMAGE_GRAYSCALE)
{
channels = 1;
glType = GL_LUMINANCE;
}
else
{
return false;
}
const int width = fbo.getWidth();
const int height = fbo.getHeight();
if (async)
{
index = (index + 1) % num_buffers;
nextIndex = (index + 1) % num_buffers;
}
else
{
index = nextIndex = 0;
}
size_t nb = width * height * channels * sizeof(float); // LS: don't just deal with 8-bit color channels..
if (nb != num_bytes)
{
num_bytes = nb;
setupPBOs(num_bytes);
}
glReadBuffer(GL_FRONT);
fbo.bind();
glBindBuffer(GL_PIXEL_PACK_BUFFER, pboIds[index]);
glReadPixels(0, 0, width, height, glType, GL_FLOAT, NULL);
glBindBuffer(GL_PIXEL_PACK_BUFFER, pboIds[nextIndex]);
float* mem = (float*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
if (mem)
{
pix.setFromPixels(mem, width, height, channels);
//pix.setFromAlignedPixels(mem, width, height, channels, width*channels); // stride = nr of elements (float, char, etc) in a row, including padding for alignment. we assume no padding..
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
}
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
fbo.unbind();
return mem != NULL;
}
示例4: readToPixels
bool ofxFastFboReader::readToPixels(ofFbo &fbo, ofPixelsRef pix, ofImageType type)
{
genPBOs();
int channels;
int glType;
if (type == OF_IMAGE_COLOR)
{
channels = 3;
glType = GL_RGB;
}
else if (type == OF_IMAGE_COLOR_ALPHA)
{
channels = 4;
glType = GL_RGBA;
}
else if (type == OF_IMAGE_GRAYSCALE)
{
channels = 1;
glType = GL_LUMINANCE;
}
else
{
return false;
}
const int width = fbo.getWidth();
const int height = fbo.getHeight();
if (async)
{
index = (index + 1) % num_buffers;
nextIndex = (index + 1) % num_buffers;
}
else
{
index = nextIndex = 0;
}
size_t nb = width * height * channels;
if (nb != num_bytes)
{
num_bytes = nb;
setupPBOs(num_bytes);
}
glReadBuffer(GL_FRONT);
fbo.bind();
glBindBuffer(GL_PIXEL_PACK_BUFFER, pboIds[index]);
glReadPixels(0, 0, width, height, glType, GL_UNSIGNED_BYTE, NULL);
glBindBuffer(GL_PIXEL_PACK_BUFFER, pboIds[nextIndex]);
unsigned char* mem = (unsigned char*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
if (mem)
{
pix.setFromPixels(mem, width, height, channels);
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
}
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
fbo.unbind();
return mem != NULL;
}