• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ofShader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ofShader的典型用法代码示例。如果您正苦于以下问题:C++ ofShader类的具体用法?C++ ofShader怎么用?C++ ofShader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ofShader类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: setupProjectionUniforms

void ofxRGBDRenderer::setupProjectionUniforms(ofShader& theShader){

    rgbMatrix = (depthToRGBView * rgbProjection);
    ofVec2f dims = ofVec2f(currentRGBImage->getTextureReference().getWidth(), 
                           currentRGBImage->getTextureReference().getHeight());
    theShader.setUniform2f("fudge", xmult, ymult);
    theShader.setUniform2f("dim", dims.x, dims.y);
    
    glMatrixMode(GL_TEXTURE);
    glPushMatrix();
    glLoadMatrixf(rgbMatrix.getPtr());
    glMatrixMode(GL_MODELVIEW);      
}
开发者ID:buenoIsHere,项目名称:ofxRGBDepth,代码行数:13,代码来源:ofxRGBDRenderer.cpp


示例2: draw

void SPECTRUM_INDICATOR__TYPE_POINT::draw(ofShader& shader, float *spectrum)
{
	/********************
	********************/
	shader.setUniform4f("BaseColor", IndicatorColor);
	
	/********************
	********************/
	ofPushMatrix();
	ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
	
	float spectrum_out = spectrum[NUM_DISP_SPECTRUMS - 1];
	
	for(int id = 0; id < NUM_DISP_SPECTRUMS; id++){
		int x = (int)(id * IndicatorHoriSpace);
		
		spectrum_out = FreqFilter_k * spectrum[id] + (1 - FreqFilter_k) * spectrum_out;
		shader.setUniform1f( "DispTextureSize", IndicatorTextureSize + IndicatorGainSize * spectrum_out ); // 描画サイズ
		// shader.setUniform1f( "TextureSize", IndicatorTextureSize ); // 描画サイズ
		for(int y = 0; y <= ofGetHeight()/2; y+= IndicatorVertSpace){
			/********************
			********************/
			vbo_drawPoint(ofVec3f(x, y, 0));
			if(y != 0) vbo_drawPoint(ofVec3f(x, -y, 0));
			
			/********************
			********************/
			if(x != 0){
				vbo_drawPoint(ofVec3f(-x, y, 0));
				if(y != 0) vbo_drawPoint(ofVec3f(-x, -y, 0));
			}
		}
	}
	
	ofPopMatrix();
}
开发者ID:SJ-magic,项目名称:work__Music_FftSpectrum_shader,代码行数:36,代码来源:SpectrumIndicator.cpp


示例3: updateRenderer

void Dude::updateRenderer( ofShader & shader )
{
    // update the rendering matrices
    renderMats = animSys.getBoneMatrices();
    std::vector<float> boneLengths = animSys.getBoneLengths();
    
    for( int i = 0; i < animSys.getNumBones(); i++ )
    {
        renderMats[i].scale(1,1,boneLengths[i]);
        //renderMats[i].preTranslate(position);
        renderMats[i].invert();
    }
    
    // prepare rendering steer matrix
    renderSteerMatrix.identity();
    renderSteerMatrix.translate(position);
    renderSteerMatrix *= steerMatrix;
    //renderSteerMatrix.translate(-position);

    // set it up
    shader.setUniformMatrix4f("steerMatrix",ofMatrix4x4((float*)renderSteerMatrix.inverse()));
    shader.setUniform1f("blend_k",blend_k);
    shader.setUniformMatrix4f("box_mats", (ofMatrix4x4&) renderMats[0], renderMats.size());//
}
开发者ID:baseio,项目名称:VolumeRunner,代码行数:24,代码来源:Dude.cpp


示例4: ofPushMatrix

