void camerasApp::draw() { gl::clear( Color( 0, 0.1f, 0.2f ) ); // draw the cube gl::pushMatrices(); gl::translate( getWindowCenter() ); gl::rotate( mArcball.getQuat() ); if(mTexture) { mTexture->enableAndBind(); gl::drawCube(Vec3f::zero(), Vec3f(320,320,320)); mTexture->unbind(); } gl::popMatrices(); }
void ProceduralAnimApp::draw() { // clear out the window with black gl::clear( Color( 0.4f, 0.5f, 0.6f ) ); gl::setMatrices( mMayaCam.getCamera() ); gl::enableDepthRead(); gl::Light light( gl::Light::DIRECTIONAL, 0 ); light.setAmbient( Color::white() ); light.setDiffuse( Color::white() ); light.setSpecular( Color::white() ); light.lookAt( mLightPos, Vec3f::zero() ); light.update( mMayaCam.getCamera() ); light.enable(); gl::pushMatrices(); float e = (float)getElapsedSeconds(); gl::translate( math<float>::sin( 1.3f * e ), math<float>::cos( 2.7f * e ) ); gl::enable( GL_LIGHTING ); gl::enable( GL_NORMALIZE ); if ( mEnableWireframe ) gl::enableWireframe(); if( mDrawMesh ) { SkinningRenderer::draw( mSkinnedVboBird ); } if ( mEnableWireframe ) gl::disableWireframe(); gl::disable( GL_LIGHTING ); gl::disable( GL_NORMALIZE ); if( mDrawSkeleton) { SkinningRenderer::draw( mSkinnedVboBird->getSkeleton() ); } if( mDrawLabels ) { SkinningRenderer::drawLabels( mSkinnedVboBird->getSkeleton(), mMayaCam.getCamera() ); } gl::popMatrices(); Vec3f mRight, mUp; mMayaCam.getCamera().getBillboardVectors(&mRight, &mUp); // gl::disableDepthRead(); gl::disableDepthWrite(); gl::enableAlphaBlending(); dustParticleTex->enableAndBind(); mDustShader->bind(); mDustShader->uniform( "tex", 0 ); for( const auto& d : mDust ) { mDustShader->uniform( "transparency", 1.0f - math<float>::abs(d.z)/(SCENE_SIZE/2.0f) ); gl::drawBillboard(d, Vec2f(60.f, 60.f), 0.0f, mRight, mUp); } mDustShader->unbind(); dustParticleTex->unbind(); mParams.draw(); }
void MeshViewApp::draw() { // Clear the window gl::clear(); gl::color(Color::white()); if(isInitialized()) { // Get ready to draw in 3D gl::pushMatrices(); gl::setMatrices(m_camera); gl::enableDepthRead(); gl::enableDepthWrite(); // Bind textures if(m_texDiffuse) m_texDiffuse->enableAndBind(); if (m_texNormal) m_texNormal->bind(1); if (m_texSpecular) m_texSpecular->bind(2); if(m_texAO) m_texAO->bind(3); if(m_texEmissive) m_texEmissive->bind(4); // Bind shader m_shader->bind(); m_shader->uniform("texDiffuse", 0); m_shader->uniform("texNormal", 1); m_shader->uniform("texSpecular", 2); m_shader->uniform("texAO", 3); m_shader->uniform("texEmissive", 4); m_shader->uniform("texDiffusePower", m_texDiffusePower); m_shader->uniform("texNormalPower", m_texNormalPower); m_shader->uniform("texSpecularPower", m_texSpecularPower); m_shader->uniform("texAOPower", m_texAOPower); m_shader->uniform("texEmissivePower", m_texEmissivePower); m_shader->uniform("diffuseEnabled", m_diffuseEnabled); m_shader->uniform("normalEnabled", m_normalEnabled); m_shader->uniform("specularEnabled", m_specularEnabled); m_shader->uniform("aoEnabled", m_aoEnabled); m_shader->uniform("emissiveEnabled", m_emissiveEnabled); m_shader->uniform("material.Ka", m_matAmbient); m_shader->uniform("material.Kd", m_matDiffuse); m_shader->uniform("material.Ks", m_matSpecular); m_shader->uniform("material.Shininess", m_matShininess); m_shader->uniform("gamma", m_gamma); // Enable lights m_light1->enable(); m_light2->enable(); // Render model gl::pushModelView(); gl::multModelView(m_matrix); m_assimpLoader.draw(); gl::popModelView(); // Disable lights m_light1->disable(); m_light2->disable(); // Unbind shader m_shader->unbind(); // Unbind textures gl::disable(m_texDiffuse->getTarget()); // Disable 3D rendering gl::disableDepthWrite(); gl::disableDepthRead(); // Restore matrices gl::popMatrices(); // Enable 2D rendering gl::setMatricesWindow(getWindowSize()); gl::setViewport(getWindowBounds()); // Render parameter window if(m_params) m_params->draw(); } // Render debug information Debug::get().draw(ColorAf::white()); }