本文整理汇总了C++中ofShader::setUniform3fv方法的典型用法代码示例。如果您正苦于以下问题:C++ ofShader::setUniform3fv方法的具体用法?C++ ofShader::setUniform3fv怎么用?C++ ofShader::setUniform3fv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofShader
的用法示例。
在下文中一共展示了ofShader::setUniform3fv方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onParticlesUpdate
// set any update uniforms in this function
void testApp::onParticlesUpdate(ofShader& shader)
{
ofVec3f mouse(ofGetMouseX() - .5f * ofGetWidth(), .5f * ofGetHeight() - ofGetMouseY() , 0.f);
shader.setUniform3fv("mouse", mouse.getPtr());
shader.setUniform1f("elapsed", ofGetLastFrameTime());
shader.setUniform1f("radiusSquared", 1000.f * 1000.f);
}
示例2: onParticlesUpdate
void ofApp::onParticlesUpdate(ofShader& shader)
{
float flip = 1.0;
if (flipParticles) {
flip = -1.0;
}
//ofVec3f mouse(ofGetMouseX() - .5f * ofGetWidth(), .5f * ofGetHeight() - ofGetMouseY() , 0.f);
ofVec3f mouse((mc.x - .5f * ofGetWidth()) * flip, .5f * ofGetHeight() - mc.y, 0.f);
ofVec3f ext1(mc.x - .5f * ofGetWidth(), .5f * ofGetHeight() - mc.y , 0.f);
shader.setUniform3fv("mouse", mouse.getPtr());
shader.setUniform1f("elapsed", ofGetLastFrameTime());
shader.setUniform1f("radiusSquared", 300.f * 300.f);
}
示例3: update
void update() {
#ifdef INSTALL
if(cam.update()) {
ofPixels& pixels = cam.getColorPixels();
#else
cam.update();
if(cam.isFrameNew()) {
ofPixels& pixels = cam.getPixelsRef();
#endif
// next two could be replaced with one line
ofxCv::rotate90(pixels, rotated, rotate ? 270 : 0);
ofxCv:flip(rotated, rotated, 1);
Mat rotatedMat = toCv(rotated);
if(tracker.update(rotatedMat)) {
ofVec2f position = tracker.getPosition();
vector<FaceTrackerData*> neighbors = data.getNeighborsCount(position, neighborCount);
FaceTrackerData curData;
curData.load(tracker);
if(!neighbors.empty()) {
nearestData = *faceCompare.nearest(curData, neighbors);
if(nearestData.label != lastLabel) {
similar.loadImage(nearestData.getImageFilename());
#ifdef INSTALL
whitePoint = getWhitePoint(similar);
#else
whitePoint.set(1, 1, 1);
#endif
}
lastLabel = nearestData.label;
}
if(faceCompare.different(curData, currentData) && faceCompare.different(curData, neighbors)) {
saveFace(curData, rotated);
currentData.push_back(pair<ofVec2f, FaceTrackerData>(position, curData));
}
}
presence.update(tracker.getFound());
if(presence.wasTriggered()) {
presenceFade.stop();
}
if(presence.wasUntriggered()) {
for(int i = 0; i < currentData.size(); i++) {
data.add(currentData[i].first, currentData[i].second);
}
currentData.clear();
presenceFade.start();
}
}
}
void draw() {
ofBackground(255);
CGDisplayHideCursor(NULL);
ofSetColor(255);
if(similar.isAllocated()) {
shader.begin();
shader.setUniformTexture("tex", similar, 0);
shader.setUniform3fv("whitePoint", (float*) &whitePoint);
similar.draw(0, 0);
shader.end();
}
ofPushStyle();
if(presenceFade.getActive()) {
ofSetColor(0, ofMap(presenceFade.get(), 0, 1, 0, 128));
ofFill();
ofRect(0, 0, ofGetWidth(), ofGetHeight());
ofSetColor(255, ofMap(presenceFade.get(), 0, 1, 0, 32));
data.drawBins();
ofSetColor(255, ofMap(presenceFade.get(), 0, 1, 0, 64));
data.drawData();
}
ofSetColor(255, 64);
ofNoFill();
if(!tracker.getFound()) {
ofCircle(tracker.getPosition(), 10);
}
tracker.draw();
ofPopStyle();
#ifndef INSTALL
drawFramerate();
#endif
}