本文整理汇总了C++中GstGLFuncs::FramebufferTexture2D方法的典型用法代码示例。如果您正苦于以下问题:C++ GstGLFuncs::FramebufferTexture2D方法的具体用法?C++ GstGLFuncs::FramebufferTexture2D怎么用?C++ GstGLFuncs::FramebufferTexture2D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GstGLFuncs
的用法示例。
在下文中一共展示了GstGLFuncs::FramebufferTexture2D方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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;
}
示例2: if
static gboolean
_2d_texture_renderer_draw (GstAmc2DTextureRenderer * renderer)
{
GstGLFuncs *gl;
guint out_width, out_height;
GLint viewport_dim[4];
/* *INDENT-OFF* */
const GLfloat vertices[] = {
1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f
};
/* *INDENT-ON* */
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
GLenum multipleRT[] = {
GL_COLOR_ATTACHMENT0,
GL_COLOR_ATTACHMENT1,
GL_COLOR_ATTACHMENT2
};
gl = renderer->context->gl_vtable;
out_width = GST_VIDEO_INFO_WIDTH (&renderer->info);
out_height = GST_VIDEO_INFO_HEIGHT (&renderer->info);
gl->BindFramebuffer (GL_FRAMEBUFFER, renderer->fbo);
/* attach the texture to the FBO to rendererer to */
gl->BindTexture (GL_TEXTURE_2D, renderer->tex_id);
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, renderer->tex_id, 0);
if (gl->DrawBuffers)
gl->DrawBuffers (1, multipleRT);
else if (gl->DrawBuffer)
gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
gl->Viewport (0, 0, out_width, out_height);
gl->ClearColor (0.0, 0.0, 0.0, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gst_gl_shader_use (renderer->shader);
gst_gl_shader_set_uniform_matrix_4fv (renderer->shader, "u_transformation", 1,
FALSE, renderer->transformation_matrix);
gl->VertexAttribPointer (renderer->shader_attr_position_loc, 4,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vertices);
gl->VertexAttribPointer (renderer->shader_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vertices[3]);
gl->EnableVertexAttribArray (renderer->shader_attr_position_loc);
gl->EnableVertexAttribArray (renderer->shader_attr_texture_loc);
gl->ActiveTexture (GL_TEXTURE0);
gl->BindTexture (GL_TEXTURE_EXTERNAL_OES, renderer->oes_tex_id);
gl->TexParameteri (GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S,
GL_CLAMP_TO_EDGE);
gl->TexParameteri (GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T,
GL_CLAMP_TO_EDGE);
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
gl->DisableVertexAttribArray (renderer->shader_attr_position_loc);
gl->DisableVertexAttribArray (renderer->shader_attr_texture_loc);
if (gl->DrawBuffer)
gl->DrawBuffer (GL_NONE);
/* we are done with the shader */
gst_gl_context_clear_shader (renderer->context);
gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
viewport_dim[3]);
gst_gl_context_check_framebuffer_status (renderer->context);
gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
return TRUE;
}
示例3: if
static gboolean
_do_convert_draw (GstGLContext * context, GstGLColorConvert * convert)
{
GstGLFuncs *gl;
struct ConvertInfo *c_info = &convert->priv->convert_info;
guint out_width, out_height;
gint i;
GLint viewport_dim[4];
const GLfloat vVertices[] = { 1.0f, -1.0f, 0.0f,
1.0f, 0.0f,
-1.0f, -1.0f, 0.0f,
0.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f, 0.0f,
1.0f, 1.0f
};
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
GLenum multipleRT[] = {
GL_COLOR_ATTACHMENT0,
GL_COLOR_ATTACHMENT1,
GL_COLOR_ATTACHMENT2
};
gl = context->gl_vtable;
out_width = GST_VIDEO_INFO_WIDTH (&convert->out_info);
out_height = GST_VIDEO_INFO_HEIGHT (&convert->out_info);
gl->BindFramebuffer (GL_FRAMEBUFFER, convert->fbo);
/* attach the texture to the FBO to renderer to */
for (i = 0; i < c_info->out_n_textures; i++) {
/* needed? */
gl->BindTexture (GL_TEXTURE_2D, convert->priv->out_tex[i]->tex_id);
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
GL_TEXTURE_2D, convert->priv->out_tex[i]->tex_id, 0);
}
if (gl->DrawBuffers)
gl->DrawBuffers (c_info->out_n_textures, multipleRT);
else if (gl->DrawBuffer)
gl->DrawBuffer (GL_COLOR_ATTACHMENT0);
gl->GetIntegerv (GL_VIEWPORT, viewport_dim);
gl->Viewport (0, 0, out_width, out_height);
gl->ClearColor (0.0, 0.0, 0.0, 0.0);
gl->Clear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gst_gl_shader_use (convert->shader);
gl->VertexAttribPointer (convert->shader_attr_position_loc, 3,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), vVertices);
gl->VertexAttribPointer (convert->shader_attr_texture_loc, 2,
GL_FLOAT, GL_FALSE, 5 * sizeof (GLfloat), &vVertices[3]);
gl->EnableVertexAttribArray (convert->shader_attr_position_loc);
gl->EnableVertexAttribArray (convert->shader_attr_texture_loc);
for (i = c_info->in_n_textures - 1; i >= 0; i--) {
gchar *scale_name = g_strdup_printf ("tex_scale%u", i);
gl->ActiveTexture (GL_TEXTURE0 + i);
gl->BindTexture (GL_TEXTURE_2D, convert->priv->in_tex[i]->tex_id);
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);
gst_gl_shader_set_uniform_2fv (convert->shader, scale_name, 1,
convert->priv->in_tex[i]->tex_scaling);
g_free (scale_name);
}
gl->DrawElements (GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
gl->DisableVertexAttribArray (convert->shader_attr_position_loc);
gl->DisableVertexAttribArray (convert->shader_attr_texture_loc);
if (gl->DrawBuffer)
gl->DrawBuffer (GL_NONE);
/* we are done with the shader */
gst_gl_context_clear_shader (context);
gl->Viewport (viewport_dim[0], viewport_dim[1], viewport_dim[2],
viewport_dim[3]);
gst_gl_context_check_framebuffer_status (context);
gl->BindFramebuffer (GL_FRAMEBUFFER, 0);
//.........这里部分代码省略.........