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

Method draw

samples/_opengl/PBOReadBack/src/PBOReadBackApp.cpp:98–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98void PBOReadBackApp::draw()
99{
100 mTimer.start();
101
102 // Read from old Fbo
103 if( mUsePbo ) {
104
105 // Read to new Pbo (non-blocking)
106 {
107 gl::ScopedFramebuffer sFbo( mFbo[mIndexOld] );
108 gl::ScopedBuffer sPbo( mPbo[mIndexNew] );
109
110 gl::readBuffer( GL_COLOR_ATTACHMENT0 );
111 gl::readPixels( 0, 0, WIDTH, HEIGHT, PIXEL_FORMAT, GL_UNSIGNED_BYTE, 0 );
112 }
113
114 // Receive data from old Pbo (potentially blocking hence the Pbo ping-pong)
115 mPbo[mIndexOld]->getBufferSubData( 0, DATA_SIZE, mSurf.getData() );
116
117 } else {
118
119 // Read directly (blocking)
120 gl::ScopedFramebuffer sFbo( mFbo[mIndexOld] );
121
122 gl::readBuffer( GL_COLOR_ATTACHMENT0 );
123 gl::readPixels( 0, 0, WIDTH, HEIGHT, PIXEL_FORMAT, GL_UNSIGNED_BYTE, mSurf.getData() );
124 }
125
126 mTimer.stop();
127
128 // Render to new Fbo
129 gl::enableDepthRead();
130 gl::enableDepthWrite();
131
132 {
133 gl::ScopedFramebuffer sFbo( mFbo[mIndexNew] );
134 gl::ScopedViewport sVp( 0, 0, WIDTH, HEIGHT );
135 gl::ScopedMatrices sMat;
136
137 gl::setMatrices( mCam );
138
139 gl::clear( Color( 0.2, 0.4, 0.8 ) );
140
141 gl::rotate( mRotate, vec3( 0.0, 1.0, 0.0 ) );
142 gl::drawColorCube( vec3( 0 ) , vec3( 15 ) );
143 }
144
145 // Render to screen
146 gl::disableDepthRead();
147 gl::disableDepthWrite();
148
149 gl::setMatricesWindow( getWindowSize() );
150 gl::clear();
151
152 gl::draw( mFbo[mIndexNew]->getColorTexture(), Area( 0, 0, 256, 256 ) );
153
154 // Show the change to the data
155 mTex->setTopDown( true );

Callers

nothing calls this directly

Calls 15

readBufferFunction · 0.85
readPixelsFunction · 0.85
enableDepthReadFunction · 0.85
enableDepthWriteFunction · 0.85
setMatricesFunction · 0.85
drawColorCubeFunction · 0.85
disableDepthReadFunction · 0.85
disableDepthWriteFunction · 0.85
setMatricesWindowFunction · 0.85
getAverageFpsFunction · 0.85
drawStringFunction · 0.85
getBufferSubDataMethod · 0.80

Tested by

no test coverage detected