void QuaternionAccumApp::drawBall() { Vec3f pos = mSpline.getPosition( mSplineValue ); Vec3f delta = pos - mLastPos; // our axis of rotation is the normal to the spline at this point Vec3f normal = Vec3f( delta.z, 0, -delta.x ); // rotation amount (in radians) is the distance we've traveled divided by the radius of the ball float rotation = delta.length() / BALL_RADIUS; if( rotation ) { // increment our quaternion by a new quaternion representing how much rotating we did since the last frame Quatf incQuat( normal, rotation ); mQuat *= incQuat; mQuat.normalize(); } gl::translate( Vec3f( 0.0f, BALL_RADIUS, 0.0f ) + pos ); gl::scale( Vec3f( BALL_RADIUS, BALL_RADIUS, BALL_RADIUS ) ); gl::rotate( mQuat ); gl::color( Color( 1, 1, 1 ) ); mBallTexture.enableAndBind(); gl::drawSphere( Vec3f::zero(), 1.0f, 60 ); mBallTexture.disable(); mLastPos = pos; }
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 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 MemExploreApp::draw() { mTexture = gl::Texture(mDataPointer, GL_RGBA, mVolumeDim * mTilesDim, mVolumeDim * mTilesDim); mTexture.setWrap(GL_REPEAT, GL_REPEAT); mTexture.setMinFilter(GL_NEAREST); mTexture.setMagFilter(GL_NEAREST); float frustum[6]; mCamera.getFrustum(&frustum[0], &frustum[1], &frustum[2], &frustum[3], &frustum[4], &frustum[5]); mFbo.bindFramebuffer(); gl::setMatricesWindow(mFbo.getSize(), false); mProgram.bind(); mProgram.uniform("uTexture", 0); mProgram.uniform("uVolumeDim", mVolumeDim); mProgram.uniform("uTilesDim", mTilesDim); mProgram.uniform("uTime", (float)getElapsedSeconds()); mProgram.uniform("uEyePoint", mCamera.getEyePoint()); mProgram.uniform("uXAxis", mCamera.getOrientation() * Vec3f::xAxis()); mProgram.uniform("uYAxis", mCamera.getOrientation() * Vec3f::yAxis()); mProgram.uniform("uViewDistance", mCamera.getAspectRatio() / abs(frustum[2] - frustum[0]) * mCamera.getNearClip()); mProgram.uniform("uNegViewDir", -mCamera.getViewDirection().normalized()); mProgram.uniform("uAspectRatio", mCamera.getAspectRatio()); mTexture.enableAndBind(); gl::drawSolidRect(mFbo.getBounds()); mTexture.unbind(); mProgram.unbind(); mFbo.unbindFramebuffer(); gl::setMatricesWindow(getWindowSize()); gl::draw(mFbo.getTexture(), getWindowBounds()); }
void LEDCamApp::draw() { // clear out the window with black gl::clear( kClearColor ); if( !mTexture ) return; mFbo.bindFramebuffer(); mTexture.enableAndBind(); mShader.bind(); float aspect = kWindowHeight/kWindowWidth; cout << "Aspect: " << aspect << " \n"; mShader.uniform( "aspect", aspect ); mShader.uniform( "tex", 0 ); mShader.uniform( "bright", 3.0f ); mShader.uniform( "spacing", 3 ); mShader.uniform( "ledCount", 100.0f ); gl::drawSolidRect( getWindowBounds() ); mTexture.unbind(); mShader.unbind(); mFbo.unbindFramebuffer(); gl::Texture fboTexture = mFbo.getTexture(); fboTexture.setFlipped(); gl::draw( fboTexture ); }
void QuickTimeSampleApp::loadMovieFile( const fs::path& moviePath ) { try { // load up the movie, set it to loop, and begin playing mMovie = qtime::MovieGl( moviePath ); mMovie.setLoop(); mMovie.play(); // create a texture for showing some info about the movie TextLayout infoText; infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) ); infoText.setColor( Color::white() ); infoText.addCenteredLine( getPathFileName( moviePath.string() ) ); infoText.addLine( toString( mMovie.getWidth() ) + " x " + toString( mMovie.getHeight() ) + " pixels" ); infoText.addLine( toString( mMovie.getDuration() ) + " seconds" ); infoText.addLine( toString( mMovie.getNumFrames() ) + " frames" ); infoText.addLine( toString( mMovie.getFramerate() ) + " fps" ); infoText.setBorder( 4, 2 ); mInfoTexture = gl::Texture( infoText.render( true ) ); } catch( ... ) { console() << "Unable to load the movie." << std::endl; mMovie.reset(); mInfoTexture.reset(); } mFrameTexture.reset(); }
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(); }
void TutorialApp::draw() { if(isFirst) { gl::clear( Color( 0, 0, 0 ), true ); isFirst = false; } gl::enableAlphaBlending(); if( mDrawImage ){ mTexture.enableAndBind(); gl::draw( mTexture, getWindowBounds() ); } // if( mDrawParticles ){ glDisable( GL_TEXTURE_2D ); mParticleController.draw(); // } if( mDrawImage ){ mOverlay.enableAndBind(); gl::draw( mOverlay, getWindowBounds() ); } // if( mSaveFrames ){ // writeImage( getHomeDirectory() / ( "image_" + toString( getElapsedFrames() ) + ".png" ), copyWindowSurface() ); // } }
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(); } }
void FastTrailsApp::draw() { // clear window gl::clear(); // set render states gl::enableWireframe(); gl::enableAlphaBlending(); gl::enableDepthRead(); gl::enableDepthWrite(); // enable 3D camera gl::pushMatrices(); gl::setMatrices( mCamera.getCamera() ); // draw VBO mesh using texture mTexture.enableAndBind(); gl::drawRange( mVboMesh, 0, mTrail.size(), 0, mTrail.size()-1 ); mTexture.unbind(); // restore camera and render states gl::popMatrices(); gl::disableDepthWrite(); gl::disableDepthRead(); gl::disableAlphaBlending(); gl::disableWireframe(); }
void BloomingNeonApp::render() { // get the current viewport Area viewport = gl::getViewport(); // adjust the aspect ratio of the camera mCamera.setAspectRatio( viewport.getWidth() / (float) viewport.getHeight() ); // render our scene (see the Picking3D sample for more info) gl::pushMatrices(); gl::setMatrices( mCamera ); gl::enableDepthRead(); gl::enableDepthWrite(); mTexture.enableAndBind(); mShaderPhong.bind(); mShaderPhong.uniform("tex0", 0); gl::pushModelView(); gl::multModelView( mTransform ); gl::color( Color::white() ); gl::draw( mMesh ); gl::popModelView(); mShaderPhong.unbind(); mTexture.unbind(); gl::disableDepthWrite(); gl::disableDepthRead(); gl::popMatrices(); }
void QuickTimePlayer::loadMovieFile( const fs::path &moviePath ) { try { // load up the movie, set it to loop, and begin playing mMovie = qtime::MovieGl::create( moviePath ); mMovie->setLoop(mMovie->getDuration()<30.0f) ; mMovie->play(); // create a texture for showing some info about the movie TextLayout infoText; infoText.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.5f ) ); infoText.setColor( Color::white() ); infoText.addCenteredLine( moviePath.filename().string() ); infoText.addLine( toString( mMovie->getWidth() ) + " x " + toString( mMovie->getHeight() ) + " pixels" ); infoText.addLine( toString( mMovie->getDuration() ) + " seconds" ); infoText.addLine( toString( mMovie->getNumFrames() ) + " frames" ); infoText.addLine( toString( mMovie->getFramerate() ) + " fps" ); infoText.setBorder( 4, 2 ); mInfoTexture = gl::Texture( infoText.render( true ) ); } catch (const std::exception &e) { console() << "Unable to load the movie:" << e.what() << std::endl; //mMovie->reset(); mInfoTexture.reset(); } mFrameTexture.reset(); }
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(); }
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(); }
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(); }
void PhotoBoothApp::touchesBegan( TouchEvent event ){ TouchEvent::Touch touch = event.getTouches().front(); Vec2f cameraButtonTargetPos = Vec2f(mCameraButtonPos.value()); float touchX = touch.getX() / DISPLAY_SCALE; float touchY = touch.getY() / DISPLAY_SCALE; switch(mCurrentState) { case STATE_PREVIEW: // see if the camera icon has been tapped (touch coordinates are reversed for landscape mode) cameraButtonTargetPos.x += mCameraButtonTexture.getWidth() / 2.0f; cameraButtonTargetPos.y += mCameraButtonTexture.getHeight() / 2.0f; if( cameraButtonTargetPos.distance( Vec2f(touchX, touchY) ) < (mCameraButtonTexture.getWidth() * 2) ) { mCountDownStartTime = getElapsedSeconds(); mCurrentState = STATE_COUNT_DOWN; } break; case STATE_COUNT_DOWN: // stub.. break; case STATE_ACCEPT: if(touchY > 1280) { // only look for touches near the bottom of the screen. // just split the screen in half, no need to do precise hit detection for save/cancel buttons.. if(touchX > width / 2){ ip::flipVertical( &mCameraSurface ); cinder::cocoa::SafeUiImage img = cocoa::createUiImage( mCameraSurface ); // Call into objective C to do upload via cocoa FileSender::sendFile(img); timeline().apply( &mPreviewTexturePos, Vec2f(0, -height ), 1.0f, EaseInCubic() ); }else{ timeline().apply( &mPreviewTexturePos, Vec2f(0, height ), 1.0f, EaseInBack() ); } mCurrentState = STATE_PREVIEW; timeline().apply( &mDarkBgAlpha, 0.0f, 1.0f, EaseInCubic() ); // Hide buttons timeline().apply( &mDiscardPos, Vec2f(100, height + 100 ), 1.0f, EaseInCubic() ); timeline().apply( &mSavePos, Vec2f(width-700, height + 100 ), 1.0f, EaseInCubic() ); } break; } }
void shaderExternalFileExampleApp::update(){ if( mCapture && mCapture.checkNewFrame() ) { mTexture = gl::Texture( mCapture.getSurface() ); mTexture.setWrap(GL_CLAMP, GL_CLAMP); mTexture.setMinFilter(GL_NEAREST); mTexture.setMagFilter(GL_NEAREST); } }
/** 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); }
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(); }
void GeometryShaderApp::draw() { // clear out the window gl::clear( Color(0.95f, 0.95f, 0.95f) ); // bind the shader and send the mesh to the GPU if(mShader && mVboMesh) { mShader.bind(); mShader.uniform( "WIN_SCALE", Vec2f( getWindowSize() ) ); // casting to Vec2f is mandatory! mShader.uniform( "MITER_LIMIT", mLimit ); mShader.uniform( "THICKNESS", mThickness ); if(mTexture) { gl::enableAlphaBlending(); gl::color( Color::white() ); mTexture.enableAndBind(); } else gl::color( Color::black() ); gl::draw( mVboMesh ); if(mTexture) { mTexture.unbind(); gl::disableAlphaBlending(); } if(mDrawWireframe) { gl::color( Color::black() ); gl::enableWireframe(); gl::draw( mVboMesh ); gl::disableWireframe(); } mShader.unbind(); } // draw all points as red circles gl::color( Color(1, 0, 0) ); std::vector<Vec2f>::const_iterator itr; for(itr=mPoints.begin();itr!=mPoints.end();++itr) gl::drawSolidCircle( *itr, mRadius ); if( ! mPoints.empty() ) gl::drawStrokedCircle( mPoints.back(), mRadius + 2.0f ); // draw help if(mHelpTexture) { gl::color( Color::white() ); gl::enableAlphaBlending(); gl::draw( mHelpTexture ); gl::disableAlphaBlending(); } }
void AudioObjApp::draw() { gl::clear( Color( 0, 0, 0 ) ); gl::enableAlphaBlending(); gl::enableDepthRead(); gl::enableDepthWrite(); gl::pushMatrices(); gl::setMatrices( mMayaCam.getCamera() ); if ( mFeature && mFeatureTex ) { mShader->bind(); mFeatureTex.enableAndBind(); mShader->uniform( "dataTex", 0 ); mShader->uniform( "texWidth", (float)mFeatureTex.getWidth() ); mShader->uniform( "texHeight", (float)mFeatureTex.getHeight() ); mShader->uniform( "soundDataSize", (float)mFeature->getSize() ); mShader->uniform( "spread", mFeatureSpread ); mShader->uniform( "spreadOffset", mFeatureSpreadOffset ); mShader->uniform( "time", (float)getElapsedSeconds() ); mShader->uniform( "tintColor", mObjColor ); } if ( mRenderWireframe ) gl::enableWireframe(); gl::color( Color(1.0f, 0.0f, 0.0f ) ); if ( mVbo ) gl::draw( mVbo ); if ( mRenderWireframe ) gl::disableWireframe(); mShader->unbind(); mFeatureTex.unbind(); gl::color( Color::white() ); // gl::drawCoordinateFrame(); gl::popMatrices(); gl::disableDepthRead(); gl::disableDepthWrite(); gl::setMatricesWindow( getWindowSize() ); ciXtractReceiver::drawData( mFeature, Rectf( 15, getWindowHeight() - 150, 255, getWindowHeight() - 35 ) ); gl::draw( mFeatureSurf ); mParams->draw(); }
/** 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(); }
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 }
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(); }
void pinch_tap_sampleApp::draw() { gl::clear(Color::black()); gl::setMatricesWindowPersp(getWindowSize(), 60, 1, 2000); mRectTex.enableAndBind(); for(vector<TouchRect*>::reverse_iterator it = mRects.rbegin(); it != mRects.rend(); ++it) (*it)->draw(); mRectTex.unbind(); }
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(); }
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; }
void godComplexApp::draw() { gl::enableDepthRead(); gl::enableDepthWrite(); gl::enableAlphaBlending(); // clear out the window with black gl::clear( Color( 0, 0, 0 ) ); gl::setMatrices( mMayaCam.getCamera()); if(drawWater == true){ if(mWaterModule != NULL){ gl::pushMatrices(); mWaterModule->draw(0); gl::popMatrices(); } } if(drawMesh == true){ gl::pushMatrices(); myImage.enableAndBind(); // gl::rotate( mArcball.getQuat() ); //NOTE: for debugging gl::scale(Vec3f(0.035,0.035,0.035)); glLineWidth(0.2f); gl::enableWireframe(); gl::translate(Vec3f(280.0, 0.0, -180.0)); gl::rotate(Vec3f(-10.0, -10.0, 0.0)); gl::draw(mVbo); gl::disableWireframe(); myImage.unbind(); gl::popMatrices(); } gl::pushMatrices(); mFlowField->draw(); gl::popMatrices(); /* glPushMatrix(); glColor4f(1.0, 0.0, 0.0, 1.0); gl::drawSphere(Vec3f(userIncr1, userIncr2, userIncr3), 30.0, 12.0); glPopMatrix(); */ }
/* * @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() ); }
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; }