void AudioVisualizerApp::draw()
{
	gl::clear();

	// use camera
	gl::pushMatrices();
	gl::setMatrices(mCamera);
	{
		// bind shader
		mShader.bind();
		mShader.uniform("uTexOffset", mOffset / float(kHistory));
		mShader.uniform("uLeftTex", 0);
		mShader.uniform("uRightTex", 1);

		// create textures from our channels and bind them
		mTextureLeft = gl::Texture(mChannelLeft, mTextureFormat);
		mTextureRight = gl::Texture(mChannelRight, mTextureFormat);

		mTextureLeft.enableAndBind();
		mTextureRight.bind(1);

		// draw mesh using additive blending
		gl::enableAdditiveBlending();
		gl::color( Color(1, 1, 1) );
		gl::draw( mMesh );
		gl::disableAlphaBlending();

		// unbind textures and shader
		mTextureRight.unbind();
		mTextureLeft.unbind();
		mShader.unbind();
	}
	gl::popMatrices();
}
Ejemplo n.º 2
0
void gpuPSApp::resetFBOs(){
	mCurrentFBO = 0;
	mOtherFBO = 1;
	mFBO[0].bindFramebuffer();
	mFBO[1].bindFramebuffer();
	
	// Attachment 0 - Positions
	glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
	gl::setMatricesWindow( mFBO[0].getSize(), false );
	gl::setViewport( mFBO[0].getBounds() );
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	mPositions.enableAndBind();
	gl::draw( mPositions, mFBO[0].getBounds() );
	mPositions.unbind();
	
	// Attachment 1 - Velocities
	glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	mVelocities.enableAndBind();
	gl::draw( mVelocities, mFBO[0].getBounds() );
	mVelocities.unbind();
	
	mFBO[1].unbindFramebuffer();
	mFBO[0].unbindFramebuffer();
	mPositions.disable();
	mVelocities.disable();
}
/**
 here's where the magic happens
 all calculations are done in update
 **/