void helix::drawCenteredForDOF( ofShader & dofShader, bool bDrawInner, bool bDrawOuter ){
        
               
        GLint sideLocation = dofShader.getAttributeLocation("side");
        GLint nextLocation = dofShader.getAttributeLocation("next");
        
        
        
        ofPoint midPt;
        int count = 0;
        
        for (int i = 0; i < helix0.size(); i++){
            midPt += helix0[i];
            count++;
        }
        
        for (int i = 0; i < helix1.size(); i++){
            midPt += helix1[i];
            count++;
        }
        
        for (int i = 0; i < lines.size(); i++){
            midPt += lines[i].a;
            midPt += lines[i].b;
            count += 2;
        }
        
        midPt /= (float)count;
        
        
    
    
        ofPushMatrix();
        ofTranslate(-midPt.x, -midPt.y, -midPt.z);
    
    
    if (bDrawOuter){
        glBegin(GL_TRIANGLE_STRIP);
        
        for (int i = 0; i < helix0.size()-1; i++){
            ofPoint cur = helix0[i];
            ofPoint next = helix0[i+1];
            
            ofPoint temp0 = cur;
            ofPoint temp1 = next;
            temp0.normalize();
            temp1.normalize();
            ofPoint normal = temp0.cross(temp1).normalize();
            
            
            dofShader.setAttribute1f(sideLocation, -.5);
            dofShader.setAttribute3f(nextLocation, next.x, next.y, next.z);
            
            //glNormal3f(normal.x, normal.y, normal.y);
            glVertex3f(cur.x, cur.y, cur.z);
            
            dofShader.setAttribute1f(sideLocation, +.5);
            dofShader.setAttribute3f(nextLocation, next.x, next.y, next.z);
            
            //glNormal3f(normal.x, normal.y, normal.y);
            glVertex3f(cur.x, cur.y, cur.z);
            
        }
        
        
        glEnd();
        
        glBegin(GL_TRIANGLE_STRIP);
        
        for (int i = 0; i < helix1.size()-1; i++){
            ofPoint cur = helix1[i];
            ofPoint next = helix1[i+1];
            
            ofPoint temp0 = cur;
            ofPoint temp1 = next;
            temp0.normalize();
            temp1.normalize();
            ofPoint normal = temp0.cross(temp1).normalize();
            
            
            dofShader.setAttribute1f(sideLocation, -.5);
            dofShader.setAttribute3f(nextLocation, next.x, next.y, next.z);
            //glNormal3f(normal.x, normal.y, normal.y);
            
            glVertex3f(cur.x, cur.y, cur.z);
            
            dofShader.setAttribute1f(sideLocation, +.5);
            dofShader.setAttribute3f(nextLocation, next.x, next.y, next.z);
            //glNormal3f(normal.x, normal.y, normal.y);
            
            glVertex3f(cur.x, cur.y, cur.z);
            
        }
        
        glEnd();
    }
    
        if (bDrawInner)
        for (int i = 0; i < lines.size(); i++){
            
//.........这里部分代码省略.........
开发者ID:imclab,项目名称:helix,代码行数:101,代码来源:helix.cpp


示例5: uploadMatrices

void ofBaseMaterial::uploadMatrices(const ofShader & shader,ofGLProgrammableRenderer & renderer) const{
	const ofMatrix4x4 & normalMatrix = renderer.getCurrentNormalMatrix();
	shader.setUniformMatrix4f("normalMatrix",normalMatrix);
}
开发者ID:K0j0,项目名称:openFrameworks,代码行数:4,代码来源:ofBaseTypes.cpp


示例6: updateLights

void ofMaterial::updateLights(const ofShader & shader,ofGLProgrammableRenderer & renderer) const{
	for(size_t i=0;i<ofLightsData().size();i++){
		string idx = ofToString(i);
		shared_ptr<ofLight::Data> light = ofLightsData()[i].lock();
		if(!light || !light->isEnabled){
			shader.setUniform1f("lights["+idx+"].enabled",0);
			continue;
		}
		auto lightEyePosition = renderer.getCurrentViewMatrix() * light->position;
		shader.setUniform1f("lights["+idx+"].enabled",1);
		shader.setUniform1f("lights["+idx+"].type", light->lightType);
		shader.setUniform4f("lights["+idx+"].position", lightEyePosition);
		shader.setUniform4f("lights["+idx+"].ambient", light->ambientColor);
		shader.setUniform4f("lights["+idx+"].specular", light->specularColor);
		shader.setUniform4f("lights["+idx+"].diffuse", light->diffuseColor);

		if(light->lightType!=OF_LIGHT_DIRECTIONAL){
			shader.setUniform1f("lights["+idx+"].constantAttenuation", light->attenuation_constant);
			shader.setUniform1f("lights["+idx+"].linearAttenuation", light->attenuation_linear);
			shader.setUniform1f("lights["+idx+"].quadraticAttenuation", light->attenuation_quadratic);
		}

		if(light->lightType==OF_LIGHT_SPOT){
			auto direction = toGlm(light->position).xyz() + light->direction;
			auto direction4 = renderer.getCurrentViewMatrix() * glm::vec4(direction,1.0);
			direction = direction4.xyz() / direction4.w;
			direction = direction - lightEyePosition.xyz();
			shader.setUniform3f("lights["+idx+"].spotDirection", glm::normalize(direction));
			shader.setUniform1f("lights["+idx+"].spotExponent", light->exponent);
			shader.setUniform1f("lights["+idx+"].spotCutoff", light->spotCutOff);
			shader.setUniform1f("lights["+idx+"].spotCosCutoff", cos(ofDegToRad(light->spotCutOff)));
		}else if(light->lightType==OF_LIGHT_DIRECTIONAL){
			auto halfVector = glm::normalize(glm::vec4(0.f, 0.f, 1.f, 0.f) + lightEyePosition);
			shader.setUniform3f("lights["+idx+"].halfVector", halfVector.xyz());
		}else if(light->lightType==OF_LIGHT_AREA){
			shader.setUniform1f("lights["+idx+"].width", light->width);
			shader.setUniform1f("lights["+idx+"].height", light->height);
			auto direction = light->position.xyz() + light->direction;
			auto direction4 = renderer.getCurrentViewMatrix() * glm::vec4(direction, 1.0);
			direction = direction4.xyz() / direction4.w;
			direction = direction - lightEyePosition.xyz();
			shader.setUniform3f("lights["+idx+"].spotDirection", glm::normalize(direction));
			auto right = toGlm(light->position).xyz() + light->right;
			auto right4 = renderer.getCurrentViewMatrix() * glm::vec4(right, 1.0);
			right = right4.xyz() / right4.w;
			right = right - lightEyePosition.xyz();
			auto up = glm::cross(toGlm(right), direction);
			shader.setUniform3f("lights["+idx+"].right", glm::normalize(toGlm(right)));
			shader.setUniform3f("lights["+idx+"].up", glm::normalize(up));
		}
	}
}
开发者ID:RebelMoogle,项目名称:openFrameworks,代码行数:52,代码来源:ofMaterial.cpp


示例7: update

	//--------------------------------------------------------------
	void SnapshotRamses::update(ofShader& shader)
	{
		shader.setUniformTexture("uTransform", m_bufferTexture, 0);
	}
开发者ID:arturoc,项目名称:Entropy,代码行数:5,代码来源:SnapshotRamses.cpp


示例8: updateMaterial

void ofMaterial::updateMaterial(const ofShader & shader,ofGLProgrammableRenderer & renderer) const{
	shader.setUniform4fv("mat_ambient", &data.ambient.r);
	shader.setUniform4fv("mat_diffuse", &data.diffuse.r);
	shader.setUniform4fv("mat_specular", &data.specular.r);
	shader.setUniform4fv("mat_emissive", &data.emissive.r);
	shader.setUniform4fv("global_ambient", &ofGetGlobalAmbientColor().r);
	shader.setUniform1f("mat_shininess",data.shininess);
	for(auto & uniform: uniforms1f){
		shader.setUniform1f(uniform.first, uniform.second);
	}
	for (auto & uniform : uniforms2f) {
		shader.setUniform2f(uniform.first, uniform.second);
	}
	for (auto & uniform : uniforms3f) {
		shader.setUniform3f(uniform.first, uniform.second);
	}
	for (auto & uniform : uniforms4f) {
		shader.setUniform4f(uniform.first, uniform.second);
	}
	for (auto & uniform : uniforms1i) {
		shader.setUniform1i(uniform.first, uniform.second);
	}
	for (auto & uniform : uniforms2i) {
		shader.setUniform2i(uniform.first, uniform.second.x, uniform.second.y);
	}
	for (auto & uniform : uniforms3i) {
		shader.setUniform3i(uniform.first, uniform.second.x, uniform.second.y, uniform.second.z);
	}
	for (auto & uniform : uniforms4i) {
		shader.setUniform4i(uniform.first, uniform.second.x, uniform.second.y, uniform.second.z, uniform.second.w);
	}
	for (auto & uniform : uniformstex) {
		shader.setUniformTexture(uniform.first,
								 uniform.second.textureTarget,
								 uniform.second.textureID,
								 uniform.second.textureLocation);
	}
}
开发者ID:RebelMoogle,项目名称:openFrameworks,代码行数:38,代码来源:ofMaterial.cpp


示例9: setupProjectionUniforms

//--------------------------------------------------------------- ACTIONS
void CloudsRGBDVideoPlayer::setupProjectionUniforms(ofShader& shader){
    
	if(!getPlayer().isLoaded() || !getTextureReference().isAllocated()){
		//ofLogWarning() << " CloudsRGBDVideoPlayer::setupProjectionUniforms -- player is not ready";
		return;
	}
	
	if(playingVO){
		return;
	}

    shader.setUniformTexture("rgbdTexture", getTextureReference(), 1);
    shader.setUniform2f("textureSize",  getPlayer().getWidth(), getPlayer().getHeight());
    
    shader.setUniform4f("colorRect", colorRect.x, colorRect.y, colorRect.width, colorRect.height);
    shader.setUniform2f("colorScale", colorScale.x, colorScale.y);
    
    shader.setUniform2f("colorFOV", colorFOV.x, colorFOV.y );
    shader.setUniform2f("colorPP", colorPrincipalPoint.x, colorPrincipalPoint.y);
    shader.setUniform3f("dK", distortionK.x, distortionK.y, distortionK.z);
    shader.setUniform2f("dP", distortionP.x, distortionP.y);
    
	ofMatrix4x4 adjustmentMatrix;
	adjustmentMatrix.rotate(adjustRotate.x, 0, 1, 0);
	adjustmentMatrix.rotate(adjustRotate.y, 1, 0, 0);
	adjustmentMatrix.translate(adjustTranslate.x, adjustTranslate.y, adjustTranslate.z);

	shader.setUniformMatrix4f("extrinsics", extrinsics * adjustmentMatrix );
    
    shader.setUniform4f("depthRect", depthRect.x, depthRect.y, depthRect.width, depthRect.height);
	shader.setUniform2f("depthPP", depthPrincipalPoint.x, depthPrincipalPoint.y);
	shader.setUniform2f("depthFOV", depthFOV.x, depthFOV.y);
    
    shader.setUniform4f("normalRect", normalRect.x, normalRect.y, normalRect.width, normalRect.height);
    shader.setUniform4f("faceFeatureRect", faceFeatureRect.x, faceFeatureRect.y, faceFeatureRect.width, faceFeatureRect.height);
    shader.setUniform4f("deltaChangeRect", deltaChangeRect.x, deltaChangeRect.y, deltaChangeRect.width, deltaChangeRect.height);
	
	shader.setUniform1f("farClip", farClip);
    shader.setUniform1f("nearClip", nearClip);
	shader.setUniform1f("edgeClip", edgeClip);

	shader.setUniform1f("minDepth", minDepth);
    shader.setUniform1f("maxDepth", maxDepth);
	
	shader.setUniform3f("skinSampleColor",skinSampleColor.r,skinSampleColor.g,skinSampleColor.b);
	shader.setUniform3f("skinWeights", skinWeights.x,skinWeights.y,skinWeights.z);
	shader.setUniform2f("skinThreshold", skinThreshold.min, skinThreshold.max);

	shader.setUniform3f("headPosition",headPosition.x,-headPosition.y,headPosition.z);
	
	shader.setUniform1f("flowPosition", flowPosition);
}
开发者ID:SethGibson,项目名称:CLOUDS,代码行数:53,代码来源:CloudsRGBDVideoPlayer.cpp


示例10: setupProjectionUniforms

//--------------------------------------------------------------- ACTIONS
void CloudsRGBDVideoPlayer::setupProjectionUniforms(ofShader& shader){
    
	if(!getPlayer().isLoaded()){
		ofLogWarning() << " CloudsRGBDVideoPlayer::setupProjectionUniforms -- player is not ready";
		return;
	}
	
    shader.setUniformTexture("rgbdTexture", getPlayer().getTextureReference(), 0);
    shader.setUniform2f("textureSize",  getPlayer().getWidth(), getPlayer().getHeight());
    
    shader.setUniform4f("colorRect", colorRect.x, colorRect.y, colorRect.width, colorRect.height);
    shader.setUniform2f("colorScale", colorScale.x, colorScale.y);
    
    shader.setUniform2f("colorFOV", colorFOV.x, colorFOV.y );
    shader.setUniform2f("colorPP", colorPrincipalPoint.x, colorPrincipalPoint.y);
    shader.setUniform3f("dK", distortionK.x, distortionK.y, distortionK.z);
    shader.setUniform2f("dP", distortionP.x, distortionP.y);
    
	ofMatrix4x4 adjustmentMatrix;
	adjustmentMatrix.rotate(adjustRotate.x, 0, 1, 0);
	adjustmentMatrix.rotate(adjustRotate.y, 1, 0, 0);
	adjustmentMatrix.translate(adjustTranslate.x, adjustTranslate.y, adjustTranslate.z);

	shader.setUniformMatrix4f("extrinsics", extrinsics * adjustmentMatrix );
    
    shader.setUniform4f("depthRect", depthRect.x, depthRect.y, depthRect.width, depthRect.height);
	shader.setUniform2f("depthPP", depthPrincipalPoint.x, depthPrincipalPoint.y);
	shader.setUniform2f("depthFOV", depthFOV.x, depthFOV.y);
    
    shader.setUniform4f("normalRect", normalRect.x, normalRect.y, normalRect.width, normalRect.height);
    shader.setUniform4f("faceFeatureRect", faceFeatureRect.x, faceFeatureRect.y, faceFeatureRect.width, faceFeatureRect.height);
    shader.setUniform4f("deltaChangeRect", deltaChangeRect.x, deltaChangeRect.y, deltaChangeRect.width, deltaChangeRect.height);

	shader.setUniform1i("useFaces", useFaces ? 1 : 0);
	shader.setUniform1f("flowPosition", flowPosition);
	
	shader.setUniform1f("farClip", farClip);
    shader.setUniform1f("nearClip", nearClip);
	shader.setUniform1f("edgeClip", edgeClip);

	shader.setUniform1f("minDepth", minDepth);
    shader.setUniform1f("maxDepth", maxDepth);

}
开发者ID:CLOUDS-Interactive-Documentary,项目名称:VisualSystemsLibrary,代码行数:45,代码来源:CloudsRGBDVideoPlayer.cpp


示例11: 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();
}
开发者ID:guidosoetens,项目名称:visualtest,代码行数:84,代码来源:BGNode.cpp


示例12: setup

    void setup() {
        ofEnableDepthTest();
        ofDisableArbTex();

        img.loadImage("img1.jpg");
        env.loadImage("env.jpg");
        env1.loadImage("env1.jpg");


        shader.load("material.vert","material.frag");
	model.loadModel("wolf.dae", true);
    }
开发者ID:drakh,项目名称:glslMaterial,代码行数:12,代码来源:main.cpp


示例13: 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);
    }
