EGL:创建pBuffer曲面时是否创建了FBO?

时间:2016-04-05 08:27:18

标签: opengl-es-2.0 egl

我在ARM GPU上使用EGL,我使用pbuffer进行屏幕外渲染。我遵循文档中描述的标准程序来设置所有内容:

    EGLDisplay display;
    EGLConfig config;
    EGLContext context;
    EGLSurface surface;
    EGLint num_config;

    // assume I allocated both attrib lists somewhere
    attribute_list[0] = EGL_SURFACE_TYPE;
    attribute_list[1] = EGL_PBUFFER_BIT;
    attribute_list[2] = EGL_RENDERABLE_TYPE;
    attribute_list[3] = EGL_OPENGL_ES2_BIT;
    attribute_list[4] = EGL_OPENGL_RED_SIZE;
    attribute_list[5] = 8;
    attribute_list[6] = EGL_OPENGL_GREEN_SIZE;
    attribute_list[7] = 8;
    attribute_list[8] = EGL_OPENGL_BLUE_SIZE;
    attribute_list[9] = 8;
    attribute_list[9] = EGL_OPENGL_ALPHA_SIZE;
    attribute_list[10] = 8;
    attribute_list[11] = EGL_OPENGL_DEPTH_SIZE;
    attribute_list[12] = 8;
    attribute_list[13] = EGL_NONE;

    pbuffer_attribs[0] = EGL_WIDTH;
    pbuffer_attribs[1] = 512;
    pbuffer_attribs[2] = EGL_HEIGHT;
    pbuffer_attribs[3] = 512;
    pbuffer_attribs[4] = EGL_NONE;

    /* get an EGL display connection */
    display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    /* initialize the EGL display connection */
    eglInitialize(display, NULL, NULL);

    /* get an appropriate EGL frame buffer configuration */
    eglChooseConfig(display, attribute_list, &config, 1, &num_config);                

    /* create an EGL rendering context */
    context = eglCreateContext(display, config, EGL_NO_CONTEXT, NULL);

    /* create the surface */
    surface = eglCreatePbufferSurface(display, config, pbuffer_attribs);

    /* connect the context to the surface */
    eglMakeCurrent(display, surface, surface, context);

在此之后,我的读写操作应与此屏幕外pBuffer相关联,对吗?这个pBuffer是否有一个与其相关的默认帧缓冲区不同的FBO?我遇到的问题是,当我尝试GL_FRAMEBUFFER_UNDEFINED时出现glReadPixels错误。在以下情况下会发生此错误:

    GL_FRAMEBUFFER_UNDEFINED is returned if target is the default framebuffer, but the default framebuffer does not exist.

我对这个错误的解读是我渲染到默认的FBO而不是pBuffer FBO。这种解释是否正确?如果是这样,我还需要做什么,所以我可以读写pBuffer FBO?

1 个答案:

答案 0 :(得分:1)

如果上面的序列成功完成(没有错误),那么,是的,屏幕外的pBuffer成为OpenGL ES上下文的默认帧缓冲区,所有读写都将与pBuffer相关联(除非绑定了非默认的FBO) )。

值得检查eglGetError()在每次EGL调用后返回EGL_SUCCESS。您的代码清单的以下部分看起来很可疑:

attribute_list[9] = 8;
attribute_list[9] = EGL_OPENGL_ALPHA_SIZE;