void millionParticlesApp::update()
{

    mFbo[mBufferIn].bindFramebuffer();

    //set viewport to fbo size
    gl::setMatricesWindow( mFbo[0].getSize(), false ); // false to prevent vertical flipping
    gl::setViewport( mFbo[0].getBounds() );

    GLenum buffer[3] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT };
    glDrawBuffers(3,buffer);

    mFbo[mBufferOut].bindTexture(0,0);
    mFbo[mBufferOut].bindTexture(1,1);
    mFbo[mBufferOut].bindTexture(2,2);

    mVelTex.bind(3);
    mPosTex.bind(4);
    mNoiseTex.bind(5);

    mVelShader.bind();
    mVelShader.uniform("positions",0);
    mVelShader.uniform("velocities",1);
    mVelShader.uniform("information",2);
    mVelShader.uniform("oVelocities",3);
    mVelShader.uniform("oPositions",4);
    mVelShader.uniform("noiseTex",5);

    glBegin(GL_QUADS);
    glTexCoord2f( 0.0f, 0.0f);
    glVertex2f( 0.0f, 0.0f);
    glTexCoord2f( 0.0f, 1.0f);
    glVertex2f( 0.0f, PARTICLES);
    glTexCoord2f( 1.0f, 1.0f);
    glVertex2f( PARTICLES, PARTICLES);
    glTexCoord2f( 1.0f, 0.0f);
    glVertex2f( PARTICLES, 0.0f);
    glEnd();

    mVelShader.unbind();

    mFbo[mBufferOut].unbindTexture();

    mVelTex.unbind();
    mPosTex.unbind();

    mFbo[mBufferIn].unbindFramebuffer();

    mBufferIn = (mBufferIn + 1) % 2;
    mBufferOut = (mBufferIn + 1) % 2;

    //for recording
    //    if (getElapsedFrames() == 600)
    //        exit(0);

}
Ejemplo n.º 4
0
void ViewAddVel::render(gl::Texture texturePos, gl::Texture textureVel) {
    shader->bind();
    shader->uniform("texturePos", 0);
    texturePos.bind(0);
    shader->uniform("textureVel", 1);
    textureVel.bind(1);
    gl::draw(mesh);
    texturePos.unbind();
    textureVel.unbind();
    shader->unbind();
}
Ejemplo n.º 5
0
void BoidsApp::drawCapture(){
	if( texture){
		glPushAttrib(GL_CURRENT_BIT);
		

		
		gl::enableDepthRead( false );
		gl::enableDepthWrite( true );
		
		glDepthMask( GL_FALSE ); //IMPORTANT
		glDisable( GL_DEPTH_TEST ); //IMPORTANT
		glEnable( GL_BLEND ); //IMPORTANT
		glBlendFunc( GL_SRC_ALPHA, GL_ONE ); //IMPORTANT
		
		texture.bind();
		gl::color( ColorA( 1.0f, 1.0f, 1.0f, 0.0f ) );
		gl::color(imageColor);
		gl::pushModelView();
		gl::multModelView(imageToScreenMap);
		gl::draw(texture);
		gl::popModelView();
		texture.unbind();
		
		glPopAttrib();
		
	}
}
Ejemplo n.º 6
0
void BloomingNeonApp::render()
{
	// get the current viewport
	Area viewport = gl::getViewport();

	// adjust the aspect ratio of the camera
	mCamera.setAspectRatio( viewport.getWidth() / (float) viewport.getHeight() );
	
	// render our scene (see the Picking3D sample for more info)
	gl::pushMatrices();

		gl::setMatrices( mCamera );
		gl::enableDepthRead();
		gl::enableDepthWrite();
		
		mTexture.enableAndBind();
			mShaderPhong.bind();
			mShaderPhong.uniform("tex0", 0);
				gl::pushModelView();
				gl::multModelView( mTransform );
					gl::color( Color::white() );
					gl::draw( mMesh );
				gl::popModelView();		
			mShaderPhong.unbind();
		mTexture.unbind();

		gl::disableDepthWrite();
		gl::disableDepthRead();

	gl::popMatrices();
}
Ejemplo n.º 7
0
void LEDCamApp::draw()
{
	// clear out the window with black
	gl::clear( kClearColor ); 
	
	if( !mTexture ) return;
	mFbo.bindFramebuffer();
	mTexture.enableAndBind();
	mShader.bind();
	float aspect = kWindowHeight/kWindowWidth;
	cout << "Aspect: " << aspect << " \n";
	mShader.uniform( "aspect", aspect );
	mShader.uniform( "tex", 0 );
	mShader.uniform( "bright", 3.0f );
	mShader.uniform( "spacing", 3 );
	mShader.uniform( "ledCount", 100.0f );
	gl::drawSolidRect( getWindowBounds() );
	mTexture.unbind();
	mShader.unbind();
	mFbo.unbindFramebuffer();
	
	gl::Texture fboTexture = mFbo.getTexture();
	fboTexture.setFlipped();
	gl::draw( fboTexture );

}
Ejemplo n.º 8
0
void TextureTestApp::draw()
{
	gl::clear(Color(0.2f, 0.2f, 0.2f));

  // カメラの状態から行列を作成
  // 視点座標変換用と正規化デバイス座標変換用の2つを用意する
  gl::setMatrices(camera);

  // ライティング開始
  light->enable();

  // ローカル→ワールド変換行列を用意
  gl::scale(100.0, 100.0, 100.0);
  gl::rotate(Vec3f(rx, ry, rz));

  gl::pushModelView();
  // テクスチャを拘束
  image.bind();
  gl::translate(Vec3f(1.5f, 0, 0));
  gl::color(Color::white());
  // ポリゴンを描画
  gl::drawCube(Vec3f(0.0, 0.0, 0.0), Vec3f(2.0, 2.0, 2.0));
  //gl::drawCylinder(1, 2, 2, 12, 2);

  // 拘束を解除
  image.unbind();
  gl::popModelView();

  gl::pushModelView();
  gl::color(Color(1, 0, 0));
  gl::translate(Vec3f(-3, 0, 0));
  gl::drawCube(Vec3f(1, 0, 0), Vec3f(2.f, 2.f, 2.f));
  gl::popModelView();

}
Ejemplo n.º 9
0
void BoidsApp::draw()
{	
	
	glEnable( GL_TEXTURE_2D );
	gl::clear( Color( 0, 0, 0 ), true );	//this clears the old images off the window.
	
	
	mParticleTexture.bind();
	flock_one.draw();
	flock_two.draw();
	mParticleTexture.unbind();
	
	//drawCapture();
	drawPolyLines();

	/*
	if( mSaveFrames ){
		writeImage( getHomeDirectory() + "flocking/image_" + toString( getElapsedFrames() ) + ".png", copyWindowSurface() );
	}
		*/
	
	

	
	// DRAW PARAMS WINDOW
	params::InterfaceGl::draw();
}
Ejemplo n.º 10
0
void DeferredRenderingApp::drawShadowCasters(gl::GlslProg* deferShader) const
{
	//just some test objects
    if(deferShader != NULL) {
        deferShader->uniform("useTexture", 1.0f);
        deferShader->uniform("tex0", 0);
        mEarthTex.bind(0);
    }
    
    glColor3ub(255,255,255);
    gl::drawSphere( Vec3f(-1.0, 0.0,-1.0), 1.0f, 30 );
    
    if(deferShader != NULL) {
        deferShader->uniform("useTexture", 0.0f);
        mEarthTex.unbind(0);
    }
    
	glColor3ub(0,255,0);
    gl::drawCube( Vec3f( 1.0f, 0.0f, 1.0f ), Vec3f( 2.0f, 2.0f, 2.0f ) );
    
    glColor3ub(255,0,255);
    gl::drawCube( Vec3f( 0.0f, 0.0f, 4.5f ), Vec3f( 1.0f, 2.0f, 1.0f ) );
    
    glColor3ub(255,255,0);
    gl::drawCube( Vec3f( 3.0f, 0.0f, -1.5f ), Vec3f( 1.0f, 3.0f, 1.0f ) );
    
	glColor3ub(255,0,255);
    gl::pushMatrices();
	glTranslatef(-2.0f, -0.7f, 2.0f);
	glRotated(90.0f, 1, 0, 0);
    gl::drawTorus( 1.0f, 0.3f, 32, 64 );
	gl::popMatrices();
    
}
Ejemplo n.º 11
0
void FastTrailsApp::draw()
{
	// clear window
	gl::clear(); 

	// set render states
	gl::enableWireframe();
	gl::enableAlphaBlending();

	gl::enableDepthRead();
	gl::enableDepthWrite();

	// enable 3D camera
	gl::pushMatrices();
	gl::setMatrices( mCamera.getCamera() );

	// draw VBO mesh using texture
	mTexture.enableAndBind();
	gl::drawRange( mVboMesh, 0, mTrail.size(), 0, mTrail.size()-1 );
	mTexture.unbind();

	// restore camera and render states
	gl::popMatrices();

	gl::disableDepthWrite();
	gl::disableDepthRead();

	gl::disableAlphaBlending();
	gl::disableWireframe();
}
Ejemplo n.º 12
0
void MemExploreApp::draw()
{
  mTexture = gl::Texture(mDataPointer, GL_RGBA, mVolumeDim * mTilesDim, mVolumeDim * mTilesDim);
  mTexture.setWrap(GL_REPEAT, GL_REPEAT);
  mTexture.setMinFilter(GL_NEAREST);
  mTexture.setMagFilter(GL_NEAREST);
  
  float frustum[6];
  mCamera.getFrustum(&frustum[0], &frustum[1], &frustum[2], &frustum[3], &frustum[4], &frustum[5]);

  mFbo.bindFramebuffer();
  gl::setMatricesWindow(mFbo.getSize(), false);

  mProgram.bind();
  mProgram.uniform("uTexture", 0);
  mProgram.uniform("uVolumeDim", mVolumeDim);
  mProgram.uniform("uTilesDim", mTilesDim);
  mProgram.uniform("uTime", (float)getElapsedSeconds());
  mProgram.uniform("uEyePoint", mCamera.getEyePoint());
  mProgram.uniform("uXAxis", mCamera.getOrientation() * Vec3f::xAxis());
  mProgram.uniform("uYAxis", mCamera.getOrientation() * Vec3f::yAxis());
  mProgram.uniform("uViewDistance", mCamera.getAspectRatio() / abs(frustum[2] - frustum[0]) * mCamera.getNearClip());
  mProgram.uniform("uNegViewDir", -mCamera.getViewDirection().normalized());
  mProgram.uniform("uAspectRatio", mCamera.getAspectRatio());
  mTexture.enableAndBind();
  gl::drawSolidRect(mFbo.getBounds());
  mTexture.unbind();
  mProgram.unbind();
  
  mFbo.unbindFramebuffer();
  
  gl::setMatricesWindow(getWindowSize());
  gl::draw(mFbo.getTexture(), getWindowBounds());
}
void millionParticlesApp::initFBO()
{
    mPos = 0;
    mBufferIn = 0;
    mBufferOut = 1;

    mFbo[0].bindFramebuffer();
    mFbo[1].bindFramebuffer();

    //Positionen
    glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);

    gl::setMatricesWindow( mFbo[0].getSize(), false );
    gl::setViewport( mFbo[0].getBounds() );

    glClearColor(0.0f,0.0f,0.0f,1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    mPosTex.enableAndBind();
    gl::draw(mPosTex,mFbo[0].getBounds());
    mPosTex.unbind();

    //velocity buffer
    glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    mVelTex.enableAndBind();
    gl::draw(mVelTex,mFbo[0].getBounds());
    mVelTex.unbind();

    //particle information buffer
    glDrawBuffer(GL_COLOR_ATTACHMENT2_EXT);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    mInfoTex.enableAndBind();
    gl::draw(mInfoTex,mFbo[0].getBounds());
    mInfoTex.unbind();

    mFbo[1].unbindFramebuffer();
    mFbo[0].unbindFramebuffer();

    mPosTex.disable();
    mVelTex.disable();
    mInfoTex.disable();
}
Ejemplo n.º 14
0
void HexagonMirrorApp::draw()
{
    // clear the window
    gl::clear();

    // activate our camera
    gl::pushMatrices();
    gl::setMatrices( mCamera.getCamera() );

    // set render states
    gl::enable( GL_CULL_FACE );
    gl::enableDepthRead();
    gl::enableDepthWrite();
    gl::color( Color::white() );

    if( mVboMesh && mShaderInstanced && mBuffer )
    {
        // bind webcam image
        if( mWebcamTexture )
            mWebcamTexture.bind(0);

        // bind the shader, which will do all the hard work for us
        mShaderInstanced.bind();
        mShaderInstanced.uniform( "texture", 0 );
        mShaderInstanced.uniform( "scale", Vec2f( 1.0f / (3.0f * INSTANCES_PER_ROW), 1.0f / (3.0f * INSTANCES_PER_ROW) ) );

        // bind the buffer containing the model matrix for each instance,
        // this will allow us to pass this information as a vertex shader attribute.
        // See: initializeBuffer()
        glBindVertexArray(mVAO);

        // we do all positioning in the shader, and therefor we only need
        // a single draw call to render all instances.
        drawInstanced( mVboMesh, NUM_INSTANCES );

        // make sure our VBO is no longer bound
        mVboMesh.unbindBuffers();

        // unbind vertex array object containing our buffer
        glBindVertexArray(0);

        // unbind shader
        mShaderInstanced.unbind();

        if( mWebcamTexture )
            mWebcamTexture.unbind();
    }

    // reset render states
    gl::disableDepthWrite();
    gl::disableDepthRead();
    gl::disable( GL_CULL_FACE );

    // restore 2D drawing
    gl::popMatrices();
}
Ejemplo n.º 15
0
void AudioObjApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
    gl::enableAlphaBlending();
    gl::enableDepthRead();
    gl::enableDepthWrite();
    
    gl::pushMatrices();

	gl::setMatrices( mMayaCam.getCamera() );
	
	if ( mFeature && mFeatureTex )
	{
		mShader->bind();
		mFeatureTex.enableAndBind();
		mShader->uniform( "dataTex",		0 );
		mShader->uniform( "texWidth",		(float)mFeatureTex.getWidth() );
		mShader->uniform( "texHeight",		(float)mFeatureTex.getHeight() );
		mShader->uniform( "soundDataSize",  (float)mFeature->getSize() );
		mShader->uniform( "spread",         mFeatureSpread );
		mShader->uniform( "spreadOffset",   mFeatureSpreadOffset );
        mShader->uniform( "time",           (float)getElapsedSeconds() );
		mShader->uniform( "tintColor",      mObjColor );
	}
    
    if ( mRenderWireframe )
        gl::enableWireframe();
    
	gl::color( Color(1.0f, 0.0f, 0.0f ) );
    
	if ( mVbo )
	    gl::draw( mVbo );

    if ( mRenderWireframe )
        gl::disableWireframe();
    
	mShader->unbind();
	mFeatureTex.unbind();

	gl::color( Color::white() );
