MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCL-CTS / ReadGLRenderbuffer

Function ReadGLRenderbuffer

test_common/gles/helpers.cpp:577–623  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

575}
576
577void * ReadGLRenderbuffer( GLuint glFramebuffer, GLuint glRenderbuffer,
578 GLenum attachment,
579 GLenum rbFormat, GLenum rbType,
580 GLenum texFormat, GLenum texType,
581 ExplicitType typeToReadAs,
582 size_t outWidth, size_t outHeight )
583{
584 glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, glFramebuffer );
585 glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER_EXT, glRenderbuffer );
586
587 // Attach to the framebuffer
588 GLint err = glGetError();
589 if( glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT ) != GL_FRAMEBUFFER_COMPLETE_EXT )
590 {
591 log_error( "ERROR: Unable to attach renderbuffer to framebuffer (%s)\n", gluErrorString( err ) );
592 return NULL;
593 }
594
595 // Read results from the GL renderbuffer
596#ifdef GLES_DEBUG
597 log_info( "- Reading back from GL: %d x %d : %s : %s : %s\n",
598 (int)outWidth, (int)outHeight,
599 GetGLFormatName( glInternalFormat ),
600 GetGLFormatName( glFormat ),
601 GetGLTypeName( glType ));
602#endif
603
604 GLenum readBackFormat = GL_RGBA;
605 GLenum readBackType = texType;
606
607 size_t outBytes = outWidth * outHeight * 4 * GetGLTypeSize(readBackType);
608 void *outBuffer = malloc( outBytes );
609 memset(outBuffer, 0, outBytes);
610
611 glReadPixels( 0, 0, (GLsizei)outWidth, (GLsizei)outHeight, readBackFormat, readBackType, outBuffer );
612
613#ifdef GLES_DEBUG
614 log_info( "- glReadPixels: %d : %d : %s : %s \n",
615 (int)outWidth, (int)outHeight,
616 GetGLFormatName(readBackFormat),
617 GetGLTypeName(readBackType));
618
619 DumpGLBuffer(readBackType, outWidth, outHeight, outBuffer);
620#endif
621
622 return (void *)outBuffer;
623}
624
625GLenum
626GetGLFormat(GLenum internalFormat)

Callers

nothing calls this directly

Calls 5

gluErrorStringFunction · 0.70
GetGLFormatNameFunction · 0.70
GetGLTypeNameFunction · 0.70
GetGLTypeSizeFunction · 0.70
DumpGLBufferFunction · 0.70

Tested by

no test coverage detected