| 575 | } |
| 576 | |
| 577 | void * 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 | |
| 625 | GLenum |
| 626 | GetGLFormat(GLenum internalFormat) |
nothing calls this directly
no test coverage detected