昨天我尝试创建一个256x8大小的帧缓冲区时遇到了问题 - 在iOS设备上(在iPad 3,iPhone 4和iPad Mini上测试),某些尺寸会因GL_FRAMEBUFFER_UNSUPPORTED
而失败。这些相同的大小适用于iOS模拟器。
此问题先前已报告here,但仍未得到答复。我创建了一个测试来检查哪些帧缓冲区大小不起作用。需要说明的是,这些尺寸仅在实际的iOS硬件上失败,尺寸在iOS模拟器中正常工作。
有谁知道这些尺寸失败的原因(包括在下面)?这些尺寸应该有效吗?或者他们失败的原因是什么?或者它只是一个错误?有趣的是,每个尺寸(宽度或高度)总是2的幂。我测试的每种非尺寸的两种尺寸都可以工作。
以下是测试帧缓冲区大小的代码:
void initGL()
{
// create OpenGL ES 2.0 context
EAGLContext * context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
if ( !context )
return;
[EAGLContext setCurrentContext:context];
}
void framebufferTest( int width, int height )
{
// create empty texture
GLuint texture = 0;
glActiveTexture( GL_TEXTURE0 );
glGenTextures( 1, &texture );
glBindTexture( GL_TEXTURE_2D, texture );
GLenum dataType = GL_UNSIGNED_BYTE;
GLint internalFormat = GL_RGBA;
glTexImage2D( GL_TEXTURE_2D, 0, internalFormat, width, height, 0, internalFormat, dataType, NULL );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
// This is necessary for non-power-of-two textures
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
// create a framebuffer & attatch to texture
GLuint framebuffer = 0;
glGenFramebuffers( 1, &framebuffer );
glBindFramebuffer( GL_FRAMEBUFFER, framebuffer );
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0 );
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if ( status != GL_FRAMEBUFFER_COMPLETE )
printf( "%5dx%5d\t\tFAILED! FBO status: 0x%x\n", width, height, status );
// cleanup
glDeleteFramebuffers( 1, &framebuffer );
glDeleteTextures( 1, &texture );
glBindTexture( GL_TEXTURE_2D, 0 );
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
}
无效帧缓冲区大小列表(在iPad3和iPhone 4上运行)
1x 4 FAILED! FBO status: 0x8cdd
1x 8 FAILED! FBO status: 0x8cdd
1x 16 FAILED! FBO status: 0x8cdd
1x 32 FAILED! FBO status: 0x8cdd
1x 64 FAILED! FBO status: 0x8cdd
1x 128 FAILED! FBO status: 0x8cdd
1x 256 FAILED! FBO status: 0x8cdd
1x 512 FAILED! FBO status: 0x8cdd
1x 1024 FAILED! FBO status: 0x8cdd
1x 2048 FAILED! FBO status: 0x8cdd
2x 1 FAILED! FBO status: 0x8cdd
2x 8 FAILED! FBO status: 0x8cdd
2x 16 FAILED! FBO status: 0x8cdd
2x 32 FAILED! FBO status: 0x8cdd
2x 64 FAILED! FBO status: 0x8cdd
2x 128 FAILED! FBO status: 0x8cdd
2x 256 FAILED! FBO status: 0x8cdd
2x 512 FAILED! FBO status: 0x8cdd
2x 1024 FAILED! FBO status: 0x8cdd
2x 2048 FAILED! FBO status: 0x8cdd
4x 1 FAILED! FBO status: 0x8cdd
4x 2 FAILED! FBO status: 0x8cdd
4x 16 FAILED! FBO status: 0x8cdd
4x 32 FAILED! FBO status: 0x8cdd
4x 64 FAILED! FBO status: 0x8cdd
4x 128 FAILED! FBO status: 0x8cdd
4x 256 FAILED! FBO status: 0x8cdd
4x 512 FAILED! FBO status: 0x8cdd
4x 1024 FAILED! FBO status: 0x8cdd
4x 2048 FAILED! FBO status: 0x8cdd
8x 1 FAILED! FBO status: 0x8cdd
8x 2 FAILED! FBO status: 0x8cdd
8x 4 FAILED! FBO status: 0x8cdd
8x 32 FAILED! FBO status: 0x8cdd
8x 64 FAILED! FBO status: 0x8cdd
8x 128 FAILED! FBO status: 0x8cdd
8x 256 FAILED! FBO status: 0x8cdd
8x 512 FAILED! FBO status: 0x8cdd
8x 1024 FAILED! FBO status: 0x8cdd
8x 2048 FAILED! FBO status: 0x8cdd
16x 1 FAILED! FBO status: 0x8cdd
16x 2 FAILED! FBO status: 0x8cdd
16x 4 FAILED! FBO status: 0x8cdd
16x 8 FAILED! FBO status: 0x8cdd
32x 1 FAILED! FBO status: 0x8cdd
32x 2 FAILED! FBO status: 0x8cdd
32x 4 FAILED! FBO status: 0x8cdd
32x 8 FAILED! FBO status: 0x8cdd
64x 1 FAILED! FBO status: 0x8cdd
64x 2 FAILED! FBO status: 0x8cdd
64x 4 FAILED! FBO status: 0x8cdd
64x 8 FAILED! FBO status: 0x8cdd
128x 1 FAILED! FBO status: 0x8cdd
128x 2 FAILED! FBO status: 0x8cdd
128x 4 FAILED! FBO status: 0x8cdd
128x 8 FAILED! FBO status: 0x8cdd
256x 1 FAILED! FBO status: 0x8cdd
256x 2 FAILED! FBO status: 0x8cdd
256x 4 FAILED! FBO status: 0x8cdd
256x 8 FAILED! FBO status: 0x8cdd
512x 1 FAILED! FBO status: 0x8cdd
512x 2 FAILED! FBO status: 0x8cdd
512x 4 FAILED! FBO status: 0x8cdd
512x 8 FAILED! FBO status: 0x8cdd
1024x 1 FAILED! FBO status: 0x8cdd
1024x 2 FAILED! FBO status: 0x8cdd
1024x 4 FAILED! FBO status: 0x8cdd
1024x 8 FAILED! FBO status: 0x8cdd
2048x 1 FAILED! FBO status: 0x8cdd
2048x 2 FAILED! FBO status: 0x8cdd
2048x 4 FAILED! FBO status: 0x8cdd
2048x 8 FAILED! FBO status: 0x8cdd