static gboolean _2d_texture_renderer_init_fbo (GstAmc2DTextureRenderer * renderer) { GstGLFuncs *gl; GLuint fake_texture = 0; guint out_width, out_height; out_width = GST_VIDEO_INFO_WIDTH (&renderer->info); out_height = GST_VIDEO_INFO_HEIGHT (&renderer->info); gl = renderer->context->gl_vtable; if (!gl->GenFramebuffers) { /* turn off the pipeline because Frame buffer object is a not present */ gst_gl_context_set_error (renderer->context, "Context, EXT_framebuffer_object supported: no"); return FALSE; } GST_INFO ("Context, EXT_framebuffer_object supported: yes"); /* setup FBO */ gl->GenFramebuffers (1, &renderer->fbo); gl->BindFramebuffer (GL_FRAMEBUFFER, renderer->fbo); /* setup the render buffer for depth */ gl->GenRenderbuffers (1, &renderer->depth_buffer); gl->BindRenderbuffer (GL_RENDERBUFFER, renderer->depth_buffer); gl->RenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, out_width, out_height); /* a fake texture is attached to the render FBO (cannot init without it) */ gl->GenTextures (1, &fake_texture); gl->BindTexture (GL_TEXTURE_2D, fake_texture); gl->TexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, out_width, out_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); /* attach the texture to the FBO to renderer to */ gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fake_texture, 0); /* attach the depth render buffer to the FBO */ gl->FramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderer->depth_buffer); if (!gst_gl_context_check_framebuffer_status (renderer->context)) { gst_gl_context_set_error (renderer->context, "GL framebuffer status incomplete"); return FALSE; } /* unbind the FBO */ gl->BindFramebuffer (GL_FRAMEBUFFER, 0); gl->DeleteTextures (1, &fake_texture); return TRUE; }