Beispiel #1
0
void Day72App::setup()
{
    mGlsl = gl::GlslProg::create(loadAsset("vertex.vert"), loadAsset("fragment.frag"));
    mCamPos = vec3(0,0,4);
    mCam.lookAt(mCamPos, vec3(0));
    mCam.setPerspective(60.f, getWindowAspectRatio(), 1.f, 1000.f);
    mCamUi = CameraUi(&mCam, getWindow());
    
    mSkyBoxTex = gl::TextureCubeMap::create(loadImage(loadAsset("boxy.jpg")));
    auto cube = geom::Cube();
    mSkyBoxBatch = gl::Batch::create(cube >> geom::Scale(SKY_BOX_SIZE,SKY_BOX_SIZE,SKY_BOX_SIZE), mGlsl);
    
    auto sphere = geom::Sphere().subdivisions(64);
    auto c = geom::Cube();
    auto torus = geom::Torus().subdivisionsAxis(64).subdivisionsHeight(32);
    auto icos = geom::Icosahedron();
    
    mSphere = gl::Batch::create(sphere, mGlsl);
    mTorus = gl::Batch::create(torus >> geom::Scale(1.3,1.3,1.3), mGlsl);
    mIcos = gl::Batch::create(icos >> geom::Scale(0.8,0.8,0.8), mGlsl);
    mCube = gl::Batch::create(c, mGlsl);
    
    //SET THE LOCATION OF THE TEXTURE
    mSkyBoxBatch->getGlslProg()->uniform("uCubeMapTex", 0);
    
    mSkyBoxTex->bind();
    
    gl::enableDepth();
    
}
void CubeMappingApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
	gl::setMatrices( mCam );

	mCubeMap->bind();
	gl::pushMatrices();
		gl::multModelMatrix( mObjectRotation );
		gl::scale( vec3( 4 ) );
		mTeapotBatch->draw();
	gl::popMatrices();
	
	// draw sky box
	gl::pushMatrices();
		gl::scale( SKY_BOX_SIZE, SKY_BOX_SIZE, SKY_BOX_SIZE );
		mSkyBoxBatch->draw();
	gl::popMatrices();		
}
Beispiel #3
0
void BayBridgeApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );

	gl::setMatrices(mCamera);
	
	gl::disableDepthRead();
	mTexSkybox->bind(0);
	mBatchSkybox->draw();
	mTexSkybox->unbind(0);
	gl::enableDepthRead();

	drawBridge(vec3(0.25f), 0.15f);
	mBridge.Draw();

	gl::setMatricesWindow(getWindowSize());
	gl::enableAdditiveBlending();
	gl::disableDepthRead();
	gl::draw(mFboBlurV->getColorTexture(), vec2(0));
	gl::disableAlphaBlending();

	mGUI->draw();
}