MCPcopy Create free account
hub / github.com/cinder/Cinder / draw

Method draw

samples/FrustumCulling/src/FrustumCullingApp.cpp:206–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204}
205
206void FrustumCullingReduxApp::draw()
207{
208 // Clear the window.
209 gl::clear( Color::gray( 0.25f ) );
210
211 {
212 // Get ready to render a 3D world.
213 gl::ScopedMatrices scopeMatrix;
214 gl::setMatrices( mRenderCam );
215
216 gl::ScopedState scopeState( GL_CULL_FACE, true );
217 gl::enableDepthRead();
218 gl::enableDepthWrite();
219
220 // Draw all objects.
221 for( auto & obj : mObjects )
222 obj->draw();
223
224 // Draw bounding volumes.
225 if( mDrawWorldSpaceBounds ) {
226 for( auto & obj : mObjects ) {
227 // Use cyan bounds if not culled, orange bounds if culled.
228 if( !obj->isCulled() )
229 gl::color( Color( 0, 1, 1 ) );
230 else
231 gl::color( Color( 1, 0.5f, 0 ) );
232
233 if( mCullWithSpheres ) {
234 // Create a fast approximation of the world space bounding sphere.
235 Sphere worldBoundingSphere = mObjectBoundingSphere.transformed( obj->getTransform() );
236
237 gl::ScopedModelMatrix mtx;
238 gl::translate( worldBoundingSphere.getCenter() );
239 gl::scale( vec3( worldBoundingSphere.getRadius() ) );
240 mSphereBatch->draw();
241 }
242 else {
243 // Create a fast approximation of the world space bounding box by transforming the
244 // eight corners and using them to create a new axis aligned bounding box.
245 AxisAlignedBox worldBoundingBox = mObjectBoundingBox.transformed( obj->getTransform() );
246
247 gl::ScopedModelMatrix mtx;
248 gl::translate( worldBoundingBox.getCenter() );
249 gl::scale( worldBoundingBox.getSize() );
250 mBoxBatch->draw();
251 }
252
253 // Don't draw object space bounds if culled.
254 if( obj->isCulled() )
255 continue;
256
257 if( mDrawObjectSpaceBounds ) {
258 if( mCullWithSpheres ) {
259 // Draw the precise bounding sphere in yellow. You will be able to
260 // see how much it differs from the world space bounding sphere approximation.
261 gl::color( Color( 1, 1, 0 ) );
262
263 gl::ScopedModelMatrix mtx;

Callers

nothing calls this directly

Calls 15

grayFunction · 0.85
setMatricesFunction · 0.85
enableDepthReadFunction · 0.85
enableDepthWriteFunction · 0.85
multModelMatrixFunction · 0.85
disableDepthWriteFunction · 0.85
disableDepthReadFunction · 0.85
enableAlphaBlendingFunction · 0.85
whiteFunction · 0.85
disableAlphaBlendingFunction · 0.85
isCulledMethod · 0.80
clearFunction · 0.50

Tested by

no test coverage detected