//	gl::drawCoordinateFrame();
  
	gl::popMatrices();
    
    gl::disableDepthRead();
    gl::disableDepthWrite();
    
	gl::setMatricesWindow( getWindowSize() );

	ciXtractReceiver::drawData( mFeature, Rectf( 15, getWindowHeight() - 150, 255, getWindowHeight() - 35 ) );
	
	gl::draw( mFeatureSurf );

    mParams->draw();
}
Ejemplo n.º 16
0
void GeometryShaderApp::draw()
{
	// clear out the window 
	gl::clear( Color(0.95f, 0.95f, 0.95f) );

	// bind the shader and send the mesh to the GPU
	if(mShader && mVboMesh) {
		mShader.bind();
		mShader.uniform( "WIN_SCALE", Vec2f( getWindowSize() ) ); // casting to Vec2f is mandatory!
		mShader.uniform( "MITER_LIMIT", mLimit );
		mShader.uniform( "THICKNESS", mThickness );
		
		if(mTexture) {
			gl::enableAlphaBlending();
			gl::color( Color::white() );
			mTexture.enableAndBind();
		}
		else
			gl::color( Color::black() );

		gl::draw( mVboMesh );

		if(mTexture) {
			mTexture.unbind();
			gl::disableAlphaBlending();
		}

		if(mDrawWireframe) {
			gl::color( Color::black() );
			gl::enableWireframe();
			gl::draw( mVboMesh );
			gl::disableWireframe();
		}

		mShader.unbind();
	}

	// draw all points as red circles
	gl::color( Color(1, 0, 0) );

	std::vector<Vec2f>::const_iterator itr;
	for(itr=mPoints.begin();itr!=mPoints.end();++itr)
		gl::drawSolidCircle( *itr, mRadius );

	if( ! mPoints.empty() )
		gl::drawStrokedCircle( mPoints.back(), mRadius + 2.0f );

	// draw help
	if(mHelpTexture) {
		gl::color( Color::white() );
		gl::enableAlphaBlending();
		gl::draw( mHelpTexture );
		gl::disableAlphaBlending();
	}
}
/**
 the draw method displays the last filled buffer
 **/
