Ejemplo n.º 1
0
// Render
void MeshApp::draw()
{

	// Set up window
	gl::clear( ColorAf::black(), true );
	gl::setMatrices( mCamera );
	gl::color( ColorAf::white() );

	// Check texture and VBO
	if ( mTextureDepth && mTextureColor && mVboMesh ) {

		// Position world
		gl::pushMatrices();
		gl::scale( -1.0f, -1.0f, -1.0f );
		gl::rotate( mRotation );

		// Bind textures
		mTextureDepth.bind( 0 );
		mTextureColor.bind( 1 );
		
		// Bind and configure shader
		mShader.bind();
		mShader.uniform( "brightTolerance",	mBrightTolerance 						);
		mShader.uniform( "eyePoint",		mEyePoint 								);
		mShader.uniform( "lightAmbient",	mLightAmbient 							);
		mShader.uniform( "lightDiffuse",	mLightDiffuse 							);
		mShader.uniform( "lightPosition",	mLightPosition 							);
		mShader.uniform( "lightSpecular",	mLightSpecular 							);
		mShader.uniform( "positions",		0 										);
		mShader.uniform( "scale",			mScale 									);
		mShader.uniform( "showColor",		mShowColor 								);
		mShader.uniform( "shininess",		mLightShininess 						);
		mShader.uniform( "Color",			1 										);
		mShader.uniform( "ColorOffset",		Vec2f( mColorOffsetX, mColorOffsetY )	);
		mShader.uniform( "uvmix",			mMeshUvMix								);

		// Draw VBO
		gl::draw( mVboMesh );

		// Stop drawing
		mShader.unbind();
		mTextureDepth.unbind();
		mTextureColor.unbind();
		gl::popMatrices();

	}

	// Draw params
	params::InterfaceGl::draw();

}
Ejemplo n.º 2
0
void BulletTestApp::unbindTexture( uint32_t index )
{
	if ( mTest > 4 ) {
		if ( index == 0 ) {
			mTexTerrain.unbind();
		} else {
			if ( mTest < 7 ) {
				mTexSphere.unbind();
			}
		}
	} else {
		if ( ( ( mTest == 0 || mTest == 3 ) && index > 0 ) || mTest == 1 ) {
			mTexSquare.unbind();
		}
	}
}
Ejemplo n.º 3
0
void Fluid2DTextureApp::draw()
{
	// clear out the window with black
	gl::clear( Color( 0, 0, 0 ) ); 
	gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );

	// Update the positions and tex coords
	Rectf drawRect = getWindowBounds();
	int limX = mFluid2D.resX() - 1;
	int limY = mFluid2D.resY() - 1;
	float dx = drawRect.getWidth()/(float)limX;
	float dy = drawRect.getHeight()/(float)limY;
	
	for( int j = 0; j < mFluid2D.resY(); ++j ) {
		for( int i = 0; i < mFluid2D.resX(); ++i ) {
			Vec2f P = Vec2f( i*dx, j*dy );
			Vec2f uv = mFluid2D.texCoordAt( i, j );

			int idx = j*mFluid2D.resX() + i;
			mTriMesh.getVertices()[idx] = P;
			mTriMesh.getTexCoords()[idx] = uv;
			
		}
	}

	mTex.bind();
	gl::draw( mTriMesh ); 
	mTex.unbind();
	
	mParams.draw();	
}
Ejemplo n.º 4
0
void Pumpkin::drawPumpkin(const ci::gl::Texture & PumpkinTexture)
{
  PumpkinTexture.bind();
  ci::gl::translate(mPos);
  ci::gl::rotate(ci::Vec3f(180.f, 0.f, 0.f));
  ci::gl::drawCube(ci::Vec3f(ci::Vec3f::zero()), mSize);
  PumpkinTexture.unbind();
}
Ejemplo n.º 5
0
void TownwindowHit::drawTownwindow(const ci::gl::Texture& mTownwindowTexture)
{
  mTownwindowTexture.bind();
  ci::gl::translate(mPos);
  ci::gl::rotate(ci::Vec3f(180.f, 0.f, 0.f));
  ci::gl::drawCube(ci::Vec3f(ci::Vec3f::zero()), mSize);
  mTownwindowTexture.unbind();
}
Ejemplo n.º 6
0
void King2::drawKing2(const ci::gl::Texture& texture)
{
  texture.bind();
  ci::gl::translate(mPos);
  ci::gl::rotate(mRotate);
  ci::gl::drawCube(ci::Vec3f(ci::Vec3f::zero()), mSize);
  texture.unbind();
}
Ejemplo n.º 7
0
void BulletTestApp::unbindTexture( TextureType type )
{
    switch( type )
    {
    case TT_GROUND     :
        mTexGround.unbind();
        break;
    case TT_BACKBOARD  :
        mTexBackBoard.unbind();
        break;
    case TT_RING       :
        mTexRing.unbind();
        break;
    case TT_BASKETBALL :
        mTexBasketBall.unbind();
        break;
    }
}
Ejemplo n.º 8
0
void Cinderella::drawCinderella(const ci::gl::Texture & texture, const ci::Vec3f& offset)
{
  ci::gl::pushModelView();
  
  texture.bind();
  ci::gl::translate(mPos);
  ci::gl::rotate(mRotate);
  ci::gl::translate(offset);
  ci::gl::drawCube(ci::Vec3f(ci::Vec3f::zero()), mSize);
  texture.unbind();
  
  ci::gl::popModelView();
}
Ejemplo n.º 9
0
void BulletTestApp::setup()
{
	mDragging	= false;
	mFrameRate	= 0.0f;
	mTest		= 9;
	mTestPrev	= mTest;

	// Set up lighting
	mLight = new gl::Light( gl::Light::DIRECTIONAL, 0 );
	mLight->setDirection( Vec3f( 0.0f, 0.1f, 0.3f ).normalized() );
	mLight->setAmbient( ColorAf( 0.2f, 0.2f, 0.2f, 1.0f ) );
	mLight->setDiffuse( ColorAf( 1.0f, 1.0f, 1.0f, 1.0f ) );
	mLight->enable();

	// Load meshes
	loadModels();

	// Create a Bullet dynamics world
	mWorld = bullet::createWorld();

	// Load texture
	mTexSquare	= gl::Texture( loadImage( loadResource( RES_TEX_SQUARE ) ) );
	mTexSphere	= gl::Texture( loadImage( loadResource( RES_TEX_SPHERE ) ) );
	mTexTerrain	= gl::Texture( loadImage( loadResource( RES_TEX_TERRAIN ) ) );
	mTexTerrain.setWrap( GL_REPEAT, GL_REPEAT );
	mTexTerrain.unbind();

	// Init terrain pointer
	mTerrain = 0;

	// Parameters
	mParams = params::InterfaceGl( "Params", Vec2i( 200, 120 ) );
	mParams.addParam( "Frame Rate",		&mFrameRate,								"", true );
	mParams.addParam( "Test",			&mTest,										"min=0 max=9 step=1 keyDecr=t keyIncr=T" ); 
	mParams.addButton( "Drop",			bind( &BulletTestApp::drop, this ),			"key=space" );
	mParams.addButton( "Screen shot",	bind( &BulletTestApp::screenShot, this ),	"key=s" );
	mParams.addButton( "Quit",			bind( &BulletTestApp::quit, this ),			"key=q" );

	// Initialize
	initTest();

	// Run first resize to initialize view
	resize( ResizeEvent( getWindowSize() ) );

}
Ejemplo n.º 10
0
void FloorView::draw()
{

	const ci::gl::Texture fbotex = fbo.getTexture();
	
	gl::enableAdditiveBlending(); 

	fbotex.enableAndBind(); 

	//draw fbo with shader
	shader->bind();
	shader->uniform( "alpha", alpha->value() );
	drawQuad();
	shader->unbind(); 
	fbotex.unbind(); 

	gl::enableAlphaBlending(); 
}
Ejemplo n.º 11
0
void BulletTestApp::setup()
{

	// Set test mode
	mTest = 0;
	mTestPrev = mTest;

	// Set up lighting
	mLight = new gl::Light( gl::Light::DIRECTIONAL, 0 );
	mLight->setDirection( Vec3f( 0.0f, 0.1f, 0.3f ).normalized() );
	mLight->setAmbient( ColorAf( 0.2f, 0.2f, 0.2f, 1.0f ) );
	mLight->setDiffuse( ColorAf( 1.0f, 1.0f, 1.0f, 1.0f ) );
	mLight->enable();

	// Load meshes
	loadModels();

	// Create a Bullet dynamics world
	mWorld = bullet::createWorld();

	// Load texture
	mTexSquare = gl::Texture( loadImage( loadResource( RES_TEX_SQUARE ) ) );
	mTexSphere = gl::Texture( loadImage( loadResource( RES_TEX_SPHERE ) ) );
	mTexTerrain = gl::Texture( loadImage( loadResource( RES_TEX_TERRAIN ) ) );
	mTexTerrain.setWrap( GL_REPEAT, GL_REPEAT );
	mTexTerrain.unbind();

	// Init terrain pointer
	mTerrain = 0;

	// Parameters
	mFrameRate = 0.0f;
	mParams = params::InterfaceGl( "Params", Vec2i( 150, 100) );
	mParams.addParam( "Frame Rate", &mFrameRate, "", true );
	mParams.addParam( "Test", &mTest, "min=0 max=7 step=1 keyDecr=d keyIncr=D" ); 

	// Initialize
	initTest();

	// Run first resize to initialize view
	resize( ResizeEvent( getWindowSize() ) );

}
Ejemplo n.º 12
0
void Fluid2DCamAppApp::draw()
{
	// clear out the window with black
	gl::clear( Color( 0, 0, 0 ) ); 
	gl::color( Colorf::white() );
	gl::setMatricesWindow( getWindowWidth(), getWindowHeight() );
	
	if( mTexCam ) {
		gl::draw( mTexCam, Rectf( 0*kDrawScale*mFluid2DResX, 0*kDrawScale*mFluid2DResY, 1*kDrawScale*mFluid2DResX, 1*kDrawScale*mFluid2DResY ) );
	}

	gl::draw( mTexVel0, Rectf( 0*kDrawScale*mFluid2DResX, 1*kDrawScale*mFluid2DResY, 1*kDrawScale*mFluid2DResX, 2*kDrawScale*mFluid2DResY ) );
	gl::draw( mTexVel1, Rectf( 1*kDrawScale*mFluid2DResX, 1*kDrawScale*mFluid2DResY, 2*kDrawScale*mFluid2DResX, 2*kDrawScale*mFluid2DResY ) );
	gl::draw( mTexDen0, Rectf( 2*kDrawScale*mFluid2DResX, 1*kDrawScale*mFluid2DResY, 3*kDrawScale*mFluid2DResX, 2*kDrawScale*mFluid2DResY ) );
	gl::draw( mTexDen1, Rectf( 3*kDrawScale*mFluid2DResX, 1*kDrawScale*mFluid2DResY, 4*kDrawScale*mFluid2DResX, 2*kDrawScale*mFluid2DResY ) );

	gl::draw( mTexDiv,     Rectf( 0*kDrawScale*mFluid2DResX, 2*kDrawScale*mFluid2DResY, 1*kDrawScale*mFluid2DResX, 4*kDrawScale*mFluid2DResY ) );
	gl::draw( mTexPrs,     Rectf( 1*kDrawScale*mFluid2DResX, 2*kDrawScale*mFluid2DResY, 2*kDrawScale*mFluid2DResX, 4*kDrawScale*mFluid2DResY ) );
	gl::draw( mTexCurl,    Rectf( 2*kDrawScale*mFluid2DResX, 2*kDrawScale*mFluid2DResY, 3*kDrawScale*mFluid2DResX, 4*kDrawScale*mFluid2DResY ) );
	gl::draw( mTexCurlLen, Rectf( 3*kDrawScale*mFluid2DResX, 2*kDrawScale*mFluid2DResY, 4*kDrawScale*mFluid2DResX, 4*kDrawScale*mFluid2DResY ) );

	mTexCurlLen.unbind();

	gl::color( Color( 1, 0, 0 ) );
	glLineWidth( 0.5f );
	glBegin( GL_LINES );
		glVertex2f( Vec2f( 0, 1*kDrawScale*mFluid2DResY ) );
		glVertex2f( Vec2f( (float)getWindowWidth(), 1*kDrawScale*mFluid2DResY ) );
		glVertex2f( Vec2f( 0, 2*kDrawScale*mFluid2DResY ) );
		glVertex2f( Vec2f( (float)getWindowWidth(), 2*kDrawScale*mFluid2DResY ) );

		glVertex2f( Vec2f( 1*kDrawScale*mFluid2DResX, 0 ) );
		glVertex2f( Vec2f( 1*kDrawScale*mFluid2DResX, (float)getWindowHeight() ) );
		glVertex2f( Vec2f( 2*kDrawScale*mFluid2DResX, 0 ) );
		glVertex2f( Vec2f( 2*kDrawScale*mFluid2DResX, (float)getWindowHeight() ) );
		glVertex2f( Vec2f( 3*kDrawScale*mFluid2DResX, 0 ) );
		glVertex2f( Vec2f( 3*kDrawScale*mFluid2DResX, (float)getWindowHeight() ) );
	glEnd();
	mParams.draw();
}
Ejemplo n.º 13
0
void LocationOrbitalOverlay::draw()
{

	const ci::gl::Texture fbotex = mFbo->getTexture();
	
	gl::enableAdditiveBlending(); 
	
	mShader->bind();
	
	fbotex.bind(0); 
	mSphereAlpha->getTexture()->bind(1);

	mShader->uniform("mapTexture", 0);
	mShader->uniform("alphaTexture", 1);

	drawQuad();
	
	fbotex.unbind(0);
	mSphereAlpha->getTexture()->unbind(1);

	mShader->unbind();

	gl::enableAlphaBlending(); 
}
Ejemplo n.º 14
0
void VboMeshSampleApp::draw()
{
	// Set up window
	gl::setViewport( getWindowBounds() );
	gl::setMatrices( mCamera );
	gl::clear( ColorAf::gray( 0.6f ) );

	// Use arcball to rotate model view
	glMultMatrixf( mArcball.getQuat() );

	// Enabled lighting, texture mapping, wireframe
	if ( mLightEnabled ) {
		gl::enable( GL_LIGHTING );
	}
	if ( mTextureEnabled && mTexture ) {
		gl::enable( GL_TEXTURE_2D );
		mTexture.bind();
	}
	if ( mWireframe ) {
		gl::enableWireframe();
	}

	// Apply scale
	gl::pushMatrices();
	gl::scale( mScale );
	
	// Draw selected mesh
	switch ( (MeshType)mMeshIndex ) {
	case MESH_TYPE_CIRCLE:
		gl::draw( mCircle );
		break;
	case MESH_TYPE_CONE:
		gl::draw( mCone );
		break;
	case MESH_TYPE_CUBE:
		gl::draw( mCube );
		break;
	case MESH_TYPE_CUSTOM:
		gl::draw( mCustom );
		break;
	case MESH_TYPE_CYLINDER:
		gl::draw( mCylinder );
		break;
	case MESH_TYPE_RING:
		gl::draw( mRing );
		break;
	case MESH_TYPE_SPHERE:
		gl::draw( mSphere );
		break;
	case MESH_TYPE_SQUARE:
		gl::draw( mSquare );
		break;
	}
	
	// End scale
	gl::popMatrices();

	// Disable wireframe, texture mapping, lighting
	if ( mWireframe ) {
		gl::disableWireframe();
	}
	if ( mTextureEnabled && mTexture ) {
		mTexture.unbind();
		gl::disable( GL_TEXTURE_2D );
	}
	if ( mLightEnabled ) {
		gl::disable( GL_LIGHTING );
	}

	// Draw params GUI
	mParams.draw();
}