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 Tiler::setMatrices( const CameraPersp &camera ) { mCamera = camera; float left, top, right, bottom, nearPlane, farPlane; camera.getFrustum( &left, &top, &right, &bottom, &nearPlane, &farPlane ); if( camera.isPersp() ) { frustum( left, right, bottom, top, nearPlane, farPlane ); } else { ortho( left, right, bottom, top, nearPlane, farPlane ); } }