MCPcopy Create free account
hub / github.com/SpartanJ/eepp / getFrontBufferImage

Method getFrontBufferImage

src/eepp/window/window.cpp:306–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304}
305
306Image 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
337bool Window::isRunning() const {
338 return mWindow.Created;

Callers 1

compareImagesFunction · 0.80

Calls 5

getPixelsMethod · 0.80
getChannelsMethod · 0.80
drawMethod · 0.45
getHeightMethod · 0.45
getWidthMethod · 0.45

Tested by 1

compareImagesFunction · 0.64