本文整理汇总了C++中ofShader::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ ofShader::begin方法的具体用法?C++ ofShader::begin怎么用?C++ ofShader::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofShader
的用法示例。
在下文中一共展示了ofShader::begin方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2:
void lb::LightSystem::ConfigureShader( const ofShader& _shader ) const
{
_shader.begin();
_shader.bindUniformBlock( m_pointLightUboBinding, "LightBlock" );
_shader.setUniform1i( "uLightPointerTex", m_lightPointerTexUnit );
_shader.setUniform1i( "uLightIndexTex", m_lightIndexTexUnit );
_shader.end();
}
示例3: configureShader
//--------------------------------------------------------------
void ViewUbo::configureShader(const ofShader & shader)
{
shader.begin();
{
shader.bindUniformBlock(this->binding, "uViewBlock");
}
shader.end();
}
示例4: 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();
}
}
示例5: draw
void draw() {
ofBackgroundGradient(64, 0);
if(reflect || sreflect)
env.draw(0,0,env.getWidth()/8,env.getHeight()/8);
if(sreflect)
env1.draw(env.getWidth()/8,0,env1.getWidth()/8,env1.getHeight()/8);
ofEnableDepthTest();
cam.begin();
shader.begin();
if(sreflect){
// shader.setUniform3f("CameraPos",cam.getGlobalPosition().x, cam.getGlobalPosition().y, cam.getGlobalPosition().z);
// shader.setUniformMatrix4f("ModelWorld4x4",cam.getGlobalTransformMatrix());
shader.setUniform3f("CameraPos",cam.getPosition().x, cam.getPosition().y, cam.getPosition().z);
shader.setUniformMatrix4f("ModelWorld4x4",cam.getModelViewMatrix());//getLocalTransformMatrix());
shader.setUniformTexture("frontMap", env,1);
shader.setUniformTexture("backMap", env1,2);
}
if(reflect){
shader.setUniformTexture("colorMap",env1,1);
shader.setUniformTexture("envMap", env,2);
}else if(sreflect==false){
shader.setUniformTexture("texture", img, 1);
shader.setUniform1f("time", ofGetElapsedTimef());
}
if(cube)
ofDrawBox(200);
else {
ofTranslate(0,-150,0);
ofRotateX(-90);
ofRotateY(-90);
ofRotateZ(45);
model.drawFaces();
}
shader.end();
cam.end();
ofDisableDepthTest();
ofDrawBitmapString(ofToString((int) ofGetFrameRate()), 10, 20);
}
示例6: draw
void draw() {
ofBackground(25);
fbo.begin();
ofClear(0,0,0,0);
ofEnableDepthTest();
camera.begin();
glPushMatrix();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0);
if(dvel) draw_velocity();
if(dden){
draw_density();
}
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
glPopMatrix();
if( drawAxis ){ ofDrawAxis(15); }
camera.end();
ofDisableDepthTest();
fbo.end();
shader.begin();
shader.setUniformTexture("tex",fbo.getTextureReference(),0);
shader.setUniform2f("resolution",dw,dh);
shader.setUniform1f("timer",ofGetElapsedTimef());
fbo.draw(0,0);
shader.end();
gui.draw();
}
示例7: drawFace
void BGNode::drawFace(ofShader & mEyeShader) {
/*
int n = neighbours.size();
ofVec2f toVector(1,0);
if(n > 0)
toVector = (neighbours[0]->position - position).normalize();
ofVec2f perpVec(-toVector.y, toVector.x);
*/
ofSetColor(255);
float offset = .05 * nodeRadius;
float perpOffset = .6 * nodeRadius;
float eyeRadius = .6 * nodeRadius;
ofVec2f toVector = mSurfaceNormal;
ofVec2f perpVec(-toVector.y, toVector.x);
ofVec2f goalPos = position;
if(neighbours.size() > 0)
goalPos = neighbours[0]->position;
float texFactor = .6 * nodeRadius;
for(int i=0; i<2; ++i) {
int factor = i == 0 ? 1 : -1;
ofVec2f pos = position + toVector * offset + factor * perpVec * perpOffset;
ofMesh eyeMesh;
eyeMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
for(int j=0; j<4; ++j) {
ofVec2f texPos(j % 2, j / 2);
ofVec2f vPos = pos + (texPos.x - .5) * texFactor * perpVec + (texPos.y - .5) * texFactor * toVector;
eyeMesh.addVertex(ofVec3f(vPos.x, vPos.y, 0));
eyeMesh.addTexCoord(texPos);
}
ofVec2f goalPos = position;
if(neighbours.size() > 0)
goalPos = neighbours[0]->position;
ofVec2f toGoal = goalPos - pos;
float toGoalLength = toGoal.length();
ofVec2f pupilPos = pos;
if(toGoalLength > 0.01)
pupilPos = pos + .25 * eyeRadius / toGoalLength * toGoal;
mEyeShader.begin();
mEyeShader.setUniform2f("uCenter", pos.x, pos.y);
mEyeShader.setUniform2f("uFocusPoint", goalPos.x, goalPos.y);
mEyeShader.setUniform2f("uPupilLoc", pupilPos.x, pupilPos.y);
mEyeShader.setUniform1i("uFlipHorizontally", i > 0);
eyeMesh.draw();
mEyeShader.end();
}
ofMesh mouthMesh;
mouthMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
for(int i=0; i<21; ++i) {
float t = i / 20.0;
float x = .6 * (t - .5) * nodeRadius;
float yVar = 2 * abs(t - .5);
float y = (-yVar * yVar * (1 - yVar) * .6 - .3) * nodeRadius;
for(int it=0; it<2; ++it) {
mouthMesh.addVertex(position + y * toVector + x * perpVec);
mouthMesh.addColor(ofColor(0));
y -= 3;
}
}
mouthMesh.draw();
}
示例8: 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
}