开发者ID:drakh,项目名称:glslMaterial,代码行数:45,代码来源:main.cpp


示例14: 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();
		}
开发者ID:kashimAstro,项目名称:3DFlare,代码行数:39,代码来源:main.cpp


示例15: setup

		void setup() {
            ofSetFrameRate(60);
            ofSetVerticalSync(true);

            dw=ofGetScreenWidth();
			dh=ofGetScreenHeight();
			ofDisableArbTex();
            fbo.allocate(dw,dh);
            shader.load("shaders/fluid.vert","shaders/fluid.frag");

			camera.setFarClip(100000);
			camera.setNearClip(.1);
            if ( !allocate_data () ){
                    cout<<"error allocate!"<<endl;
                    exit();
			}
            clear_data ();

			gui.setup();
            gui.setPosition(ofPoint(10,10));

			gui.add(size_cube.setup("size box", 100.0f,0.0f,255.0f));
            gui.add(dvel.setup("draw velocity", true));
            gui.add(dden.setup("draw density",  false));

			gui.add(TaddSource.setup("add source",false));
			gui.add(Bclear.setup("clear source",false));

			gui.add(addX.setup("add x",false));
			gui.add(addY.setup("add y",false));
			gui.add(addZ.setup("add z",false));
			gui.add(dt.setup("time delta", 0.9f,0.0f,25.0f));
			gui.add(diff.setup("diffuse",  0.0f,0.0f,25.0f));
			gui.add(visc.setup("viscosity", 0.0f,0.0f,25.0f));
			gui.add(force.setup("add force",30.0f,0.0f,60.0f));
			gui.add(source.setup("density", 200.0f,0.0f,600.0f));
			gui.add(source_alpha.setup("alpha",0.05,0.0,1.0));
			gui.add(drawAbstacle.setup("draw abstacle",false));
			gui.add(drawAxis.setup("draw Axis",true));

			gui.add(sourcePosX.setup("source posX", 0,-10,SIZE));
			gui.add(sourcePosY.setup("source posY", 0,-10,SIZE));
			gui.add(sourcePosZ.setup("source posZ", 0,-10,SIZE));
		}
