Ejemplo n.º 1
0
void Day61App::draw()
{
    gl::setMatrices(mCam);
    gl::clear( Color( 0.0, 0.0, 0.0 ) );

    {
        gl::ScopedMatrices scpMtr;
        gl::rotate(angleAxis(theta, vec3(0,1,0)));
        gl::color(ColorAf(1.,1.,1.,1.));
        mSolidSphere->draw();
    }
    
  //  mBatch->draw();
    for (int i = 0 ; i < 20 ; i++)
    {
        mPos.x = cos(theta + 12*i);
        mPos.y = 0.5 - cos(sin(theta + i));
        mPos.z = sin(theta + 12*i);
        gl::ScopedMatrices push;
        gl::translate(mPos);
        mBatch->draw();
    }
    
    //if(getElapsedFrames() > 240) saveGif();
    saveGif();
    
}
Ejemplo n.º 2
0
void Day59App::draw()
{
    gl::setMatrices(mCam);
    gl::clear( Color( 0.1, 0.1, 0.1 ) );
    gl::color(Color(0.,0.,0.));
    gl::clear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
    mCam.setEyePoint(vec3(0.,0.,fabs(cos(omega) * 50.f)));
  mPerlin.setSeed(getElapsedFrames());
    
    // enable stencil test to be able to give the stencil buffers values.
    gl::ScopedState scopeStencil( GL_STENCIL_TEST, true );
  //  gl::rotate(angleAxis(theta/2, vec3(0.,1.,0.)));
    for (int i =0; i <NUM_OBJS; i++)
    {
        
        vec3 noise = mPerlin.dfBm(mRandomPositions[i]);
    
        gl::ScopedMatrices scpMtx;
        gl::translate(mRandomPositions[i]);
        
    
        {
            gl::ScopedMatrices push;
            gl::rotate(angleAxis(theta + mOffsets[i], vec3(1.0, 0., 0.)));
            gl::translate(mRandomPositions[i]);
            gl::scale(mScales[i]);
            
            //DRAW THE MAIN OBJECT (1ST RENDER PASS) AS NORMAL, FILL THE STENCIL BUFFER
            gl::stencilFunc(GL_ALWAYS, 1, 0xFF); //ALL FRAGMENTS MUST UPDATE THE STENCIL BUFFER
            gl::stencilMask(0xFF); //ENABLE WRITING TO THE STENCIL BUFFER
            mObject->draw();
        }
        
        //IF THE STENCIL TEST FAILS, KEEP THE FRAGMENT
        //IF STENCIL PASSES AND DEPTH FAILS, KEEP THE FRAGMENT
        //IF THE DEPTH TEST AND STENCIL TEST PASS, REPLACE THE FRAGMENT
        glStencilOp(GL_KEEP  , GL_KEEP, GL_REPLACE);
        
        //2ND RENDER PASS - DRAW OBJECT SLIGHTLY BIGGER, BUT DISABLE STENCIL WRITING.  BECAUSE THE STENCIL BUFFER IS FILLED WITH 1s (PARTICULARLY IN THE AREA OF THE ORIGINAL OBJECT), THE ONLY THING THAT WILL BE DRAWN IS THE AREA OF THE 2ND OBJECT, IE. THE SIZE DIFFERENCE
        
        gl::stencilFunc(GL_NOTEQUAL, 1, 0xFF); //don't update the stencil buffer
        gl::stencilMask(0x00);
        gl::disable(GL_DEPTH_TEST);
        {
            gl::ScopedMatrices push;
            gl::rotate(angleAxis(theta + mOffsets[i], vec3(1.0, 0., 0.)));
            gl::translate(mRandomPositions[i]);
            
            gl::scale(vec3(mScales[i] + vec3(0.1) ));
            
            mBorderObject->draw();
        }
    
    }
    
    gl::stencilMask(0xFF);
    gl::enable(GL_DEPTH_TEST);
  //  saveGif();
    
}
Ejemplo n.º 3
0
void Day44App::draw()
{
    gl::setMatrices(mCam);
    gl::clear( Color( 0.0, 0.0, 0.0 ) );
    
    // gl::rotate(angleAxis(theta, vec3(0.1,1.,0.)));
    // gl::rotate(angleAxis(theta, vec3(0.3,0.,0.)));
    
    int counter = 100;
    for (vec3 v : mPositions)
    {
        gl::ScopedMatrices push;
        gl::translate(v);
        //  gl::rotate(counter + theta, vec3(1.,0.,0.));
        // gl::rotate(counter + theta, vec3(0.5,0.8,0.));
        mBatch->draw();
        counter++;
    }
    
    //    {
    //        gl::ScopedMatrices push;
    //        gl::translate(1.5f, 0.f,0.f);
    //        mBatchB->draw();
    //    }
    
    {
        gl::ScopedMatrices push;
        gl::translate(lightPos.x, lightPos.y, lightPos.z);
        mLight->draw();
    }
    
    if (getElapsedFrames() > 240.f) saveGif();
    
}
void EnvironmentTestApp::draw() {
  gl::enableDepthRead();
  gl::enableDepthWrite();

#ifdef ENABLE_DOF
  mDOFFilter->beginRender();
#endif
  {
    gl::ScopedMatrices mtx;
    gl::setMatrices(mCam);
    gl::clear(Color::black());

    {
      gl::ScopedModelMatrix modelMtx;
      gl::scale(0.5, 0.5, 0.5);
#ifdef ENABLE_SEM
      gl::ScopedTextureBind tex0(mEnvironmentTexture, 0);
      gl::ScopedTextureBind tex1(mIlluminationTexture, 1);
#endif
      mObjectBatch->draw();
    }
    
    gl::ScopedFaceCulling culling(true, GL_FRONT);
    gl::ScopedTextureBind environmentTex(mEnvironmentTexture);
    mEnvironmentBatch->draw();
  }
#ifdef ENABLE_DOF
  mDOFFilter->endRender();
  mDOFFilter->drawFullscreen();
#endif

#ifdef EXPORT_FRAMES
  saveFrame();
#endif
}
void ImageBasedLighting_05App::draw()
{
    gl::clear( Color( 0, 0, 0 ) );
    
    gl::setMatrices( mCam );
    
    // enable depth testing
    gl::ScopedDepth scopedDepth( true );
    
    // bind the cubemap textures
    gl::ScopedTextureBind scopedTexBind0( mTextureRadianceMap, 0 );
    gl::ScopedTextureBind scopedTexBind1( mTextureIrradianceMap, 1 );
    gl::ScopedTextureBind scopedTexBind2( mNormalMap, 2 );
    gl::ScopedTextureBind scopedTexBind3( mRoughnessMap, 3 );
    gl::ScopedTextureBind scopedTexBind4( mMetallicMap, 4 );
    gl::ScopedTextureBind scopedTexBind5( mColorMap, 5 );
    gl::ScopedTextureBind scopedTexBind6( mAOMap, 6 );
    gl::ScopedTextureBind scopedTexBind7( mSpecularMap, 7 );
    
    auto shader = mBatchModel->getGlslProg();
    shader->uniform( "uRadianceMap", 0 );
    shader->uniform( "uIrradianceMap", 1 );
    shader->uniform( "uNormalMap", 2 );
    shader->uniform( "uRoughnessMap", 3 );
    shader->uniform( "uMetallicMap", 4 );
    shader->uniform( "uColorMap", 5 );
    shader->uniform( "uAOMap", 6 );
    shader->uniform( "uSpecularMap", 7);
    
    // sends the base color, the specular opacity,
    // the light position, color and radius to the shader
//    shader->uniform( "uBaseColor", mBaseColor );
//    shader->uniform( "uSpecular", mSpecular );
//    shader->uniform( "uNormalMapScale",mNormalMapScale);
    
    // sends the tone-mapping uniforms
    shader->uniform( "uExposure", mExposure );
    shader->uniform( "uGamma", mGamma );
    
    // render a grid of sphere with different roughness/metallic values and colors
    {
        
//        shader->uniform( "uRoughness", mRoughness );
//        shader->uniform( "uRoughness4", pow( mRoughness, 4.0f ) );
//        shader->uniform( "uMetallic", mMetallic );
        
        mBatchModel->draw();
        
    }
    
    // render skybox
    shader = mBatchSkyBox->getGlslProg();
    shader->uniform( "uExposure", mExposure );
    shader->uniform( "uGamma", mGamma );
    mBatchSkyBox->draw();
    
    //  DRAW SETTINGS
    _params->draw();
}
Ejemplo n.º 6
0
void RandomSpawn::drawParticles()
{
    mBatch_P->getGlslProg()->uniform("ViewDirection", mCamera.getViewDirection());
    mBatch_P->getGlslProg()->uniform("LightPosition", vec3(0, 10, 0));
    mBatch_P->getGlslProg()->uniform("SpecPow", 4.0f);
    mBatch_P->getGlslProg()->uniform("SpecStr", 2.0f);

    mBatch_P->drawInstanced(mPointsParticles.size());
}
Ejemplo n.º 7
0
void GeometryApp::draw()
{
	// Prepare for drawing.
	gl::clear();
	gl::setMatrices( mCamera );
	
	// Draw the grid.
	if( mShowGrid && mGrid ) {
		gl::ScopedGlslProg scopedGlslProg( gl::context()->getStockShader( gl::ShaderDef().color() ) );
		// draw the coordinate frame with length 2.
		gl::drawCoordinateFrame( 2 );
		mGrid->draw();
	}

	if( mPrimitive ) {
		gl::ScopedTextureBind scopedTextureBind( mTexture );
		mPhongShader->uniform( "uTexturingMode", mTexturingMode );

		// Rotate it slowly around the y-axis.
		gl::ScopedModelMatrix matScope;
		gl::rotate( float( getElapsedSeconds() / 5 ), 0, 1, 0 );

		// Draw the normals.
		if( mShowNormals && mPrimitiveNormalLines ) {
			gl::ScopedColor colorScope( Color( 1, 1, 0 ) );
			mPrimitiveNormalLines->draw();
		}

		// Draw the primitive.
		gl::ScopedColor colorScope( Color( 0.7f, 0.5f, 0.3f ) );

		if( mViewMode == WIREFRAME ) {
			// We're using alpha blending, so render the back side first.
			gl::ScopedAlphaBlend blendScope( false );
			gl::ScopedFaceCulling cullScope( true, GL_FRONT );

			mWireframeShader->uniform( "uBrightness", 0.5f );
			mPrimitiveWireframe->draw();

			// Now render the front side.
			gl::cullFace( GL_BACK );

			mWireframeShader->uniform( "uBrightness", 1.0f );
			mPrimitiveWireframe->draw();
		}
		else
			mPrimitive->draw();
	}

	// Render the parameter window.
#if ! defined( CINDER_GL_ES )
	if( mParams )
		mParams->draw();
#endif
}
Ejemplo n.º 8
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();
    
}
Ejemplo n.º 9
0
void EarthquakeApp::draw()
{
	gl::clear( Color( 1, 0, 0 ) );

	gl::ScopedDepth       depth( true );
	gl::ScopedColor       color( 1, 1, 1 );

	// Draw stars.
	if( mShowStars ) {
		gl::ScopedTextureBind tex0( mStars, 0 );
		gl::ScopedFaceCulling cull( true, GL_FRONT );
		mStarSphere->draw();
	}

	// Draw Earth.
	if( mShowEarth ) {
		mEarth.draw();
	}

	// Draw quakes.
	if( mShowQuakes ) {
		mEarth.drawQuakes();
	}

	// Draw labels.
	if( mShowText ) {
		mEarth.drawQuakeLabelsOnSphere( mPov.mEyeNormal, mPov.mDist );
	}

	if( mSaveFrames ) {
		static int currentFrame = 0;
		writeImage( getHomeDirectory() / "CinderScreengrabs" / ( "Highoutput_" + toString( currentFrame++ ) + ".png" ), copyWindowSurface() );
	}
}
Ejemplo n.º 10
0
void InstancedTeapotsApp::draw()
{
	gl::clear( Color::black() );
	gl::setMatrices( mCam );

	mBatch->drawInstanced( NUM_INSTANCES_X * NUM_INSTANCES_Y );
}
Ejemplo n.º 11
0
void basic3_batchApp::draw()
{
	gl::clear();
    gl::enableDepthRead();
    gl::enableDepthWrite();
    
    gl::setMatrices(mCam);
    
    int numSpheres = 64;
    float maxAngle = M_PI * 7;
    float spiralRadius = 1;
    float height = 2;
    float boxSize = 0.05f;
    float anim = getElapsedFrames() / 60.0f;
    
    for (int s = 0; s<numSpheres; ++s) {
        float rel = s/(float)numSpheres;
        float angle = rel * maxAngle;
        float y = fabs(cos(rel*M_PI*anim))*height;
        float r = rel * spiralRadius;
        vec3 offset(r*cos(angle), y/2, r*sin(angle));
        
        gl::pushModelMatrix();
        gl::translate(offset);
        gl::scale(vec3(boxSize, y, boxSize));
        gl::color(Color(CM_HSV, rel, 1, 1));
        mBox->draw();
        gl::popModelMatrix();
    }
}
void PointCloudApp::update()
{
	
	mCinderRS->update();
	mPoints.clear();
	Channel16u cChanDepth = mCinderRS->getDepthFrame();

	mTexRgb->update(mCinderRS->getRgbFrame());
	for (int dy = 0; dy < mDepthDims.y; ++dy)
	{
		for (int dx = 0; dx < mDepthDims.x; ++dx)
		{
			float cDepth = (float)*cChanDepth.getData(dx, dy);
			if (cDepth > 100 && cDepth < 1000)
			{
				vec3 cPos = mCinderRS->getDepthSpacePoint(vec3(dx, dy, cDepth));
				vec2 cUV = mCinderRS->getColorCoordsFromDepthImage(static_cast<float>(dx),
																	static_cast<float>(dy),
																	cDepth);
				mPoints.push_back(CloudPoint(cPos, cUV));
			}
		}
	}

	mBufferObj->bufferData(mPoints.size()*sizeof(CloudPoint), mPoints.data(), GL_DYNAMIC_DRAW);
	mMeshObj = gl::VboMesh::create(mPoints.size(), GL_POINTS, { { mAttribObj, mBufferObj } });
	mDrawObj->replaceVboMesh(mMeshObj);
}
void SphericalStereoApp::update()
{
	if( mRift ) {
		hmd::ScopedRiftBuffer bind{ mRift };
		gl::clear();
		for( auto eye : mRift->getEyes() ) {
			mRift->enableEye( eye );
			const auto& pano = mPanos.at( mPanoIndex );
			mStereoGlsl->uniform( "uDisplayMode", pano.mDisplayMode );
			mStereoGlsl->uniform( "uRightEye", static_cast<int>(eye) );
			gl::ScopedTextureBind tex0( pano.mLatLong );
			mSphere->draw();

			{
				auto size = mRift->getFboSize();
				gl::ScopedMatrices push;
				gl::setMatricesWindow( size.x / 2, size.y );
				vec3 latencies = mRift->getLatencies();

				stringstream ss;
				ss << mPanos.at( mPanoIndex ).mName << std::endl;
				ss << " " << std::endl;
				ss << "App fps: " << toString( getAverageFps() ) << std::endl;
				ss << "Ren: " << latencies.x << std::endl;
				ss << "TWrp: " << latencies.y << std::endl;
				ss << "PostPresent: " << latencies.z << std::endl;

				auto tbox = TextBox().text( ss.str() ).font( Font( "Arial", 20.0f ) ).color( Color::white() ).backgroundColor( Color::black() );
				gl::draw( gl::Texture2d::create( tbox.render() ), vec2( size.x / 3, size.y / 2 ) );
			}
		}
	}
}
Ejemplo n.º 14
0
void Day48App::draw()
{
    gl::setMatrices(mCam);
    gl::clear( Color( 0, 0, 0 ) );
    gl::color(ColorAf(1.0f,1.f,1.f,1.f));
    
    //gl::rotate(angleAxis(theta/2, vec3(0.,1.,0.)));
    
    for (int i = 0; i < NUM_OBJS; i++)
    {
        gl::ScopedMatrices push;
        gl::translate(mPositions[i]);
        mBatch->draw();
        
    }
    
    
    
    //COLOUR AND DRAW THE POINT LIGHTS
    for (int i = 0; i < mPointLights.size(); i++)
    {
        switch (i){
            case 0:
                gl::color(Color(1.,1.,1.));
                break;
                
            case 1: //RED
                gl::color(Color(1.,0.,0.));
                break;
                
            case 2:  //BLUE
                gl::color(Color(0.,1.,0.));
                break;
                
            case 3:  //GREEN
                gl::color(Color(0.,0.,1.));
                break;
        }
        
        gl::ScopedMatrices push;
        gl::translate(mPointLights[i]);
        mLight->draw();
        
    }
     
}
Ejemplo n.º 15
0
void ArcballTestApp::draw()
{
	CameraPersp &cam = ( mUsingCameraUi ) ? mDebugCam : mCam;
	gl::clear( Color( 0, 0.0f, 0.15f ) );
	gl::setMatrices( cam );

	// draw the earth
	gl::enableDepthRead();
	gl::enableDepthWrite();
	gl::translate( mEarthSphere.getCenter() );
	gl::rotate( mArcball.getQuat() );
	mEarthTex->bind();
	mEarth->draw();

	// draw constraint axis
	if( mArcball.isUsingConstraint() ) {
		gl::setMatrices( cam );
		gl::color( 1, 1, 0 );
		gl::translate( mEarthSphere.getCenter() );
		gl::rotate( glm::rotation( vec3( 0, 1, 0 ), mArcball.getConstraintAxis() ) );
		mConstraintAxis->draw();
	}

	gl::disableDepthRead();

	// draw from vector marker
	gl::setMatrices( cam );
	gl::color( 0, 1, 0.25f );
	gl::translate( mEarthSphere.getCenter() + mArcball.getFromVector() * mEarthSphere.getRadius() );
	mMarker->draw();

	// draw to vector marker
	gl::setMatrices( cam );
	gl::color( 1, 0.5f, 0.25f );
	gl::translate( mEarthSphere.getCenter() + mArcball.getToVector() * mEarthSphere.getRadius() );
	mMarker->draw();

	// draw the elliptical axes
	gl::setMatricesWindow( getWindowSize() );
	gl::color( 1, 0, 0 );
	vec2 center, axisA, axisB;
	mCam.calcScreenProjection( mEarthSphere, getWindowSize(), &center, &axisA, &axisB );
	gl::drawLine( center - axisA, center + axisA );
	gl::drawLine( center - axisB, center + axisB );
}
Ejemplo n.º 16
0
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();		
}
Ejemplo n.º 17
0
void Day72App::draw()
{
    gl::clear( Color( 0, 0, 0 ) );
    gl::setMatrices(mCam);
    gl::color(Color(0.2,0.2,0.2));
    
    gl::rotate(angleAxis(theta/2, vec3(0.,1.,0.)));
    gl::rotate(angleAxis(cos(theta/2), normalize(vec3(1., 0., 0.4))));
    
    int i = getElapsedFrames();
    
    if ( i <= 80 ) mIcos->draw();
    else if ( i > 80 && i <= 160) mTorus->draw();
    else mCube->draw();
    
    
    saveGif();
}
Ejemplo n.º 18
0
void NormalMappingBasicApp::draw()
{
	gl::clear();

	gl::setMatrices( mCam );
	gl::ScopedModelMatrix modelScope;
	gl::multModelMatrix( mCubeRotation );
	mGlsl->uniform( "uLightLocViewSpace", vec3( mCam.getViewMatrix() * vec4( mLightPosWorldSpace, 1 )) );
	mBatch->draw();
}
Ejemplo n.º 19
0
void Day37bApp::draw()
{
    gl::setMatrices(mCam);
    gl::clear( Color( 0., 0., 0 ) );
    
    {
        gl::ScopedMatrices push;
        gl::rotate(theta, vec3(1.,0.,0.));
        mBatch->draw();
    }
    
    {
        gl::ScopedMatrices push;
        gl::translate(lightPos.x, lightPos.y, lightPos.z);
        mLight->draw();
    }
    
    if (getElapsedFrames() > 240.f) saveGif();
    
}
void ViewportArrayApp::update()
{
	// bind the fbo and enable depth testing
	gl::ScopedFramebuffer scopedFbo( mFbo );
	gl::ScopedDepth scopedDepthTest( true );
	
	// clear our fbo
	gl::clear( Color( 0, 0, 0 ) );
	
	// create an array with the different cameras matrices
	vector<mat4> matrices;
	for( auto cam : mCameras ) {
		matrices.push_back( cam.getProjectionMatrix() * cam.getViewMatrix() );
	}
	// and send it to the shader
	mTeapot->getGlslProg()->uniform( "uMatrices", &matrices[0], mCameras.size() );
	
	// render the teapot once (the geometry shader takes care of the rest)
	mTeapot->draw();
}
Ejemplo n.º 21
0
void Day41App::draw()
{
    gl::setMatrices(mCam);
    gl::clear( Color( .0, 0., 0. ) );

    for (int i = 0; i < 4; i++)
    {
        gl::ScopedMatrices push;
        gl::translate(0.,1.*i, 0.);;
        gl::rotate(0.5*sin(i*3), vec3(0.,1.,0.));
        mBatch->draw();
    }

    {
        gl::ScopedMatrices push;
        gl::translate(lightPos);
        mLight->draw();
    }
    if (getElapsedFrames() > 240.f) saveGif();

}
Ejemplo n.º 22
0
void RotatingCubeApp::draw()
{
	gl::clear();

	gl::setMatrices( mCam );

	gl::ScopedModelMatrix modelScope;
	gl::multModelMatrix( mCubeRotation );

	mTexture->bind();
	mBatch->draw();
}
Ejemplo n.º 23
0
void ShadowMappingBasic::drawScene( bool shadowMap )
{
	gl::pushModelMatrix();
	gl::color( Color( 0.4f, 0.6f, 0.9f ) );
	gl::rotate( mTime * 2.0f, 1.0f, 1.0f, 1.0f );

	if( shadowMap )
		mTeapotBatch->draw();
	else
		mTeapotShadowedBatch->draw();

	gl::popModelMatrix();
	
	gl::color( Color( 0.7f, 0.7f, 0.7f ) );
	gl::translate( 0.0f, -2.0f, 0.0f );
	
	if( shadowMap )
		mFloorBatch->draw();
	else
		mFloorShadowedBatch->draw();
}
Ejemplo n.º 24
0
void CubeMappingApp::setup()
{
	mCubeMap = gl::TextureCubeMap::createHorizontalCross( loadImage( loadAsset( "env_map.jpg" ) ), gl::TextureCubeMap::Format().mipmap() );

#if defined( CINDER_GL_ES )
	auto envMapGlsl = gl::GlslProg::create( loadAsset( "env_map_es2.vert" ), loadAsset( "env_map_es2.frag" ) );
	auto skyBoxGlsl = gl::GlslProg::create( loadAsset( "sky_box_es2.vert" ), loadAsset( "sky_box_es2.frag" ) );
#else
	auto envMapGlsl = gl::GlslProg::create( loadAsset( "env_map.vert" ), loadAsset( "env_map.frag" ) );
	auto skyBoxGlsl = gl::GlslProg::create( loadAsset( "sky_box.vert" ), loadAsset( "sky_box.frag" ) );
#endif

	mTeapotBatch = gl::Batch::create( geom::Teapot().subdivisions( 7 ), envMapGlsl );
	mTeapotBatch->getGlslProg()->uniform( "uCubeMapTex", 0 );

	mSkyBoxBatch = gl::Batch::create( geom::Cube(), skyBoxGlsl );
	mSkyBoxBatch->getGlslProg()->uniform( "uCubeMapTex", 0 );
	
	gl::enableDepthRead();
	gl::enableDepthWrite();	
}
void PointCloudApp::draw()
{
	gl::clear(Color(0.25f, 0.1f, 0.15f));
	
	//gl::enableAdditiveBlending();
	gl::enableDepthRead();
	gl::enableDepthWrite();
	gl::setMatrices(mMayaCam.getCamera());

	gl::ScopedTextureBind cTexture(mTexRgb);
	gl::pointSize(getWindowWidth()/mDepthDims.x);
	mDrawObj->draw();
}
Ejemplo n.º 26
0
void ObjLoaderApp::draw()
{
    gl::enableDepthWrite();
    gl::enableDepthRead();

    gl::clear( Color( 0.0f, 0.1f, 0.2f ) );

    gl::setMatrices( mCam );

    gl::pushMatrices();
    gl::rotate( mArcball.getQuat() );
    mBatch->draw();
    gl::popMatrices();
}
Ejemplo n.º 27
0
void BayBridgeApp::setup()
{
	mGUI = params::InterfaceGl::create("Params", ivec2(300, 50));
	mParamInvert = false;
	mParamClear = true;
	mGUI->addParam<bool>("paramInvert", &mParamInvert).optionsStr("label='Inverted'");
	mGUI->addParam<bool>("paramClear", &mParamClear).optionsStr("label='Clear Frame'");

	getWindow()->setSize(1280, 720);
	getWindow()->setPos(ivec2(20));
	setFrameRate(60);
	mBridgeShader = gl::GlslProg::create(loadAsset("shaders/light_vert.glsl"), loadAsset("shaders/light_frag.glsl"));
	
	mBridge.Init(mBridgeShader);

	mCamera.setPerspective(45.0f, getWindowAspectRatio(), 10.0f, 10000.0f);
	mCamera.lookAt(vec3(0, 50, -525), vec3(0,50,0), vec3(0, 1, 0));
	mCamUi = CameraUi(&mCamera, getWindow());

	mDS = CinderDSAPI::create();
	mDS->init();
	mDS->initDepth(FrameSize::DEPTHSD, 60);
	mDS->start();

	ImageSourceRef skybox[6]
	{
		loadImage(loadAsset("textures/px04.png")), loadImage(loadAsset("textures/nx04.png")),
		loadImage(loadAsset("textures/py04.png")), loadImage(loadAsset("textures/ny04.png")),
		loadImage(loadAsset("textures/pz04.png")), loadImage(loadAsset("textures/nz04.png"))
	};

	mTexSkybox = gl::TextureCubeMap::create(skybox);
	mShaderSkybox = gl::GlslProg::create(loadAsset("shaders/skybox_vert.glsl"), loadAsset("shaders/skybox_frag.glsl"));
	mBatchSkybox = gl::Batch::create(geom::Cube(), mShaderSkybox);
	mBatchSkybox->getGlslProg()->uniform("uCubemapSampler", 0);

	mShaderDiffuse = gl::GlslProg::create(loadAsset("shaders/diffuse_vert.glsl"), loadAsset("shaders/diffuse_frag.glsl"));

	//Bloom
	mFboRaw = gl::Fbo::create(1280, 720, gl::Fbo::Format().colorTexture(gl::Texture2d::Format().dataType(GL_FLOAT).internalFormat(GL_RGBA32F)));
	mFboHiPass = gl::Fbo::create(1280, 720);
	mFboBlurU = gl::Fbo::create(1280, 720);
	mFboBlurV = gl::Fbo::create(1280, 720);

	mShaderHiPass = gl::GlslProg::create(loadAsset("shaders/passthru_vert.glsl"), loadAsset("shaders/highpass_frag.glsl"));
	mShaderHiPass->uniform("uTextureSampler", 0);

	mShaderBlur = gl::GlslProg::create(loadAsset("shaders/blur_vert.glsl"), loadAsset("shaders/blur_frag.glsl"));
	mShaderBlur->uniform("uTextureSampler", 0);
}
Ejemplo n.º 28
0
void MyoBlockTestApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) );
    
    gl::ScopedMatrices push;
    
    gl::setMatrices(mCam);
    
    {
        gl::ScopedModelMatrix model;
        gl::multModelMatrix(toMat4(mArmband.mRotation));
        mHelloWorld->draw();
    }
    
}
Ejemplo n.º 29
0
void BulletSpheresApp::drawToDepthFbo()
{
	// draw into the depth fbo for shadow casting
	gl::ScopedFramebuffer bindFbo( mLight->getFbo() );
	gl::clear();

	gl::ScopedState scopeCull( GL_CULL_FACE, true );
	gl::cullFace( GL_FRONT );
	
	gl::ScopedMatrices scopeMat;
	gl::setMatrices( mLight->getCam() );
	gl::viewport( mLight->getFbo()->getSize() );

	mShadowSphere->drawInstanced( NUM_PARTICLES-2 );
}
Ejemplo n.º 30
0
void BasicApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) ); 
	gl::setMatrices(mCamera);

	drawWorld(vec3(0), vec3(10), 2.0f);
	gl::pointSize(4.0f);
	mBatch->draw();

	gl::color(Color(0, 1, 1));
	gl::enableWireframe();
	gl::draw(*mTris.get());


}