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

Function ReadGLRenderbuffer

test_common/gl/helpers.cpp:1762–1807  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1760}
1761
1762void * ReadGLRenderbuffer( GLuint glFramebuffer, GLuint glRenderbuffer,
1763 GLenum attachment, GLenum glFormat,
1764 GLenum glInternalFormat, GLenum glType,
1765 ExplicitType typeToReadAs,
1766 size_t outWidth, size_t outHeight )
1767{
1768 glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, glFramebuffer );
1769 glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER_EXT, glRenderbuffer );
1770
1771 // Attach to the framebuffer
1772 GLint err = glGetError();
1773 if( glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT ) != GL_FRAMEBUFFER_COMPLETE_EXT )
1774 {
1775 log_error( "ERROR: Unable to attach renderbuffer to framebuffer (%s)\n", gluErrorString( err ) );
1776 return NULL;
1777 }
1778
1779 // Read results from the GL renderbuffer
1780#ifdef DEBUG
1781 log_info( "- Reading back from GL: %d x %d : %s : %s : %s\n",
1782 (int)outWidth, (int)outHeight,
1783 GetGLFormatName( glInternalFormat ),
1784 GetGLFormatName( glFormat ),
1785 GetGLTypeName( glType ));
1786#endif
1787
1788 GLenum readBackFormat = glFormat == GL_RGBA_INTEGER_EXT ? GL_RGBA_INTEGER_EXT : GL_RGBA;
1789 GLenum readBackType = glType;
1790
1791 size_t outBytes = outWidth * outHeight * 4 * GetGLTypeSize(readBackType);
1792 void *outBuffer = malloc( outBytes );
1793 memset(outBuffer, 0, outBytes);
1794
1795 glReadPixels( 0, 0, (GLsizei)outWidth, (GLsizei)outHeight, readBackFormat, readBackType, outBuffer );
1796
1797#ifdef DEBUG
1798 log_info( "- glReadPixels: %d : %d : %s : %s \n",
1799 (int)outWidth, (int)outHeight,
1800 GetGLFormatName(readBackFormat),
1801 GetGLTypeName(readBackType));
1802
1803 DumpGLBuffer(readBackType, outWidth, outHeight, outBuffer);
1804#endif
1805
1806 return (void *)outBuffer;
1807}
1808
1809GLenum
1810GetGLFormat(GLenum internalFormat)

Callers 4

test_fence_sync_singleFunction · 0.50
test_fence_sync_singleFunction · 0.50

Calls 5

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

Tested by 4

test_fence_sync_singleFunction · 0.40
test_fence_sync_singleFunction · 0.40