kirgene
Posts: 12
Joined: Sat Jun 07, 2014 3:13 pm

Can't render to render buffer

Sun Apr 23, 2017 1:09 pm

I'd like to do offscreen rendering and processing using render buffer and EGL_IMAGE_BRCM_VCSM:

Code: Select all

    GLuint buffer = 0;
    m_gl_funcs->glGenRenderbuffers(1, &buffer);
    m_gl_funcs->glBindRenderbuffer(GL_RENDERBUFFER, buffer);

    m_vcsm_info->width = m_vcsm_info->height = 2048;
    EGLImageKHR eglFbImage = eglCreateImageKHR(egl_display, EGL_NO_CONTEXT,
            EGL_IMAGE_BRCM_VCSM, m_vcsm_info, NULL);
    assert(eglFbImage != EGL_NO_IMAGE_KHR && m_vcsm_info->vcsm_handle != 0);

    glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER, eglFbImage);
    assert(!glGetError());
but getting GL_INVALID_OPERATION error when using glEGLImageTargetRenderbufferStorageOES.
Is glEGLImageTargetRenderbufferStorageOES supported in Raspberry Pi ?

beddu
Posts: 21
Joined: Thu May 18, 2017 8:29 am

Re: Can't render to render buffer

Wed May 24, 2017 6:05 pm

Hi!
I managed to do rendering to texture in a slightly different way.

First of all generate a texture with the same format and dimensions as my viewport and no filtering:

Code: Select all

glGenTextures(1, (GLuint*)&frameBufferTexture);
glBindTexture(GL_TEXTURE_2D, (GLuint)frameBufferTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, viewportWidth, viewportHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
Then I generate the frame buffer and bind the texture to it in this way:

Code: Select all

glGenFramebuffers(1, &frameBufferHandle);
glBindFramebuffer(GL_FRAMEBUFFER, frameBufferHandle);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, (GLuint)frameBufferTexture,0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
Then I draw a square mesh with screen dimensions and map the texture to it. Selecting the buffer in this way:

Code: Select all

glBindFramebuffer(GL_FRAMEBUFFER, frameBufferHandle);

//draw to the custom buffer

glBindFramebuffer(GL_FRAMEBUFFER, 0)

//draw the custom buffer as a textured mesh to the back-buffer

eglSwapBuffers(display, surface);
Hope it will be useful!

Return to “OpenGLES”

Who is online

Users browsing this forum: No registered users and 2 guests