예제 #1
0
void TerrainApp::drawTerrain()
{
	mRd.getHeightsTexture().bind( 0 );
	mRd.getNormalsTexture().bind( 1 );
	mGradientTex.bind( 2 );
	mSandNormalTex.bind( 3 );
	mTerrainShader.bind();
	mTerrainShader.uniform( "heightsTex", 0 );
	mTerrainShader.uniform( "normalsTex", 1 );
	mTerrainShader.uniform( "gradientTex", 2 );
	mTerrainShader.uniform( "sandNormalTex", 3 );
	mTerrainShader.uniform( "mvpMatrix", mSpringCam.mMvpMatrix );
	mTerrainShader.uniform( "terrainScale", mTerrainScale );
	mTerrainShader.uniform( "roomDims", mRoom.getDims() );
	mTerrainShader.uniform( "zoomMulti", mZoomMulti );//lerp( mZoomMulti, 1.0f, mRoom.getPower() ) );
	mTerrainShader.uniform( "power", mRoom.getPower() );
	mTerrainShader.uniform( "eyePos", mSpringCam.getEye() );
	mTerrainShader.uniform( "lightPos", mLightPos );
	mTerrainShader.uniform( "fogColor", mFogColor );
	mTerrainShader.uniform( "sandColor", mSandColor );
	mTerrainShader.uniform( "mousePosNorm", -( mMousePosNorm - Vec2f( 0.5f, 0.5f ) ) * getElapsedSeconds() * 2.0f );
	mTerrainShader.uniform( "spherePos", mSphere.getCenter() );
	mTerrainShader.uniform( "sphereRadius", mSphere.getRadius() );
	mTerrain.draw();
	mTerrainShader.unbind();
}
/**
 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);

}
예제 #3
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();
}
예제 #4
0
void HiKinectApp::draw3D() {
	
	gl::setMatrices( mCamUI.getCamera() );
	if (mWireframe) gl::enableWireframe();
	else gl::disableWireframe();
	
	if (mLighting) {
		glEnable( GL_LIGHTING );
		glEnable( GL_LIGHT0 );
	}
//	GLfloat light_position[] = { mMousePos.x, mMousePos.y, -275.0f, 0.0f };
	GLfloat light_position[] = { 0, 0, 1.0f, 0.0f };
	glLightfv( GL_LIGHT0, GL_POSITION, light_position );
	if( DIFFUSE ){
		ci::ColorA color( CM_RGB, 1.0f, 1.0f, 1.0f, 1.0f );
		glMaterialfv( GL_FRONT, GL_DIFFUSE,	color );
	} else {
		glMaterialfv( GL_FRONT, GL_DIFFUSE,	no_mat );
	}
	
	if( AMBIENT )
		glMaterialfv( GL_FRONT, GL_AMBIENT,	mat_ambient );
	else
		glMaterialfv( GL_FRONT, GL_AMBIENT,	no_mat );
	
	if( SPECULAR ){
		glMaterialfv( GL_FRONT, GL_SPECULAR, mat_specular );
		glMaterialfv( GL_FRONT, GL_SHININESS, mat_shininess );
	} else {
		glMaterialfv( GL_FRONT, GL_SPECULAR, no_mat );
		glMaterialfv( GL_FRONT, GL_SHININESS, no_shininess );
	}
	
	if( EMISSIVE )
		glMaterialfv( GL_FRONT, GL_EMISSION, mat_emission );
	else
		glMaterialfv( GL_FRONT, GL_EMISSION, no_mat );
	
	if (mDepthTexture)
		mDepthTexture.bind(0);
	mFbo.bindTexture(1);
	if (mColorTexture)
		mColorTexture.bind(2);
	
	mGridMesh.draw( lmap(mMousePos.x, 0.0f, (float)getWindowWidth(), 0.0f, 1.0f) );
	
	if (mLighting) {
		glDisable( GL_LIGHTING );
		glDisable( GL_LIGHT0 );
	}
	
	gl::disableWireframe();
}
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();
    
}
예제 #6
0
void RDiffusionApp::setup()
{
	mReactionU = 0.25f;
	mReactionV = 0.04f;
	mReactionK = 0.047f;
	mReactionF = 0.1f;

	mMousePressed = false;
	
	// Setup the parameters
	mParams = params::InterfaceGl( "Parameters", Vec2i( 175, 100 ) );
	mParams.addParam( "Reaction u", &mReactionU, "min=0.0 max=0.4 step=0.01 keyIncr=u keyDecr=U" );
	mParams.addParam( "Reaction v", &mReactionV, "min=0.0 max=0.4 step=0.01 keyIncr=v keyDecr=V" );
	mParams.addParam( "Reaction k", &mReactionK, "min=0.0 max=1.0 step=0.001 keyIncr=k keyDecr=K" );	
	mParams.addParam( "Reaction f", &mReactionF, "min=0.0 max=1.0 step=0.001 keyIncr=f keyDecr=F" );
	
	gl::Fbo::Format format;
	format.enableDepthBuffer( false );
	
	mCurrentFBO = 0;
	mOtherFBO = 1;
	mFBOs[0] = gl::Fbo( FBO_WIDTH, FBO_HEIGHT, format );
	mFBOs[1] = gl::Fbo( FBO_WIDTH, FBO_HEIGHT, format );
	
	mShader = gl::GlslProg( loadResource( RES_PASS_THRU_VERT ), loadResource( RES_GSRD_FRAG ) );
	mTexture = gl::Texture( loadImage( loadResource( RES_STARTER_IMAGE ) ) );
	mTexture.setWrap( GL_REPEAT, GL_REPEAT );
	mTexture.setMinFilter( GL_LINEAR );
	mTexture.setMagFilter( GL_LINEAR );
	mTexture.bind( 1 );
	
	resetFBOs();
}
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();
}
예제 #8
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();
}
예제 #9
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();
		
	}
}
예제 #10
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();

}
void Room::drawWalls( float power, 
					 const gl::Texture &backTex, 
					 const gl::Texture &leftTex, 
					 const gl::Texture &rightTex, 
					 const gl::Texture &ceilingTex,
					 const gl::Texture &floorTex,
					 const gl::Texture &blankTex )
{
	// If the power is on, bind the wall texture. If it's not on, bind the blank texture, and draw some billboards
	if( Rand::randFloat() < power ){
		if( Rand::randFloat() < power ){
			backTex.bind();
		} else {
			blankTex.bind();
		}
		gl::drawBillboard( Vec3f( 0.0f, 0.0f, -mDims.z ), Vec2f( mDims.xy() * 2.0f ), 0.0f, Vec3f::xAxis(), Vec3f::yAxis() );
		gl::drawBillboard( Vec3f( 0.0f, 0.0f, mDims.z ), Vec2f( mDims.xy() * 2.0f ), 0.0f, Vec3f::xAxis(), Vec3f::yAxis() );
	}
	
	if( Rand::randFloat() < power ){
		if( Rand::randFloat() < power ){
			leftTex.bind();
		} else {
			blankTex.bind();
		}
		gl::drawBillboard( Vec3f( mDims.x, 0.0f, 0.0f ), Vec2f( mDims.zy() * 2.0f ), 0.0f, Vec3f::zAxis(), Vec3f::yAxis() );
	}
	
	if( Rand::randFloat() < power ){
		if( Rand::randFloat() < power ){
			rightTex.bind();
		} else {
			blankTex.bind();
		}
		gl::drawBillboard( Vec3f( -mDims.x, 0.0f, 0.0f ), Vec2f( mDims.zy() * 2.0f ), 0.0f, Vec3f::zAxis(), Vec3f::yAxis() );
	}
	
	if( Rand::randFloat() < power ){
		if( Rand::randFloat() < power ){
			ceilingTex.bind();
		} else {
			blankTex.bind();
		}
		gl::drawBillboard( Vec3f( 0.0f, mDims.y, 0.0f ), Vec2f( mDims.xz() * 2.0f ), 0.0f, Vec3f::xAxis(), Vec3f::zAxis() );
	}
	
	if( power > 0.5f ){
		floorTex.bind();
		gl::drawBillboard( Vec3f( 0.0f, -mDims.y, 0.0f ), Vec2f( mDims.xz() * 2.0f ), 0.0f, Vec3f::xAxis(), Vec3f::zAxis() );
	}
}
예제 #12
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();
}
예제 #13
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
}
/**
 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();

}
예제 #15
0
void RDiffusionApp::resetFBOs()
{
	mTexture.bind( 0 );
	gl::setMatricesWindow( mFBOs[0].getSize(), false );
	gl::setViewport( mFBOs[0].getBounds() );
	for( int i = 0; i < 2; i++ ){
		mFBOs[i].bindFramebuffer();
		gl::draw( mTexture, mFBOs[i].getBounds() );
	}
	gl::Fbo::unbindFramebuffer();
}
예제 #16
0
ImagePtr create_image_from_texture(const gl::Texture &the_texture)
{
    ImagePtr ret;
    if(!the_texture){ return ret; }
#if !defined(KINSKI_GLES)
    ret = Image::create(the_texture.width(), the_texture.height(), 4);
    the_texture.bind();
    glGetTexImage(the_texture.target(), 0, GL_RGBA, GL_UNSIGNED_BYTE, ret->data);
    ret->flip();
#endif
    return ret;
}
/* 
 * @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() );
}
예제 #18
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;
}
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);
}
예제 #20
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 kinectPointCloudApp::draw()
{
	gl::clear( Color( 0.0f, 0.0f, 0.0f ), true );
	
	gl::pushMatrices();
		gl::scale( Vec3f( -1.0f, -1.0f, 1.0f ) );
		gl::rotate( mSceneRotation );
		mDepthTexture.bind( 0 );
		mShader.bind();
		mShader.uniform( "depthTex", 0 );
		gl::draw( mVboMesh );
		mShader.unbind();
	gl::popMatrices();
	
	params::InterfaceGl::draw();
}
예제 #22
0
void ObjLoaderApp::setup()
{
	ObjLoader loader( loadResource( RES_CUBE_OBJ )->createStream() );
	loader.load( &mMesh );
	mVBO = gl::VboMesh( mMesh );
	
	mTexture = gl::Texture( loadImage( loadResource( RES_IMAGE ) ) );
	mShader = gl::GlslProg( loadResource( RES_SHADER_VERT ), loadResource( RES_SHADER_FRAG ) );

	CameraPersp initialCam;
	initialCam.setPerspective( 45.0f, getWindowAspectRatio(), 0.1, 10000 );
	mMayaCam.setCurrentCam( initialCam );

	mTexture.bind();
	mShader.bind();
	mShader.uniform( "tex0", 0 );
}
예제 #23
0
void WaterSimApp::drawArrow()
{
	glEnable( GL_BLEND );
	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
	gl::setMatricesWindow( getWindowSize() );
	glEnable( GL_TEXTURE_2D );
	mArrow.bind();
	glColor4f( 0.5f, 0.0f, 0.0f, 1.0f );
	Vec2f center( getWindowWidth() / 2.0f, getWindowHeight() / 2.0f );
	float halfWidth = mArrow.getWidth() / 2.0f, halfHeight = mArrow.getHeight() / 2.0f;
	glTranslatef( center.x, center.y, 0 );
	glRotatef( toDegrees( math<float>::atan2( -mGravityVector.y, mGravityVector.x ) ) + 90.0f, 0, 0, 1 );
	glBegin( GL_QUADS );
		glTexCoord2f( 0, 0 ); glVertex2f( -halfWidth, -halfHeight );
		glTexCoord2f( 1.0, 0.0f ); glVertex2f( halfWidth, -halfHeight );
		glTexCoord2f( 1.0f, 1.0f ); glVertex2f( halfWidth, halfHeight );
		glTexCoord2f( 0.0f, 1.0f );	glVertex2f( -halfWidth, halfHeight );
	glEnd();
	glDisable( GL_TEXTURE_2D );
}
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();
}
예제 #25
0
void WaterSimApp::drawLogo()
{
	const int LOGO_OFFSET_X = 35, LOGO_OFFSET_Y = 20;
	glEnable( GL_BLEND );
	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
	gl::setMatricesWindow( getWindowSize() );
	glEnable( GL_TEXTURE_2D );

	mLogo.bind();
	if( mRenderInfo )
		glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
	else
		glColor4f( 1.0f, 1.0f, 1.0f, 0.1f );

	glBegin( GL_QUADS );
		glTexCoord2f( 0, 0 ); glVertex2f( getWindowWidth() - mLogo.getWidth() - LOGO_OFFSET_X, getWindowHeight() - mLogo.getHeight() - LOGO_OFFSET_Y );
		glTexCoord2f( 1.0, 0.0f ); glVertex2f( getWindowWidth() - LOGO_OFFSET_X, getWindowHeight() - mLogo.getHeight() - LOGO_OFFSET_Y );
		glTexCoord2f( 1.0f, 1.0f ); glVertex2f( getWindowWidth() - LOGO_OFFSET_X, getWindowHeight() - LOGO_OFFSET_Y );
		glTexCoord2f( 0.0f, 1.0f );	glVertex2f( getWindowWidth() - mLogo.getWidth() - LOGO_OFFSET_X, getWindowHeight() - LOGO_OFFSET_Y );
	glEnd();
	glDisable( GL_TEXTURE_2D );
}
예제 #26
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) );
	}
예제 #27
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();
}
예제 #28
0
void WaterSimApp::drawInfo()
{
	const int LOGO_OFFSET_X = 15, LOGO_OFFSET_Y = 20;
	
	glEnable( GL_BLEND );
	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
	gl::setMatricesWindow( getWindowSize() );
	glEnable( GL_TEXTURE_2D );
	mInfo.bind();
	
	glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
	
	Vec2f center( getWindowWidth() - mInfo.getWidth() / 2.0f - LOGO_OFFSET_X, mInfo.getHeight() / 2.0f + LOGO_OFFSET_Y );
	float halfWidth = mInfo.getWidth() / 2.0f, halfHeight = mInfo.getHeight() / 2.0f;
	glTranslatef( center.x, center.y, 0 );
	glBegin( GL_QUADS );
		glTexCoord2f( 0, 0 ); glVertex2f( -halfWidth, -halfHeight );
		glTexCoord2f( 1.0, 0.0f ); glVertex2f( halfWidth, -halfHeight );
		glTexCoord2f( 1.0f, 1.0f ); glVertex2f( halfWidth, halfHeight );
		glTexCoord2f( 0.0f, 1.0f );	glVertex2f( -halfWidth, halfHeight );
	glEnd();
	glDisable( GL_TEXTURE_2D );
}
예제 #29
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();
}
void BubbleChamberApp::drawGuts(Area area)
{
	float power = mRoom.getPower();
	Color powerColor = Color( power, power, power );
	
	drawIntoRoomFbo();
	
	gl::setMatricesWindow( getWindowSize(), false );
	//gl::setViewport( getWindowBounds() );
	gl::setViewport( area );

	gl::disableDepthRead();
	gl::disableDepthWrite();
	gl::enableAlphaBlending();
	gl::enable( GL_TEXTURE_2D );
	gl::color( ColorA( 1.0f, 1.0f, 1.0f, 1.0f ) );
	
	// ROOM
	mRoomFbo.bindTexture();
	gl::drawSolidRect( getWindowBounds() );
	
	
	//mActiveCam.setFixedPipeline();
	// PANEL
	drawInfoPanel();

	gl::pushMatrices();
	gl::setMatrices( mActiveCam.getCam() );

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity(); // zero it out
	glMultMatrixf(mActiveCam.mProjectionMatrix); // Apply the matrix to the loaded projection matrix
	glMatrixMode(GL_MODELVIEW); // Return to our modelview matrix
	
	gl::disable( GL_TEXTURE_2D );
	gl::enableDepthWrite();
	gl::enableDepthRead();
	gl::enableAlphaBlending();
	gl::color( ColorA( powerColor, 1.0f ) );
	
	// PARTICLES
	mController.drawParticles( power );
	
	// DRAW GIBS
	mController.drawGibs();
	
	// BUBBLES
	mController.drawBubbles( power );
	
	gl::enable( GL_TEXTURE_2D );
	gl::disableDepthWrite();
	
	// DECALS
	gl::color( powerColor );
	mDecalTex.bind( 0 );
	mController.drawDecals();
	
	// SMOKES
	Vec3f right, up;
	mActiveCam.getCam().getBillboardVectors( &right, &up );
	mSmokeTex.bind( 0 );
	mController.drawSmokes( right, up );

	gl::disable( GL_TEXTURE_2D );
	gl::enableDepthWrite();
	gl::color( powerColor );
	
	// MOTHS
	mController.drawMoths();
	
	// GLOWCUBES
	mGlowCubeShader.bind();
	mGlowCubeShader.uniform( "eyePos", mActiveCam.getEye() );
	mGlowCubeShader.uniform( "power", mRoom.getPower() );
	mGlowCubeShader.uniform( "mvpMatrix", mActiveCam.mMvpMatrix );
	mController.drawGlowCubes( &mGlowCubeShader );
	mGlowCubeShader.unbind();

	if( mSaveFrames ){
//		writeImage( getHomeDirectory() + "BubbleChamber/" + toString( mNumSaveFrames ) + ".png", copyWindowSurface() );
		mNumSaveFrames ++;
	}
	
	gl::popMatrices();
}