void millionParticlesApp::draw()
{
    gl::setMatricesWindow( getWindowSize() );
    gl::setViewport( getWindowBounds() );

    gl::clear( ColorA( 0.0f, 0.0f, 0.0f, 1.0f ) );

    gl::enableAlphaBlending();
    glDisable(GL_DEPTH_TEST);

    glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);

    mFbo[mBufferIn].bindTexture(0,0);
    mFbo[mBufferIn].bindTexture(1,1);
    mFbo[mBufferIn].bindTexture(2,2);

    mSpriteTex.bind(3);

    //Bewegungsshader
    mPosShader.bind();
    mPosShader.uniform("posTex",0);
    mPosShader.uniform("velTex",1);
    mPosShader.uniform("infTex",2);
    mPosShader.uniform("spriteTex",3);

    mPosShader.uniform("scale",(float)PARTICLES);

    gl::color(ColorA(1.0f,1.0f,1.0f,1.0f));
    //glTranslatef(Vec3f(getWindowWidth() / 4  - PARTICLES,0.0f,0.0f));
    gl::pushMatrices();

    glScalef(getWindowHeight() / (float)PARTICLES , getWindowHeight() / (float)PARTICLES ,1.0f);

    // draw particles
    gl::draw( mVbo );

    gl::popMatrices();

    mPosShader.unbind();

    mSpriteTex.unbind();

    mFbo[mBufferIn].unbindTexture();

    //    writeImage( "/Users/hacku/Desktop/img/1m/" + toString(getElapsedFrames()) + ".tif",   copyWindowSurface() );

    //	gl::color(Color(1,1,1));
    //	gl::setMatricesWindow( getWindowSize() );

    //drawText();

    gl::disableAlphaBlending();

}
Ejemplo n.º 18
0
void LocationApp::draw()
{
    // Clear the screen
    gl::enableDepthRead();
    gl::enableDepthWrite();
    gl::clear( Color::gray( 0.843f ) );

    CameraPersp camera;
    camera.setPerspective( 60.0f, getWindowAspectRatio(), 0.01f, 10.0f );
    camera.lookAt( Vec3f( 0.0f, 0.0f, 3.0f ), Vec3f::zero() );
    gl::setMatrices( camera );
    mLight->update( camera );

    // Rotate the globe
    gl::multModelView( Quatf(Vec3f::yAxis(), mRotationAngle ).normalized() );

    // Draw the globe with shading. Rotate it 90 degrees on
    // its Y axis to line up the texture with the location
    gl::color( ColorAf::white() );
    gl::enable( GL_LIGHTING );
    mTexture.bind( 0 );
    gl::pushMatrices();
    gl::rotate( Vec3f( 0.0f, 90.0f, 0.0f ) );
    gl::drawSphere( Vec3f::zero(), 1.0f, 32 );
    gl::popMatrices();
    mTexture.unbind();
    gl::disable( GL_LIGHTING );

    // Draw location
    gl::color( ColorAf( 1.0f, 0.2f, 0.18f, 0.667f ) );
    gl::drawSphere( mLocation, mDotRadius, 32 );

    ////////////////////////////////////////////////////
#if defined( CINDER_COCOA_TOUCH )
    gl::setMatricesWindow( getWindowSize() );
    gl::enableDepthRead( false );
    gl::enableDepthWrite( false );

    // Plot arrow position
    float radius = 256.0f;
    float rotation = toRadians( mHeading ) - (float)M_PI * 0.5f;
    float x = math<float>::cos( rotation );
    float y = math<float>::sin( rotation );
    Vec2f position = getWindowCenter() + Vec2f( x, y ) * radius;

    gl::translate( position );
    gl::rotate( Vec3f( 0.0f, 0.0f, -mHeading ) );
    gl::translate( position * -1.0f );
    gl::translate( position );

    gl::color( Colorf( 0, 0, 1 ) );
    gl::drawSolid( mArrow );
#endif
}
void pinch_tap_sampleApp::draw()
{
    gl::clear(Color::black());
    
    gl::setMatricesWindowPersp(getWindowSize(), 60, 1, 2000);
    
    mRectTex.enableAndBind();
    for(vector<TouchRect*>::reverse_iterator it = mRects.rbegin(); it != mRects.rend(); ++it)
        (*it)->draw();
    mRectTex.unbind();
}
Ejemplo n.º 20
0
void godComplexApp::draw()
{
	
	gl::enableDepthRead();
	gl::enableDepthWrite();
	gl::enableAlphaBlending();
	
	// clear out the window with black
	gl::clear( Color( 0, 0, 0 ) );
	gl::setMatrices( mMayaCam.getCamera());
    
    
    
	if(drawWater == true){
		if(mWaterModule != NULL){
			gl::pushMatrices();
			mWaterModule->draw(0);
			gl::popMatrices();
		}
	}
    
    
    
	if(drawMesh == true){
		gl::pushMatrices();
		myImage.enableAndBind();
        //      gl::rotate( mArcball.getQuat() ); //NOTE: for debugging
		gl::scale(Vec3f(0.035,0.035,0.035));
		glLineWidth(0.2f);
		gl::enableWireframe();
		gl::translate(Vec3f(280.0, 0.0, -180.0));
		gl::rotate(Vec3f(-10.0, -10.0, 0.0));
		gl::draw(mVbo);
		gl::disableWireframe();
		myImage.unbind();
		gl::popMatrices();
    }
	
	
	gl::pushMatrices();
	mFlowField->draw();
	gl::popMatrices();
	
    
	
	/*
     glPushMatrix();
     glColor4f(1.0, 0.0, 0.0, 1.0);
     gl::drawSphere(Vec3f(userIncr1, userIncr2, userIncr3), 30.0, 12.0);
     glPopMatrix();
     */
}
/* 
 * @Description: render SSAO now - woohoo!
 * @param: KeyEvent
 * @return: none
 */
void Base_ThreeD_ProjectApp::renderSSAOToFBO()
{
	gl::setViewport( mSSAOMap.getBounds() );
	
	//render out main scene to FBO
	mSSAOMap.bindFramebuffer();
	
	glClearColor( 0.5f, 0.5f, 0.5f, 1 );
	glClearDepth(1.0f);
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	
	gl::setMatricesWindow( mSSAOMap.getSize() );
	
	mRandomNoise.bind(1);
	mNormalDepthMap.getTexture().bind(2);
	
	mSSAOShader.bind();
	
	mSSAOShader.uniform("rnm", 1 );
	mSSAOShader.uniform("normalMap", 2 );
    
    //look at shader and see you can set these through the client if you so desire.
    //	mSSAOShader.uniform("rnm", 1 );
    //	mSSAOShader.uniform("normalMap", 2 );	
    //	mSSAOShader.uniform("totStrength", 1.38f);
    //	mSSAOShader.uniform("strength", 0.07f);
    //	mSSAOShader.uniform("offset", 10.0f);
    //	mSSAOShader.uniform("falloff", 0.2f);
    //	mSSAOShader.uniform("rad", 0.8f);
    
    //	mSSAOShader.uniform("rnm", 1 );
    //	mSSAOShader.uniform("normalMap", 2 );
    //	mSSAOShader.uniform("farClipDist", 20.0f);
    //	mSSAOShader.uniform("screenSizeWidth", (float)getWindowWidth());
    //	mSSAOShader.uniform("screenSizeHeight", (float)getWindowHeight());
	
    //	mSSAOShader.uniform("grandom", 1 );
    //	mSSAOShader.uniform("gnormals", 2 );
    //	mSSAOShader.uniform("gdepth", 1 );
    //	mSSAOShader.uniform("gdiffuse", 1 );
    
    gl::drawSolidRect( Rectf( 0, 0, getWindowWidth(), getWindowHeight()) );
	
	mSSAOShader.unbind();
	
	mNormalDepthMap.getTexture().unbind(2);
	mRandomNoise.unbind(1);
	
	mSSAOMap.unbindFramebuffer();
	
	gl::setViewport( getWindowBounds() );
}
Ejemplo n.º 22
0
void ViewFilmGrain::render(gl::Texture texture) {
    shader->bind();
    shader->uniform("texture", 0);
    shader->uniform("time", _count);
    shader->uniform("width", float(getWindowWidth()));
    shader->uniform("height", float(getWindowHeight()));
    texture.bind();
    gl::draw(mesh);
    texture.unbind();
    shader->unbind();
    
    _count += .01;
}
Ejemplo n.º 23
0
void DeferredRenderingApp::drawDepthParticles() const
{
    gl::enableAdditiveBlending();
    
    //this where typically a particle engine would go. For now lets just draw some "earths"
    glColor4ub(255, 255, 255, 160);
    mEarthTex.bind();
    gl::drawCube(Vec3f(3.0f, 2.0f, 8.0f), Vec3f(3.0f, 3.0f, 3.0f));
    gl::drawCube(Vec3f(1.0f, 5.0f, -3.0f), Vec3f(3.0f, 3.0f, 3.0f));
    gl::drawCube(Vec3f(-3.0f, 3.0f, 4.0f), Vec3f(3.0f, 3.0f, 3.0f));
    gl::drawCube(Vec3f(-2.0f, 4.0f, 7.0f), Vec3f(3.0f, 3.0f, 3.0f));
    mEarthTex.unbind();
    glColor4ub(255, 255, 255, 255);
}
Ejemplo n.º 24
0
void BouncingBallsApp::draw()
{
	gl::clear(); 
	gl::enableAdditiveBlending();

	if(mTexture) mTexture.enableAndBind();

	std::vector<BallRef>::iterator itr;
	for(itr=mBalls.begin();itr!=mBalls.end();++itr)
		(*itr)->draw( mMesh, mUseMotionBlur );

	if(mTexture) mTexture.unbind();

	gl::disableAlphaBlending();
}
Ejemplo n.º 25
0
void shaderExternalFileExampleApp::draw(){
    
	gl::clear( Color::black() );
	
    if( mTexture ) {
        mTexture.bind( 0 );
        mShader.bind();
        mShader.uniform( "texture", 0 );
        mShader.uniform( "width", (float)CAM_W );
        mShader.uniform( "height", (float)CAM_H );
        gl::drawSolidRect( getWindowBounds() );
        mShader.unbind();
        mTexture.unbind();
    }
}
void ___PACKAGENAMEASIDENTIFIER___App::draw()
{
	// clear out the window with black
	gl::clear( kClearColor ); 
	
	if( !mTexture ) return;
	mFbo.bindFramebuffer();
	mTexture.enableAndBind();
	mShader.bind();
	mShader.uniform( "tex", 0 );
	mShader.uniform( "mixColor", Vec3d( mMixColorRed, mMixColorGreen, mMixColorBlue ) );
	gl::drawSolidRect( getWindowBounds() );
	mTexture.unbind();
	mShader.unbind();
	mFbo.unbindFramebuffer();
	
	gl::Texture fboTexture = mFbo.getTexture();
	fboTexture.setFlipped();
	gl::draw( fboTexture );

	params::InterfaceGl::draw();
}
Ejemplo n.º 27
0
	void draw()
	{
		if( ! mTexture )
			return;

		GLfloat LightPosition[]= { 0, 0, 1, 0.0f };
		glMatrixMode( GL_MODELVIEW );
		glLoadIdentity();
		glLightfv( GL_LIGHT0, GL_POSITION, LightPosition );
		
		glMatrixMode( GL_PROJECTION );
		glLoadMatrixf( mCam->getProjectionMatrix().m );
		
		glMatrixMode( GL_MODELVIEW );
		glLoadMatrixf( mCam->getModelViewMatrix().m );

		
		glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
		glEnable( GL_MULTISAMPLE_ARB );
		glEnable( GL_TEXTURE_2D );
		glEnable( GL_DEPTH_TEST );
		glDepthMask( GL_TRUE );
		glShadeModel( GL_SMOOTH );
		glEnable( GL_LIGHTING );
		
		glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
		
		if( mDrawTextured )
			mTexture->bind();
		else
			glDisable( GL_TEXTURE_2D );
		for( size_t c = 0; c < mCubes.size(); ++c ) {
			mCubes[c]->draw();
		}
		mTexture->unbind();
		fli::gl::drawCube( Vec3f::zero(), Vec3f(1000, 0.01f, 1000) );
	}
void wellingtonModelApp::draw()
{
    
    gl::enableDepthRead();
    gl::enableDepthWrite();
    gl::enableAlphaBlending();
    
    // clear out the window with black
	gl::clear( Color( 0, 0, 0 ) );
    
    /*
     if(mWaterModule != NULL){
     gl::pushMatrices();
     mWaterModule->draw();
     gl::popMatrices();
     }
     */
    
    
//    /*
    gl::setMatrices( mMayaCam.getCamera());
    
    gl::pushMatrices();
    myImage.enableAndBind();
    gl::rotate( mArcball.getQuat() );
    gl::scale(Vec3f(0.035,0.035,0.035));
    glLineWidth(0.3f);
    gl::enableWireframe();
    gl::rotate(Vec3f(50.0, -20.0, 0.0));
    gl::draw(mVbo);
    myImage.unbind();
    gl::popMatrices();
     
//     */
    
 
    
}
Ejemplo n.º 29
0
void ViewSimulation::render(gl::Texture texture) {
    shader->bind();
    shader->uniform("texture", 0);
    shader->uniform("maxRaidus", GlobalSettings::getInstance().maxRadius);
    shader->uniform("gravity", GlobalSettings::getInstance().gravity);
    shader->uniform("yFloor", GlobalSettings::getInstance().floor);
    shader->uniform("yCeiling", GlobalSettings::getInstance().ceiling);
    
//    shader->uniform("zoneRadius", GlobalSettings::getInstance().zoneRadius);
    shader->uniform("zoneRadius", GlobalSettings::getInstance().noiseZoneRadius->getValue());
    
//    shader->uniform("lowThreshold", GlobalSettings::getInstance().lowThreshold);
//    shader->uniform("highThreshold", GlobalSettings::getInstance().highThreshold);

    shader->uniform("lowThreshold", GlobalSettings::getInstance().noiseLowThreshold->getValue());
    shader->uniform("highThreshold", GlobalSettings::getInstance().noiseHighThreshold->getValue());

//    shader->uniform("repelStrength", GlobalSettings::getInstance().repelStrength);
//    shader->uniform("attractStrength", GlobalSettings::getInstance().attractStrength);
//    shader->uniform("orientStrength", GlobalSettings::getInstance().orientStrength);
    
    shader->uniform("repelStrength", GlobalSettings::getInstance().noiseRepelStrength->getValue());
    shader->uniform("attractStrength", GlobalSettings::getInstance().noiseAttractStrength->getValue());
    shader->uniform("orientStrength", GlobalSettings::getInstance().noiseOrientStrength->getValue());
    
    shader->uniform("yVelDecrease", GlobalSettings::getInstance().yVelDecrease);
//    shader->uniform("flashingRadius", GlobalSettings::getInstance().flashingRadius);
    shader->uniform("flashingRadius", GlobalSettings::getInstance().noiseFlashingRadius->getValue());
    shader->uniform("catchingSpeed", GlobalSettings::getInstance().catchingSpeed);
    shader->uniform("flashingSpeed", GlobalSettings::getInstance().flashingSpeed);
    shader->uniform("maxThetaDiff", GlobalSettings::getInstance().maxThetaDiff);
    shader->uniform("speedMutiplier", GlobalSettings::getInstance().speedMutiplier);

    texture.bind();
    gl::draw(mesh);
    texture.unbind();
    shader->unbind();
}
Ejemplo n.º 30
0
void TextureTestApp::draw()
{
	gl::clear(Color(0.2f, 0.2f, 0.2f));

  // カメラの状態から行列を作成
  // 視点座標変換用と正規化デバイス座標変換用の2つを用意する
  gl::setMatrices(camera);

  // ライティング開始
  light->enable();

  // ローカル→ワールド変換行列を用意
  gl::scale(100.0, 100.0, 100.0);
  gl::rotate(Vec3f(rx, ry, rz));

  // テクスチャを拘束
  image.bind();

  // ポリゴンを描画
  gl::draw(mesh);

  // 拘束を解除
  image.unbind();
}