开发者ID:kashimAstro,项目名称:3DFlare,代码行数:44,代码来源:main.cpp


示例16: setupFromXml

 void setupFromXml(string filename) {
     size = ofVec2f(ofGetWidth(), ofGetHeight());
     if (xml.load(filename)) {
         xml.setTo("STAR[0]");
         do {
             xml.setTo("POSITION");
             int x = xml.getValue<float>("X");
             int y = xml.getValue<float>("Y");
             xml.setToParent();
             int m = xml.getValue<int>("MAGNITUDE");
             int id = xml.getValue<int>("ID");
             
             BPStar s;
             s.setPosition(x, y);
             s.setMagnitude(m);
             s.setId(id);
             stars.push_back(s);
         }while( xml.setToSibling() ); // go to next STAR
     } else {
         
     }
     shader.load("","SkyShader.frag");
     skyShader.setup();
 }
开发者ID:toruurakawa,项目名称:Climbing,代码行数:24,代码来源:BPSky.hpp


示例17: keyPressed

    void keyPressed(int key) {
	if(key == '1') { model.loadModel("wolf.dae"); cube=false; }
	if(key == '2') { model.loadModel("elephant.dae"); cube=false; }
	if(key == '3') { model.loadModel("alduin.obj"); cube=false; }
	if(key == '4') cube=!cube;


	if(key == ' ') ofToggleFullscreen();

	if(key == 'q') { shader.load("material.vert","material.frag"); reflect=false; sreflect=false; }
	if(key == 'w') { shader.load("material.vert","material1.frag"); reflect=false; sreflect=false; }
	if(key == 'e') { shader.load("material.vert","material2.frag"); reflect=false; sreflect=false; }
	if(key == 'r') { shader.load("material.vert","material3.frag"); reflect=false; sreflect=false; }
	if(key == 't') { shader.load("material.vert","material4.frag"); reflect=false; sreflect=false; }
	if(key == 'y') { shader.load("material.vert","material5.frag"); reflect=false; sreflect=false; }

	if(key == 'u') { shader.load("material.vert","material6.frag"); reflect=false; sreflect=false; }
	if(key == 'i') { shader.load("material.vert","material7.frag"); reflect=false; sreflect=false; }
	if(key == 'o') { shader.load("material.vert","material8.frag"); reflect=false; sreflect=false; }
	if(key == 'p') { shader.load("material.vert","material9.frag"); reflect=false; sreflect=false; }
	if(key == 'a') { shader.load("material.vert","material10.frag"); reflect=false; sreflect=false; }
	if(key == 's') { shader.load("material.vert","material11.frag"); reflect=false; sreflect=false; }
	if(key == 'd') { shader.load("material.vert","material12.frag"); reflect=false; sreflect=false; }
	if(key == 'f') { shader.load("material.vert","material13.frag"); reflect=false; sreflect=false; }
	if(key == 'g') { shader.load("material.vert","material14.frag"); reflect=false; sreflect=false; }
	if(key == 'h') { shader.load("material.vert","material15.frag"); reflect=false; sreflect=false; }
	if(key == 'j') { shader.load("material.vert","material16.frag"); reflect=false; sreflect=false; }
	if(key == 'k') { shader.load("material.vert","material17.frag"); reflect=false; sreflect=false; }
	if(key == 'l') { shader.load("material.vert","material18.frag"); reflect=false; sreflect=false; }
	if(key == 'z') { shader.load("material.vert","material19.frag"); reflect=false; sreflect=false; }
	if(key == 'x') { shader.load("material.vert","material20.frag"); reflect=false; sreflect=false; }

	if(key == 'c') { shader.load("material_reflect.vert","material_reflect.frag"); reflect=true; sreflect=false; }
	if(key == 'v') { shader.load("material_reflect_1.vert","material_reflect_1.frag"); reflect=true; sreflect=false; }
	if(key == 'b') { shader.load("material_reflect_2.vert","material_reflect_2.frag"); sreflect=true; reflect=false; }
    }
开发者ID:drakh,项目名称:glslMaterial,代码行数:36,代码来源:main.cpp


示例18: 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
	}
开发者ID:Abhayshar,项目名称:SharingFaces,代码行数:81,代码来源:main.cpp



注:本文中的ofShader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ofShortPixels类代码示例发布时间:2022-05-31
下一篇:
C++ ofRectangle类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap