本文整理汇总了C++中ofFbo::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ ofFbo::begin方法的具体用法?C++ ofFbo::begin怎么用?C++ ofFbo::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofFbo
的用法示例。
在下文中一共展示了ofFbo::begin方法的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: 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);
}
示例3: 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();
}
}
示例4: drawNormalized
void testApp::drawNormalized(ofxFaceTracker& tracker, ofBaseHasTexture& tex, ofFbo& result) {
result.begin();
tex.getTextureReference().bind();
drawNormalized(tracker);
tex.getTextureReference().unbind();
result.end();
}
示例5: draw
void draw(){
wc.begin();
if(!switchVideo){
wc.setUniformTexture("colorMap", img.getTexture(), 1);
wc.setUniformTexture("heightMap",gray.getTexture(), 2);
}
else{
wc.setUniformTexture("colorMap", player.getTexture(), 1);
fboDepth.begin();
player.draw(0,0);
fboDepth.end();
wc.setUniformTexture("heightMap",fboDepth.getDepthTexture(),2);
}
wc.setUniform1f("time", ofGetElapsedTimef()*time);
wc.setUniform1f("gradientStep", stepGradient);
wc.setUniform1f("advectStep", advectStep);
wc.setUniform1f("flipHeightMap",flipHeightMap);
wc.setUniform4f("advectMatrix",advectMatrix->w,advectMatrix->x,advectMatrix->y,advectMatrix->z);
fbo.draw(0,0);
wc.end();
img.draw(0,0,img.getWidth()/4,img.getHeight()/4);
player.draw(img.getWidth()/4,0,img.getWidth()/4,img.getHeight()/4);
gui.draw();
}
示例6: 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);
}
示例7: 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));
}
示例8: 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();
}
示例9: update
void update()
{
fbo.begin();
ofClear(0, 0, 0, 0);
testImage.draw(0, 0);
fbo.end();
}
示例10: 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);
}
示例11: process
void testApp::process(ofFbo & fbo, ofImage & image, string name){
fbo.begin();
ofClear(0);
shader.begin();
shader.setUniformTexture("tex", cam.getTextureReference(), 0 );
shader.setUniform2f("texSize", cam.getWidth(), cam.getHeight());
shader.setUniform2f("size", fbo.getWidth(), fbo.getHeight());
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex3f(0, 0, 0);
glTexCoord2f(fbo.getWidth(), 0);
glVertex3f(fbo.getWidth(), 0, 0);
glTexCoord2f(fbo.getWidth(), fbo.getHeight());
glVertex3f(fbo.getWidth(), fbo.getHeight(), 0);
glTexCoord2f(0,fbo.getHeight());
glVertex3f(0,fbo.getHeight(), 0);
glEnd();
shader.end();
fbo.end();
TIME_SAMPLE_START(name);
fbo.readToPixels(image.getPixelsRef());
//image.update();
TIME_SAMPLE_STOP(name);
//image.draw(0, 0);
}
示例12: 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();
}
示例13: draw
//--------------------------------------------------------------
void testApp::draw(){
ofBackground(0);
if ( cnt < maxDraw )
{
cnt++;
ofEnableAlphaBlending();
ofEnableBlendMode(OF_BLENDMODE_ADD);
fbo.begin();
ofSetColor(ofColor::white, 100);
vector<ofTTFCharacter> paths = font.getStringAsPoints("openframeworks");
ofPushMatrix();
ofTranslate(ofGetWidth()/2 - 800, ofGetHeight()/2 + font.getLineHeight() / 2);
for( int k = 0; k < paths.size(); k++)
{
vector<ofPolyline> lines = paths[k].getOutline();
for( int i = 0; i < lines.size(); i++ )
{
ofPolyline ll = lines[i].getResampledBySpacing(1);
vector<ofPoint> pts = ll.getVertices();
for( int j = 0; j < pts.size(); j++)
{
int x1 = pts[j].x + ofNoise(pts[j].x) * randomVal - randomVal*0.5;
int y1 = pts[j].y + ofNoise(pts[j].y) * randomVal - randomVal*0.5;
int x2, y2;
ofPolyline l2;
vector<ofPoint> pts2;
while (pts2.size() == 0) {
l2 = lines[ ofRandom(lines.size()) ].getResampledBySpacing(1);
pts2 = l2.getVertices();
}
int randomPoint = ofRandom(pts2.size());
{
x2 = pts2[randomPoint].x + ofNoise(pts2[randomPoint].x) * randomVal - randomVal*0.5;
y2 = pts2[randomPoint].y + ofNoise(pts2[randomPoint].y) * randomVal - randomVal*0.5;
}
ofMesh mesh;
mesh.setMode(OF_PRIMITIVE_LINES);
mesh.addColor(ofColor(255,255,255, 80));
mesh.addColor(ofColor(255,255,255, 30));
mesh.addColor(ofColor(255,255,255, 80));
mesh.addVertex(ofVec3f(x1, y1, 0));
mesh.addVertex(ofVec3f((x1+x2)/2, (y1+y2)/2, 0));
mesh.addVertex(ofVec3f(x2, y2, 0));
mesh.drawFaces();
// ofLine(x1, y1, x2, y2);
}
}
}
ofPopMatrix();
fbo.end();
}
ofSetColor(ofColor::white);
fbo.draw(0, 0);
}
示例14: draw
//--------------------------------------------------------------
void testApp::draw(){
ofEnableLighting();
light.enable();
if(rotating) t++;
fbo.begin();
glColor4f(1, 1, 1, 1);
ofClear(0, 0, 0, 0);
glPushMatrix();
glScalef(2, 2, 2);
glTranslatef(ofGetWidth()/2, ofGetHeight()/2, 0);
glRotatef(t, 0, 1, 1);
/*glBegin(GL_QUADS);
glVertex2f(-100, -100);
glVertex2f(100, -100);
glVertex2f(100, 100);
glVertex2f(-100, 100);
glEnd();*/
ofBox(0, 0, 0, 100);
glPopMatrix();
fbo.end();
ofDisableLighting();
if(shading) {
fxaa.begin();
fxaa.setUniformTexture("bgl_RenderedTexture", fbo.getTextureReference(0), 0);
fxaa.setUniform1f("bgl_RenderedTextureWidth", fbo.getWidth());
fxaa.setUniform1f("bgl_RenderedTextureHeight", fbo.getHeight());
} else {
fbo.getTextureReference(0).bind();
}
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glTexCoord2f(fbo.getWidth(), 0);
glVertex2f(ofGetWidth(), 0);
glTexCoord2f(fbo.getWidth(), fbo.getHeight());
glVertex2f(ofGetWidth(), ofGetHeight());
glTexCoord2f(0, fbo.getHeight());
glVertex2f(0, ofGetHeight());
glEnd();
if(shading) {
fxaa.end();
} else {
fbo.getTextureReference(0).unbind();
}
}
示例15: 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();
}