void	KinectEcard::clear(){
	mStoredDepthFbo.bindFramebuffer();
	gl::clear( Color::white() );
	mStoredDepthFbo.unbindFramebuffer();

	mStoredVideoFbo.bindFramebuffer();
	gl::clear( Color::white() );
	mStoredVideoFbo.unbindFramebuffer();
}
void BubbleChamberApp::drawIntoRoomFbo()
{
	mRoomFbo.bindFramebuffer();
	gl::clear( ColorA( 0.0f, 0.0f, 0.0f, 0.0f ), true );
	
	gl::setMatricesWindow( mRoomFbo.getSize(), false );
	gl::setViewport( mRoomFbo.getBounds() );
	gl::disableAlphaBlending();
	gl::enable( GL_TEXTURE_2D );
	glEnable( GL_CULL_FACE );
	glCullFace( GL_BACK );
	Matrix44f m;
	m.setToIdentity();
	m.scale( mRoom.getDims() );

	mRoomShader.bind();
	mRoomShader.uniform( "mvpMatrix", mActiveCam.mMvpMatrix );
	mRoomShader.uniform( "mMatrix", m );
	mRoomShader.uniform( "eyePos", mActiveCam.mCam.getEyePoint() );
	mRoomShader.uniform( "roomDims", mRoom.getDims() );
	mRoomShader.uniform( "power", mRoom.getPower() );
	mRoomShader.uniform( "lightPower", mRoom.getLightPower() );
	mRoomShader.uniform( "timePer", mRoom.getTimePer() * 1.5f + 0.5f );
	mRoom.draw();
	mRoomShader.unbind();
	
	mRoomFbo.unbindFramebuffer();
	glDisable( GL_CULL_FACE );
}
Esempio n. 3
0
void RepulsionApp::setFboVelocities( gl::Fbo &fbo )
{
	Surface32f vel( fbo.getTexture() );
	Surface32f::Iter it = vel.getIter();
	while( it.line() ){
		while( it.pixel() ){
			Vec3f r = Rand::randVec3f() * 0.1f;
			it.r() = 0.0f;//r.x;
			it.g() = 0.0f;//r.y;
			it.b() = 0.0f;//r.z;
			it.a() = 0.0f;
		}
	}
	
	gl::Texture velTexture( vel );
	velTexture.bind();
	
	gl::setMatricesWindow( mFboSize, false );
	gl::setViewport( mFboBounds );
	
	fbo.bindFramebuffer();
	mVelInitShader.bind();
	mVelInitShader.uniform( "initTex", 0 );
	gl::drawSolidRect( mFboBounds );
	mVelInitShader.unbind();
	fbo.unbindFramebuffer();
}
Esempio n. 4
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 );

}
Esempio n. 5
0
void BrainbowApp::updateShadowMap()
{
	mDepthFbo.bindFramebuffer();
    
	glPolygonOffset( 1.0f, 1.0f );
	glEnable( GL_POLYGON_OFFSET_FILL );
	glClear( GL_DEPTH_BUFFER_BIT );
    
	glPushAttrib( GL_VIEWPORT_BIT );
	glViewport( 0, 0, SHADOW_MAP_RESOLUTION, SHADOW_MAP_RESOLUTION );
    
	gl::pushMatrices();
	
    mLight->setShadowRenderMatrices();
    
    mDisc.draw();
    //    mCyl.draw();
    //    mCur.draw();
    mDiamond.draw();
    
	gl::popMatrices();
    
	glPopAttrib();
    
	glDisable( GL_POLYGON_OFFSET_FILL );
    
	mDepthFbo.unbindFramebuffer();
}
Esempio n. 6
0
void ShadowMapSample::updateShadowMap()
{
	mDepthFbo.bindFramebuffer();

	glPolygonOffset( 1.0f, 1.0f );
	glEnable( GL_POLYGON_OFFSET_FILL );
	glClear( GL_DEPTH_BUFFER_BIT );

	glPushAttrib( GL_VIEWPORT_BIT );
	glViewport( 0, 0, SHADOW_MAP_RESOLUTION, SHADOW_MAP_RESOLUTION );

	gl::pushMatrices();
	
		mLight->setShadowRenderMatrices();

		mBackboard.draw();
		mTorus.draw();
		gl::drawCube( vec3::zero(), vec3( 1, 1, 1 ) );
	gl::popMatrices();

	glPopAttrib();

	glDisable( GL_POLYGON_OFFSET_FILL );

	mDepthFbo.unbindFramebuffer();
}
Esempio n. 7
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());
}
Esempio n. 8
0
void SlytherinApp::setup() {
    // setup webcam
    try {
        mCapture = Capture::create(640, 480);
        mCapture->start();
    } catch(...) {
        console() << "ERROR - failed to initialize capture" << endl;
        quit();
    }

    // setup webcam FBO
    gl::Fbo::Format format;
    format.enableColorBuffer(true);
    format.enableDepthBuffer(false);
    format.setWrap(GL_CLAMP, GL_CLAMP);

    mFBO = gl::Fbo(mCapture->getWidth(), mCapture->getHeight(), format);
    mFBO.bindFramebuffer();
        gl::setViewport(mFBO.getBounds());
        gl::clear();
    mFBO.unbindFramebuffer();

    setFrameRate(60.0f);

    mLastUpdateFrame = UINT32_MAX;
    mLinesPerFrame = 2.0f; // 1 line every 2 frames (at getFrameRate())
    mLineIndex = 0;
}
void StereoscopicRenderingApp::renderAnaglyph(  const Vec2i &size, const ColorA &left, const ColorA &right )
{	
	// bind the FBO and clear its buffer
	mFbo.bindFramebuffer();
	gl::clear( mColorBackground );

	// render the scene using the side-by-side technique
	renderSideBySide( mFbo.getSize() );

	// unbind the FBO
	mFbo.unbindFramebuffer();

	// enable the anaglyph shader
	mShaderAnaglyph.bind();
	mShaderAnaglyph.uniform( "tex0", 0 );
	mShaderAnaglyph.uniform( "clr_left", left );
	mShaderAnaglyph.uniform( "clr_right", right );	

	// bind the FBO texture and draw a full screen rectangle,
	// which conveniently is exactly what the following line does
	gl::draw( mFbo.getTexture(), Rectf(0, float(size.y), float(size.x), 0) );

	// disable the anaglyph shader
	mShaderAnaglyph.unbind();
}
Esempio n. 10
0
void StereoscopicRenderingApp::renderInterlacedHorizontal( const Vec2i &size )
{
	// bind the FBO and clear its buffer
	mFbo.bindFramebuffer();
	gl::clear( mColorBackground );

	// render the scene using the over-under technique
	renderOverUnder( mFbo.getSize() );

	// unbind the FBO
	mFbo.unbindFramebuffer();

	// enable the interlace shader
	mShaderInterlaced.bind();
	mShaderInterlaced.uniform( "tex0", 0 );
	mShaderInterlaced.uniform( "window_origin", Vec2f( getWindowPos() ) );
	mShaderInterlaced.uniform( "window_size", Vec2f( getWindowSize() ) );

	// bind the FBO texture and draw a full screen rectangle,
	// which conveniently is exactly what the following line does
	gl::draw( mFbo.getTexture(), Rectf(0, float(size.y), float(size.x), 0) );

	// disable the interlace shader
	mShaderInterlaced.unbind();
}
Esempio n. 11
0
void ShadedSphereApp::drawIntoRoomFbo()
{
	mRoomFbo.bindFramebuffer();
	gl::clear( ColorA( 0.0f, 0.0f, 0.0f, 0.0f ), true );
	
	gl::setMatricesWindow( mRoomFbo.getSize(), false );
	gl::setViewport( mRoomFbo.getBounds() );
	gl::disableAlphaBlending();
	gl::enable( GL_TEXTURE_2D );
	glEnable( GL_CULL_FACE );
	glCullFace( GL_BACK );
	Matrix44f m;
	m.setToIdentity();
	m.scale( mRoom.getDims() );
	
	//	mLightsTex.bind( 0 );
	mRoomShader.bind();
	mRoomShader.uniform( "mvpMatrix", mSpringCam.mMvpMatrix );
	mRoomShader.uniform( "mMatrix", m );
	mRoomShader.uniform( "eyePos", mSpringCam.getEye() );
	mRoomShader.uniform( "roomDims", mRoom.getDims() );
	mRoomShader.uniform( "mainPower", mRoom.getPower() );
	mRoomShader.uniform( "lightPower", mRoom.getLightPower() );
	mRoom.draw();
	mRoomShader.unbind();
	
	mRoomFbo.unbindFramebuffer();
	glDisable( GL_CULL_FACE );
}
Esempio n. 12
0
// Render the torus into the FBO
void FBOMultipleTargetsApp::renderSceneToFbo()
{
	// bind the framebuffer - now everything we draw will go there
	mFbo.bindFramebuffer();

	// setup the viewport to match the dimensions of the FBO
	gl::setViewport( mFbo.getBounds() );

	// setup our camera to render the torus scene
	CameraPersp cam( mFbo.getWidth(), mFbo.getHeight(), 60.0f );
	cam.setPerspective( 60, mFbo.getAspectRatio(), 1, 1000 );
	cam.lookAt( Vec3f( 2.8f, 1.8f, -2.8f ), Vec3f::zero() );
	gl::setMatrices( cam );

	// set the modelview matrix to reflect our current rotation
	gl::multModelView( mTorusRotation );
	
	// clear out both of the attachments of the FBO with black
	gl::clear();

	// render the torus with our multiple-output shader
	mShaderMultipleOuts.bind();
	gl::drawTorus( 1.4f, 0.3f, 32, 64 );
	mShaderMultipleOuts.unbind();

	// unbind the framebuffer, so that drawing goes to the screen again
	mFbo.unbindFramebuffer();
}
/* 
 * @Description: render scene to FBO texture
 * @param: none
 * @return: none
 */
void Base_ThreeD_ProjectApp::renderSceneToFBO()
{
	mScreenSpace1.bindFramebuffer();
    
	glClearColor( 0.5f, 0.5f, 0.5f, 1 );
	glClearDepth(1.0f);
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	
	if (mLightingOn)
		glDisable(GL_LIGHTING);
	glColor3f( 1.0f, 1.0f, 0.1f );
	gl::drawFrustum( mLightRef->getShadowCamera() );
	glColor3f( 1.0f, 1.0f, 1.0f );
	if (mLightingOn)
		glEnable(GL_LIGHTING);
	
	mEye = mCam->getEyePoint();
	mEye.normalize();
	mEye = mEye * abs(mCameraDistance);
	mCam->lookAt( mEye, mCenter, mUp );
	gl::setMatrices( *mCam );
	mLight->update( *mCam );
	
	drawTestObjects();
	
	mScreenSpace1.unbindFramebuffer();
	
	glDisable(GL_LIGHTING);
}
void SmoothDisplacementMappingApp::renderDisplacementMap()
{
	if( mDispMapShader && mDispMapFbo ) 
	{
		mDispMapFbo.bindFramebuffer();
		{
			// clear the color buffer
			gl::clear();			

			// setup viewport and matrices 
			glPushAttrib( GL_VIEWPORT_BIT );
			gl::setViewport( mDispMapFbo.getBounds() );

			gl::pushMatrices();
			gl::setMatricesWindow( mDispMapFbo.getSize(), false );

			// render the displacement map
			mDispMapShader.bind();
			mDispMapShader.uniform( "time", float( getElapsedSeconds() ) );
			mDispMapShader.uniform( "amplitude", mAmplitude );
			gl::drawSolidRect( mDispMapFbo.getBounds() );
			mDispMapShader.unbind();

			// clean up after ourselves
			gl::popMatrices();
			glPopAttrib();
		}
		mDispMapFbo.unbindFramebuffer();
	}
}
Esempio n. 15
0
void CatalogApp::setFboPositions( gl::Fbo &fbo )
{
	int numBrightStars = mBrightStars.size();

	int index = 0;
	
	Surface32f posSurface( fbo.getTexture() );
	Surface32f::Iter it = posSurface.getIter();
	while( it.line() ){
		while( it.pixel() ){
			Vec3f pos = Vec3f( 1000000.0f, 0.0f, 0.0f );
			float col = 0.4f;
			float rad = 0.0f;
			if( index < numBrightStars ){
				pos = mBrightStars[index]->mPos;
				col = mBrightStars[index]->mColor;
				rad = floor( constrain( ( ( 6.0f - ( mBrightStars[index]->mAbsoluteMag ) )/6.0f ), 0.3f, 1.0f ) * 3.0f * 1000 );
			}
			it.r() = pos.x;
			it.g() = pos.y;
			it.b() = pos.z;
			it.a() = rad + col;

			index ++;
		}
	}

	gl::Texture posTexture( posSurface );
	fbo.bindFramebuffer();
	gl::setMatricesWindow( fbo.getSize(), false );
	gl::setViewport( fbo.getBounds() );
	gl::clear( ColorA( 0, 0, 0, 0 ), true );
	gl::draw( posTexture );
	fbo.unbindFramebuffer();
}
Esempio n. 16
0
void Simulacra::helix()
{
    glDisable(GL_LIGHTING);
    glDisable(GL_LIGHT0);

    // render a simple scene into mFboScene
    helixShader.bind();
    gl::translate(0,0,0);
    helixFBO.bindFramebuffer();

    helixShader.uniform("time",Vec2f(sin(rotation),1-sin(rotation*0.71)));
    gl::clear(ColorA(0,0,0,1));
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    gl::drawSolidRect(cinder::Rectf(0,0,getWindowWidth(),getWindowHeight()));
    helixFBO.unbindFramebuffer();
    helixShader.unbind();

    //Revert back to screen
    gl::color(cinder::ColorA(1,1,1,1));
    applyHelixShader.bind();
    finalFBO.bindTexture(0);
    applyHelixShader.uniform("qt_Texture0",0);
    helixFBO.bindTexture(1);
    applyHelixShader.uniform("qt_Texture1",1);

    gl::drawSolidRect(cinder::Rectf(0,getWindowHeight(),getWindowWidth(),0));
    applyHelixShader.unbind();
    helixFBO.unbindTexture();
    finalFBO.unbindTexture();

    gl::color(ColorA(1,1,1,1));
}
Esempio n. 17
0
void HiKinectApp::generateNormalMap() {
	// bind the Fbo
	mFbo.bindFramebuffer();
	// match the viewport to the Fbo dimensions
	gl::setViewport( mFbo.getBounds() );
	// setup an ortho projection
	gl::setMatricesWindow( mFbo.getWidth(), mFbo.getHeight() );
	// clear the Fbo
	gl::clear( Color( 0, 0, 0 ) );
	
	// bind the shader, set its variables
	mNormalShader.bind();
	mNormalShader.uniform( "normalStrength", mNormalStrength);
	mNormalShader.uniform( "texelWidth", 1.0f / (float)CAPTURE_WIDTH );
	
	if ( mDepthTexture ) {
		gl::pushModelView();
//		gl::translate( Vec3f( 0, mDepthTexture.getHeight(), 0 ) );
//		gl::scale( Vec3f( 1, -1, 1 ) );
		gl::draw( mDepthTexture );
		gl::popModelView();
	}
	
	// unbind the shader
	mNormalShader.unbind();
	// unbind the Fbo
	mFbo.unbindFramebuffer();
}
Esempio n. 18
0
void KinectEcard::renderDepth(){
	if( !mDepthSurface || !mVideoSurface )
		return;

	gl::pushMatrices();
	{
		mDepthFbo.bindFramebuffer();

		// clear FBO
		gl::clear( Color::black() );
		gl::color( Color::white() );

		//
		gl::setMatricesWindowPersp( mDepthFbo.getSize() );

		// draw depth 
		gl::pushMatrices();
			gl::scale( 2, 2 );
			gl::draw( gl::Texture( mDepthSurface ) );
		gl::popMatrices();

		mDepthFbo.unbindFramebuffer();
	}
	gl::popMatrices();
}
/* 
 * @Description: need to blur[the SSAO texture] horizonatally then vertically (for shader performance reasons). Called ping-ponging as it one FBO drawn to another
 * @param: KeyEvent
 * @return: none
 */
void Base_ThreeD_ProjectApp::pingPongBlur()
{
	//render horizontal blue first
	gl::setViewport( mPingPongBlurH.getBounds() );
	
	mPingPongBlurH.bindFramebuffer();
	
	glClearColor( 0.5f, 0.5f, 0.5f, 1 );
	glClearDepth(1.0f);
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	
	gl::setMatricesWindow( mPingPongBlurH.getSize() );
	
	mSSAOMap.getTexture().bind(0);
	mHBlurShader.bind();
	mHBlurShader.uniform("RTScene", 0);
    gl::drawSolidRect( Rectf( 0, 0, getWindowWidth(), getWindowHeight()) );
	mHBlurShader.unbind();
	mSSAOMap.getTexture().unbind(0);
	
	mPingPongBlurH.unbindFramebuffer();
	
	//gl::setViewport( getWindowBounds() ); //redundant
	
	//now render vertical blur
	gl::setViewport( mPingPongBlurV.getBounds() );
	
	mPingPongBlurV.bindFramebuffer();
	
	glClearColor( 0.5f, 0.5f, 0.5f, 1 );
	glClearDepth(1.0f);
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	
	gl::setMatricesWindow( mPingPongBlurV.getSize() );
	
	mPingPongBlurH.getTexture().bind(0);
	mHBlurShader.bind();
	mHBlurShader.uniform("RTBlurH", 0);
	gl::drawSolidRect( Rectf( 0, 0, getWindowWidth(), getWindowHeight()) );
	mHBlurShader.unbind();
	mPingPongBlurH.getTexture().unbind(0);
	
	mPingPongBlurV.unbindFramebuffer();
	
	gl::setViewport( getWindowBounds() );
}
Esempio n. 20
0
void Narcotic::draw()
{
	
	gl::clear();
	fboProjection.bindFramebuffer();
	gl::clear(Color::gray(0.25));
	v1.draw();
	fboProjection.unbindFramebuffer();
	gl::draw(fboProjection.getTexture(), Rectf(projectionWindow->getBounds()));
	//fboProjection.unbindTexture();
}
/* 
 * @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() );
}
void GroupingApp::draw() {
	float currTime = timer.getSeconds();
	float deltaTime = currTime - prevTime;
	prevTime = currTime;
	
	if (autoRotation) {
		rotation += deltaTime * 60;
		rotation = fmod(rotation, 360);
	}
	
	fbo.bindFramebuffer();
	
	gl::pushMatrices();
	gl::clear(ColorA(0.2, 0.2, 0.2, 1.0));
	gl::translate(Vec2f(getWindowWidth()/2, getWindowHeight()/2));
	gl::rotate(rotation);
	gl::color(color);
	gl::enableAlphaBlending();
	gl::disableDepthRead();
	
	if (fill) {
		gl::translate(Vec2f(-50, -50));
		gl::drawSolidRect(Rectf(-size/2, -size/2, size/2, size/2));
		gl::translate(Vec2f(+100, +100));
		gl::drawSolidRect(Rectf(-size/2, -size/2, size/2, size/2));
	}
	else if (stroke) {
		glLineWidth(thickness);
		gl::translate(Vec2f(-50, -50));
		gl::drawLine(Vec2f(-size/2, -size/2), Vec2f( size/2, -size/2));
		gl::drawLine(Vec2f( size/2, -size/2), Vec2f( size/2,  size/2));
		gl::drawLine(Vec2f( size/2,  size/2), Vec2f(-size/2,  size/2));
		gl::drawLine(Vec2f(-size/2,  size/2), Vec2f(-size/2, -size/2));		
		gl::translate(Vec2f(+100, +100));
		gl::drawLine(Vec2f(-size/2, -size/2), Vec2f( size/2, -size/2));
		gl::drawLine(Vec2f( size/2, -size/2), Vec2f( size/2,  size/2));
		gl::drawLine(Vec2f( size/2,  size/2), Vec2f(-size/2,  size/2));
		gl::drawLine(Vec2f(-size/2,  size/2), Vec2f(-size/2, -size/2));
		glLineWidth(1);
	}
	gl::popMatrices();	
	
	fbo.unbindFramebuffer();
	
	gl::color(ColorA(1,1,1,1));
	gl::draw(fbo.getTexture());
	
	strokePanel->enabled = stroke ? true : false;
	gui->draw();
}
Esempio n. 23
0
void ProjectionMappingApp::update()
{
	this->updateBezierMesh();// update

	gl::setMatricesWindow(getWindowSize(), false); // 画像の表示を上向きにする
	mFbo.bindFramebuffer();
	gl::clear(Color(0, 0, 0));

	mShader.bind();
	mShader.uniform("diffuseMap", 0);

#if 0
	mMovie.getTexture().bind(0);
#else 
	if (mEditMode == EditMode_EDIT) {
		if (mDispMode == DispMode_MOVIE && mHasMovie) {
			mMovie.getTexture().bind(0);
		} else {
			mDiffuseTex[mDispMode].bind(0);
		}
	} else if (mEditMode == EditMode_RECORD) {
		if (mFrame <= mDuration) {
			gl::Texture::Format texformat;
			texformat.setTargetRect();

			std::string imgName = (boost::format("%s\\%s_%05d.png") % mInImageFolder % mInImageName % mFrame).str();
			if (boost::filesystem::exists(boost::filesystem::path(imgName))) {
				mDiffuseTex[mDispMode] = gl::Texture(loadImage(imgName.c_str()), texformat);
			}
			else {
				mDispMode = DispMode_GUIDE;
				mEditMode = EditMode_EDIT;
			}
		} else {
			mEditMode = EditMode_EDIT;
		}
	}
#endif

	gl::draw(mMesh);
	mShader.unbind();

	mFbo.unbindFramebuffer();
}
/* 
 * @Description: render scene normals to FBO ( required for SSAO calculations )
 * @param: none
 * @return: none
 */
