| 304 | } |
| 305 | |
| 306 | Image Window::getFrontBufferImage() { |
| 307 | GlobalBatchRenderer::instance()->draw(); |
| 308 | Image fb( mWindow.WindowConfig.Width, mWindow.WindowConfig.Height, 3 ); |
| 309 | |
| 310 | GLint pack_alignment; |
| 311 | glGetIntegerv( GL_PACK_ALIGNMENT, &pack_alignment ); |
| 312 | if ( 1 != pack_alignment ) |
| 313 | glPixelStorei( GL_PACK_ALIGNMENT, 1 ); |
| 314 | |
| 315 | Uint8* pixelData = fb.getPixels(); |
| 316 | glReadPixels( 0, 0, mWindow.WindowConfig.Width, mWindow.WindowConfig.Height, GL_RGB, |
| 317 | GL_UNSIGNED_BYTE, pixelData ); |
| 318 | |
| 319 | if ( 1 != pack_alignment ) |
| 320 | glPixelStorei( GL_PACK_ALIGNMENT, pack_alignment ); |
| 321 | |
| 322 | for ( unsigned int j = 0; j * 2 < fb.getHeight(); ++j ) { |
| 323 | int index1 = j * fb.getWidth() * fb.getChannels(); |
| 324 | int index2 = ( fb.getHeight() - 1 - j ) * fb.getWidth() * fb.getChannels(); |
| 325 | for ( int i = fb.getWidth() * fb.getChannels(); i > 0; --i ) { |
| 326 | Uint8 temp = pixelData[index1]; |
| 327 | pixelData[index1] = pixelData[index2]; |
| 328 | pixelData[index2] = temp; |
| 329 | ++index1; |
| 330 | ++index2; |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | return fb; |
| 335 | } |
| 336 | |
| 337 | bool Window::isRunning() const { |
| 338 | return mWindow.Created; |