本文整理汇总了C++中ofFbo类的典型用法代码示例。如果您正苦于以下问题:C++ ofFbo类的具体用法?C++ ofFbo怎么用?C++ ofFbo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ofFbo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: maskBlur
void testApp::maskBlur(ofBaseHasTexture& tex, ofFbo& result) {
int k = ofMap(mouseX, 0, ofGetWidth(), 1, 128, true);
halfMaskBlur.begin();
ofClear(0, 0);
maskBlurShader.begin();
maskBlurShader.setUniformTexture("tex", tex, 1);
maskBlurShader.setUniformTexture("mask", faceMask, 2);
maskBlurShader.setUniform2f("direction", 1, 0);
maskBlurShader.setUniform1i("k", k);
tex.getTextureReference().draw(0, 0);
maskBlurShader.end();
halfMaskBlur.end();
result.begin();
ofClear(0, 0);
maskBlurShader.begin();
maskBlurShader.setUniformTexture("tex", halfMaskBlur, 1);
maskBlurShader.setUniformTexture("mask", faceMask, 2);
maskBlurShader.setUniform2f("direction", 0, 1);
maskBlurShader.setUniform1i("k", k);
halfMaskBlur.draw(0, 0);
maskBlurShader.end();
result.end();
}
示例2: doRender
void GaussianBlurFxModule::doRender(ofFbo& input) {
if (m_param_enabled) {
// first pass of shader: horizontal blur
m_ping_pong_fbo.getPing().begin();
ofClear(0.f);
m_shader.begin();
m_shader.setUniform1i("uVertical", false); // HORIZONTAL
m_shader.setUniform1i("uStrength", m_param_strength);
input.draw(0, 0);
m_shader.end();
m_ping_pong_fbo.getPing().end();
// second pass of shader: vertical blur
m_ping_pong_fbo.getPong().begin();
ofClear(0.f);
m_shader.begin();
m_shader.setUniform1i("uVertical", true); // VERTICAL
m_shader.setUniform1i("uStrength", m_param_strength);
m_ping_pong_fbo.getPing().draw(0, 0);
m_shader.end();
m_ping_pong_fbo.getPong().end();
// swap buffers: pong -> ping
m_ping_pong_fbo.swap();
// draw result of shader back to input fbo
input.begin();
ofClear(0.f);
m_ping_pong_fbo.getPing().draw(0, 0);
input.end();
}
}
示例3: draw
void mdQuad::draw(ofFbo fbo,ofShader shader){
fbo.getTexture(0).bind();
glBegin(GL_QUADS);
glTexCoord2f(0.0,0.0);
glVertex3f(x1, y1, 0.0); // Bottom Left Of The Texture and Quad
glTexCoord2f(320,0);
glVertex3f(x2, y2, 0.0); // Bottom Right Of The Texture and Quad
glTexCoord2f(320,240);
glVertex3f( x3, y3, 0.0); // Top Right Of The Texture and Quad
glTexCoord2f(0,240);
glVertex3f(x4, y4, 0.0); // Top Left Of The Texture and Quad
glEnd();
//glActiveTexture(GL_TEXTURE0);
fbo.getTexture().unbind();
if(videoOn){
videoTexture.setPoints(x1,y1,x2,y2,x3,y3,x4,y4);
//videoTexture.loadData(vPlayer->getPixels(), vPlayer->getWidth(), vPlayer->getHeight(), GL_RGB);
///videoTexture.loadData(fbo.getPixels(),fbo.getWidth(), fbo.getHeight(), GL_RGB);
videoTexture.draw();
}
}
示例4: moveAndDraw
void Brush::moveAndDraw(float x, float y, ofFbo& fbo){
ofPushStyle();
pos.set(x, y);
if (pos == lastPos || !isWorking) return;
ofVec2f direc = pos - lastPos;
ofVec2f perp = direc.perpendicular().normalize();
ofVec2f target, diff, sum(0,0);
lastPos.set(pos);
fbo.begin();
for (int i = 0; i < brushTips.size(); i ++) {
target.set(perp.x * brushTipDevs[i] + x, perp.y * brushTipDevs[i] + y);
brushTips[i] += (target - brushTips[i]) * 0.1;
diff.set((target - brushTips[i]).normalize());
ofSetColor(128 + diff.x * 128, 128 + diff.y * 128, 0, brushTipAlphas[i]);
ofLine(brushTips[i], brushTipLogs[i]);
brushTipLogs[i].set(brushTips[i]);
sum += brushTips[i];
}
fbo.end();
ofPopStyle();
sum /= brushTips.size();
lastPos.set(sum);
}
示例5: drawNormalized
void testApp::drawNormalized(ofxFaceTracker& tracker, ofBaseHasTexture& tex, ofFbo& result) {
result.begin();
tex.getTextureReference().bind();
drawNormalized(tracker);
tex.getTextureReference().unbind();
result.end();
}
示例6: setup
void setup(){
ofSetVerticalSync(false);
w=ofGetScreenWidth();
h=ofGetScreenHeight();
ofDisableArbTex();
img.load("1.jpg");
player.load("1.mp4");
player.play();
player.setLoopState(OF_LOOP_NORMAL);
gray = img;
gray.setImageType(OF_IMAGE_GRAYSCALE);
wc.load("wcolor.vert","wcolor.frag");
ofFbo::Settings s;
s.depthStencilAsTexture=true;
s.useDepth=true;
s.width=w;
s.height=h;
fboDepth.allocate(s);
fbo.allocate(w,h);
fbo.begin();
ofClear(0,0,100,255);
fbo.end();
gui.setup();
gui.add(stepGradient.set("step gradient", .0015, -1., 1.));
gui.add(advectStep.set("step advect", .0015, -.1, .1));
gui.add(flipHeightMap.set("flip height map", 0.7, 0., 2.));
gui.add(time.set("time", 0., 0., 1.));
gui.add(advectMatrix.set("advect matrix", ofVec4f(0.1), ofVec4f(-1.), ofVec4f(1.)));
gui.add(switchVideo.set("switch video", false));
}
示例7: roi
// draw texture in fbo using a normalized Region Of Interest
void ftUtil::roi(ofFbo& _dst, ofTexture& _tex, ofRectangle _roi) {
ofMesh quad;
quad.setMode(OF_PRIMITIVE_TRIANGLE_FAN);
quad.addVertex(glm::vec3(0,0,0));
quad.addVertex(glm::vec3(_dst.getWidth(),0,0));
quad.addVertex(glm::vec3(_dst.getWidth(),_dst.getHeight(),0));
quad.addVertex(glm::vec3(0,_dst.getHeight(),0));
float t0x = _roi.x * _tex.getWidth();
float t0y = _roi.y * _tex.getHeight();
float t1x = (_roi.x + _roi.width) * _tex.getWidth();
float t1y = (_roi.y + _roi.height) * _tex.getHeight();
quad.addTexCoord(glm::vec2(t0x, t0y));
quad.addTexCoord(glm::vec2(t1x, t0y));
quad.addTexCoord(glm::vec2(t1x, t1y));
quad.addTexCoord(glm::vec2(t0x, t1y));
_dst.begin();
ofClear(0,0);
_tex.bind();
quad.draw();
_tex.unbind();
_dst.end();
}
示例8: Obj
Obj(ofFbo & videoFrame)
:pixelsChanged(false)
,createdTexPixels(false)
{
pixels.allocate(videoFrame.getWidth(),videoFrame.getHeight(),ofGetImageTypeFromGLType(videoFrame.getTextureReference().texData.glInternalFormat));
updateTexture(videoFrame);
total_num_frames++;
}
示例9: init
void Buffer::init(ofFbo &b, const ofColor &bg) {
b.allocate();
b.begin();
ofFill();
ofSetColor(bg);
ofRect(0, 0, b.getWidth(), b.getHeight());
b.end();
}
示例10: fill
void ofApp::fill(ofFbo &dest, ofFloatColor c, ofBlendMode mode){
ofPushStyle();
ofFill();
ofEnableBlendMode(mode);
ofSetColor(c);
dest.begin();
ofDrawRectangle(0, 0, dest.getWidth(), dest.getHeight());
dest.end();
ofPopStyle();
}
示例11: center
//--------------------------------------------------------------
void center(const ofTexture& texture, ofFbo& container, int angle) {
if (angle % 2 == 0) {
ofTranslate(container.getWidth() * 0.5f - texture.getWidth() * 0.5f,
container.getHeight() * 0.5f - texture.getHeight() * 0.5f);
}
else {
ofTranslate(container.getWidth() * 0.5f - texture.getHeight() * 0.5f,
container.getHeight() * 0.5f - texture.getWidth() * 0.5f);
}
}
示例12: update
void update()
{
fbo.begin();
ofClear(0, 0, 0, 0);
testImage.draw(0, 0);
fbo.end();
}
示例13: draw
//--------------------------------------------------------------
void testApp::draw(){
ofSetHexColor(0xFFFFFF);
ofBackground(0);
if(bShowInput) grayImage.drawROI(roi.x, roi.y);
if(bShowOutput) fbo.draw(0, 0);
L.draw(pix);
if(bInfo){
ofSetHexColor(0xFF0000);
char reportStr[1024];
sprintf(reportStr, "[P] process on/off [F] snapshot [7 8 9 0] roi mask");
ofDrawBitmapString(reportStr, 20, 10);
sprintf(reportStr, "fps:%3.0f opencv:%3.2f madMapper:%3.2f", ofGetFrameRate(), t1, t2);
ofDrawBitmapString(reportStr, 20, 25);
sprintf(reportStr, "[1] show input [2] show output [i] info ");
ofDrawBitmapString(reportStr, 20, 40);
sprintf(reportStr, "[c] Contrast %.2f [b] Brightness %.2f ", contrast, brightness);
ofDrawBitmapString(reportStr, 20, 55);
sprintf(reportStr, "gray image [%4d, %4d] fbo [%4.f, %4.f] ",
roiW, roiH, fbo.getWidth(), fbo.getHeight());
int idx = (mouseY * pix.getWidth()+ mouseX) * pix.getBytesPerPixel();
sprintf(reportStr, "pixels %d", pix.getPixels()[idx]);
ofDrawBitmapString(reportStr, 20, 85);
}
}
示例14: update
void update() {
for(int i = 0; i < pulses.size(); i++) {
pulses[i].update(people);
}
fbo.begin();
ofPushStyle();
ofSetLineWidth(30);
ofSetColor(0, 10);
ofFill();
ofRect(0, 0, fbo.getWidth(), fbo.getHeight());
ofSetColor(255);
ofTranslate(ofGetWidth() / 2, ofGetHeight() / 2);
float saturation = ofMap(pulses.size(), 1, 10, 0, 255, true);
for(int i = 0; i < pulses.size(); i++) {
ofPushMatrix();
ofRotate(pulses[i].getAngle());
ofSetColor(ofColor::fromHsb(pulses[i].getHue(), saturation, 255));
ofLine(0, 0, ofGetWidth() / 2, 0);
ofPopMatrix();
}
ofPopStyle();
fbo.end();
fbo.readToPixels(fboPixels);
ledRing.update(fboPixels);
float presence = 0;
for(int i = 0; i < people.size(); i++) {
presence += people[i].getPresence();
}
presence /= people.size();
midi.sendControlChange(2, 1, presence);
}
示例15: draw
//--------------------------------------------------------------
void ofApp::draw(){
ofBackground(255,255,255); //Устанавливаем белый фон
//1. Рисуем в буфер
fbo.begin();
//Рисуем полупрозрачный белый прямоугольник, который будет создавать эффект исчезновения
ofEnableAlphaBlending();
float alpha = (1-history) * 255;
ofSetColor(255,255,255,alpha);
ofFill();
ofRect(0,0,ofGetWidth(),ofGetHeight());
ofDisableAlphaBlending();
//Рисуем частицу
ofFill();
for (int i=0; i<p.size(); ++i)
{
p[i].draw();
}
fbo.end();
//2. Рисуем содержимое буфера на экране
ofSetColor(255,255,255);
fbo.draw(0,0);
}