void Base_ThreeD_ProjectApp::renderNormalsDepthToFBO()
{
	gl::setViewport( mNormalDepthMap.getBounds() );
	
	//render out main scene to FBO
	mNormalDepthMap.bindFramebuffer();
	
	glClearColor( 0.5f, 0.5f, 0.5f, 1 );
	glClearDepth(1.0f);
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	
	mNormalDepthShader.bind();
    drawTestObjects();
	mNormalDepthShader.unbind();
	
	mNormalDepthMap.unbindFramebuffer();
	
	gl::setViewport( getWindowBounds() );
}
Esempio n. 25
0
void ardroneApp::draw()
{
    renderFbo.bindFramebuffer();

	gl::clear( Color( 0, 0, 0 ) );
    gl::color( Color::white() );
	if ( mFrameTexture ) {
		Rectf centeredRect = Rectf( mFrameTexture.getBounds() ).getCenteredFit( getWindowBounds(), true );
		gl::draw( mFrameTexture, centeredRect  );
	}
    
    renderFbo.blitToScreen(renderFbo.getBounds(), getWindowBounds());
    mSyphonServer.publishTexture(renderFbo.getTexture(), false);

    renderFbo.unbindFramebuffer(); // return rendering to the window's own frame buffer

	if( mInfoTexture ) {
		glDisable( GL_TEXTURE_RECTANGLE_ARB );
		gl::draw( mInfoTexture, Vec2f( 5, getWindowHeight() - 5 - mInfoTexture.getHeight() ) );
	}
}
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();
}
Esempio n. 27
0
void Grove::copyBlur(gl::Fbo& source, gl::Fbo& target, Vec2f sampleOffset)
{
	// bind the blur shader
	mBlurShader.bind();
	mBlurShader.uniform("tex0", 0); // use texture unit 0
	mBlurShader.uniform("sampleOffset", sampleOffset);

	// copy a horizontally blurred version of our scene into the first blur Fbo
	gl::setViewport( target.getBounds() );
	target.bindFramebuffer();
		source.bindTexture(0);
		gl::pushMatrices();
		gl::setMatricesWindow(target.getSize(), false);
			gl::clear( Color::black() );
			gl::drawSolidRect( target.getBounds() );
		gl::popMatrices();
		source.unbindTexture();
	target.unbindFramebuffer();	

	// unbind the shader
	mBlurShader.unbind();
}
void SmoothDisplacementMappingApp::renderNormalMap()
{
	if( mNormalMapShader && mNormalMapFbo ) 
	{
		mNormalMapFbo.bindFramebuffer();
		{
			// setup viewport and matrices 
			glPushAttrib( GL_VIEWPORT_BIT );
			gl::setViewport( mNormalMapFbo.getBounds() );

			gl::pushMatrices();
			gl::setMatricesWindow( mNormalMapFbo.getSize(), false );

			// clear the color buffer
			gl::clear();			

			// bind the displacement map
			mDispMapFbo.getTexture().bind(0);

			// render the normal map
			mNormalMapShader.bind();
			mNormalMapShader.uniform( "texture", 0 );
			mNormalMapShader.uniform( "amplitude", 4.0f );

			Area bounds = mNormalMapFbo.getBounds(); //bounds.expand(-1, -1);
			gl::drawSolidRect( bounds );

			mNormalMapShader.unbind();

			// clean up after ourselves
			mDispMapFbo.getTexture().unbind();

			gl::popMatrices();

			glPopAttrib();
		}
		mNormalMapFbo.unbindFramebuffer();
	}
}
void ScreenShadersApp::draw()
{
	// clear out the window with black
	gl::clear( Color( 0, 0, 0 ) ); 
	
	// bind the Fbo
	mFbo.bindFramebuffer();
	// match the viewport to the Fbo dimensions
	gl::setViewport( mFbo.getBounds() );
	// setup an ortho projection
	gl::setMatricesWindow( mFbo.getWidth(), mFbo.getHeight() );
	// clear the Fbo
	gl::clear( Color( 0, 0, 0 ) );
	
	if ( mTexture ) {
		gl::draw( mTexture );
	}
	
	// unbind the Fbo
	mFbo.unbindFramebuffer();
	
	gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );
	
	float kernelRes = 21.0f;
	
	mBlurShader.bind();
	mBlurShader.uniform( "kernelRes", kernelRes );
	mBlurShader.uniform( "invKernelRes", 1.0f / kernelRes );
	mBlurShader.uniform( "fboTex", 0 );
	mBlurShader.uniform( "kernelTex", 1 );
	mBlurShader.uniform( "orientationVector", Vec2f( 1.0f, 1.0f ) );
	mBlurShader.uniform( "blurAmt", 1.0f );
	mBlurShader.uniform( "colMulti", 1.0f );
	
	mBlurKernel.bind( 1 );
	
	gl::draw( mFbo.getTexture(0), Rectf( 0, getWindowHeight(), getWindowWidth(), 0 ) );
	mBlurShader.unbind();
}
Esempio n. 30
0
void KinectEcard::renderVideo(){
	if( !mVideoSurface )
		return;

	gl::pushMatrices();
	{
		//
		mVideoFbo.bindFramebuffer();

		// clear FBO
		gl::clear( Color::black() );
		gl::color( Color::white() );

		// 
		gl::Texture tex0( mVideoSurface );
		gl::Texture tex1( mCorrectionMap );

		mDepthCorrectionShader.bind();
		mDepthCorrectionShader.uniform( "tex0", 0 );
		mDepthCorrectionShader.uniform( "tex1", 1 );

		tex0.bind(0);
		tex1.bind(1);

		gl::setMatricesWindowPersp( mVideoFbo.getSize() );

		// draw video surface
		gl::drawSolidRect( mVideoFbo.getBounds() );
		//gl::draw( mCorrectionMap );

		mDepthCorrectionShader.unbind();

		mVideoFbo.unbindFramebuffer();
	}
	gl::popMatrices();
	
}